6 trap_handler_t trap_handler
[NHARTS
] = {0};
8 void set_trap_handler(trap_handler_t handler
)
10 unsigned hartid
= csr_read(mhartid
);
11 trap_handler
[hartid
] = handler
;
14 void enable_timer_interrupts()
16 set_csr(mie
, MIP_MTIP
);
17 set_csr(mstatus
, MSTATUS_MIE
);
20 void handle_trap(unsigned int mcause
, unsigned int mepc
, unsigned int sp
)
22 unsigned hartid
= csr_read(mhartid
);
23 if (trap_handler
[hartid
]) {
24 trap_handler
[hartid
](hartid
, mcause
, mepc
, sp
);
32 void _exit(int status
)
34 // Make sure gcc doesn't inline _exit, so we can actually set a breakpoint
39 // _exit isn't supposed to return.