pub trait PageTableFn {
// Required methods
unsafe fn map(
&mut self,
cfg: &MapConfig,
page_level: usize,
access: &mut impl Access,
) -> PagingResult;
fn level_entry_size(&self, level: usize) -> usize;
unsafe fn new(access: &mut impl Access) -> PagingResult<Self>
where Self: Sized;
// Provided methods
fn detect_page_level(&self, vaddr: *const u8, size: usize) -> usize { ... }
unsafe fn map_region(
&mut self,
config: MapConfig,
size: usize,
allow_block: bool,
access: &mut impl Access,
) -> PagingResult<()> { ... }
unsafe fn map_region_with_handle(
&mut self,
cfg: MapConfig,
size: usize,
allow_block: bool,
access: &mut impl Access,
on_page_mapped: Option<&impl Fn(*const u8)>,
) -> PagingResult { ... }
}
Required Methods§
Sourceunsafe fn map(
&mut self,
cfg: &MapConfig,
page_level: usize,
access: &mut impl Access,
) -> PagingResult
unsafe fn map( &mut self, cfg: &MapConfig, page_level: usize, access: &mut impl Access, ) -> PagingResult
Map a page or block of memory.
§Safety
The caller must ensure that the memory is valid and that the page table is valid.
page_level
range: [1, MAX_LEVEL]
1 => 4K
2 => 2M
3 => 1G
fn level_entry_size(&self, level: usize) -> usize
Provided Methods§
fn detect_page_level(&self, vaddr: *const u8, size: usize) -> usize
unsafe fn map_region( &mut self, config: MapConfig, size: usize, allow_block: bool, access: &mut impl Access, ) -> PagingResult<()>
Sourceunsafe fn map_region_with_handle(
&mut self,
cfg: MapConfig,
size: usize,
allow_block: bool,
access: &mut impl Access,
on_page_mapped: Option<&impl Fn(*const u8)>,
) -> PagingResult
unsafe fn map_region_with_handle( &mut self, cfg: MapConfig, size: usize, allow_block: bool, access: &mut impl Access, on_page_mapped: Option<&impl Fn(*const u8)>, ) -> PagingResult
Map a contiguous virtual memory region to a contiguous physical memory
region with the given mapping flags
.
The virtual and physical memory regions start with vaddr
and paddr
respectively. The region size is size
. The addresses and size
must
be aligned to 4K, otherwise it will return Err(PagingError::NotAligned)
.
When allow_huge
is true, it will try to map the region with huge pages
if possible. Otherwise, it will map the region with 4K pages.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.