pub trait DeviceConfigSpace: Sized {
// Required method
fn read_config_with<F, T>(self, f: F) -> T
where F: FnMut() -> T;
}
Expand description
Common device configuration space functionality.
Required Methods§
Sourcefn read_config_with<F, T>(self, f: F) -> Twhere
F: FnMut() -> T,
fn read_config_with<F, T>(self, f: F) -> Twhere
F: FnMut() -> T,
Read from device configuration space.
This function should be used when reading from fields greater than 32 bits wide or when reading from multiple fields.
As described in Driver Requirements: Device Configuration Space, this method checks the configuration atomicity value of the device and only returns once the value was the same before and after the provided function.
§Examples
use virtio::net::ConfigVolatileFieldAccess;
use virtio::DeviceConfigSpace;
use volatile::access::ReadOnly;
use volatile::VolatilePtr;
fn read_mac(
common_cfg: VolatilePtr<'_, virtio::pci::CommonCfg, ReadOnly>,
net_cfg: VolatilePtr<'_, virtio::net::Config, ReadOnly>,
) -> [u8; 6] {
common_cfg.read_config_with(|| net_cfg.mac().read())
}
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.