Trait IoManagerContext

Source
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§

Source

type Context

Type of context object passed to the callbacks.

Required Methods§

Source

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.

Source

fn commit_tx(&self, ctx: Self::Context)

Commit the transaction.

Source

fn cancel_tx(&self, ctx: Self::Context)

Cancel the transaction.

Source

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 registered
  • resources: 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.
Source

fn unregister_device_io( &self, ctx: &mut Self::Context, resources: &[Resource], ) -> Result<()>

Unregister a device from the IO manager.

§Arguments
  • ctx: context object returned by begin_tx().
  • resources: resource list containing all trapped address ranges for the device.

Implementations on Foreign Types§

Source§

impl<T: IoManagerContext> IoManagerContext for Arc<T>

Source§

type Context = <T as IoManagerContext>::Context

Source§

fn begin_tx(&self) -> Self::Context

Source§

fn commit_tx(&self, ctx: Self::Context)

Source§

fn cancel_tx(&self, ctx: Self::Context)

Source§

fn register_device_io( &self, ctx: &mut Self::Context, device: Arc<dyn DeviceIo>, resources: &[Resource], ) -> Result<(), Error>

Source§

fn unregister_device_io( &self, ctx: &mut Self::Context, resources: &[Resource], ) -> Result<(), Error>

Implementors§