Files
mini-riscv-os/04-TimerInterrupt/sys.s
2021-11-09 10:32:07 +08:00

16 lines
372 B
ArmAsm

# This Code derived from xv6-riscv (64bit)
# -- https://github.com/mit-pdos/xv6-riscv/blob/riscv/kernel/swtch.S
.globl sys_timer
.align 4
sys_timer:
# call the C timer_handler(reg_t epc, reg_t cause)
csrr a0, mepc
csrr a1, mcause
call timer_handler
# timer_handler will return the return address via a0.
csrw mepc, a0
mret # back to interrupt location (pc=mepc)