From fa3951df22300f8c8c8273328c7ac354932bda81 Mon Sep 17 00:00:00 2001 From: Samuel Ortiz Date: Thu, 18 Apr 2019 11:57:01 +0200 Subject: [PATCH] devices: Add PCI configuration registers method to the BusDevice Trait This is the only clean, or not so dirty way for us to pass a BusDevice instance to the PciRoot add_device() method. This is very similar to what crosvm does and we now understand why... Signed-off-by: Samuel Ortiz --- devices/src/bus.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/devices/src/bus.rs b/devices/src/bus.rs index 3b32856c4..bc5047049 100644 --- a/devices/src/bus.rs +++ b/devices/src/bus.rs @@ -24,6 +24,16 @@ pub trait BusDevice: Send { fn write(&mut self, offset: u64, data: &[u8]) {} /// Triggers the `irq_mask` interrupt on this device fn interrupt(&self, irq_mask: u32) {} + + /// 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. + fn write_config_register(&mut self, reg_idx: usize, offset: u64, data: &[u8]) {} + /// Gets a register from the configuration space. Only used by PCI. + /// * `reg_idx` - The index of the config register to read. + fn read_config_register(&self, reg_idx: usize) -> u32 { + 0 + } } #[derive(Debug)]