-uintptr_t handle_trap(uintptr_t cause, uintptr_t epc, uintptr_t regs[32])
-{
- if (cause != CAUSE_MACHINE_ECALL)
- tohost_exit(1337);
- else if (regs[17] == SYS_exit)
- tohost_exit(regs[10]);
- else if (regs[17] == SYS_stats)
- regs[10] = handle_stats(regs[10]);
- else
- regs[10] = handle_frontend_syscall(regs[17], regs[10], regs[11], regs[12]);
-
- return epc + ((*(unsigned short*)epc & 3) == 3 ? 4 : 2);
-}
-
-static uintptr_t syscall(uintptr_t num, uintptr_t arg0, uintptr_t arg1, uintptr_t arg2)