diff --git a/docs/.vuepress/public/images/int_exception_table.png b/docs/.vuepress/public/images/int_exception_table.png new file mode 100644 index 0000000..8d33caf Binary files /dev/null and b/docs/.vuepress/public/images/int_exception_table.png differ diff --git a/docs/.vuepress/public/images/int_isr.png b/docs/.vuepress/public/images/int_isr.png new file mode 100644 index 0000000..85e5597 Binary files /dev/null and b/docs/.vuepress/public/images/int_isr.png differ diff --git a/docs/.vuepress/public/images/int_process.png b/docs/.vuepress/public/images/int_process.png new file mode 100644 index 0000000..fbc4b0b Binary files /dev/null and b/docs/.vuepress/public/images/int_process.png differ diff --git a/docs/.vuepress/public/images/int_riscv_controller.png b/docs/.vuepress/public/images/int_riscv_controller.png new file mode 100644 index 0000000..b5a9c55 Binary files /dev/null and b/docs/.vuepress/public/images/int_riscv_controller.png differ diff --git a/docs/doc/kernel/int.md b/docs/doc/kernel/int.md index b0d3847..256cc48 100644 --- a/docs/doc/kernel/int.md +++ b/docs/doc/kernel/int.md @@ -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中断控制器如下图所示: + + ### 中断处理流程 #### 中断服务程序 每一个中断源对应一个中断号,每一个中断号又通过中断向量表和中断服务程序进行关联。当中断产生后,通过中断向量表跳转到中断服务程序的入口地址进行执行。如下图所示: - + +