添加一些 los_dispatch.S 注释
This commit is contained in:
@@ -114,9 +114,12 @@ HalTaskContextSwitch:
|
|||||||
and a0, a0, a2
|
and a0, a0, a2
|
||||||
|
|
||||||
// get mie
|
// get mie
|
||||||
|
// a0 中保存着关闭中断之前的mstatus状态,如果中中断中进的这个函数,则mie为0
|
||||||
|
// 如果从task中进的这个函数,则mie为1
|
||||||
andi a1, a0, RISCV_MSTATUS_MIE // 0x00000008
|
andi a1, a0, RISCV_MSTATUS_MIE // 0x00000008
|
||||||
|
|
||||||
// must be in machine mode
|
// must be in machine mode
|
||||||
|
// 这里左移4位,把mie的状态保存在mpie中,mret指令将恢复这个状态
|
||||||
ori a1, a1, 0x180
|
ori a1, a1, 0x180
|
||||||
slli a1, a1, 0x4
|
slli a1, a1, 0x4
|
||||||
or a0, a0, a1
|
or a0, a0, a1
|
||||||
@@ -127,7 +130,8 @@ HalTaskContextSwitch:
|
|||||||
and a0, a0, a2
|
and a0, a0, a2
|
||||||
// a0 清除 mie后的 mstatus
|
// a0 清除 mie后的 mstatus
|
||||||
SREG a0, 16 * REGBYTES(sp)
|
SREG a0, 16 * REGBYTES(sp)
|
||||||
// 返回地址
|
// 返回地址,把ra地址保存到mepc寄存器中,则mret指令的作用类似于ret
|
||||||
|
// 区别是mret附带一个是否打开中断的效果
|
||||||
SREG ra, 17 * REGBYTES(sp)
|
SREG ra, 17 * REGBYTES(sp)
|
||||||
|
|
||||||
la a1, g_losTask
|
la a1, g_losTask
|
||||||
@@ -155,7 +159,7 @@ HalStartToRun:
|
|||||||
|
|
||||||
// retrieve the registers
|
// retrieve the registers
|
||||||
POP_ALL_REG
|
POP_ALL_REG
|
||||||
|
// 如果是从task中调用,这里会打开中断,如果是从中断中调用,这里不会打开中断
|
||||||
mret
|
mret
|
||||||
|
|
||||||
.section .text
|
.section .text
|
||||||
|
Reference in New Issue
Block a user