File tree 2 files changed +4
-4
lines changed
2 files changed +4
-4
lines changed Original file line number Diff line number Diff line change 28
28
29
29
接着我们要在 `` _start `` 中设置内核的运行环境了,我们直接来看代码:
30
30
31
- ``` asm
31
+ ``` riscv
32
32
# src/boot/entry64.asm
33
33
34
34
.section .text.entry
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ __trapret
26
26
27
27
我们定义几个宏:
28
28
29
- ``` asm
29
+ ``` riscv
30
30
# src/trap/trap.asm
31
31
32
32
# 表示每个寄存器占的字节数,由于是64位,都是8字节
@@ -45,7 +45,7 @@ __trapret
45
45
46
46
`` SAVE_ALL `` 的原理是:将一整个 `` TrapFrame `` 保存在** 内核栈** 上。我们现在就处在内核态(S 态),因此现在的栈顶地址 `` sp `` 就指向内核栈地址。但是,之后我们还要支持运行** 用户态程序** ,顾名思义,要在用户态(U 态)上运行,在中断时栈顶地址 `` sp `` 将指向用户栈顶地址,这种情况下我们要从用户栈切换到内核栈。
47
47
48
- ``` asm
48
+ ``` riscv
49
49
# src/trap/trap.asm
50
50
51
51
# 规定若在中断之前处于 U 态(用户态)
@@ -107,7 +107,7 @@ trap_from_user:
107
107
108
108
而 `` RESTORE_ALL `` 正好是一个反过来的过程:
109
109
110
- ``` asm
110
+ ``` riscv
111
111
# src/trap/trap.asm
112
112
113
113
.macro RESTORE_ALL
You can’t perform that action at this time.
0 commit comments