Next Generation WASM Microkernel Operating System
at trap_handler 49 lines 2.0 kB view raw
1// Copyright 2025 Jonas Kruckenberg 2// 3// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or 4// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or 5// http://opensource.org/licenses/MIT>, at your option. This file may not be 6// copied, modified, or distributed except according to those terms. 7 8use crate::arch::trap::Trap; 9use crate::mem::VirtualAddress; 10use crate::state::global; 11use core::ops::ControlFlow; 12 13pub fn handle_page_fault(_trap: Trap, _tval: VirtualAddress) -> ControlFlow<()> { 14 let current_task = global() 15 .executor 16 .current_scheduler() 17 .unwrap() 18 .current_task(); 19 20 let Some(_current_task) = current_task.as_ref() else { 21 // if we're not inside a task we're inside some critical kernel code 22 // none of that should use ever trap 23 tracing::warn!("no currently active task"); 24 return ControlFlow::Continue(()); 25 }; 26 27 // FIXME we have no page fault handling right now 28 ControlFlow::Continue(()) 29 30 // let mut aspace = current_task.header().aspace.as_ref().unwrap().lock(); 31 32 // let flags = match trap { 33 // Trap::Exception(Exception::LoadPageFault) => PageFaultFlags::LOAD, 34 // Trap::Exception(Exception::StorePageFault) => PageFaultFlags::STORE, 35 // Trap::Exception(Exception::InstructionPageFault) => PageFaultFlags::INSTRUCTION, 36 // // not a page fault exception, continue with the next fault handler 37 // _ => return ControlFlow::Continue(()), 38 // }; 39 // 40 // if let Err(err) = aspace.page_fault(tval, flags) { 41 // // the address space knew about the faulting address, but the requested access was invalid 42 // tracing::warn!("page fault handler couldn't correct fault {err}"); 43 // ControlFlow::Continue(()) 44 // } else { 45 // // the address space knew about the faulting address and could correct the fault 46 // tracing::trace!("page fault handler successfully corrected fault"); 47 // ControlFlow::Break(()) 48 // } 49}