Struct polyhal::PageTableWrapper
source · pub struct PageTableWrapper(pub PageTable);Expand description
Page Table Wrapper
You can use this wrapper to packing PageTable. If you release the PageTableWrapper, the PageTable will release its page table entry.
Tuple Fields§
§0: PageTableImplementations§
source§impl PageTableWrapper
impl PageTableWrapper
Allocate a new PageTableWrapper with new page table root
This operation will restore the page table.
Methods from Deref<Target = PageTable>§
pub fn restore(&self)
pub fn change(&self)
sourcepub fn map_page(
&self,
vpn: VirtPage,
ppn: PhysPage,
flags: MappingFlags,
_size: MappingSize,
)
pub fn map_page( &self, vpn: VirtPage, ppn: PhysPage, flags: MappingFlags, _size: MappingSize, )
Mapping a page to specific virtual page (user space address).
Ensure that PageTable is which you want to map. vpn: Virtual page will be mapped. ppn: Physical page. flags: Mapping flags, include Read, Write, Execute and so on. size: MappingSize. Just support 4KB page currently.
sourcepub fn map_kernel(
&self,
vpn: VirtPage,
ppn: PhysPage,
flags: MappingFlags,
_size: MappingSize,
)
pub fn map_kernel( &self, vpn: VirtPage, ppn: PhysPage, flags: MappingFlags, _size: MappingSize, )
Mapping a page to specific address(kernel space address).
TODO: This method is not implemented. TIPS: If we mapped to kernel, the page will be shared between different pagetable.
Ensure that PageTable is which you want to map. vpn: Virtual page will be mapped. ppn: Physical page. flags: Mapping flags, include Read, Write, Execute and so on. size: MappingSize. Just support 4KB page currently.
How to implement shared.
sourcepub fn unmap_page(&self, vpn: VirtPage)
pub fn unmap_page(&self, vpn: VirtPage)
Unmap a page from specific virtual page (user space address).
Ensure the virtual page is exists. vpn: Virtual address.
sourcepub fn translate(&self, vaddr: VirtAddr) -> Option<(PhysAddr, MappingFlags)>
pub fn translate(&self, vaddr: VirtAddr) -> Option<(PhysAddr, MappingFlags)>
Translate a virtual adress to a physical address and mapping flags.
Return None if the vaddr isn’t mapped. vpn: The virtual address will be translated.
sourcepub fn release(&self)
pub fn release(&self)
Release the page table entry.
The page table entry in the user space address will be released. Page Table Wikipedia. You don’t need to care about this if you just want to use.