MCPcopy Create free account
hub / github.com/KernelErr/MoeOS / trap_handler

Function trap_handler

src/trap.rs:33–57  ·  view source on GitHub ↗
(cx: &mut TrapContext)

Source from the content-addressed store, hash-verified

31
32#[no_mangle]
33extern "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}

Callers

nothing calls this directly

Calls 1

timer_next_trigerFunction · 0.85

Tested by

no test coverage detected