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: VaThe virtual address (VA) associated with this page table index breakdown.
pml4ei: usizePage Map Level 4 Index (PML4EI).
pdptei: usizePage Directory Pointer table Index (PDPTEI).
pdei: usizePage Directory Index (PDEI).
ptei: usizePage Table Index (PTEI).
Implementations§
Source§impl PtIndices
impl PtIndices
Sourcepub fn from_va(va: Va) -> Result<Self, PageTableMappingError>
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): Ifvais page-aligned (i.e., lower 12 bits are zero).Err(PageTableMappingError::Unaligned): Ifvais not page-aligned.