diff --git a/devices/src/acpi.rs b/devices/src/acpi.rs index 1bee3c9eb..c342817b4 100644 --- a/devices/src/acpi.rs +++ b/devices/src/acpi.rs @@ -5,7 +5,6 @@ use std::sync::Arc; use vm_device::interrupt::InterruptSourceGroup; -use vm_memory::GuestAddress; use vmm_sys_util::eventfd::EventFd; use BusDevice; use HotPlugNotificationFlags; @@ -61,22 +60,14 @@ pub struct AcpiGEDDevice { interrupt: Arc>, notification_type: HotPlugNotificationFlags, ged_irq: u32, - device_base: GuestAddress, } impl AcpiGEDDevice { - pub const DEVICE_SIZE: u64 = 1; - - pub fn new( - interrupt: Arc>, - ged_irq: u32, - device_base: GuestAddress, - ) -> AcpiGEDDevice { + pub fn new(interrupt: Arc>, ged_irq: u32) -> AcpiGEDDevice { AcpiGEDDevice { interrupt, notification_type: HotPlugNotificationFlags::NO_DEVICES_CHANGED, ged_irq, - device_base, } } @@ -91,13 +82,9 @@ impl AcpiGEDDevice { pub fn irq(&self) -> u32 { self.ged_irq } - - pub fn device_base(&self) -> GuestAddress { - self.device_base - } } -// MMIO region reports what type of notification was made +// I/O port reports what type of notification was made impl BusDevice for AcpiGEDDevice { // Spec has all fields as zero fn read(&mut self, _base: u64, _offset: u64, data: &mut [u8]) { diff --git a/vmm/src/device_manager.rs b/vmm/src/device_manager.rs index 52f938d58..a7597ef9d 100644 --- a/vmm/src/device_manager.rs +++ b/vmm/src/device_manager.rs @@ -192,9 +192,6 @@ pub enum DeviceManagerError { /// Failed creating IOAPIC. CreateIoapic(ioapic::Error), - - /// Failed to allocate MMIO area - AllocateMMIO, } pub type DeviceManagerResult = result::Result; @@ -752,28 +749,22 @@ impl DeviceManager { .create_group(PIN_IRQ, ged_irq as InterruptIndex, 1 as InterruptIndex) .map_err(DeviceManagerError::CreateInterruptGroup)?; - let ged_base = address_manager - .allocator - .lock() - .unwrap() - .allocate_mmio_addresses(None, devices::AcpiGEDDevice::DEVICE_SIZE, None) - .ok_or(DeviceManagerError::AllocateMMIO)?; - let ged_device = Arc::new(Mutex::new(devices::AcpiGEDDevice::new( interrupt_group, ged_irq, - ged_base, ))); address_manager - .mmio_bus - .insert( - ged_device.clone(), - ged_base.0, - devices::AcpiGEDDevice::DEVICE_SIZE, - ) - .map_err(DeviceManagerError::BusError)?; + .allocator + .lock() + .unwrap() + .allocate_io_addresses(Some(GuestAddress(0xb000)), 0x1, None) + .ok_or(DeviceManagerError::AllocateIOPort)?; + address_manager + .io_bus + .insert(ged_device.clone(), 0xb000, 0x1) + .map_err(DeviceManagerError::BusError)?; Ok(Some(ged_device)) } @@ -1660,7 +1651,7 @@ impl Drop for DeviceManager { } #[cfg(feature = "acpi")] -fn create_ged_device(ged_base: u64, ged_irq: u32) -> Vec { +fn create_ged_device(ged_irq: u32) -> Vec { aml::Device::new( "_SB_.GED_".into(), vec![ @@ -1672,12 +1663,7 @@ fn create_ged_device(ged_base: u64, ged_irq: u32) -> Vec { true, true, false, false, ged_irq, )]), ), - &aml::OpRegion::new( - "GDST".into(), - aml::OpRegionSpace::SystemMemory, - ged_base as usize, - devices::AcpiGEDDevice::DEVICE_SIZE as usize, - ), + &aml::OpRegion::new("GDST".into(), aml::OpRegionSpace::SystemIO, 0xb000, 0x1), &aml::Field::new( "GDST".into(), aml::FieldAccessType::Byte, @@ -1784,21 +1770,14 @@ impl Aml for DeviceManager { let s5_sleep_data = aml::Name::new("_S5_".into(), &aml::Package::new(vec![&5u8])).to_aml_bytes(); - let ged_irq = self - .ged_notification_device - .as_ref() - .unwrap() - .lock() - .unwrap() - .irq(); - let ged_base = self - .ged_notification_device - .as_ref() - .unwrap() - .lock() - .unwrap() - .device_base(); - let ged_data = create_ged_device(ged_base.0, ged_irq); + let ged_data = create_ged_device( + self.ged_notification_device + .as_ref() + .unwrap() + .lock() + .unwrap() + .irq(), + ); bytes.extend_from_slice(pci_dsdt_data.as_slice()); bytes.extend_from_slice(mbrd_dsdt_data.as_slice());