pub struct VirtualMemoryPageBits {}Expand description
Unified, ergonomic view over x86-64 paging entries (all levels / forms).
This type deliberately does not use bit-packing. Instead, it models the semantic superset of fields across:
- L4:
Pml4Entry(non-leaf only) - L3:
Pdpte(non-leaf) /Pdpte1G(1 GiB leaf) - L2:
Pde(non-leaf) /Pde2M(2 MiB leaf) - L1:
PtEntry4k(4 KiB leaf)
Use the provided from_* and to_* helpers to map between this view and
the actual bitfield entries. Alignment and level-specific constraints are
validated in to_* conversions (debug assertions).
Fields§
§present: boolPresent (P): valid entry if true.
writable: boolWritable (RW): allows writes if true.
user: boolUser/Supervisor (US): user-mode access if true.
write_through: boolPage Write-Through (PWT): write-through policy (PAT bit0).
cache_disable: boolPage Cache Disable (PCD): disable caching (PAT bit1).
accessed: boolAccessed (A): set by CPU on first access. Not a permission bit.
dirty: boolDirty (D): set by CPU on first write.
Meaningful for leaf entries only. Ignored in non-leaf mappings.
global: boolGlobal (G): TLB not flushed on CR3 reload (leaf only).
no_execute: boolExecute Disable / NX: disallow instruction fetch if true.
Requires EFER.NXE support. Applies across the walk (permission
intersection).
protection_key: u8Protection key (PKU) or OS-use (bits 59..62).
Only meaningful if PKU is supported; otherwise free for OS use.
Value is masked to 4 bits on to_*.
os_available_low: u8OS-available (low): bits 9..11 (masked to 3 bits in to_*).
os_available_high: u8OS-available (high): bits 52..58 (masked to 7 bits in to_*).
pat_bit2: boolPAT selector bit #2:
- 4 KiB leaf: this is PTE bit7 (PAT small).
- 2 MiB leaf: this is PDE bit12 (PAT large).
- 1 GiB leaf: this is PDPTE bit12 (PAT large).
- Non-leaf: ignored and forced to
falseinto_*.
Combined with write_through(bit3) and cache_disable(bit4) to form the
3-bit PAT index: [pat_bit2 : PCD : PWT].
Implementations§
Source§impl VirtualMemoryPageBits
impl VirtualMemoryPageBits
pub fn set_present(&mut self, value: bool) -> &mut Self
pub const fn with_present(self, value: bool) -> Self
pub fn set_writable(&mut self, value: bool) -> &mut Self
pub const fn with_writable(self, value: bool) -> Self
pub fn set_user(&mut self, value: bool) -> &mut Self
pub const fn with_user(self, value: bool) -> Self
pub fn set_write_through(&mut self, value: bool) -> &mut Self
pub const fn with_write_through(self, value: bool) -> Self
pub fn set_cache_disable(&mut self, value: bool) -> &mut Self
pub const fn with_cache_disable(self, value: bool) -> Self
pub fn set_accessed(&mut self, value: bool) -> &mut Self
pub const fn with_accessed(self, value: bool) -> Self
pub fn set_dirty(&mut self, value: bool) -> &mut Self
pub const fn with_dirty(self, value: bool) -> Self
pub fn set_global(&mut self, value: bool) -> &mut Self
pub const fn with_global(self, value: bool) -> Self
pub fn set_no_execute(&mut self, value: bool) -> &mut Self
pub const fn with_no_execute(self, value: bool) -> Self
pub fn set_protection_key(&mut self, value: u8) -> &mut Self
pub const fn with_protection_key(self, value: u8) -> Self
pub fn set_os_available_low(&mut self, value: u8) -> &mut Self
pub const fn with_os_available_low(self, value: u8) -> Self
pub fn set_os_available_high(&mut self, value: u8) -> &mut Self
pub const fn with_os_available_high(self, value: u8) -> Self
pub fn set_pat_bit2(&mut self, value: bool) -> &mut Self
pub const fn with_pat_bit2(self, value: bool) -> Self
Source§impl VirtualMemoryPageBits
impl VirtualMemoryPageBits
Sourcepub const fn with_write_combining(self) -> Self
pub const fn with_write_combining(self) -> Self
Enable write-combining (WC) via PAT registers.
Sourcepub const fn from_pml4e(e: &Pml4Entry) -> Self
pub const fn from_pml4e(e: &Pml4Entry) -> Self
Populate from an L4 Pml4Entry (non-leaf).
Sourcepub const fn from_pdpte(e: &Pdpte) -> Self
pub const fn from_pdpte(e: &Pdpte) -> Self
Populate from an L3 Pdpte (non-leaf).
Sourcepub const fn from_pdpte_1g(e: &Pdpte1G) -> Self
pub const fn from_pdpte_1g(e: &Pdpte1G) -> Self
Populate from an L3 Pdpte1G (1 GiB leaf).
Sourcepub const fn from_pde_2m(e: &Pde2M) -> Self
pub const fn from_pde_2m(e: &Pde2M) -> Self
Populate from an L2 Pde2M (2 MiB leaf).
Sourcepub const fn from_pte_4k(e: &PtEntry4k) -> Self
pub const fn from_pte_4k(e: &PtEntry4k) -> Self
Populate from an L1 PtEntry4k (4 KiB leaf).
Source§impl VirtualMemoryPageBits
impl VirtualMemoryPageBits
Sourcepub const fn to_pml4e(&self, page: PhysicalPage<Size4K>) -> Pml4Entry
pub const fn to_pml4e(&self, page: PhysicalPage<Size4K>) -> Pml4Entry
Encode into Pml4Entry (non-leaf).
- Requires
form == L4Entry - Enforces 4 KiB alignment; ignores
dirty,global,pat_bit2.
Sourcepub const fn to_pdpte(&self, page: PhysicalPage<Size4K>) -> Pdpte
pub const fn to_pdpte(&self, page: PhysicalPage<Size4K>) -> Pdpte
Encode into Pdpte (non-leaf).
Sourcepub const fn to_pdpte_1g(&self, page: PhysicalPage<Size1G>) -> Pdpte1G
pub const fn to_pdpte_1g(&self, page: PhysicalPage<Size1G>) -> Pdpte1G
Encode into Pdpte1G (1 GiB leaf).
Trait Implementations§
Source§impl Clone for VirtualMemoryPageBits
impl Clone for VirtualMemoryPageBits
Source§fn clone(&self) -> VirtualMemoryPageBits
fn clone(&self) -> VirtualMemoryPageBits
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more