PageLevel

Struct PageLevel 

Source
pub struct PageLevel<PTE>
where PTE: PrimInt + Unsigned,
{ pub shift_bits: usize, pub va_bits: usize, pub present_bit: (PTE, PTE), pub huge_page_bit: (PTE, PTE), pub page_table_mask: PTE, }
Expand description

Describes a single page level of the page hierarchy.

Fields§

§shift_bits: usize

The number of bits to shift right in the virtual address to get the index bits for this page level.

§va_bits: usize

The number of bits in the virtual address to extract as the index for this page level.

§present_bit: (PTE, PTE)

The present bit in the PTE. The first mask is to select the relevants bits, the second is what the value should be upon masking.

§huge_page_bit: (PTE, PTE)

The huge page bit in the PTE. If the current page level does not support huge pages, then this should be set to zero. The first mask is to select the relevant bits, the second is what the value should be upon masking.

§page_table_mask: PTE

The page table mask that should be set when allocating new page tables.

Implementations§

Source§

impl<PTE> PageLevel<PTE>
where PTE: PrimInt + Unsigned,

Source

pub fn entries(&self) -> usize

Calculates the number of entries present in a page table for this page level.

Source

pub fn page_size(&self) -> usize

Calculates the page size for this page level.

Source

pub fn mask(&self) -> usize

Calculates the shifted mask to select the appropriate bits from the virtual address.

Source

pub fn end(&self, addr: usize) -> usize

Calculates the last virtual address within the same page for the current page level of the given a virtual address. This can be used to retrieve the first address of the next page for the current page level by simply adding one.

Source

pub fn pte_index(&self, addr: usize) -> usize

Calculates the PTE index of the given virtual address for the current page table level, which can then be used to index into the page table to get the corresponding PTE for this virtual address.

Source

pub fn is_present(&self, pte: PTE) -> bool

Given a PTE, it checks if the PTE points to a present page or page table.

Source

pub fn is_huge_page(&self, pte: PTE) -> bool

Given a PTE, it checks if the PTE points to a huge page. Always returns false if the current page level does not support huge pages.

Trait Implementations§

Source§

impl<PTE> Clone for PageLevel<PTE>
where PTE: PrimInt + Unsigned + Clone,

Source§

fn clone(&self) -> PageLevel<PTE>

Returns a duplicate 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<PTE> Debug for PageLevel<PTE>
where PTE: PrimInt + Unsigned + Debug,

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<PTE> Freeze for PageLevel<PTE>
where PTE: Freeze,

§

impl<PTE> RefUnwindSafe for PageLevel<PTE>
where PTE: RefUnwindSafe,

§

impl<PTE> Send for PageLevel<PTE>
where PTE: Send,

§

impl<PTE> Sync for PageLevel<PTE>
where PTE: Sync,

§

impl<PTE> Unpin for PageLevel<PTE>
where PTE: Unpin,

§

impl<PTE> UnwindSafe for PageLevel<PTE>
where PTE: UnwindSafe,

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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.