mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-01-09 14:25:21 +00:00
vmm: acpi: Move DeviceManager ACPI device to an MMIO address
Migrate the DeviceManager from a fixed I/O port address to an allocated MMIO address. Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
55a3a38e14
commit
d578c408b7
@ -379,6 +379,9 @@ pub type DeviceManagerResult<T> = result::Result<T, DeviceManagerError>;
|
|||||||
|
|
||||||
type VirtioDeviceArc = Arc<Mutex<dyn virtio_devices::VirtioDevice>>;
|
type VirtioDeviceArc = Arc<Mutex<dyn virtio_devices::VirtioDevice>>;
|
||||||
|
|
||||||
|
#[cfg(feature = "acpi")]
|
||||||
|
const DEVICE_MANAGER_ACPI_SIZE: usize = 0x10;
|
||||||
|
|
||||||
pub fn get_win_size() -> (u16, u16) {
|
pub fn get_win_size() -> (u16, u16) {
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
@ -788,6 +791,9 @@ pub struct DeviceManager {
|
|||||||
// Virtio Device activation EventFd to allow the VMM thread to trigger device
|
// Virtio Device activation EventFd to allow the VMM thread to trigger device
|
||||||
// activation and thus start the threads from the VMM thread
|
// activation and thus start the threads from the VMM thread
|
||||||
activate_evt: EventFd,
|
activate_evt: EventFd,
|
||||||
|
|
||||||
|
#[cfg(feature = "acpi")]
|
||||||
|
acpi_address: GuestAddress,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DeviceManager {
|
impl DeviceManager {
|
||||||
@ -825,6 +831,13 @@ impl DeviceManager {
|
|||||||
vm,
|
vm,
|
||||||
));
|
));
|
||||||
|
|
||||||
|
#[cfg(feature = "acpi")]
|
||||||
|
let acpi_address = address_manager
|
||||||
|
.allocator
|
||||||
|
.lock()
|
||||||
|
.unwrap()
|
||||||
|
.allocate_mmio_addresses(None, DEVICE_MANAGER_ACPI_SIZE as u64, None)
|
||||||
|
.ok_or(DeviceManagerError::AllocateIOPort)?;
|
||||||
let device_manager = DeviceManager {
|
let device_manager = DeviceManager {
|
||||||
address_manager: Arc::clone(&address_manager),
|
address_manager: Arc::clone(&address_manager),
|
||||||
console: Arc::new(Console::default()),
|
console: Arc::new(Console::default()),
|
||||||
@ -860,25 +873,19 @@ impl DeviceManager {
|
|||||||
activate_evt: activate_evt
|
activate_evt: activate_evt
|
||||||
.try_clone()
|
.try_clone()
|
||||||
.map_err(DeviceManagerError::EventFd)?,
|
.map_err(DeviceManagerError::EventFd)?,
|
||||||
};
|
|
||||||
|
|
||||||
#[cfg(feature = "acpi")]
|
#[cfg(feature = "acpi")]
|
||||||
address_manager
|
acpi_address,
|
||||||
.allocator
|
};
|
||||||
.lock()
|
|
||||||
.unwrap()
|
|
||||||
.allocate_io_addresses(Some(GuestAddress(0xae00)), 0x10, None)
|
|
||||||
.ok_or(DeviceManagerError::AllocateIOPort)?;
|
|
||||||
|
|
||||||
let device_manager = Arc::new(Mutex::new(device_manager));
|
let device_manager = Arc::new(Mutex::new(device_manager));
|
||||||
|
|
||||||
#[cfg(feature = "acpi")]
|
#[cfg(feature = "acpi")]
|
||||||
address_manager
|
address_manager
|
||||||
.io_bus
|
.mmio_bus
|
||||||
.insert(
|
.insert(
|
||||||
Arc::clone(&device_manager) as Arc<Mutex<dyn BusDevice>>,
|
Arc::clone(&device_manager) as Arc<Mutex<dyn BusDevice>>,
|
||||||
0xae00,
|
acpi_address.0,
|
||||||
0x10,
|
DEVICE_MANAGER_ACPI_SIZE as u64,
|
||||||
)
|
)
|
||||||
.map_err(DeviceManagerError::BusError)?;
|
.map_err(DeviceManagerError::BusError)?;
|
||||||
|
|
||||||
@ -3315,15 +3322,22 @@ impl Aml for DeviceManager {
|
|||||||
&aml::Name::new("_STA".into(), &0x0bu8),
|
&aml::Name::new("_STA".into(), &0x0bu8),
|
||||||
&aml::Name::new("_UID".into(), &"PCI Hotplug Controller"),
|
&aml::Name::new("_UID".into(), &"PCI Hotplug Controller"),
|
||||||
&aml::Mutex::new("BLCK".into(), 0),
|
&aml::Mutex::new("BLCK".into(), 0),
|
||||||
// I/O port for PCI hotplug controller
|
|
||||||
&aml::Name::new(
|
&aml::Name::new(
|
||||||
"_CRS".into(),
|
"_CRS".into(),
|
||||||
&aml::ResourceTemplate::new(vec![&aml::IO::new(
|
&aml::ResourceTemplate::new(vec![&aml::AddressSpace::new_memory(
|
||||||
0xae00, 0xae00, 0x01, 0x10,
|
aml::AddressSpaceCachable::NotCacheable,
|
||||||
|
true,
|
||||||
|
self.acpi_address.0 as u64,
|
||||||
|
self.acpi_address.0 + DEVICE_MANAGER_ACPI_SIZE as u64 - 1,
|
||||||
)]),
|
)]),
|
||||||
),
|
),
|
||||||
// OpRegion and Fields map I/O port into individual field values
|
// OpRegion and Fields map MMIO range into individual field values
|
||||||
&aml::OpRegion::new("PCST".into(), aml::OpRegionSpace::SystemIO, 0xae00, 0x10),
|
&aml::OpRegion::new(
|
||||||
|
"PCST".into(),
|
||||||
|
aml::OpRegionSpace::SystemMemory,
|
||||||
|
self.acpi_address.0 as usize,
|
||||||
|
DEVICE_MANAGER_ACPI_SIZE,
|
||||||
|
),
|
||||||
&aml::Field::new(
|
&aml::Field::new(
|
||||||
"PCST".into(),
|
"PCST".into(),
|
||||||
aml::FieldAccessType::DWord,
|
aml::FieldAccessType::DWord,
|
||||||
|
Loading…
Reference in New Issue
Block a user