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§
sourcefn debug_label(&self) -> String
fn debug_label(&self) -> String
Returns a label suitable for debug output.
Provided Methods§
sourcefn read(&mut self, offset: BusAccessInfo, data: &mut [u8])
fn read(&mut self, offset: BusAccessInfo, data: &mut [u8])
Reads at offset
from this device
sourcefn write(&mut self, offset: BusAccessInfo, data: &[u8])
fn write(&mut self, offset: BusAccessInfo, data: &[u8])
Writes at offset
into this device
sourcefn config_register_write(
&mut self,
reg_idx: usize,
offset: u64,
data: &[u8]
) -> ConfigWriteResult
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.
sourcefn config_register_read(&self, reg_idx: usize) -> u32
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.
sourcefn init_pci_config_mapping(
&mut self,
shmem: &SharedMemory,
base: usize,
len: usize
) -> bool
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.
sourcefn virtual_config_register_write(&mut self, reg_idx: usize, value: u32)
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.
sourcefn virtual_config_register_read(&self, reg_idx: usize) -> u32
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.
sourcefn on_sandboxed(&mut self)
fn on_sandboxed(&mut self)
Invoked when the device is sandboxed.
sourcefn get_ranges(&self) -> Vec<(BusRange, BusType)>
fn get_ranges(&self) -> Vec<(BusRange, BusType)>
Gets a list of all ranges registered by this BusDevice.
sourcefn destroy_device(&mut self)
fn destroy_device(&mut self)
Invoked when the device is destroyed