vm-allocator: Allow for freeing system resources

We allow freeing PIO and MMIO address ranges for now.

Fixes: #27

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
This commit is contained in:
Samuel Ortiz 2019-05-21 17:43:03 +02:00
parent 4b451b01d9
commit 9f247751e7

View File

@ -100,4 +100,18 @@ impl SystemAllocator {
) -> Option<GuestAddress> {
self.mmio_address_space.allocate(address, size)
}
/// Free an IO address range.
/// We can only free a range if it matches exactly an already allocated range.
pub fn free_io_addresses(&mut self, address: GuestAddress, size: GuestUsize) {
if let Some(io_address) = self.io_address_space.as_mut() {
io_address.free(address, size)
}
}
/// Free an MMIO address range.
/// We can only free a range if it matches exactly an already allocated range.
pub fn free_mmio_addresses(&mut self, address: GuestAddress, size: GuestUsize) {
self.mmio_address_space.free(address, size)
}
}