insert the images into kernel/int.md

This commit is contained in:
Yan_yan 2020-11-02 11:55:17 +08:00
parent bdea091ec0
commit 92db010310
5 changed files with 19 additions and 5 deletions

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

View File

@ -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域标识是何种异常或者何种中断。定义如下图表格所示
![XiUOS EXCEPTION TABLE](/images/int_exception_table.png)
+ 退出异常时需要从异常服务程序中退出并返回主程序。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中断控制器如下图所示
![XiUOS RISC-V CONTROLLER](/images/int_riscv_controller.png)
### 中断处理流程
#### 中断服务程序
每一个中断源对应一个中断号,每一个中断号又通过中断向量表和中断服务程序进行关联。当中断产生后,通过中断向量表跳转到中断服务程序的入口地址进行执行。如下图所示:
<center>
![XiUOS ISR](/images/int_isr.png)
</center>
#### 中断处理流程
CPU响应中断并进行处理通常经历以下过程保存当前线程的栈信息、跳转中断服务程序运行、恢复被打断的线程栈继续运行。
如下图所示:
<center>
![XiUOS PROCESS](/images/int_process.png)
</center>
### 中断函数接口
## 中断函数接口
```c
typedef void *xs_handler_x(int irq_num, void *arg)