pub struct UniqueMmioPointer<'a, T: ?Sized>(/* private fields */);Expand description
A unique owned pointer to the registers of some MMIO device.
It is guaranteed to be valid and unique; no other access to the MMIO space of the device may
happen for the lifetime 'a.
A UniqueMmioPointer may be created from a mutable reference, but this should only be used for
testing purposes, as references should never be constructed for real MMIO address space.
Implementations§
Source§impl<T> UniqueMmioPointer<'_, T>
impl<T> UniqueMmioPointer<'_, T>
Sourcepub unsafe fn read_unsafe(&mut self) -> T
pub unsafe fn read_unsafe(&mut self) -> T
Performs an MMIO read of the entire T.
§Safety
This field must be safe to perform an MMIO read from.
Sourcepub unsafe fn write_unsafe(&mut self, value: T)
pub unsafe fn write_unsafe(&mut self, value: T)
Performs an MMIO write of the entire T.
Note that this takes &mut self rather than &self because an MMIO read may cause
side-effects that change the state of the device.
§Safety
This field must be safe to perform an MMIO write to.
Source§impl<T: ?Sized> UniqueMmioPointer<'_, T>
impl<T: ?Sized> UniqueMmioPointer<'_, T>
Sourcepub unsafe fn new(regs: NonNull<T>) -> Self
pub unsafe fn new(regs: NonNull<T>) -> Self
Creates a new UniqueMmioPointer from a non-null raw pointer.
§Safety
regs must be a properly aligned and valid pointer to some MMIO address space of type T,
which is mapped as device memory and valid to read and write from any thread with volatile
operations. There must not be any other aliases which are used to access the same MMIO
region while this UniqueMmioPointer exists.
If T contains any fields wrapped in ReadOnly, WriteOnly or ReadWrite then they
must indeed be safe to perform MMIO reads or writes on.
Sourcepub unsafe fn child<U>(&mut self, regs: NonNull<U>) -> UniqueMmioPointer<'_, U>
pub unsafe fn child<U>(&mut self, regs: NonNull<U>) -> UniqueMmioPointer<'_, U>
Sourcepub fn ptr_nonnull(&mut self) -> NonNull<T>
pub fn ptr_nonnull(&mut self) -> NonNull<T>
Returns a NonNull<T> pointer to the MMIO registers.
Source§impl<T: Immutable + IntoBytes> UniqueMmioPointer<'_, ReadPureWrite<T>>
impl<T: Immutable + IntoBytes> UniqueMmioPointer<'_, ReadPureWrite<T>>
Source§impl<T> UniqueMmioPointer<'_, [T]>
impl<T> UniqueMmioPointer<'_, [T]>
Sourcepub fn get(&mut self, index: usize) -> Option<UniqueMmioPointer<'_, T>>
pub fn get(&mut self, index: usize) -> Option<UniqueMmioPointer<'_, T>>
Returns a UniqueMmioPointer to an element of this slice, or None if the index is out of
bounds.
§Example
use safe_mmio::{UniqueMmioPointer, fields::ReadWrite};
let mut slice: UniqueMmioPointer<[ReadWrite<u32>]>;
let mut element = slice.get(1).unwrap();
element.write(42);Source§impl<T, const LEN: usize> UniqueMmioPointer<'_, [T; LEN]>
impl<T, const LEN: usize> UniqueMmioPointer<'_, [T; LEN]>
Sourcepub fn split(&mut self) -> [UniqueMmioPointer<'_, T>; LEN]
pub fn split(&mut self) -> [UniqueMmioPointer<'_, T>; LEN]
Splits a UniqueMmioPointer to an array into an array of UniqueMmioPointers.
Sourcepub fn get(&mut self, index: usize) -> Option<UniqueMmioPointer<'_, T>>
pub fn get(&mut self, index: usize) -> Option<UniqueMmioPointer<'_, T>>
Returns a UniqueMmioPointer to an element of this array, or None if the index is out of
bounds.
§Example
use safe_mmio::{UniqueMmioPointer, fields::ReadWrite};
let mut slice: UniqueMmioPointer<[ReadWrite<u32>; 3]>;
let mut element = slice.get(1).unwrap();
element.write(42);