pub trait MmioExt: Mmio {
Show 21 methods
// Provided methods
fn check_aligned_for<T>(&self, offset: usize) -> Result<(), MmioError> { ... }
fn check_capacity_for<T>(&self, offset: usize) -> Result<(), MmioError> { ... }
fn check_suitable_for<T>(&self, offset: usize) -> Result<(), MmioError> { ... }
fn try_load<T: MmioOperand>(&self, offset: usize) -> Result<T, MmioError> { ... }
fn load<T: MmioOperand>(&self, offset: usize) -> T { ... }
fn try_store<T: MmioOperand>(
&mut self,
offset: usize,
value: T,
) -> Result<(), MmioError> { ... }
fn store<T: MmioOperand>(&mut self, offset: usize, value: T) { ... }
fn try_masked_load<T: MmioOperand>(
&self,
offset: usize,
mask: T,
) -> Result<T, MmioError> { ... }
fn masked_load<T: MmioOperand>(&self, offset: usize, mask: T) -> T { ... }
fn try_masked_modify<T: MmioOperand>(
&mut self,
offset: usize,
mask: T,
value: T,
) -> Result<(), MmioError> { ... }
fn masked_modify<T: MmioOperand>(
&mut self,
offset: usize,
mask: T,
value: T,
) { ... }
fn read_reg<R: ReadableRegister>(&self) -> R { ... }
fn write_reg<R: WritableRegister>(&mut self, reg: R) { ... }
fn update_reg<R: ReadableRegister + WritableRegister, F>(&mut self, f: F)
where F: FnOnce(&mut R) { ... }
fn read_index_reg<R: ReadableIndexedRegister>(&self, index: usize) -> R { ... }
fn write_index_reg<R: WritableIndexedRegister>(
&mut self,
index: usize,
reg: R,
) { ... }
fn update_index_reg<R: ReadableIndexedRegister + WritableIndexedRegister, F>(
&mut self,
index: usize,
f: F,
)
where F: FnOnce(&mut R) { ... }
fn reg<R: Register>(&self) -> RegisterProxy<'_, Self, R> { ... }
fn reg_mut<R: Register>(&mut self) -> RegisterProxyMut<'_, Self, R> { ... }
fn indexed_reg<R: IndexedRegister>(
&self,
) -> IndexedRegisterProxy<'_, Self, R> { ... }
fn indexed_reg_mut<R: IndexedRegister>(
&mut self,
) -> IndexedRegisterProxyMut<'_, Self, R> { ... }
}Expand description
This trait extends Mmio with some useful utilities. There is a blanket implementation for all types implementing Mmio.
Functions may go into this trait instead of Mmio if any of the following is true:
- their behavior shouldn’t differ across Mmio implementations
- they would make Mmio not dyn compatible
- they would introduce an unnecessary burden on Mmio implementers
Provided Methods§
Sourcefn check_aligned_for<T>(&self, offset: usize) -> Result<(), MmioError>
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.
Returns MmioError::Unaligned if the offset os not suitably aligned.
Sourcefn check_capacity_for<T>(&self, offset: usize) -> Result<(), MmioError>
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.
Sourcefn check_suitable_for<T>(&self, offset: usize) -> Result<(), MmioError>
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.
Sourcefn try_load<T: MmioOperand>(&self, offset: usize) -> Result<T, MmioError>
fn try_load<T: MmioOperand>(&self, offset: usize) -> Result<T, MmioError>
Loads an MmioOperand from the MMIO region at the given offset.
§Errors
- MmioError::OutOfRange: if the load would exceed the bounds of this MMIO region.
- MmioError::Unaligned: if the offset is not suitably aligned.
Sourcefn load<T: MmioOperand>(&self, offset: usize) -> T
fn load<T: MmioOperand>(&self, offset: usize) -> T
Loads an MmioOperand from the MMIO region at the given offset.
§Panics
If self.check_suitable_for::<T>(offset) would fail.
See MmioExt::try_load for a non-panicking version.
Sourcefn try_store<T: MmioOperand>(
&mut self,
offset: usize,
value: T,
) -> Result<(), MmioError>
fn try_store<T: MmioOperand>( &mut self, offset: usize, value: T, ) -> Result<(), MmioError>
Stores an MmioOperand to the MMIO region at the given offset.
§Errors
- MmioError::OutOfRange: if the store would exceed the bounds of this MMIO region.
- MmioError::Unaligned: if the offset is not suitably aligned.
Sourcefn store<T: MmioOperand>(&mut self, offset: usize, value: T)
fn store<T: MmioOperand>(&mut self, offset: usize, value: T)
Stores an MmioOperand to the MMIO region at the given offset.
§Panics
If self.check_suitable_for::<T>(offset) would fail.
See MmioExt::try_store for a non-panicking version.
Sourcefn try_masked_load<T: MmioOperand>(
&self,
offset: usize,
mask: T,
) -> Result<T, MmioError>
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.
§Errors
- MmioError::OutOfRange: if the load would exceed the bounds of this MMIO region.
- MmioError::Unaligned: if the offset is not suitably aligned.
Sourcefn masked_load<T: MmioOperand>(&self, offset: usize, mask: T) -> T
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.
§Panics
If self.check_suitable_for::<T>(offset) would fail.
See MmioExt::try_masked_load for a non-panicking version.
Sourcefn try_masked_modify<T: MmioOperand>(
&mut self,
offset: usize,
mask: T,
value: T,
) -> Result<(), MmioError>
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.
This operation performs a read-modify-write in order to only modify the bits matching the mask. As this is performed as a load from device memory followed by a store to device memory, the device may change state in between these operations.
Callers must ensure that the this sequence of operations is valid for the device they’re accessing and their use case.
§Errors
- MmioError::OutOfRange: if the load would exceed the bounds of this MMIO region.
- MmioError::Unaligned: if the offset is not suitably aligned.
Sourcefn masked_modify<T: MmioOperand>(&mut self, offset: usize, mask: T, value: T)
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.
This operation performs a read-modify-write in order to only modify the bits matching the mask. As this is performed as a load from device memory followed by a store to device memory, the device may change state in between these operations.
Callers must ensure that the this sequence of operations is valid for the device they’re accessing and their use case.
§Panics
If self.check_suitable_for::<T>(offset) would fail.
See MmioExt::try_masked_modify for a non-panicking version.
Sourcefn read_reg<R: ReadableRegister>(&self) -> R
fn read_reg<R: ReadableRegister>(&self) -> R
Reads a ReadableRegister from the MMIO region.
Sourcefn write_reg<R: WritableRegister>(&mut self, reg: R)
fn write_reg<R: WritableRegister>(&mut self, reg: R)
Writes a WritableRegister to the MMIO region.
Sourcefn update_reg<R: ReadableRegister + WritableRegister, F>(&mut self, f: F)
fn update_reg<R: ReadableRegister + WritableRegister, F>(&mut self, f: F)
Reads a Register from the MMIO region, updates it with the given function, and writes it
back.
Sourcefn read_index_reg<R: ReadableIndexedRegister>(&self, index: usize) -> R
fn read_index_reg<R: ReadableIndexedRegister>(&self, index: usize) -> R
Reads a ReadableIndexedRegister from the MMIO region at the given index.
Sourcefn write_index_reg<R: WritableIndexedRegister>(&mut self, index: usize, reg: R)
fn write_index_reg<R: WritableIndexedRegister>(&mut self, index: usize, reg: R)
Writes a WritableIndexedRegister to the MMIO region at the given index.
Sourcefn update_index_reg<R: ReadableIndexedRegister + WritableIndexedRegister, F>(
&mut self,
index: usize,
f: F,
)
fn update_index_reg<R: ReadableIndexedRegister + WritableIndexedRegister, F>( &mut self, index: usize, f: F, )
Reads an IndexedRegister from the MMIO region at the given index, updates it with the
given function, and writes it back.
Sourcefn reg<R: Register>(&self) -> RegisterProxy<'_, Self, R>
fn reg<R: Register>(&self) -> RegisterProxy<'_, Self, R>
Returns a RegisterProxy to ergonomically read a single Register.
Sourcefn reg_mut<R: Register>(&mut self) -> RegisterProxyMut<'_, Self, R>
fn reg_mut<R: Register>(&mut self) -> RegisterProxyMut<'_, Self, R>
Returns a RegisterProxyMut to ergonomically mutate a single Register.
Sourcefn indexed_reg<R: IndexedRegister>(&self) -> IndexedRegisterProxy<'_, Self, R>
fn indexed_reg<R: IndexedRegister>(&self) -> IndexedRegisterProxy<'_, Self, R>
Returns an IndexedRegisterProxy to ergonomically read a single IndexedRegister.
Sourcefn indexed_reg_mut<R: IndexedRegister>(
&mut self,
) -> IndexedRegisterProxyMut<'_, Self, R>
fn indexed_reg_mut<R: IndexedRegister>( &mut self, ) -> IndexedRegisterProxyMut<'_, Self, R>
Returns an IndexedRegisterProxyMut to ergonomically mutate a single IndexedRegister.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.