pub trait UnsafeMmio {
// Required methods
fn len(&self) -> usize;
fn align_offset(&self, align: usize) -> usize;
unsafe fn load8_unchecked(&self, offset: usize) -> u8;
unsafe fn load16_unchecked(&self, offset: usize) -> u16;
unsafe fn load32_unchecked(&self, offset: usize) -> u32;
unsafe fn load64_unchecked(&self, offset: usize) -> u64;
unsafe fn store8_unchecked(&self, offset: usize, v: u8);
unsafe fn store16_unchecked(&self, offset: usize, v: u16);
unsafe fn store32_unchecked(&self, offset: usize, v: u32);
unsafe fn store64_unchecked(&self, offset: usize, v: u64);
}
Expand description
An MMIO region that can be stored to through a shared reference.
This trait requires the caller to uphold some safety constraints, but enables a generic implementation of MmioSplit. See the MmioRegion which provides a safe wrapper on top of this trait.
This is primarily intended to simplify implementing the MmioSplit trait, not for users of the library. However, it is possible to use UnsafeMmio directly, provided the safety requirements are met.
§Safety
- Callers must ensure that stores are never performed concurrently with any other operation on an overlapping range.
- Concurrent loads are allowed on overlapping ranges.
- Callers must ensure that offsets are suitably aligned for the type being loaded or stored.
Required Methods§
Sourcefn len(&self) -> usize
fn len(&self) -> usize
Returns the size, in bytes, of the underlying MMIO region that can be accessed through this object.
Sourcefn align_offset(&self, align: usize) -> usize
fn align_offset(&self, align: usize) -> usize
Returns the first offset into this MMIO region that is suitably aligned foralign
.
An offset is suitably aligned if offset = align_offset(align) + i * align
for some i
.