pub enum DmaSliceMutImmut<'a, T: ImmutableFromIntoBytes> {
Immutable(DmaSlice<'a, T>),
Mutable(DmaSliceMut<'a, T>),
}Expand description
A buffer that can be safely used for read-only DMA operations, backed by either a shared (immutable) or unique (mutable) Rust slice.
Creating a DmaSliceMutImmut over a Rust slice ensures that all prior
Rust writes to this slice are observable by any DMA operations initiated
through an MMIO write operation, where that MMIO write is performed after
constructing the DmaSliceMutImmut.
For this guarantee to hold, the DmaSliceMutImmut instance must exist for
the duration of the entire DMA operation, until the Rust program has
observed that the operation is complete (such as by reading a status bit in
memory or an MMIO register).
DmaSliceMutImmut may wrap an immutable, shared Rust slice
reference. Furthermore, in contrast to DmaSliceMut, DmaSliceMutImmut may
not expose writes performed by a DMA operation back to Rust. As such, its
contents must not be modified by the DMA operation. For a DMA operation
that may write to the supplied buffer, use DmaSliceMut instead.
Variants§
Immutable(DmaSlice<'a, T>)
Mutable(DmaSliceMut<'a, T>)
Implementations§
Source§impl<'a, T: ImmutableFromIntoBytes> DmaSliceMutImmut<'a, T>
impl<'a, T: ImmutableFromIntoBytes> DmaSliceMutImmut<'a, T>
Sourcepub fn new(slice: &[T], fence: impl DmaFence) -> DmaSliceMutImmut<'_, T>
pub fn new(slice: &[T], fence: impl DmaFence) -> DmaSliceMutImmut<'_, T>
Create a DmaSliceMutImmut from a shared, immutable Rust slice.
This function uses the supplied fence object to ensure that all prior
writes to slice are exposed to any DMA operations initiated by an MMIO
read or write operation after this function returns, and which finish
before the resulting DmaSliceMutImmut is dropped.
Sourcepub fn new_mut(slice: &mut [T], fence: impl DmaFence) -> DmaSliceMutImmut<'_, T>
pub fn new_mut(slice: &mut [T], fence: impl DmaFence) -> DmaSliceMutImmut<'_, T>
Create a DmaSliceMutImmut from a unique, mutable Rust slice.
This function uses the supplied fence object to ensure that all prior
writes to slice are exposed to any DMA operations initiated by an MMIO
read or write operation after this function returns, and which finish
before the resulting DmaSliceMutImmut is dropped.
Even though this method takes a unique, mutable Rust slice, DMA operations must not modify the buffers contents.
Sourcepub fn as_ptr(&self) -> *const T
pub fn as_ptr(&self) -> *const T
Returns the pointer to the first element of the wrapped slice reference.
Sourcepub fn get(&self) -> &'a [T]
pub fn get(&self) -> &'a [T]
Retrieve the inner slice reference.
This is safe, as DmaSliceMutImmut can only be used for read-only DMA
operations. The DMA hardware and software may read the underlying slice
concurrently.