Trait chipset_device::pio::ControlPortIoIntercept

source ·
pub trait ControlPortIoIntercept: Send + Sync {
    // Required methods
    fn region_name(&self) -> &str;
    fn map(&mut self, addr: u16);
    fn unmap(&mut self);
    fn addr(&self) -> Option<u16>;
    fn len(&self) -> u16;
    fn offset_of(&self, addr: u16) -> Option<u16>;
}
Expand description

A trait to map/unmap a device-specific IO memory region.

Required Methods§

source

fn region_name(&self) -> &str

Return the region’s name.

source

fn map(&mut self, addr: u16)

Enables the IO region at the given address.

This method will never fail, as devices are not expected to gracefully handle the case where an IO region overlaps with an existing region.

source

fn unmap(&mut self)

Disables the IO region.

source

fn addr(&self) -> Option<u16>

Return the currently mapped address.

Returns None if the region is currently unmapped.

source

fn len(&self) -> u16

Return the length of the region.

source

fn offset_of(&self, addr: u16) -> Option<u16>

Return the offset of addr from the region’s base address.

Returns None if the provided addr is outside of the memory region, or the region is currently unmapped.

§Example
let foo_region = register.new_io_region("foo", 0x10);
foo_region.map(0x1000);
assert_eq!(foo_region.offset_of(0x1003), Some(3));
assert_eq!(foo_region.offset_of(0x900), None);
assert_eq!(foo_region.offset_of(0x1020), None);
foo_region.unmap();
assert_eq!(foo_region.offset_of(0x1003), None);

Trait Implementations§

source§

impl Inspect for dyn ControlPortIoIntercept

source§

fn inspect(&self, req: Request<'_>)

Inspects the object.

Implementations on Foreign Types§

source§

impl ControlPortIoIntercept for ()

source§

fn region_name(&self) -> &str

source§

fn map(&mut self, _addr: u16)

source§

fn unmap(&mut self)

source§

fn addr(&self) -> Option<u16>

source§

fn len(&self) -> u16

source§

fn offset_of(&self, _addr: u16) -> Option<u16>

Implementors§