pub trait PageTableEntryTrait:
Clone
+ Copy
+ Debug
+ Default
+ Pod
+ PodOnce
+ Sized
+ Send
+ Sync
+ 'static {
// Required methods
fn is_present(&self) -> bool;
fn new_page(paddr: Paddr, level: PagingLevel, prop: PageProperty) -> Self;
fn new_pt(paddr: Paddr) -> Self;
fn paddr(&self) -> Paddr;
fn prop(&self) -> PageProperty;
fn set_prop(&mut self, prop: PageProperty);
fn is_last(&self, level: PagingLevel) -> bool;
// Provided methods
fn new_absent() -> Self { ... }
fn as_usize(self) -> usize { ... }
fn from_usize(pte_raw: usize) -> Self { ... }
}
Expand description
A trait that abstracts architecture-specific page table entries (PTEs).
Note that a default PTE should be a PTE that points to nothing.
Required Methods§
Sourcefn is_present(&self) -> bool
fn is_present(&self) -> bool
Returns if the PTE points to something.
For PTEs created by Self::new_absent
, this method should return
false. For PTEs created by Self::new_page
or Self::new_pt
and modified with Self::set_prop
, this method should return true.
Sourcefn new_page(paddr: Paddr, level: PagingLevel, prop: PageProperty) -> Self
fn new_page(paddr: Paddr, level: PagingLevel, prop: PageProperty) -> Self
Creates a new PTE that maps to a page.
Sourcefn paddr(&self) -> Paddr
fn paddr(&self) -> Paddr
Returns the physical address from the PTE.
The physical address recorded in the PTE is either:
- the physical address of the next-level page table, or
- the physical address of the page that the PTE maps to.
Sourcefn prop(&self) -> PageProperty
fn prop(&self) -> PageProperty
Returns the page property of the PTE.
Sourcefn set_prop(&mut self, prop: PageProperty)
fn set_prop(&mut self, prop: PageProperty)
Sets the page property of the PTE.
This methold has an impact only if the PTE is present. If not, this method will do nothing.
Sourcefn is_last(&self, level: PagingLevel) -> bool
fn is_last(&self, level: PagingLevel) -> bool
Returns if the PTE maps a page rather than a child page table.
The method needs to know the level of the page table where the PTE resides, since architectures like x86-64 have a huge bit only in intermediate levels.
Provided Methods§
Sourcefn new_absent() -> Self
fn new_absent() -> Self
Creates a PTE that points to nothing.
Note that currently the implementation requires a zeroed PTE to be an absent PTE.
Sourcefn from_usize(pte_raw: usize) -> Self
fn from_usize(pte_raw: usize) -> Self
Converts the raw usize
value into a PTE.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.