1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use crate::{utils::init_once::InitOnce, MMUFlags, PhysAddr, VirtAddr};
pub trait KernelHandler: Send + Sync + 'static {
fn frame_alloc(&self) -> Option<PhysAddr> {
unimplemented!()
}
fn frame_alloc_contiguous(&self, _frame_count: usize, _align_log2: usize) -> Option<PhysAddr> {
unimplemented!()
}
fn frame_dealloc(&self, _paddr: PhysAddr) {
unimplemented!()
}
fn handle_page_fault(&self, _fault_vaddr: VirtAddr, _access_flags: MMUFlags) {
}
}
#[allow(dead_code)]
pub(crate) struct DummyKernelHandler;
#[cfg(feature = "libos")]
pub(crate) static KHANDLER: InitOnce<&dyn KernelHandler> =
InitOnce::new_with_default(&DummyKernelHandler);
#[cfg(not(feature = "libos"))]
pub(crate) static KHANDLER: InitOnce<&dyn KernelHandler> = InitOnce::new();