pub struct PageMapper { /* private fields */ }Expand description
Page mapper for modifying page tables
Implementations§
Source§impl PageMapper
impl PageMapper
Sourcepub unsafe fn new(l4_table: *mut PageTable) -> Self
pub unsafe fn new(l4_table: *mut PageTable) -> Self
Create a new page mapper (unsafe: requires valid mapped L4 table)
§Safety
The l4_table pointer must:
- Point to a valid, mapped page table
- Remain valid for the lifetime of the PageMapper
- Not be accessed through any other means while this exists
Sourcepub unsafe fn new_with_recursive(
l4_table: *mut PageTable,
recursive_index: PageTableIndex,
) -> Self
pub unsafe fn new_with_recursive( l4_table: *mut PageTable, recursive_index: PageTableIndex, ) -> Self
Create a new page mapper with recursive mapping
§Safety
Same requirements as new, plus:
- The recursive_index must be set up for recursive mapping
Sourcepub fn map_page(
&mut self,
page: VirtualAddress,
frame: FrameNumber,
flags: PageFlags,
allocator: &mut impl FrameAllocator,
) -> Result<(), KernelError>
pub fn map_page( &mut self, page: VirtualAddress, frame: FrameNumber, flags: PageFlags, allocator: &mut impl FrameAllocator, ) -> Result<(), KernelError>
Map a page to a frame
Sourcepub fn translate_page(
&self,
page: VirtualAddress,
) -> Result<(FrameNumber, PageFlags), KernelError>
pub fn translate_page( &self, page: VirtualAddress, ) -> Result<(FrameNumber, PageFlags), KernelError>
Look up the physical frame mapped at a virtual address.
Walks the page table hierarchy and returns the frame number and flags of the L1 (leaf) entry if the page is present at all four levels.
Sourcepub fn update_page_flags(
&mut self,
page: VirtualAddress,
new_flags: PageFlags,
) -> Result<PageFlags, KernelError>
pub fn update_page_flags( &mut self, page: VirtualAddress, new_flags: PageFlags, ) -> Result<PageFlags, KernelError>
Update the flags on an existing page table entry without changing the mapped frame.
Returns the old flags on success.
Sourcepub fn unmap_page(
&mut self,
page: VirtualAddress,
) -> Result<FrameNumber, KernelError>
pub fn unmap_page( &mut self, page: VirtualAddress, ) -> Result<FrameNumber, KernelError>
Unmap a page