(cx: &mut TrapContext)
| 31 | |
| 32 | #[no_mangle] |
| 33 | extern "C" fn trap_handler(cx: &mut TrapContext) -> &mut TrapContext { |
| 34 | let scause = scause::read(); |
| 35 | let stval = stval::read(); |
| 36 | match scause.cause() { |
| 37 | Trap::Exception(Exception::UserEnvCall) => { |
| 38 | cx.spec += 4; |
| 39 | cx.x[10] = 0; |
| 40 | }, |
| 41 | Trap::Exception(Exception::StoreFault) | |
| 42 | Trap::Exception(Exception::StorePageFault) => { |
| 43 | error!("{:?} va = {:#x} instruction = {:#x}", scause.cause(), stval::read(), sepc::read()); |
| 44 | panic!("page fault!"); |
| 45 | }, |
| 46 | Trap::Exception(Exception::IllegalInstruction) => { |
| 47 | error!("IllegalInstruction"); |
| 48 | }, |
| 49 | Trap::Interrupt(Interrupt::SupervisorTimer) => { |
| 50 | timer_next_triger(); |
| 51 | } |
| 52 | _ => { |
| 53 | panic!("Unhandled trap: {:?} stval = {:#x}", scause.cause(), stval); |
| 54 | } |
| 55 | } |
| 56 | cx |
| 57 | } |
nothing calls this directly
no test coverage detected