pub struct RootTable<T: Translation> { /* private fields */ }Expand description
A complete hierarchy of page tables including all levels.
Implementations§
Source§impl<T: Translation> RootTable<T>
impl<T: Translation> RootTable<T>
Sourcepub fn new(
translation: T,
level: usize,
translation_regime: TranslationRegime,
va_range: VaRange,
) -> Self
pub fn new( translation: T, level: usize, translation_regime: TranslationRegime, va_range: VaRange, ) -> Self
Creates a new page table starting at the given root level.
The level must be between 0 and 3; level -1 (for 52-bit addresses with LPA2) is not
currently supported by this library. The value of TCR_EL1.T0SZ must be set appropriately
to match.
Sourcepub fn size(&self) -> usize
pub fn size(&self) -> usize
Returns the size in bytes of the virtual address space which can be mapped in this page table.
This is a function of the chosen root level.
Sourcepub fn map_range(
&mut self,
range: &MemoryRegion,
pa: PhysicalAddress,
flags: Attributes,
constraints: Constraints,
) -> Result<(), MapError>
pub fn map_range( &mut self, range: &MemoryRegion, pa: PhysicalAddress, flags: Attributes, constraints: Constraints, ) -> Result<(), MapError>
Recursively maps a range into the pagetable hierarchy starting at the root level, mapping
the pages to the corresponding physical address range starting at pa. Block and page
entries will be written to, but will only be mapped if flags contains Attributes::VALID.
Returns an error if the virtual address range is out of the range covered by the pagetable,
or if the flags argument has unsupported attributes set.
Sourcepub fn to_physical(&self) -> PhysicalAddress
pub fn to_physical(&self) -> PhysicalAddress
Returns the physical address of the root table in memory.
Sourcepub fn va_range(&self) -> VaRange
pub fn va_range(&self) -> VaRange
Returns the virtual address range for which this table is intended.
This affects which TTBR register is used.
Sourcepub fn translation_regime(&self) -> TranslationRegime
pub fn translation_regime(&self) -> TranslationRegime
Returns the translation regime for which this table is intended.
Sourcepub fn translation(&self) -> &T
pub fn translation(&self) -> &T
Returns a reference to the translation used for this page table.
Sourcepub fn modify_range<F>(
&mut self,
range: &MemoryRegion,
f: &F,
) -> Result<(), MapError>
pub fn modify_range<F>( &mut self, range: &MemoryRegion, f: &F, ) -> Result<(), MapError>
Applies the provided updater function to the page table descriptors covering a given memory range.
This may involve splitting block entries if the provided range is not currently mapped
down to its precise boundaries. For visiting all the descriptors covering a memory range
without potential splitting (and no descriptor updates), use
walk_range instead.
The updater function receives the following arguments:
- The virtual address range mapped by each page table descriptor. A new descriptor will have been allocated before the invocation of the updater function if a page table split was needed.
- A mutable reference to the page table descriptor that permits modifications.
- The level of a translation table the descriptor belongs to.
The updater function should return:
Okto continue updating the remaining entries.Errto signal an error and stop updating the remaining entries.
This should generally only be called while the page table is not active. In particular, any change that may require break-before-make per the architecture must be made while the page table is inactive. Mapping a previously unmapped memory range may be done while the page table is active.
§Errors
Returns MapError::PteUpdateFault if the updater function returns an error.
Returns MapError::RegionBackwards if the range is backwards.
Returns MapError::AddressRange if the largest address in the range is greater than the
largest virtual address covered by the page table given its root level.
Returns [`MapError::BreakBeforeMakeViolation’] if the range intersects with live mappings, and modifying those would violate architectural break-before-make (BBM) requirements.
Sourcepub fn walk_range<F>(
&self,
range: &MemoryRegion,
f: &mut F,
) -> Result<(), MapError>
pub fn walk_range<F>( &self, range: &MemoryRegion, f: &mut F, ) -> Result<(), MapError>
Applies the provided callback function to the page table descriptors covering a given memory range.
The callback function receives the following arguments:
- The range covered by the current step in the walk. This is always a subrange of
rangeeven when the descriptor covers a region that exceeds it. - The page table descriptor itself.
- The level of a translation table the descriptor belongs to.
The callback function should return:
Okto continue visiting the remaining entries.Errto signal an error and stop visiting the remaining entries.
§Errors
Returns MapError::PteUpdateFault if the callback function returns an error.
Returns MapError::RegionBackwards if the range is backwards.
Returns MapError::AddressRange if the largest address in the range is greater than the
largest virtual address covered by the page table given its root level.