summary refs log tree commit diff
path: root/arch/src/lib.rs
diff options
context:
space:
mode:
authorDylan Reid <dgreid@chromium.org>2018-05-17 18:47:11 -0700
committerchrome-bot <chrome-bot@chromium.org>2018-06-29 17:50:17 -0700
commitef7352f20828fbe3f7498b4bed231deb98c3da9c (patch)
tree365dddace4f9d09dfd599fc3ef9cad2607ca6301 /arch/src/lib.rs
parent473ae270d0e7b80046471826ffe2d75068605305 (diff)
downloadcrosvm-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 'arch/src/lib.rs')
-rw-r--r--arch/src/lib.rs22
1 files changed, 13 insertions, 9 deletions
diff --git a/arch/src/lib.rs b/arch/src/lib.rs
index 9b781c5..19ea98b 100644
--- a/arch/src/lib.rs
+++ b/arch/src/lib.rs
@@ -3,10 +3,10 @@
 // found in the LICENSE file.
 
 extern crate sys_util;
+extern crate resources;
 extern crate kernel_cmdline;
 extern crate kvm;
 extern crate libc;
-extern crate device_manager;
 extern crate devices;
 
 use std::ffi::CStr;
@@ -14,8 +14,10 @@ use std::fs::File;
 use std::result;
 use std::sync::{Arc, Mutex};
 
+use devices::Bus;
 use kvm::{Kvm, Vm, Vcpu};
 use sys_util::{EventFd, GuestMemory};
+use resources::SystemAllocator;
 
 pub type Result<T> = result::Result<T, Box<std::error::Error>>;
 
@@ -52,6 +54,14 @@ pub trait LinuxArch {
     /// * `mem` - The memory to be used by the guest.
     fn create_vm(kvm: &Kvm, mem: GuestMemory) -> Result<Vm>;
 
+    /// This adds any early platform devices for this architecture.
+    ///
+    /// # Arguments
+    ///
+    /// * `vm` - The vm to add irqs to.
+    /// * `bus` - The bus to add devices to.
+    fn add_arch_devs(_vm: &mut Vm, _bus: &mut Bus) -> Result<()> { Ok(()) }
+
     /// This creates a GuestMemory object for this VM
     ///
     /// * `mem_size` - Desired physical memory size in bytes for this VM
@@ -76,14 +86,8 @@ pub trait LinuxArch {
     /// This returns a minimal kernel command for this architecture.
     fn get_base_linux_cmdline() -> kernel_cmdline::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>;
+    /// Returns a system resource allocator.
+    fn get_resource_allocator(mem_size: u64) -> SystemAllocator;
 
     /// Sets up the IO bus for this platform
     ///