pci: Extend PciDevice trait with new free_bars() method

The point of this new method is to let the caller decide when the
implementation of the PciDevice should free the BARs previously
allocated through the other method allocate_bars().

This provides a way to perform proper cleanup for any PCI device.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf 2020-03-11 09:25:26 +01:00 committed by Rob Bradford
parent 911a2d61d7
commit f3dc245c4f

View File

@ -55,6 +55,11 @@ pub trait PciDevice: BusDevice {
Ok(Vec::new())
}
/// Frees the PCI BARs previously allocated with a call to allocate_bars().
fn free_bars(&mut self, _allocator: &mut SystemAllocator) -> Result<()> {
Ok(())
}
/// Sets a register in the configuration space.
/// * `reg_idx` - The index of the config register to modify.
/// * `offset` - Offset in to the register.