SimpleKernel 1.17.0
Loading...
Searching...
No Matches
interrupt_main.cpp File Reference
#include <cpu_io.h>
#include "arch.h"
#include "basic_info.hpp"
#include "interrupt.h"
#include "kernel.h"
#include "kernel_fdt.hpp"
#include "kernel_log.hpp"
#include "kstd_cstdio"
#include "pl011/pl011_driver.hpp"
#include "pl011_singleton.h"
Include dependency graph for interrupt_main.cpp:

Go to the source code of this file.

Typedefs

using InterruptDelegate = InterruptBase::InterruptDelegate
 

Functions

auto vector_table () -> void
 异常向量表入口
 
auto sync_current_el_sp0_handler (cpu_io::TrapContext *context) -> void
 同步异常处理 - Current EL with SP0
 
auto irq_current_el_sp0_handler (cpu_io::TrapContext *context) -> void
 IRQ 异常处理 - Current EL with SP0.
 
auto fiq_current_el_sp0_handler (cpu_io::TrapContext *context) -> void
 FIQ 异常处理 - Current EL with SP0.
 
auto error_current_el_sp0_handler (cpu_io::TrapContext *context) -> void
 错误异常处理 - Current EL with SP0
 
auto sync_current_el_spx_handler (cpu_io::TrapContext *context) -> void
 同步异常处理 - Current EL with SPx
 
auto irq_current_el_spx_handler (cpu_io::TrapContext *context) -> void
 IRQ 异常处理 - Current EL with SPx.
 
auto fiq_current_el_spx_handler (cpu_io::TrapContext *context) -> void
 FIQ 异常处理 - Current EL with SPx.
 
auto error_current_el_spx_handler (cpu_io::TrapContext *context) -> void
 错误异常处理 - Current EL with SPx
 
auto sync_lower_el_aarch64_handler (cpu_io::TrapContext *context) -> void
 同步异常处理 - Lower EL using AArch64
 
auto irq_lower_el_aarch64_handler (cpu_io::TrapContext *context) -> void
 IRQ 异常处理 - Lower EL using AArch64.
 
auto fiq_lower_el_aarch64_handler (cpu_io::TrapContext *context) -> void
 FIQ 异常处理 - Lower EL using AArch64.
 
auto error_lower_el_aarch64_handler (cpu_io::TrapContext *context) -> void
 错误异常处理 - Lower EL using AArch64
 
auto sync_lower_el_aarch32_handler (cpu_io::TrapContext *context) -> void
 同步异常处理 - Lower EL using AArch32
 
auto irq_lower_el_aarch32_handler (cpu_io::TrapContext *context) -> void
 IRQ 异常处理 - Lower EL using AArch32.
 
auto fiq_lower_el_aarch32_handler (cpu_io::TrapContext *context) -> void
 FIQ 异常处理 - Lower EL using AArch32.
 
auto error_lower_el_aarch32_handler (cpu_io::TrapContext *context) -> void
 错误异常处理 - Lower EL using AArch32
 
auto uart_handler (uint64_t cause, cpu_io::TrapContext *) -> uint64_t
 UART 中断处理函数
 
auto InterruptInit (int, const char **) -> void
 体系结构相关中断初始化
 
auto InterruptInitSMP (int, const char **) -> void
 从核的体系结构相关中断初始化
 

Typedef Documentation

◆ InterruptDelegate

Definition at line 17 of file interrupt_main.cpp.

Function Documentation

◆ error_current_el_sp0_handler()

auto error_current_el_sp0_handler ( cpu_io::TrapContext context) -> void

错误异常处理 - Current EL with SP0

Definition at line 76 of file interrupt_main.cpp.

77 {
78 HandleException("Error Exception at Current EL with SP0", context);
79}

◆ error_current_el_spx_handler()

auto error_current_el_spx_handler ( cpu_io::TrapContext context) -> void

错误异常处理 - Current EL with SPx

Definition at line 103 of file interrupt_main.cpp.

104 {
105 HandleException("Error Exception at Current EL with SPx", context);
106}

◆ error_lower_el_aarch32_handler()

auto error_lower_el_aarch32_handler ( cpu_io::TrapContext context) -> void

错误异常处理 - Lower EL using AArch32

