Struct page_table::PageTable64

source ·
pub struct PageTable64<M: PagingMetaData, PTE: GenericPTE, IF: PagingIf> { /* private fields */ }
Expand description

A generic page table struct for 64-bit platform.

It also tracks all intermediate level tables. They will be deallocated When the PageTable64 itself is dropped.

Implementations§

source§

impl<M: PagingMetaData, PTE: GenericPTE, IF: PagingIf> PageTable64<M, PTE, IF>

source

pub fn try_new() -> PagingResult<Self>

Creates a new page table instance or returns the error.

It will allocate a new page for the root page table.

source

pub const fn root_paddr(&self) -> PhysAddr

Returns the physical address of the root page table.

source

pub fn map( &mut self, vaddr: VirtAddr, target: PhysAddr, page_size: PageSize, flags: MappingFlags ) -> PagingResult

Maps a virtual page to a physical frame with the given page_size and mapping flags.

The virtual page starts with vaddr, amd the physical frame starts with target. If the addresses is not aligned to the page size, they will be aligned down automatically.

Returns Err(PagingError::AlreadyMapped) if the mapping is already present.

source

pub fn unmap(&mut self, vaddr: VirtAddr) -> PagingResult<(PhysAddr, PageSize)>

Unmaps the mapping starts with vaddr.

Returns Err(PagingError::NotMapped) if the mapping is not present.

source

pub fn query( &self, vaddr: VirtAddr ) -> PagingResult<(PhysAddr, MappingFlags, PageSize)>

Query the result of the mapping starts with vaddr.

Returns the physical address of the target frame, mapping flags, and the page size.

Returns Err(PagingError::NotMapped) if the mapping is not present.

source

pub fn update( &mut self, vaddr: VirtAddr, paddr: Option<PhysAddr>, flags: Option<MappingFlags> ) -> PagingResult<PageSize>

Updates the target or flags of the mapping starts with vaddr. If the corresponding argument is None, it will not be updated.

Returns the page size of the mapping.

Returns Err(PagingError::NotMapped) if the mapping is not present.

source

pub fn map_region( &mut self, vaddr: VirtAddr, paddr: PhysAddr, size: usize, flags: MappingFlags, allow_huge: bool ) -> PagingResult

Map a contiguous virtual memory region to a contiguous physical memory region with the given mapping flags.

The virtual and physical memory regions start with vaddr and paddr respectively. The region size is size. The addresses and size must be aligned to 4K, otherwise it will return Err(PagingError::NotAligned).

When allow_huge is true, it will try to map the region with huge pages if possible. Otherwise, it will map the region with 4K pages.

source

pub fn unmap_region(&mut self, vaddr: VirtAddr, size: usize) -> PagingResult

Unmap a contiguous virtual memory region.

The region must be mapped before using PageTable64::map_region, or unexpected behaviors may occur.

source

pub fn walk<F>(&self, limit: usize, func: &F) -> PagingResultwhere F: Fn(usize, usize, VirtAddr, &PTE),

Walk the page table recursively.

When reaching the leaf page table, call func on the current page table entry. The max number of enumerations in one table is limited by limit.

The arguments of func are:

  • Current level (starts with 0): usize
  • The index of the entry in the current-level table: usize
  • The virtual address that is mapped to the entry: VirtAddr
  • The reference of the entry: &PTE

Trait Implementations§

source§

impl<M: PagingMetaData, PTE: GenericPTE, IF: PagingIf> Drop for PageTable64<M, PTE, IF>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<M, PTE, IF> RefUnwindSafe for PageTable64<M, PTE, IF>where IF: RefUnwindSafe, M: RefUnwindSafe, PTE: RefUnwindSafe,

§

impl<M, PTE, IF> Send for PageTable64<M, PTE, IF>where IF: Send,

§

impl<M, PTE, IF> Sync for PageTable64<M, PTE, IF>where IF: Sync,

§

impl<M, PTE, IF> Unpin for PageTable64<M, PTE, IF>where IF: Unpin, M: Unpin, PTE: Unpin,

§

impl<M, PTE, IF> UnwindSafe for PageTable64<M, PTE, IF>where IF: UnwindSafe, M: UnwindSafe, PTE: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere 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 Twhere 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.