Struct MmioRegion

Source
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:

  1. An MmioRegion has exclusive ownership of a sub-region from the wrapped UnsafeMmio implementation (required by MmioRegion::new).
  2. An MmioRegion only performs operations that are fully contained within the region it owns.
  3. All stores are performed through a mutable reference (ensuring stores are exclusive with all other operations to the owned region).
  4. 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 the Impl instance.

An MmioRegion is splittable if Owner can be cloned.

Implementations§

Source§

impl<U: UnsafeMmio> MmioRegion<U>

Source

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

Source

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>

Source

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>

Source§

fn len(&self) -> usize

Returns the size in bytes of this MMIO region.
Source§

fn align_offset(&self, align: usize) -> usize

Computes the first offset within this region that is aligned to align. Read more
Source§

fn try_load8(&self, offset: usize) -> Result<u8, MmioError>

Loads one byte from this MMIO region at the given offset. Read more
Source§

fn try_load16(&self, offset: usize) -> Result<u16, MmioError>

Loads two bytes from this MMIO region at the given offset. Read more
Source§

fn try_load32(&self, offset: usize) -> Result<u32, MmioError>

Loads four bytes from this MMIO region at the given offset. Read more
Source§

fn try_load64(&self, offset: usize) -> Result<u64, MmioError>

Loads eight bytes from this MMIO region at the given offset. Read more
Source§

fn try_store8(&mut self, offset: usize, v: u8) -> Result<(), MmioError>

Stores one byte to this MMIO region at the given offset. Read more
Source§

fn try_store16(&mut self, offset: usize, v: u16) -> Result<(), MmioError>

Stores two bytes to this MMIO region at the given offset. Read more
Source§

fn try_store32(&mut self, offset: usize, v: u32) -> Result<(), MmioError>

Stores four bytes to this MMIO region at the given offset. Read more
Source§

fn try_store64(&mut self, offset: usize, v: u64) -> Result<(), MmioError>

Stores eight bytes to this MMIO region at the given offset. Read more
Source§

fn load8(&self, offset: usize) -> u8

Loads one byte from this MMIO region at the given offset. Read more
Source§

fn load16(&self, offset: usize) -> u16

Loads two bytes from this MMIO region at the given offset. Read more
Source§

fn load32(&self, offset: usize) -> u32

Loads four bytes from this MMIO region at the given offset. Read more
Source§

fn load64(&self, offset: usize) -> u64

Loads eight bytes from this MMIO region at the given offset. Read more
Source§

fn store8(&mut self, offset: usize, value: u8)

Stores one byte to this MMIO region at the given offset. Read more
Source§

fn store16(&mut self, offset: usize, value: u16)

Stores two bytes to this MMIO region at the given offset. Read more
Source§

fn store32(&mut self, offset: usize, value: u32)

Stores four bytes to this MMIO region at the given offset. Read more
Source§

fn store64(&mut self, offset: usize, value: u64)

Stores eight bytes to this MMIO region at the given offset. Read more
Source§

impl<Impl: UnsafeMmio, Owner: Borrow<Impl> + Clone> MmioSplit for MmioRegion<Impl, Owner>

Source§

fn try_split_off(&mut self, mid: usize) -> Result<Self, MmioError>

Splits this Mmio region into two at the given mid-point and returns the left-hand-side. This MMIO region’s bounds are updated to contain only the right-hand-side. Read more
Source§

fn split_off(&mut self, mid: usize) -> Self

Splits this MMIO region into two at the given mid-point and returns the left-hand-side. This MMIO region’s bounds are updated to contain only the right-hand-side. Read more

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>
where Owner: Send, Impl: Send,

§

impl<Impl, Owner> Sync for MmioRegion<Impl, Owner>
where Owner: Sync, Impl: Sync,

§

impl<Impl, Owner> Unpin for MmioRegion<Impl, Owner>
where Owner: Unpin, Impl: Unpin,

§

impl<Impl, Owner> UnwindSafe for MmioRegion<Impl, Owner>
where Owner: UnwindSafe, Impl: UnwindSafe,

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> 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<M> MmioExt for M
where M: Mmio,

Source§

fn check_aligned_for<T>(&self, offset: usize) -> Result<(), MmioError>

Check that the given offset into this MMIO region would be suitable aligned for type 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 more
Source§

fn check_capacity_for<T>(&self, offset: usize) -> Result<(), MmioError>

Checks that the given offset into this MMIO region has sufficient capacity to hold a value of type 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>

Checks that the given offset into this MMIO rgion is suitably aligned and has sufficient capacity for a value of type T.
Source§

fn try_load<T: MmioOperand>(&self, offset: usize) -> Result<T, MmioError>

Loads an MmioOperand from the MMIO region at the given offset. Read more
Source§

fn load<T: MmioOperand>(&self, offset: usize) -> T

Loads an MmioOperand from the MMIO region at the given offset. Read more
Source§

fn try_store<T: MmioOperand>( &mut self, offset: usize, value: T, ) -> Result<(), MmioError>

Stores an MmioOperand to the MMIO region at the given offset. Read more
Source§

fn store<T: MmioOperand>(&mut self, offset: usize, value: T)

Stores an MmioOperand to the MMIO region at the given offset. Read more
Source§

fn try_masked_load<T: MmioOperand>( &self, offset: usize, mask: T, ) -> Result<T, MmioError>

Loads an MmioOperand value from an MMIO region at the given offset, returning only the bits set in the given mask. Read more
Source§

fn masked_load<T: MmioOperand>(&self, offset: usize, mask: T) -> T

Loads an MmioOperand value from an MMIO region at the given offset, returning only the bits set in the given mask. Read more
Source§

fn try_masked_modify<T: MmioOperand>( &mut self, offset: usize, mask: T, value: T, ) -> Result<(), MmioError>

Updates the value in the MMIO region at the given offset, only modifying the bits set in the given mask. Read more
Source§

fn masked_modify<T: MmioOperand>(&mut self, offset: usize, mask: T, value: T)

Updates the value in the MMIO region at the given offset, only modifying the bits set in the given mask. Read more
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.