pub struct MmioRegion {
base: usize,
size: usize,
}Fields§
§base: usize§size: usizeImplementations§
Source§impl MmioRegion
impl MmioRegion
Sourcepub fn contains(&self, offset: usize, width: usize) -> bool
pub fn contains(&self, offset: usize, width: usize) -> bool
Bounds + alignment check for a would-be access of width bytes at
offset, without performing it.
Drivers exposing user-controllable offsets (e.g. /bus/<drv>/reg/<hex>)
must call this before touching MMIO so an out-of-range request fails
with a clean error instead of tripping the panic backstop in
Self::checked_addr and taking the kernel down.
Sourcepub fn check_user_offset(&self, offset: usize) -> Result<(), BusError>
pub fn check_user_offset(&self, offset: usize) -> Result<(), BusError>
Validate a caller-supplied 32-bit register offset (bounds + natural
alignment), mapping failures to [BusError::InvalidAddress] instead
of tripping the panic backstop inside the accessors.
Sourcefn checked_addr(&self, offset: usize, width: usize) -> usize
fn checked_addr(&self, offset: usize, width: usize) -> usize
Performs the checked addr operation.
Enforces region bounds AND natural alignment for the access width:
read_volatile/write_volatile on a misaligned pointer is UB on
several supported architectures (strict-alignment ARM/MIPS), not
just a slow access.
Sourcepub fn set_bits32(&self, offset: usize, bits: u32)
pub fn set_bits32(&self, offset: usize, bits: u32)
Sets bits32.
Sourcepub fn clear_bits32(&self, offset: usize, bits: u32)
pub fn clear_bits32(&self, offset: usize, bits: u32)
Performs the clear bits32 operation.
Sourcepub fn write_field32(&self, offset: usize, mask: u32, shift: u32, value: u32)
pub fn write_field32(&self, offset: usize, mask: u32, shift: u32, value: u32)
Writes field32.
value is masked to the field width before shifting so that a
caller passing an unshifted field value can never trigger a shift
overflow (value may be up to u32::MAX when shift > 0). Bits of
value outside the field width are ignored by contract.