Definition at line 159 of file interrupt_main.cpp.

160 {
161 HandleException("Error Exception at Lower EL using AArch32", context);
162}

◆ error_lower_el_aarch64_handler()

auto error_lower_el_aarch64_handler ( cpu_io::TrapContext context) -> void

错误异常处理 - Lower EL using AArch64

Definition at line 131 of file interrupt_main.cpp.

132 {
133 HandleException("Error Exception at Lower EL using AArch64", context);
134}

◆ fiq_current_el_sp0_handler()

auto fiq_current_el_sp0_handler ( cpu_io::TrapContext context) -> void

FIQ 异常处理 - Current EL with SP0.

Definition at line 68 of file interrupt_main.cpp.

69 {
70 klog::Err("FIQ Exception at Current EL with SP0");
71 // 处理 FIQ 中断
72 // ...
73}
auto Err(etl::format_string< Args... > fmt, Args &&... args) -> void
以 ERROR 级别记录日志
Here is the call graph for this function:

◆ fiq_current_el_spx_handler()

auto fiq_current_el_spx_handler ( cpu_io::TrapContext context) -> void

FIQ 异常处理 - Current EL with SPx.

Definition at line 95 of file interrupt_main.cpp.

96 {
97 klog::Err("FIQ Exception at Current EL with SPx");
98 // 处理 FIQ 中断
99 // ...
100}
Here is the call graph for this function:

◆ fiq_lower_el_aarch32_handler()

auto fiq_lower_el_aarch32_handler ( cpu_io::TrapContext context) -> void

FIQ 异常处理 - Lower EL using AArch32.

Definition at line 151 of file interrupt_main.cpp.

152 {
153 klog::Err("FIQ Exception at Lower EL using AArch32");
154 // 处理 FIQ 中断
155 // ...
156}
Here is the call graph for this function:

◆ fiq_lower_el_aarch64_handler()

auto fiq_lower_el_aarch64_handler ( cpu_io::TrapContext context) -> void

FIQ 异常处理 - Lower EL using AArch64.

Definition at line 123 of file interrupt_main.cpp.

124 {
125 klog::Err("FIQ Exception at Lower EL using AArch64");
126 // 处理 FIQ 中断
127 // ...
128}
Here is the call graph for this function:

◆ InterruptInit()

auto InterruptInit ( int  argc,
const char **  argv 
) -> void

体系结构相关中断初始化

Parameters
argc在不同体系结构有不同含义,同 _start
argv在不同体系结构有不同含义,同 _start
Precondition
ArchInit 已完成
Postcondition
中断控制器已初始化,中断向量表已设置

Definition at line 175 of file interrupt_main.cpp.

175 {
176 InterruptSingleton::create();
177
178 cpu_io::VBAR_EL1::Write(reinterpret_cast<uint64_t>(vector_table));
179
180 auto uart_intid =
181 KernelFdtSingleton::instance().GetAarch64Intid("arm,pl011").value() +
183
184 klog::Info("uart_intid: {}", uart_intid);
185
186 // 通过统一接口注册 UART 外部中断(先注册 handler,再启用 GIC SPI)
187 InterruptSingleton::instance()
188 .RegisterExternalInterrupt(uart_intid, cpu_io::GetCurrentCoreId(), 0,
189 InterruptDelegate::create<uart_handler>())
190 .or_else([](Error err) -> Expected<void> {
191 klog::Err("Failed to register UART IRQ: {}", err.message());
192 return std::unexpected(err);
193 });
194
196
197 klog::Info("Hello InterruptInit");
198}
auto vector_table() -> void
异常向量表入口
static constexpr size_t kSpiBase
Definition gic.h:25
std::expected< T, Error > Expected
std::expected 别名模板
Definition expected.hpp:365
auto GetCurrentCoreId() -> size_t
Definition cpu_io.h:26
void EnableInterrupt()
Definition cpu_io.h:34
auto Info(etl::format_string< Args... > fmt, Args &&... args) -> void
以 INFO 级别记录日志
错误类型,用于 std::expected
Definition expected.hpp:343
constexpr auto message() const -> const char *
Definition expected.hpp:358
Here is the call graph for this function:
Here is the caller graph for this function:

◆ InterruptInitSMP()

