Skip to main content

MmioExt

Trait MmioExt 

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

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.

Returns MmioError::Unaligned if the offset os not suitably aligned.

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.

§Errors
Source

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.

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.

§Errors
Source

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.

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.

§Errors
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.

§Panics

If self.check_suitable_for::<T>(offset) would fail.

See MmioExt::try_masked_load for a non-panicking version.

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.

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
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.

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.

Source

fn read_reg<R: ReadableRegister>(&self) -> R

Reads a ReadableRegister from the MMIO region.

Source

fn write_reg<R: WritableRegister>(&mut self, reg: R)

Writes a WritableRegister to the MMIO region.

Source

fn update_reg<R: ReadableRegister + WritableRegister, F>(&mut self, f: F)
where F: FnOnce(&mut R),

Reads a Register from the MMIO region, updates it with the given function, and writes it back.

Source

fn read_index_reg<R: ReadableIndexedRegister>(&self, index: usize) -> R

Reads a ReadableIndexedRegister from the MMIO region at the given index.

Source

fn write_index_reg<R: WritableIndexedRegister>(&mut self, index: usize, reg: R)

Writes a WritableIndexedRegister to the MMIO region at the given index.

Source

fn update_index_reg<R: ReadableIndexedRegister + WritableIndexedRegister, F>( &mut self, index: usize, f: F, )
where F: FnOnce(&mut R),

Reads an IndexedRegister from the MMIO region at the given index, updates it with the given function, and writes it back.

Source

fn reg<R: Register>(&self) -> RegisterProxy<'_, Self, R>

Returns a RegisterProxy to ergonomically read a single Register.

Source

fn reg_mut<R: Register>(&mut self) -> RegisterProxyMut<'_, Self, R>

Returns a RegisterProxyMut to ergonomically mutate a single Register.

Source

fn indexed_reg<R: IndexedRegister>(&self) -> IndexedRegisterProxy<'_, Self, R>

Returns an IndexedRegisterProxy to ergonomically read a single IndexedRegister.

Source

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.

Implementors§

Source§

impl<M: Mmio + ?Sized> MmioExt for M