#[repr(transparent)]pub struct Pml4e(pub usize);Expand description
Page Map Level 4 Entry (PML4E).
This struct represents a Page Map Level 4 Entry (PML4E), which is the top-level entry in the 4-level page table system used in x86_64 architecture. A PML4E is the highest-level entry in the virtual memory hierarchy and points to a Page Directory Pointer Table (PDP) or a higher-level page table that contains further mappings for virtual to physical memory.
The Pml4e struct provides methods for working with the physical address
and flags associated with a PML4E, allowing manipulation of page tables in
the virtual memory system.
Tuple Fields§
§0: usizeImplementations§
Source§impl Pml4e
impl Pml4e
Sourcepub const fn pa(&self) -> Option<Pa>
pub const fn pa(&self) -> Option<Pa>
Get the physical address pointed to by this entry.
This function checks whether the PML4 entry is present (i.e., if the “P” flag is set in the entry). If the entry is present, it extracts the physical address by clearing the flags from the entry.
§Returns
Some(Pa)if the PML4E is present, containing the physical address.Noneif the PML4E is not present (i.e., the “P” flag is not set).
Sourcepub const fn flags(&self) -> Pml4eFlags
pub const fn flags(&self) -> Pml4eFlags
Get the flags associated with this entry.
This function extracts the flags from the PML4E, which may indicate whether the page map level entry is present, writable, user-accessible, etc.
§Returns
A Pml4eFlags value representing the flags associated with this
entry.
Sourcepub fn set_pa(&mut self, pa: Pa) -> Result<&mut Self, PageTableMappingError>
pub fn set_pa(&mut self, pa: Pa) -> Result<&mut Self, PageTableMappingError>
Set the physical address for this entry.
This method updates the physical address of the PML4E while preserving the current flags (e.g., read/write permissions). It ensures that the provided physical address is aligned to a 4K boundary (the page size), as required by the architecture.
§Parameters
pa: The new physical address to set for the entry.
§Returns
Ok(&mut Self)if the address is valid and the update is successful.Err(PageTableMappingError::Unaligned)if the provided physical address is not aligned.
§Warning
This operation does not modify the flags of the entry.
Sourcepub fn set_flags(&mut self, perm: Pml4eFlags) -> &mut Self
pub fn set_flags(&mut self, perm: Pml4eFlags) -> &mut Self
Set the flags for this entry.
This method allows you to update the flags associated with the PML4E without modifying the physical address. It combines the current physical address with the new flags and sets the updated value back into the entry.
§Parameters
perm: The new set of flags to assign to the entry.
§Returns
A mutable reference to self, allowing for method chaining.
Sourcepub fn clear(&mut self) -> Option<Pa>
pub fn clear(&mut self) -> Option<Pa>
Clears the entry.
This method removes any previously set physical address and flags from the entry. If the entry contained a valid physical address before being cleared, that address is returned.
§Returns
Some(Pa): The physical address that was previously stored in the entry, if it existed.None: If the entry did not contain a valid physical address.
Sourcepub fn into_pdp_mut(&mut self) -> Result<&mut [Pdpe], PageTableMappingError>
pub fn into_pdp_mut(&mut self) -> Result<&mut [Pdpe], PageTableMappingError>
Get a mutable reference to the page directory pointer table pointed to by this entry.
This method retrieves a mutable reference to the page directory pointer table (PDP) that this PML4E points to, assuming that the entry is present (i.e., the “P” flag is set).
§Returns
Ok(&mut [Pdpe])if the page directory pointer table is valid, represented as a mutable slice ofPdpe(page directory pointer entries).Err(PageTableMappingError::NotExist)if the PML4E is not present or invalid.
§Safety
This operation assumes that the physical address of the page directory pointer table is valid and properly aligned.
Sourcepub fn into_pdp(&self) -> Result<&[Pdpe], PageTableMappingError>
pub fn into_pdp(&self) -> Result<&[Pdpe], PageTableMappingError>
Get a reference to the page directory pointer table pointed to by this entry.
This method retrieves an immutable reference to the page directory pointer table (PDP) that this PML4E points to, assuming that the entry is present (i.e., the “P” flag is set).
§Returns
Ok(&[Pdpe])if the page directory pointer table is valid, represented as an immutable slice ofPdpe(page directory pointer entries).Err(PageTableMappingError::NotExist)if the PML4E is not present or invalid.
§Safety
This operation assumes that the physical address of the page directory pointer table is valid and properly aligned.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Pml4e
impl RefUnwindSafe for Pml4e
impl Send for Pml4e
impl Sync for Pml4e
impl Unpin for Pml4e
impl UnwindSafe for Pml4e
Blanket Implementations§
§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)