Struct PageTable

Source
#[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

Source

pub const PAGE_SIZE: usize = 4_096usize

The size of the page for this platform.

Source

pub const PAGE_LEVEL: usize = 4usize

Source

pub const PTE_NUM_IN_PAGE: usize = 512usize

Source

pub fn restore(&self)

Source

pub fn current() -> Self

Source

pub fn change(&self)

Source§

impl PageTable

Source

pub const fn root(&self) -> PhysAddr

Get the root Physical Page

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for PageTable

Source§

fn clone(&self) -> PageTable

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PageTable

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Copy for PageTable

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.