arch: acpi: Only add ACPI COM1 device if serial is turned on

Only add the ACPI PNP device for the COM1 serial port if it is not
turned off with "--serial off"

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
Rob Bradford 2019-08-22 11:18:48 +01:00 committed by Samuel Ortiz
parent 15387cd96a
commit 2610f4353d
4 changed files with 19 additions and 10 deletions

View File

@ -16,6 +16,7 @@ pub fn configure_system(
_cmdline_addr: GuestAddress,
_cmdline_size: usize,
_num_cpus: u8,
_serial_enabled: bool,
) -> super::Result<()> {
Ok(())
}

View File

@ -37,7 +37,7 @@ struct PCIRangeEntry {
_reserved: u32
}
pub fn create_dsdt_table() -> SDT {
pub fn create_dsdt_table(serial_enabled: bool) -> SDT {
/*
The hex tables in this file are generated from the ASL below with:
"iasl -tc <dsdt.asl>"
@ -142,18 +142,23 @@ pub fn create_dsdt_table() -> SDT {
// DSDT
let mut dsdt = SDT::new(*b"DSDT", 36, 6, *b"CLOUDH", *b"CHDSDT ", 1);
dsdt.append(pci_dsdt_data);
dsdt.append(com1_dsdt_data);
if serial_enabled {
dsdt.append(com1_dsdt_data);
}
dsdt
}
pub fn create_acpi_tables(guest_mem: &GuestMemoryMmap, num_cpus: u8) -> GuestAddress {
pub fn create_acpi_tables(
guest_mem: &GuestMemoryMmap,
num_cpus: u8,
serial_enabled: bool,
) -> GuestAddress {
// RSDP is at the EBDA
let rsdp_offset = super::EBDA_START;
let mut tables: Vec<u64> = Vec::new();
// DSDT
let dsdt = create_dsdt_table();
let dsdt = create_dsdt_table(serial_enabled);
let dsdt_offset = rsdp_offset.checked_add(RSDP::len() as u64).unwrap();
guest_mem
.write_slice(dsdt.as_slice(), dsdt_offset)

View File

@ -127,6 +127,7 @@ pub fn configure_system(
cmdline_size: usize,
num_cpus: u8,
setup_hdr: Option<setup_header>,
serial_enabled: bool,
) -> super::Result<()> {
const KERNEL_BOOT_FLAG_MAGIC: u16 = 0xaa55;
const KERNEL_HDR_MAGIC: u32 = 0x53726448;
@ -182,7 +183,7 @@ pub fn configure_system(
}
}
let rsdp_addr = acpi::create_acpi_tables(guest_mem, num_cpus);
let rsdp_addr = acpi::create_acpi_tables(guest_mem, num_cpus, serial_enabled);
params.0.acpi_rsdp_addr = rsdp_addr.0;
let zero_page_addr = layout::ZERO_PAGE_START;
@ -251,7 +252,7 @@ mod tests {
fn test_system_configuration() {
let no_vcpus = 4;
let gm = GuestMemoryMmap::new(&vec![(GuestAddress(0), 0x10000)]).unwrap();
let config_err = configure_system(&gm, GuestAddress(0), 0, 1, None);
let config_err = configure_system(&gm, GuestAddress(0), 0, 1, None, false);
assert!(config_err.is_err());
assert_eq!(
config_err.unwrap_err(),
@ -269,7 +270,7 @@ mod tests {
.map(|r| (r.0, r.1))
.collect();
let gm = GuestMemoryMmap::new(&ram_regions).unwrap();
configure_system(&gm, GuestAddress(0), 0, no_vcpus, None).unwrap();
configure_system(&gm, GuestAddress(0), 0, no_vcpus, None, false).unwrap();
// Now assigning some memory that is equal to the start of the 32bit memory hole.
let mem_size = 3328 << 20;
@ -280,7 +281,7 @@ mod tests {
.map(|r| (r.0, r.1))
.collect();
let gm = GuestMemoryMmap::new(&ram_regions).unwrap();
configure_system(&gm, GuestAddress(0), 0, no_vcpus, None).unwrap();
configure_system(&gm, GuestAddress(0), 0, no_vcpus, None, false).unwrap();
// Now assigning some memory that falls after the 32bit memory hole.
let mem_size = 3330 << 20;
@ -291,7 +292,7 @@ mod tests {
.map(|r| (r.0, r.1))
.collect();
let gm = GuestMemoryMmap::new(&ram_regions).unwrap();
configure_system(&gm, GuestAddress(0), 0, no_vcpus, None).unwrap();
configure_system(&gm, GuestAddress(0), 0, no_vcpus, None, false).unwrap();
}
#[test]

View File

@ -1634,6 +1634,7 @@ impl<'a> Vm<'a> {
cmdline_cstring.to_bytes().len() + 1,
vcpu_count,
Some(hdr),
self.config.serial.mode != ConsoleOutputMode::Off,
)
.map_err(|_| Error::CmdLine)?;
@ -1652,6 +1653,7 @@ impl<'a> Vm<'a> {
cmdline_cstring.to_bytes().len() + 1,
vcpu_count,
None,
self.config.serial.mode != ConsoleOutputMode::Off,
)
.map_err(|_| Error::CmdLine)?;