Trait kernel::io::Io

source ·
pub trait Io {
Show 19 methods // Required methods fn addr(&self) -> usize; fn maxsize(&self) -> usize; // Provided methods fn io_addr<U>(&self, offset: usize) -> Result<usize> { ... } fn try_read8(&self, _offset: usize) -> Result<u8> where Self: IoCapable<u8> { ... } fn try_read16(&self, _offset: usize) -> Result<u16> where Self: IoCapable<u16> { ... } fn try_read32(&self, _offset: usize) -> Result<u32> where Self: IoCapable<u32> { ... } fn try_read64(&self, _offset: usize) -> Result<u64> where Self: IoCapable<u64> { ... } fn try_write8(&self, _value: u8, _offset: usize) -> Result where Self: IoCapable<u8> { ... } fn try_write16(&self, _value: u16, _offset: usize) -> Result where Self: IoCapable<u16> { ... } fn try_write32(&self, _value: u32, _offset: usize) -> Result where Self: IoCapable<u32> { ... } fn try_write64(&self, _value: u64, _offset: usize) -> Result where Self: IoCapable<u64> { ... } fn read8(&self, _offset: usize) -> u8 where Self: IoKnownSize + IoCapable<u8> { ... } fn read16(&self, _offset: usize) -> u16 where Self: IoKnownSize + IoCapable<u16> { ... } fn read32(&self, _offset: usize) -> u32 where Self: IoKnownSize + IoCapable<u32> { ... } fn read64(&self, _offset: usize) -> u64 where Self: IoKnownSize + IoCapable<u64> { ... } fn write8(&self, _value: u8, _offset: usize) where Self: IoKnownSize + IoCapable<u8> { ... } fn write16(&self, _value: u16, _offset: usize) where Self: IoKnownSize + IoCapable<u16> { ... } fn write32(&self, _value: u32, _offset: usize) where Self: IoKnownSize + IoCapable<u32> { ... } fn write64(&self, _value: u64, _offset: usize) where Self: IoKnownSize + IoCapable<u64> { ... }
}
Expand description

Types implementing this trait (e.g. MMIO BARs or PCI config regions) can perform I/O operations on regions of memory.

This is an abstract representation to be implemented by arbitrary I/O backends (e.g. MMIO, PCI config space, etc.).

The Io trait provides:

  • Base address and size information
  • Helper methods for offset validation and address calculation
  • Fallible (runtime checked) accessors for different data widths

Which I/O methods are available depends on which IoCapable<T> traits are implemented for the type.

§Examples

For MMIO regions, all widths (u8, u16, u32, and u64 on 64-bit systems) are typically supported. For PCI configuration space, u8, u16, and u32 are supported but u64 is not.

Required Methods§

source

fn addr(&self) -> usize

Returns the base address of this mapping.

source

fn maxsize(&self) -> usize

Returns the maximum size of this mapping.

Provided Methods§

source

fn io_addr<U>(&self, offset: usize) -> Result<usize>

Returns the absolute I/O address for a given offset, performing runtime bound checks.

source

fn try_read8(&self, _offset: usize) -> Result<u8>
where Self: IoCapable<u8>,

Fallible 8-bit read with runtime bounds check.

source

fn try_read16(&self, _offset: usize) -> Result<u16>
where Self: IoCapable<u16>,

Fallible 16-bit read with runtime bounds check.

source

fn try_read32(&self, _offset: usize) -> Result<u32>
where Self: IoCapable<u32>,

Fallible 32-bit read with runtime bounds check.

source

fn try_read64(&self, _offset: usize) -> Result<u64>
where Self: IoCapable<u64>,

Fallible 64-bit read with runtime bounds check.

source

fn try_write8(&self, _value: u8, _offset: usize) -> Result
where Self: IoCapable<u8>,

Fallible 8-bit write with runtime bounds check.

source

fn try_write16(&self, _value: u16, _offset: usize) -> Result
where Self: IoCapable<u16>,

Fallible 16-bit write with runtime bounds check.

source

fn try_write32(&self, _value: u32, _offset: usize) -> Result
where Self: IoCapable<u32>,

Fallible 32-bit write with runtime bounds check.

source

fn try_write64(&self, _value: u64, _offset: usize) -> Result
where Self: IoCapable<u64>,

Fallible 64-bit write with runtime bounds check.

source

fn read8(&self, _offset: usize) -> u8
where Self: IoKnownSize + IoCapable<u8>,

Infallible 8-bit read with compile-time bounds check.

source

fn read16(&self, _offset: usize) -> u16
where Self: IoKnownSize + IoCapable<u16>,

Infallible 16-bit read with compile-time bounds check.

source

fn read32(&self, _offset: usize) -> u32
where Self: IoKnownSize + IoCapable<u32>,

Infallible 32-bit read with compile-time bounds check.

source

fn read64(&self, _offset: usize) -> u64
where Self: IoKnownSize + IoCapable<u64>,

Infallible 64-bit read with compile-time bounds check.

source

fn write8(&self, _value: u8, _offset: usize)
where Self: IoKnownSize + IoCapable<u8>,

Infallible 8-bit write with compile-time bounds check.

source

fn write16(&self, _value: u16, _offset: usize)
where Self: IoKnownSize + IoCapable<u16>,

Infallible 16-bit write with compile-time bounds check.

source

fn write32(&self, _value: u32, _offset: usize)
where Self: IoKnownSize + IoCapable<u32>,

Infallible 32-bit write with compile-time bounds check.

source

fn write64(&self, _value: u64, _offset: usize)
where Self: IoKnownSize + IoCapable<u64>,

Infallible 64-bit write with compile-time bounds check.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<'a, S: ConfigSpaceKind> Io for ConfigSpace<'a, S>

source§

impl<const SIZE: usize> Io for Mmio<SIZE>