auto InterruptInitSMP ( int  argc,
const char **  argv 
) -> void

从核的体系结构相关中断初始化

Parameters
argc在不同体系结构有不同含义,同 _start
argv在不同体系结构有不同含义,同 _start
Precondition
主核已完成 InterruptInit
Postcondition
从核的中断控制器已初始化

Definition at line 200 of file interrupt_main.cpp.

200 {
201 cpu_io::VBAR_EL1::Write(reinterpret_cast<uint64_t>(vector_table));
202
203 InterruptSingleton::instance().SetUp();
204
206
207 klog::Info("Hello InterruptInitSMP");
208}
Here is the call graph for this function:

◆ irq_current_el_sp0_handler()

auto irq_current_el_sp0_handler ( cpu_io::TrapContext context) -> void

IRQ 异常处理 - Current EL with SP0.

Definition at line 60 of file interrupt_main.cpp.

61 {
62 klog::Err("IRQ Exception at Current EL with SP0");
63 // 处理 IRQ 中断
64 // ...
65}
Here is the call graph for this function:

◆ irq_current_el_spx_handler()

auto irq_current_el_spx_handler ( cpu_io::TrapContext context) -> void

IRQ 异常处理 - Current EL with SPx.

Definition at line 88 of file interrupt_main.cpp.

89 {
90 auto cause = cpu_io::ICC_IAR1_EL1::INTID::Get();
91 InterruptSingleton::instance().Do(cause, context);
92}

◆ irq_lower_el_aarch32_handler()

auto irq_lower_el_aarch32_handler ( cpu_io::TrapContext context) -> void

IRQ 异常处理 - Lower EL using AArch32.

Definition at line 143 of file interrupt_main.cpp.

144 {
145 klog::Err("IRQ Exception at Lower EL using AArch32");
146 // 处理 IRQ 中断
147 // ...
148}
Here is the call graph for this function:

◆ irq_lower_el_aarch64_handler()

auto irq_lower_el_aarch64_handler ( cpu_io::TrapContext context) -> void

IRQ 异常处理 - Lower EL using AArch64.

Definition at line 115 of file interrupt_main.cpp.

116 {
117 klog::Err("IRQ Exception at Lower EL using AArch64");
118 // 处理 IRQ 中断
119 // ...
120}
Here is the call graph for this function:

◆ sync_current_el_sp0_handler()

auto sync_current_el_sp0_handler ( cpu_io::TrapContext context) -> void

同步异常处理 - Current EL with SP0

Definition at line 54 of file interrupt_main.cpp.

55 {
56 HandleException("Sync Exception at Current EL with SP0", context, 4);
57}

◆ sync_current_el_spx_handler()

auto sync_current_el_spx_handler ( cpu_io::TrapContext context) -> void

同步异常处理 - Current EL with SPx

Definition at line 82 of file interrupt_main.cpp.

83 {
84 HandleException("Sync Exception at Current EL with SPx", context, 4);
85}

◆ sync_lower_el_aarch32_handler()

auto sync_lower_el_aarch32_handler ( cpu_io::TrapContext context) -> void

同步异常处理 - Lower EL using AArch32

Definition at line 137 of file interrupt_main.cpp.

138 {
139 HandleException("Sync Exception at Lower EL using AArch32", context);
140}

◆ sync_lower_el_aarch64_handler()

auto sync_lower_el_aarch64_handler ( cpu_io::TrapContext context) -> void

同步异常处理 - Lower EL using AArch64

Definition at line 109 of file interrupt_main.cpp.

110 {
111 HandleException("Sync Exception at Lower EL using AArch64", context, 8);
112}

◆ uart_handler()

auto uart_handler ( uint64_t  cause,
cpu_io::TrapContext  
) -> uint64_t

UART 中断处理函数

Parameters
cause中断号
Returns
中断号

Definition at line 169 of file interrupt_main.cpp.

169 {
170 Pl011Singleton::instance().HandleInterrupt(
171 [](uint8_t ch) { etl_putchar(ch); });
172 return cause;
173}
auto etl_putchar(int c) -> void
早期控制台字符输出
Here is the call graph for this function:

◆ vector_table()

auto vector_table ( ) -> void

异常向量表入口

Here is the caller graph for this function: