Trait VirtIOTransport

Source
pub trait VirtIOTransport {
    // Required methods
    fn initialize(
        &self,
        driver: &dyn VirtIODeviceDriver,
        queues: &'static [&'static dyn Virtqueue],
    ) -> Result<VirtIODeviceType, VirtIOInitializationError>;
    fn queue_notify(&self, queue_id: u32);
}
Expand description

VirtIO transports.

VirtIO can be used over multiple different transports, such as over a PCI bus, an MMIO device or channel IO. This trait provides a basic abstraction over such transports.

Required Methods§

Source

fn initialize( &self, driver: &dyn VirtIODeviceDriver, queues: &'static [&'static dyn Virtqueue], ) -> Result<VirtIODeviceType, VirtIOInitializationError>

Initialize the VirtIO transport using a device driver instance.

This function is expected to run the basic initialization routine as defined for the various VirtIO transports. As part of this routine, it shall

  • negotiate device features,
  • invoke the driver pre_device_initialization hook before and device_initialized hook after announcing the DRIVER_OK device status flag to the device,
  • register the passed Virtqueues with the device, calling the Virtqueue::initialize function with the registered queue ID before registration,
  • as well as perform any other required initialization of the VirtIO transport.

The passed Virtqueues are registered with a queue ID matching their offset in the supplied slice.

If the initialization fails, it shall report this condition to the device (setting FAILED) if it has started initializing the device (setting the ACKNOWLEDGE device status flag), and return an appropriate VirtIOInitializationError. Otherwise, it shall return the type of device connected to this VirtIO transport.

Source

fn queue_notify(&self, queue_id: u32)

Notify the device of a changed Virtqueue.

Whenever a queue has been updated (e.g. move descriptors from the used to available ring) and these updates shall be made visible to the driver, the queue can invoke this function, passing its own respective queue ID.

Implementors§