Struct TORRegionSpec

Source
pub struct TORRegionSpec { /* private fields */ }
Expand description

A RISC-V PMP memory region specification, configured in TOR mode.

This type checks that the supplied start and end addresses meet the RISC-V TOR requirements, namely that

  • the region’s start address is aligned to a 4-byte boundary
  • the region’s end address is aligned to a 4-byte boundary
  • the region is at least 4 bytes long

Finally, RISC-V restricts physical address spaces to 34 bit on RV32, and 56 bit on RV64 platforms. A TORRegionSpec must not cover addresses exceeding this address space, respectively. In practice, this means that on RV64 platforms TORRegionSpecs whose encoded pmpaddrX CSR contains any non-zero bits in the 10 most significant bits will be rejected. In particular, with the end pmpaddrX CSR / address being exclusive, the region cannot span the last 4 bytes of the 56-bit address space on RV64, or the last 4 bytes of the 34-bit address space on RV32.

By accepting this type, PMP implementations can rely on these requirements to be verified.

Implementations§

Source§

impl TORRegionSpec

Source

pub fn from_pmpaddr_csrs( pmpaddr_a: usize, pmpaddr_b: usize, ) -> Option<TORRegionSpec>

Construct a new TORRegionSpec from a pair of pmpaddrX CSR values.

This method accepts two pmpaddrX CSR values that together are configured to describe a single TOR memory region. The second pmpaddr_b must be strictly greater than pmpaddr_a, which translates into a minimum region size of 4 bytes. Otherwise this function returns None.

For RV64 platforms, this operation also checks if the range would include any address outside of the 56 bit physical address space and, in this case, returns None (tests whether any of the 10 most significant bits of either pmpaddr are non-zero).

Source

pub fn from_start_end(start: *const u8, end: *const u8) -> Option<Self>

Construct a new TORRegionSpec from a range of addresses.

This method accepts a start and end address. It returns Some(region) when all constraints specified in the TORRegionSpec’s documentation are satisfied, otherwise None.

Source

pub fn pmpaddr_a(&self) -> usize

Get the first pmpaddrX CSR value that this TORRegionSpec encodes.

Source

pub fn pmpaddr_b(&self) -> usize

Trait Implementations§

Source§

impl Clone for TORRegionSpec

Source§

fn clone(&self) -> TORRegionSpec

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TORRegionSpec

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Copy for TORRegionSpec

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.