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§
sourcefn region_name(&self) -> &str
fn region_name(&self) -> &str
Return the region’s name.
sourcefn map(&mut self, addr: u64)
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.
sourcefn addr(&self) -> Option<u64>
fn addr(&self) -> Option<u64>
Return the currently mapped address.
Returns None
if the region is currently unmapped.
sourcefn offset_of(&self, addr: u64) -> Option<u64>
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);