trap.S 修改注释格式

ch2
zhangxinyu 2 years ago
parent e3f52de1fd
commit 7f64711219

@ -1,71 +1,73 @@
# trap__alltraps, __restore
.altmacro
.macro SAVE_GP n
sd x\n, \n*8(sp) // x_n
sd x\n, \n*8(sp) # x_n
.endm
.macro LOAD_GP n
ld x\n, \n*8(sp) // x_n
ld x\n, \n*8(sp) # x_n
.endm
.section .text // .text
.globl __alltraps // __alltraps
.globl __restore // __restore
.align 2 // 2^2 = 4
.section .text # .text
.globl __alltraps # __alltraps
.globl __restore # __restore
.align 2 # 2^2 = 4
__alltraps: // __alltraps
csrrw sp, sscratch, sp // sp sscratch
__alltraps: # __alltraps
csrrw sp, sscratch, sp # sp sscratch
# sp sscratch
# TrapContext
addi sp, sp, -34*8 // 34*8
addi sp, sp, -34*8 # 34*8
#
sd x1, 1*8(sp) // x1 (x0, 便)
sd x1, 1*8(sp) # x1 (x0, 便)
# sp(x2)
sd x3, 3*8(sp) // x3 (x4, 便)
sd x3, 3*8(sp) # x3 (x4, 便)
# tp(x4)使
# x5~x31
.set n, 5 // n 5
.rept 27 // 27
SAVE_GP %n // x_n
.set n, n+1 // n 1
.endr //
.set n, 5 # n 5
.rept 27 # 27
SAVE_GP %n # x_n
.set n, n+1 # n 1
.endr #
# 使 t0/t1/t2
csrr t0, sstatus // sstatus
csrr t1, sepc // sepc
sd t0, 32*8(sp) // sstatus
sd t1, 33*8(sp) // sepc
csrr t0, sstatus # sstatus
csrr t1, sepc # sepc
sd t0, 32*8(sp) # sstatus
sd t1, 33*8(sp) # sepc
# sscratch
csrr t2, sscratch // sscratch
sd t2, 2*8(sp) // trap context
csrr t2, sscratch # sscratch
sd t2, 2*8(sp) # trap context
# trap_handler(cx: &mut TrapContext)
mv a0, sp // TrapContext a0
call trap_handler // trap_handler #
mv a0, sp # TrapContext a0
call trap_handler # trap_handler #
__restore: // __restore
__restore: # __restore
# case1:
# case2: U
mv sp, a0 // a0 sp sp KERNEL_STACK_SIZE,
mv sp, a0 # a0 sp sp KERNEL_STACK_SIZE,
# sstatus/sepc
ld t0, 32*8(sp) // sstatus
ld t1, 33*8(sp) // sepc
ld t2, 2*8(sp) //
csrw sstatus, t0 // sstatus
csrw sepc, t1 // sepc
csrw sscratch, t2 // sscratch
ld t0, 32*8(sp) # sstatus
ld t1, 33*8(sp) # sepc
ld t2, 2*8(sp) #
csrw sstatus, t0 # sstatus
csrw sepc, t1 # sepc
csrw sscratch, t2 # sscratch
# sp sscratch
# sp/tp
# x0
ld x1, 1*8(sp) // x1
ld x1, 1*8(sp) # x1
# x2
ld x3, 3*8(sp) // x3
ld x3, 3*8(sp) # x3
#
.set n, 5 // n 5
.rept 27 // 27
LOAD_GP %n // x_n
.set n, n+1 // n 1
.endr //
.set n, 5 # n 5
.rept 27 # 27
LOAD_GP %n # x_n
.set n, n+1 # n 1
.endr #
# sp sscratch , TrapContext, ,
addi sp, sp, 34*8 // sizeof<TrapContext>
addi sp, sp, 34*8 # sizeof<TrapContext>
csrrw sp, sscratch, sp // sp sscratch , sscratch, sp USER_STACK()
sret // , sstatus(/) sepc(/ pc)
csrrw sp, sscratch, sp # sp sscratch , sscratch, sp USER_STACK()
sret # , sstatus(/) sepc(/ pc)
Loading…
Cancel
Save