Trait PageTableEntryTrait

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

Source

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.

Source

fn new_page(paddr: Paddr, level: PagingLevel, prop: PageProperty) -> Self

Creates a new PTE that maps to a page.

Source

fn new_pt(paddr: Paddr) -> Self

Creates a new PTE that maps to a child page table.

Source

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

fn prop(&self) -> PageProperty

Returns the page property of the PTE.

Source

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.

Source

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§

Source

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.

Source

fn as_usize(self) -> usize

Converts the PTE into a raw usize value.

Source

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.

Implementors§

Source§

impl PageTableEntryTrait for ostd::arch::iommu::dma_remapping::second_stage::PageTableEntry

Source§

impl PageTableEntryTrait for ostd::arch::mm::PageTableEntry