device: Improvement for BusDevice trait and PciDevice trait

BusDevice includes two methods which are only for PCI devices, which should
be as members of PciDevice trait for a better clean high level APIs.

Signed-off-by: Jing Liu <jing2.liu@linux.intel.com>
This commit is contained in:
Jing Liu
2019-06-05 17:24:18 +08:00
committed by Sebastien Boeuf
parent 5f7d520dc1
commit 9da2343cb7
5 changed files with 31 additions and 27 deletions

View File

@@ -80,6 +80,13 @@ pub trait PciDevice: BusDevice {
fn ioeventfds(&self) -> Vec<(&EventFd, u64, u64)> {
Vec::new()
}
/// Sets a register in the configuration space.
/// * `reg_idx` - The index of the config register to modify.
/// * `offset` - Offset in to the register.
fn write_config_register(&mut self, reg_idx: usize, offset: u64, data: &[u8]);
/// Gets a register from the configuration space.
/// * `reg_idx` - The index of the config register to read.
fn read_config_register(&self, reg_idx: usize) -> u32;
/// Reads from a BAR region mapped in to the device.
/// * `addr` - The guest address inside the BAR.
/// * `data` - Filled with the data from `addr`.