pub trait IoManagerContext {
type Context;
// Required methods
fn begin_tx(&self) -> Self::Context;
fn commit_tx(&self, ctx: Self::Context);
fn cancel_tx(&self, ctx: Self::Context);
fn register_device_io(
&self,
ctx: &mut Self::Context,
device: Arc<dyn DeviceIo>,
resources: &[Resource],
) -> Result<()>;
fn unregister_device_io(
&self,
ctx: &mut Self::Context,
resources: &[Resource],
) -> Result<()>;
}
Expand description
Trait for IO manager context object to support device hotplug at runtime.
The IoManagerContext
objects are passed to devices by the IO manager, so the devices could
use it to hot-add/hot-remove other devices at runtime. It provides a transaction mechanism
to hot-add/hot-remove devices.
Required Associated Types§
Required Methods§
Sourcefn begin_tx(&self) -> Self::Context
fn begin_tx(&self) -> Self::Context
Begin a transaction and return a context object.
The returned context object must be passed to commit_tx() or cancel_tx() later.
Sourcefn register_device_io(
&self,
ctx: &mut Self::Context,
device: Arc<dyn DeviceIo>,
resources: &[Resource],
) -> Result<()>
fn register_device_io( &self, ctx: &mut Self::Context, device: Arc<dyn DeviceIo>, resources: &[Resource], ) -> Result<()>
Register a new device with its associated resources to the IO manager.
§Arguments
ctx
: context object returned by begin_tx().device
: device instance object to be registeredresources
: resources representing trapped MMIO/PIO address ranges. Only MMIO/PIO address ranges will be handled, and other types of resource will be ignored. So the caller does not need to filter out non-MMIO/PIO resources.