Trait UnsafeMmio

Source
pub trait UnsafeMmio {
    // Required methods
    fn len(&self) -> usize;
    fn align_offset(&self, align: usize) -> usize;
    unsafe fn load8_unchecked(&self, offset: usize) -> u8;
    unsafe fn load16_unchecked(&self, offset: usize) -> u16;
    unsafe fn load32_unchecked(&self, offset: usize) -> u32;
    unsafe fn load64_unchecked(&self, offset: usize) -> u64;
    unsafe fn store8_unchecked(&self, offset: usize, v: u8);
    unsafe fn store16_unchecked(&self, offset: usize, v: u16);
    unsafe fn store32_unchecked(&self, offset: usize, v: u32);
    unsafe fn store64_unchecked(&self, offset: usize, v: u64);
}
Expand description

An MMIO region that can be stored to through a shared reference.

This trait requires the caller to uphold some safety constraints, but enables a generic implementation of MmioSplit. See the MmioRegion which provides a safe wrapper on top of this trait.

This is primarily intended to simplify implementing the MmioSplit trait, not for users of the library. However, it is possible to use UnsafeMmio directly, provided the safety requirements are met.

§Safety

  • Callers must ensure that stores are never performed concurrently with any other operation on an overlapping range.
  • Concurrent loads are allowed on overlapping ranges.
  • Callers must ensure that offsets are suitably aligned for the type being loaded or stored.

Required Methods§

Source

fn len(&self) -> usize

Returns the size, in bytes, of the underlying MMIO region that can be accessed through this object.

Source

fn align_offset(&self, align: usize) -> usize

Returns the first offset into this MMIO region that is suitably aligned foralign.

An offset is suitably aligned if offset = align_offset(align) + i * align for some i.

Source

unsafe fn load8_unchecked(&self, offset: usize) -> u8

Loads a u8 from this MMIO region at the given offset.

§Safety

See the trait-level documentation.

Source

unsafe fn load16_unchecked(&self, offset: usize) -> u16

Loads a u16 from this MMIO region at the given offset.

§Safety

See the trait-level documentation.

Source

unsafe fn load32_unchecked(&self, offset: usize) -> u32

Loads a u32 from this MMIO region at the given offset.

§Safety

See the trait-level documentation.

Source

unsafe fn load64_unchecked(&self, offset: usize) -> u64

Loads a u64 from this MMIO region at the given offset.

§Safety

See the trait-level documentation.

Source

unsafe fn store8_unchecked(&self, offset: usize, v: u8)

Stores a u8 to this MMIO region at the given offset.

§Safety

See the trait-level documentation.

Source

unsafe fn store16_unchecked(&self, offset: usize, v: u16)

Stores a u16 to this MMIO region at the given offset.

§Safety

See the trait-level documentation.

Source

unsafe fn store32_unchecked(&self, offset: usize, v: u32)

Stores a u32 to this MMIO region at the given offset.

§Safety

See the trait-level documentation.

Source

unsafe fn store64_unchecked(&self, offset: usize, v: u64)

Stores a u64 to this MMIO region at the given offset.

§Safety

See the trait-level documentation.

Implementors§