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: PageTable

Implementations§

source§

impl PageTableWrapper

Allocate a new PageTableWrapper with new page table root

This operation will restore the page table.

source

pub fn alloc() -> Self

Alloc a new PageTableWrapper with new page table root This operation will copy kernel page table space from booting page table.

Methods from Deref<Target = PageTable>§

source

pub fn restore(&self)

source

pub fn change(&self)

source

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.

source

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.

source

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.

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 Debug for PageTableWrapper

source§

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

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

impl Deref for PageTableWrapper

§

type Target = PageTable

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl Drop for PageTableWrapper

Page Table Release.

You must implement this trait to release page table. Include the page table entry and root page.

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

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> 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>,

§

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>,

§

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.