vmm: Port DeviceManager to Aml::append_aml_bytes()

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
Rob Bradford 2021-11-04 17:12:59 +00:00
parent 185f0c1bf3
commit d96d98d88e

View File

@ -3889,12 +3889,10 @@ fn numa_node_id_from_memory_zone_id(numa_nodes: &NumaNodes, memory_zone_id: &str
#[cfg(feature = "acpi")] #[cfg(feature = "acpi")]
impl Aml for DeviceManager { impl Aml for DeviceManager {
fn to_aml_bytes(&self) -> Vec<u8> { fn append_aml_bytes(&self, bytes: &mut Vec<u8>) {
#[cfg(target_arch = "aarch64")] #[cfg(target_arch = "aarch64")]
use arch::aarch64::DeviceInfoForFdt; use arch::aarch64::DeviceInfoForFdt;
let mut bytes = Vec::new();
let mut pci_scan_methods = Vec::new(); let mut pci_scan_methods = Vec::new();
for i in 0..self.pci_segments.len() { for i in 0..self.pci_segments.len() {
pci_scan_methods.push(aml::MethodCall::new( pci_scan_methods.push(aml::MethodCall::new(
@ -3908,8 +3906,7 @@ impl Aml for DeviceManager {
} }
// PCI hotplug controller // PCI hotplug controller
bytes.extend_from_slice( aml::Device::new(
&aml::Device::new(
"_SB_.PHPR".into(), "_SB_.PHPR".into(),
vec![ vec![
&aml::Name::new("_HID".into(), &aml::EisaName::new("PNP0A06")), &aml::Name::new("_HID".into(), &aml::EisaName::new("PNP0A06")),
@ -3963,10 +3960,13 @@ impl Aml for DeviceManager {
&aml::Method::new("PSCN".into(), 0, true, pci_scan_inner), &aml::Method::new("PSCN".into(), 0, true, pci_scan_inner),
], ],
) )
.to_aml_bytes(), .append_aml_bytes(bytes);
);
let mbrd_dsdt_data = aml::Device::new( for segment in &self.pci_segments {
segment.append_aml_bytes(bytes);
}
aml::Device::new(
"_SB_.MBRD".into(), "_SB_.MBRD".into(),
vec![ vec![
&aml::Name::new("_HID".into(), &aml::EisaName::new("PNP0C02")), &aml::Name::new("_HID".into(), &aml::EisaName::new("PNP0C02")),
@ -3981,7 +3981,7 @@ impl Aml for DeviceManager {
), ),
], ],
) )
.to_aml_bytes(); .append_aml_bytes(bytes);
// Serial device // Serial device
#[cfg(target_arch = "x86_64")] #[cfg(target_arch = "x86_64")]
@ -3998,7 +3998,8 @@ impl Aml for DeviceManager {
// If serial is turned off, add a fake device with invalid irq. // If serial is turned off, add a fake device with invalid irq.
31 31
}; };
let com1_dsdt_data = aml::Device::new( if self.config.lock().unwrap().serial.mode != ConsoleOutputMode::Off {
aml::Device::new(
"_SB_.COM1".into(), "_SB_.COM1".into(),
vec![ vec![
&aml::Name::new( &aml::Name::new(
@ -4025,41 +4026,26 @@ impl Aml for DeviceManager {
), ),
], ],
) )
.to_aml_bytes(); .append_aml_bytes(bytes);
}
let s5_sleep_data = aml::Name::new("_S5_".into(), &aml::Package::new(vec![&5u8])).append_aml_bytes(bytes);
aml::Name::new("_S5_".into(), &aml::Package::new(vec![&5u8])).to_aml_bytes();
let power_button_dsdt_data = aml::Device::new( aml::Device::new(
"_SB_.PWRB".into(), "_SB_.PWRB".into(),
vec![ vec![
&aml::Name::new("_HID".into(), &aml::EisaName::new("PNP0C0C")), &aml::Name::new("_HID".into(), &aml::EisaName::new("PNP0C0C")),
&aml::Name::new("_UID".into(), &aml::ZERO), &aml::Name::new("_UID".into(), &aml::ZERO),
], ],
) )
.to_aml_bytes(); .append_aml_bytes(bytes);
let ged_data = self self.ged_notification_device
.ged_notification_device
.as_ref() .as_ref()
.unwrap() .unwrap()
.lock() .lock()
.unwrap() .unwrap()
.to_aml_bytes(); .append_aml_bytes(bytes);
for segment in &self.pci_segments {
let pci_dsdt_data = segment.to_aml_bytes();
bytes.extend_from_slice(pci_dsdt_data.as_slice());
}
bytes.extend_from_slice(mbrd_dsdt_data.as_slice());
if self.config.lock().unwrap().serial.mode != ConsoleOutputMode::Off {
bytes.extend_from_slice(com1_dsdt_data.as_slice());
}
bytes.extend_from_slice(s5_sleep_data.as_slice());
bytes.extend_from_slice(power_button_dsdt_data.as_slice());
bytes.extend_from_slice(ged_data.as_slice());
bytes
} }
} }