pub struct MmioRegion<Impl, Owner = Impl> { /* private fields */ }
Expand description
An MmioRegion
provides a safe implementation of Mmio and MmioSplit on top of an
UnsafeMmio implementation.
The safety constraints of UnsafeMmio require callers to ensure that stores are not performed concurrently with loads for any overlapping range.
This type meets these requirements while supporting being split into independently owned due to the following:
- An MmioRegion has exclusive ownership of a sub-region from the wrapped UnsafeMmio implementation (required by MmioRegion::new).
- An MmioRegion only performs operations that are fully contained within the region it owns.
- All stores are performed through a mutable reference (ensuring stores are exclusive with all other operations to the owned region).
- When splitting off
MmioRegions
, the split_off region owns a range that was owned by region it was split off from prior to the split, and that it has exclusive ownership of after the split.
§Type Parameters
An MmioRegion is parameterized by two types:
Impl
: the UnsafeMmio implementation wrapped by this region.Owner
: an object with shared ownership of theImpl
instance.
An MmioRegion is splittable if Owner
can be cloned.
Implementations§
Source§impl<U: UnsafeMmio> MmioRegion<U>
impl<U: UnsafeMmio> MmioRegion<U>
Sourcepub fn new(inner: U) -> Self
pub fn new(inner: U) -> Self
Create a new MmioRegion
that has exclusive ownership of the entire range.
The returned object is guaranteed to be the only one capable of referencing any value in the range. It can be converted into one that can be split
Sourcepub fn into_split(self) -> MmioRegion<U, Rc<U>>
pub fn into_split(self) -> MmioRegion<U, Rc<U>>
Converts this region into one which can be split.
Source§impl<U: UnsafeMmio + Send + Sync> MmioRegion<U>
impl<U: UnsafeMmio + Send + Sync> MmioRegion<U>
Sourcepub fn into_split_send(self) -> MmioRegion<U, Arc<U>>
pub fn into_split_send(self) -> MmioRegion<U, Arc<U>>
Converts this region into one which can be split and sent.
Trait Implementations§
Source§impl<Impl: UnsafeMmio, Owner: Borrow<Impl>> Mmio for MmioRegion<Impl, Owner>
impl<Impl: UnsafeMmio, Owner: Borrow<Impl>> Mmio for MmioRegion<Impl, Owner>
Source§fn align_offset(&self, align: usize) -> usize
fn align_offset(&self, align: usize) -> usize
align
. Read moreSource§fn try_load8(&self, offset: usize) -> Result<u8, MmioError>
fn try_load8(&self, offset: usize) -> Result<u8, MmioError>
Source§fn try_load16(&self, offset: usize) -> Result<u16, MmioError>
fn try_load16(&self, offset: usize) -> Result<u16, MmioError>
Source§fn try_load32(&self, offset: usize) -> Result<u32, MmioError>
fn try_load32(&self, offset: usize) -> Result<u32, MmioError>
Source§fn try_load64(&self, offset: usize) -> Result<u64, MmioError>
fn try_load64(&self, offset: usize) -> Result<u64, MmioError>
Source§fn try_store8(&mut self, offset: usize, v: u8) -> Result<(), MmioError>
fn try_store8(&mut self, offset: usize, v: u8) -> Result<(), MmioError>
Source§fn try_store16(&mut self, offset: usize, v: u16) -> Result<(), MmioError>
fn try_store16(&mut self, offset: usize, v: u16) -> Result<(), MmioError>
Source§fn try_store32(&mut self, offset: usize, v: u32) -> Result<(), MmioError>
fn try_store32(&mut self, offset: usize, v: u32) -> Result<(), MmioError>
Source§fn try_store64(&mut self, offset: usize, v: u64) -> Result<(), MmioError>
fn try_store64(&mut self, offset: usize, v: u64) -> Result<(), MmioError>
Source§fn load8(&self, offset: usize) -> u8
fn load8(&self, offset: usize) -> u8
Source§fn load16(&self, offset: usize) -> u16
fn load16(&self, offset: usize) -> u16
Source§fn load32(&self, offset: usize) -> u32
fn load32(&self, offset: usize) -> u32
Source§fn load64(&self, offset: usize) -> u64
fn load64(&self, offset: usize) -> u64
Source§fn store8(&mut self, offset: usize, value: u8)
fn store8(&mut self, offset: usize, value: u8)
Source§fn store16(&mut self, offset: usize, value: u16)
fn store16(&mut self, offset: usize, value: u16)
Source§impl<Impl: UnsafeMmio, Owner: Borrow<Impl> + Clone> MmioSplit for MmioRegion<Impl, Owner>
impl<Impl: UnsafeMmio, Owner: Borrow<Impl> + Clone> MmioSplit for MmioRegion<Impl, Owner>
Auto Trait Implementations§
impl<Impl, Owner> Freeze for MmioRegion<Impl, Owner>where
Owner: Freeze,
impl<Impl, Owner> RefUnwindSafe for MmioRegion<Impl, Owner>where
Owner: RefUnwindSafe,
Impl: RefUnwindSafe,
impl<Impl, Owner> Send for MmioRegion<Impl, Owner>
impl<Impl, Owner> Sync for MmioRegion<Impl, Owner>
impl<Impl, Owner> Unpin for MmioRegion<Impl, Owner>
impl<Impl, Owner> UnwindSafe for MmioRegion<Impl, Owner>where
Owner: UnwindSafe,
Impl: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<M> MmioExt for Mwhere
M: Mmio,
impl<M> MmioExt for Mwhere
M: Mmio,
Source§fn check_aligned_for<T>(&self, offset: usize) -> Result<(), MmioError>
fn check_aligned_for<T>(&self, offset: usize) -> Result<(), MmioError>
T
.
There is no guarantee that this offset is within the bounds of the MMIO region or that
there would be sufficient capacity to hold a T
at that offset. See
MmioExt::check_suitable_for. Read moreSource§fn check_capacity_for<T>(&self, offset: usize) -> Result<(), MmioError>
fn check_capacity_for<T>(&self, offset: usize) -> Result<(), MmioError>
T
. There is no guarantee that the offset is suitably aligned. See
MmioExt::check_capacity_for.Source§fn check_suitable_for<T>(&self, offset: usize) -> Result<(), MmioError>
fn check_suitable_for<T>(&self, offset: usize) -> Result<(), MmioError>
T
.