insert the images into kernel/int.md
This commit is contained in:
parent
bdea091ec0
commit
92db010310
Binary file not shown.
After Width: | Height: | Size: 147 KiB |
Binary file not shown.
After Width: | Height: | Size: 32 KiB |
Binary file not shown.
After Width: | Height: | Size: 21 KiB |
Binary file not shown.
After Width: | Height: | Size: 23 KiB |
|
@ -26,8 +26,9 @@
|
|||
+ mepc(Machine Exception Program Register):机器模式异常PC寄存器
|
||||
+ mtval(Machine Trap Value Register):机器模式异常值寄存器
|
||||
+ mstatus(Machine Status Register):机器模式状态寄存器
|
||||
mcause寄存器的Exception Code域标识是何种异常或者何种中断。定义如下图表格所示:
|
||||
|
||||
|
||||
mcause寄存器的Exception Code域标识是何种异常或者何种中断。定义如下图表格所示:
|
||||

|
||||
|
||||
+ 退出异常时,需要从异常服务程序中退出,并返回主程序。RISC-V架构定义了一组专门的退出异常指令:MRET、SRET、URET,分别对应机器模式、监督模式、用户模式的退出。
|
||||
以MRET为例,当处理器执行MRET指令后,硬件行为如下:
|
||||
|
@ -46,17 +47,30 @@ CLINT 的全称为处理器核局部中断控制器(Core Local Interrupts Cont
|
|||
+ PLIC 管理多个外部中断
|
||||
PLIC 全称为平台级别中断控制器(Platform Level Interrupt Controller),它是 RISC-V架构标准定义的系统中断控制器,主要用于多个外部中断源的优先级仲裁。
|
||||
RISC-V中断控制器如下图所示:
|
||||
|
||||

|
||||
|
||||
### 中断处理流程
|
||||
#### 中断服务程序
|
||||
每一个中断源对应一个中断号,每一个中断号又通过中断向量表和中断服务程序进行关联。当中断产生后,通过中断向量表跳转到中断服务程序的入口地址进行执行。如下图所示:
|
||||
|
||||
|
||||
<center>
|
||||
|
||||

|
||||
|
||||
</center>
|
||||
|
||||
#### 中断处理流程
|
||||
CPU响应中断并进行处理,通常经历以下过程:保存当前线程的栈信息、跳转中断服务程序运行、恢复被打断的线程栈继续运行。
|
||||
如下图所示:
|
||||
|
||||
<center>
|
||||
|
||||

|
||||
|
||||
</center>
|
||||
|
||||
|
||||
### 中断函数接口
|
||||
## 中断函数接口
|
||||
|
||||
```c
|
||||
typedef void *xs_handler_x(int irq_num, void *arg)
|
||||
|
|
Loading…
Reference in New Issue