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 /x86_64 | |
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 'x86_64')
-rw-r--r-- | x86_64/Cargo.toml | 2 | ||||
-rw-r--r-- | x86_64/src/lib.rs | 26 |
2 files changed, 13 insertions, 15 deletions
diff --git a/x86_64/Cargo.toml b/x86_64/Cargo.toml index 3a88f98..5baf336 100644 --- a/x86_64/Cargo.toml +++ b/x86_64/Cargo.toml @@ -7,10 +7,10 @@ authors = ["The Chromium OS Authors"] arch = { path = "../arch" } data_model = { path = "../data_model" } devices = { path = "../devices" } -device_manager = { path = "../device_manager" } kvm_sys = { path = "../kvm_sys" } kvm = { path = "../kvm" } sys_util = { path = "../sys_util" } +resources = { path = "../resources" } kernel_cmdline = { path = "../kernel_cmdline" } kernel_loader = { path = "../kernel_loader" } libc = "*" diff --git a/x86_64/src/lib.rs b/x86_64/src/lib.rs index 1fcaed0..1e13e77 100644 --- a/x86_64/src/lib.rs +++ b/x86_64/src/lib.rs @@ -6,11 +6,11 @@ extern crate arch; extern crate byteorder; extern crate data_model; extern crate devices; -extern crate device_manager; extern crate kvm; extern crate kvm_sys; extern crate libc; extern crate sys_util; +extern crate resources; extern crate kernel_cmdline; extern crate kernel_loader; @@ -70,6 +70,7 @@ use std::io::stdout; use bootparam::boot_params; use bootparam::E820_RAM; use sys_util::{EventFd, GuestAddress, GuestMemory}; +use resources::{AddressRanges, SystemAllocator}; use kvm::*; #[derive(Debug)] @@ -132,6 +133,7 @@ const ZERO_PAGE_OFFSET: u64 = 0x7000; const KERNEL_START_OFFSET: u64 = 0x200000; const CMDLINE_OFFSET: u64 = 0x20000; const CMDLINE_MAX_SIZE: u64 = KERNEL_START_OFFSET - CMDLINE_OFFSET; +const X86_64_IRQ_BASE: u32 = 5; fn configure_system(guest_mem: &GuestMemory, kernel_addr: GuestAddress, @@ -314,19 +316,15 @@ impl arch::LinuxArch for X8664arch { cmdline } - /// This creates and returns a device_manager object for this vm. - /// - /// # Arguments - /// - /// * `vm` - the vm object - /// * `mem` - A copy of the GuestMemory object for this VM. - fn get_device_manager(vm: &mut Vm, mem: GuestMemory) -> - Result<device_manager::DeviceManager> { - const MMIO_BASE: u64 = 0xd0000000; - const MMIO_LEN: u64 = 0x1000; - const IRQ_BASE: u32 = 5; - - Ok(device_manager::DeviceManager::new(vm, mem, MMIO_LEN, MMIO_BASE, IRQ_BASE)) + /// Returns a system resource allocator. + fn get_resource_allocator(mem_size: u64) -> SystemAllocator { + const MMIO_BASE: u64 = 0xe0000000; + let device_addr_start = Self::get_base_dev_pfn(mem_size) * sys_util::pagesize() as u64; + AddressRanges::new() + .add_io_addresses(0xc000, 0x10000) + .add_mmio_addresses(MMIO_BASE, 0x10000) + .add_device_addresses(device_addr_start, u64::max_value() - device_addr_start) + .create_allocator(X86_64_IRQ_BASE).unwrap() } /// Sets up the IO bus for this platform |