PtIndices

Struct PtIndices 

Source
pub struct PtIndices {
    pub va: Va,
    pub pml4ei: usize,
    pub pdptei: usize,
    pub pdei: usize,
    pub ptei: usize,
}
Expand description

Represents page table indices for a given virtual address (VA).

In the x86_64 architecture, virtual addresses are translated to physical addresses using a 4-level paging hierarchy:

  • PML4 (Page Map Level 4)
  • PDPT (Page Directory Pointer Table)
  • PD (Page Directory)
  • PT (Page Table)

This structure extracts the index values for each of these levels from a virtual address. This struct provides a way to decompose a virtual address into its respective page table indices.

Fields§

§va: Va

The virtual address (VA) associated with this page table index breakdown.

§pml4ei: usize

Page Map Level 4 Index (PML4EI).

§pdptei: usize

Page Directory Pointer table Index (PDPTEI).

§pdei: usize

Page Directory Index (PDEI).

§ptei: usize

Page Table Index (PTEI).

Implementations§

Source§

impl PtIndices

Source

pub fn from_va(va: Va) -> Result<Self, PageTableMappingError>

Extracts page table indices from a given virtual address (Va).

This function takes a virtual address and calculates the corresponding PML4, PDPT, PD, and PT indices based on x86_64 paging structure.

§Arguments
  • va: A virtual address (Va) to be broken down into page table indices.
§Returns
  • Ok(Self): If va is page-aligned (i.e., lower 12 bits are zero).
  • Err(PageTableMappingError::Unaligned): If va is not page-aligned.

Auto Trait Implementations§

§

impl Freeze for PtIndices

§

impl RefUnwindSafe for PtIndices

§

impl Send for PtIndices

§

impl Sync for PtIndices

§

impl Unpin for PtIndices

§

impl UnwindSafe for PtIndices

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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.
§

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

Performs the conversion.