#[repr(C)]pub struct PageTable(/* private fields */);
Expand description
Page Table
This is just the page table defination. The implementation of the page table in the specific architecture mod. Such as: x86_64/page_table.rs riscv64/page_table/sv39.rs aarch64/page_table.rs loongarch64/page_table.rs
Implementations§
Source§impl PageTable
impl PageTable
Sourcepub fn map_page(
&self,
vaddr: VirtAddr,
paddr: PhysAddr,
flags: MappingFlags,
_size: MappingSize,
)
pub fn map_page( &self, vaddr: VirtAddr, paddr: PhysAddr, 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,
vaddr: VirtAddr,
paddr: PhysAddr,
flags: MappingFlags,
_size: MappingSize,
)
pub fn map_kernel( &self, vaddr: VirtAddr, paddr: PhysAddr, 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, vaddr: VirtAddr)
pub fn unmap_page(&self, vaddr: VirtAddr)
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.