Trait chipset_device::mmio::ControlMmioIntercept

source ·
pub trait ControlMmioIntercept: Send + Sync {
    // Required methods
    fn region_name(&self) -> &str;
    fn map(&mut self, addr: u64);
    fn unmap(&mut self);
    fn addr(&self) -> Option<u64>;
    fn len(&self) -> u64;
    fn offset_of(&self, addr: u64) -> Option<u64>;
}
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: u64)

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

Return the currently mapped address.

Returns None if the region is currently unmapped.

source

fn len(&self) -> u64

Return the length of the region.

source

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

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 ControlMmioIntercept

source§

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

Inspects the object.

Implementations on Foreign Types§

source§

impl ControlMmioIntercept for ()

source§

fn region_name(&self) -> &str

source§

fn map(&mut self, _addr: u64)

source§

fn unmap(&mut self)

source§

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

source§

fn len(&self) -> u64

source§

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

Implementors§