-.globl trap_entry
-trap_entry: # only check for SYS_exit, otherwise crash out
- li a3, 1337 # magic "bad things" happened error code
- csrr a1, cause
- li a2, 6 # syscall exception number
- bne a1, a2, exit_error
-handle_syscall:
- li a1, 93 # SYS_exit number
- bne v0, a1, exit_error
- li a1, 1 # successful exit code
- move a3, a0
- bne a3, a1, exit_error
- csrw tohost, a1 # exit successfully (tohost == 1)
-1:b 1b
-exit_error:
- sll a3, a3, 1
- or a3, a3, 1
- csrw tohost, a3
-1:b 1b
-
- .bss
- .globl stacktop
-
- .align 4
- .skip 131072
-stacktop: