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 TORRegionSpec
s 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
impl TORRegionSpec
Sourcepub fn from_pmpaddr_csrs(
pmpaddr_a: usize,
pmpaddr_b: usize,
) -> Option<TORRegionSpec>
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).
Sourcepub fn from_start_end(start: *const u8, end: *const u8) -> Option<Self>
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
.
Sourcepub fn pmpaddr_a(&self) -> usize
pub fn pmpaddr_a(&self) -> usize
Get the first pmpaddrX
CSR value that this TORRegionSpec encodes.
pub fn pmpaddr_b(&self) -> usize
Trait Implementations§
Source§impl Clone for TORRegionSpec
impl Clone for TORRegionSpec
Source§fn clone(&self) -> TORRegionSpec
fn clone(&self) -> TORRegionSpec
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more