Trait devices::bus::BusDevice

source ·
pub trait BusDevice: Send + Suspendable {
Show 13 methods // Required methods fn debug_label(&self) -> String; fn device_id(&self) -> DeviceId; // Provided methods fn read(&mut self, offset: BusAccessInfo, data: &mut [u8]) { ... } fn write(&mut self, offset: BusAccessInfo, data: &[u8]) { ... } fn config_register_write( &mut self, reg_idx: usize, offset: u64, data: &[u8] ) -> ConfigWriteResult { ... } fn config_register_read(&self, reg_idx: usize) -> u32 { ... } fn init_pci_config_mapping( &mut self, shmem: &SharedMemory, base: usize, len: usize ) -> bool { ... } fn virtual_config_register_write(&mut self, reg_idx: usize, value: u32) { ... } fn virtual_config_register_read(&self, reg_idx: usize) -> u32 { ... } fn on_sandboxed(&mut self) { ... } fn get_ranges(&self) -> Vec<(BusRange, BusType)> { ... } fn destroy_device(&mut self) { ... } fn is_bridge(&self) -> Option<u8> { ... }
}
Expand description

Trait for devices that respond to reads or writes in an arbitrary address space.

The device does not care where it exists in address space as each method is only given an offset into its allocated portion of address space.

Required Methods§

source

fn debug_label(&self) -> String

Returns a label suitable for debug output.

source

fn device_id(&self) -> DeviceId

Returns a unique id per device type suitable for metrics gathering.

Provided Methods§

source

fn read(&mut self, offset: BusAccessInfo, data: &mut [u8])

Reads at offset from this device

source

fn write(&mut self, offset: BusAccessInfo, data: &[u8])

Writes at offset into this device

source

fn config_register_write( &mut self, reg_idx: usize, offset: u64, data: &[u8] ) -> ConfigWriteResult

Sets a register in the configuration space. Only used by PCI.

  • reg_idx - The index of the config register to modify.
  • offset - Offset in to the register.
source

fn config_register_read(&self, reg_idx: usize) -> u32

Gets a register from the configuration space. Only used by PCI.

  • reg_idx - The index of the config register to read.
source

fn init_pci_config_mapping( &mut self, shmem: &SharedMemory, base: usize, len: usize ) -> bool

Provides a memory region to back MMIO access to the configuration space. If the device can keep the memory region up to date, then it should return true, after which no more calls to config_register_read will be made. Otherwise the device should return false.

The device must set the header type register (0x0E) before returning from this function, and must make no further modifications to it after returning. This is to allow the caller to manage the multi- function device bit without worrying about race conditions.

  • shmem - The shared memory to use for the configuration space.
  • base - The base address of the memory region in shmem.
  • len - The length of the memory region.
source

fn virtual_config_register_write(&mut self, reg_idx: usize, value: u32)

Sets a register in the virtual config space. Only used by PCI.

  • reg_idx - The index of the config register to modify.
  • value - The value to be written.
source

fn virtual_config_register_read(&self, reg_idx: usize) -> u32

Gets a register from the virtual config space. Only used by PCI.

  • reg_idx - The index of the config register to read.
source

fn on_sandboxed(&mut self)

Invoked when the device is sandboxed.

source

fn get_ranges(&self) -> Vec<(BusRange, BusType)>

Gets a list of all ranges registered by this BusDevice.

source

fn destroy_device(&mut self)

Invoked when the device is destroyed

source

fn is_bridge(&self) -> Option<u8>

Returns the secondary bus number if this bus device is pci bridge

Implementors§