diff options
author | Dylan Reid <dgreid@chromium.org> | 2018-05-17 18:47:11 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-06-29 17:50:17 -0700 |
commit | ef7352f20828fbe3f7498b4bed231deb98c3da9c (patch) | |
tree | 365dddace4f9d09dfd599fc3ef9cad2607ca6301 /resources | |
parent | 473ae270d0e7b80046471826ffe2d75068605305 (diff) | |
download | crosvm-ef7352f20828fbe3f7498b4bed231deb98c3da9c.tar crosvm-ef7352f20828fbe3f7498b4bed231deb98c3da9c.tar.gz crosvm-ef7352f20828fbe3f7498b4bed231deb98c3da9c.tar.bz2 crosvm-ef7352f20828fbe3f7498b4bed231deb98c3da9c.tar.lz crosvm-ef7352f20828fbe3f7498b4bed231deb98c3da9c.tar.xz crosvm-ef7352f20828fbe3f7498b4bed231deb98c3da9c.tar.zst crosvm-ef7352f20828fbe3f7498b4bed231deb98c3da9c.zip |
Remove the device manager and use the new resource allocator
Allow IRQs to be assigned before creating device manager. For PCI, we need to add devices with interrupts before MMIO setup. Add the ability to tell the architecture device manager about IRQs that we have stolen. There was only one function in device_manager and all of its state is now delegated to the resource allocator, remove it. Change-Id: I9afa0e3081a20cb024551ef18ae34fe76a1ef39d Reviewed-on: https://chromium-review.googlesource.com/1089720 Commit-Ready: Dylan Reid <dgreid@chromium.org> Tested-by: Dylan Reid <dgreid@chromium.org> Reviewed-by: Sonny Rao <sonnyrao@chromium.org>
Diffstat (limited to 'resources')
-rw-r--r-- | resources/src/system_allocator.rs | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/resources/src/system_allocator.rs b/resources/src/system_allocator.rs index e03f8c2..fec8b41 100644 --- a/resources/src/system_allocator.rs +++ b/resources/src/system_allocator.rs @@ -23,7 +23,7 @@ use sys_util::pagesize; /// ``` #[derive(Debug, Eq, PartialEq)] pub struct SystemAllocator { - io_address_space: AddressAllocator, + io_address_space: Option<AddressAllocator>, device_address_space: AddressAllocator, mmio_address_space: AddressAllocator, next_irq: u32, @@ -41,14 +41,17 @@ impl SystemAllocator { /// * `mmio_base` - The starting address of MMIO space. /// * `mmio_size` - The size of MMIO space. /// * `first_irq` - The first irq number to give out. - fn new(io_base: u64, io_size: u64, - dev_base: u64, dev_size: u64, - mmio_base: u64, mmio_size: u64, - first_irq: u32) - -> Option<Self> { + fn new(io_base: Option<u64>, io_size: Option<u64>, + dev_base: u64, dev_size: u64, + mmio_base: u64, mmio_size: u64, + first_irq: u32) -> Option<Self> { let page_size = pagesize() as u64; Some(SystemAllocator { - io_address_space: AddressAllocator::new(io_base, io_size, Some(0x400))?, + io_address_space: if let (Some(b), Some(s)) = (io_base, io_size) { + Some(AddressAllocator::new(b, s, Some(0x400))?) + } else { + None + }, device_address_space: AddressAllocator::new(dev_base, dev_size, Some(page_size))?, mmio_address_space: AddressAllocator::new(mmio_base, mmio_size, Some(page_size))?, next_irq: first_irq, @@ -67,7 +70,7 @@ impl SystemAllocator { /// Reserves a section of `size` bytes of IO address space. pub fn allocate_io_addresses(&mut self, size: u64) -> Option<u64> { - self.io_address_space.allocate(size) + self.io_address_space.as_mut()?.allocate(size) } /// Reserves a section of `size` bytes of device address space. @@ -122,7 +125,7 @@ impl AddressRanges { } pub fn create_allocator(&self, first_irq: u32) -> Option<SystemAllocator> { - SystemAllocator::new(self.io_base?, self.io_size?, + SystemAllocator::new(self.io_base, self.io_size, self.device_base?, self.device_size?, self.mmio_base?, self.mmio_size?, first_irq) |