mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-10-01 02:55:45 +00:00
arch: x86_64: acpi: Generate MCFG table
The MCFG table contains some PCI configuration details in particular details of where the enhanced configuration space is. Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
451502b50b
commit
638bf0378c
@ -27,6 +27,16 @@ struct IOAPIC {
|
|||||||
pub gsi_base: u32,
|
pub gsi_base: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[repr(packed)]
|
||||||
|
#[derive(Default)]
|
||||||
|
struct PCIRangeEntry {
|
||||||
|
pub base_address: u64,
|
||||||
|
pub segment: u16,
|
||||||
|
pub start: u8,
|
||||||
|
pub end: u8,
|
||||||
|
_reserved: u32
|
||||||
|
}
|
||||||
|
|
||||||
pub fn create_acpi_tables(guest_mem: &GuestMemoryMmap, num_cpus: u8) -> GuestAddress {
|
pub fn create_acpi_tables(guest_mem: &GuestMemoryMmap, num_cpus: u8) -> GuestAddress {
|
||||||
// RSDP is at the EBDA
|
// RSDP is at the EBDA
|
||||||
let rsdp_offset = super::EBDA_START;
|
let rsdp_offset = super::EBDA_START;
|
||||||
@ -93,6 +103,24 @@ pub fn create_acpi_tables(guest_mem: &GuestMemoryMmap, num_cpus: u8) -> GuestAdd
|
|||||||
.expect("Error writing MADT table");
|
.expect("Error writing MADT table");
|
||||||
tables.push(madt_offset.0);
|
tables.push(madt_offset.0);
|
||||||
|
|
||||||
|
// MCFG
|
||||||
|
let mut mcfg = SDT::new(*b"MCFG", 60, 1, *b"CLOUDH", *b"CHMCFG ", 1);
|
||||||
|
|
||||||
|
// 32-bit PCI enhanced configuration mechanism
|
||||||
|
mcfg.append(PCIRangeEntry {
|
||||||
|
base_address: super::MEM_32BIT_DEVICES_GAP_SIZE,
|
||||||
|
segment: 0,
|
||||||
|
start: 0,
|
||||||
|
end: 0xff,
|
||||||
|
..Default::default()
|
||||||
|
});
|
||||||
|
|
||||||
|
let mcfg_offset = madt_offset.checked_add(madt.len() as u64).unwrap();
|
||||||
|
guest_mem
|
||||||
|
.write_slice(mcfg.as_slice(), mcfg_offset)
|
||||||
|
.expect("Error writing MCFG table");
|
||||||
|
tables.push(mcfg_offset.0);
|
||||||
|
|
||||||
// XSDT
|
// XSDT
|
||||||
let mut xsdt = SDT::new(*b"XSDT", 36, 1, *b"CLOUDH", *b"CHXSDT ", 1);
|
let mut xsdt = SDT::new(*b"XSDT", 36, 1, *b"CLOUDH", *b"CHXSDT ", 1);
|
||||||
for table in tables {
|
for table in tables {
|
||||||
@ -100,7 +128,7 @@ pub fn create_acpi_tables(guest_mem: &GuestMemoryMmap, num_cpus: u8) -> GuestAdd
|
|||||||
}
|
}
|
||||||
xsdt.update_checksum();
|
xsdt.update_checksum();
|
||||||
|
|
||||||
let xsdt_offset = madt_offset.checked_add(madt.len() as u64).unwrap();
|
let xsdt_offset = mcfg_offset.checked_add(mcfg.len() as u64).unwrap();
|
||||||
guest_mem
|
guest_mem
|
||||||
.write_slice(xsdt.as_slice(), xsdt_offset)
|
.write_slice(xsdt.as_slice(), xsdt_offset)
|
||||||
.expect("Error writing XSDT table");
|
.expect("Error writing XSDT table");
|
||||||
|
@ -51,7 +51,7 @@ const EBDA_START: GuestAddress = GuestAddress(0xa0000);
|
|||||||
const FIRST_ADDR_PAST_32BITS: GuestAddress = GuestAddress(1 << 32);
|
const FIRST_ADDR_PAST_32BITS: GuestAddress = GuestAddress(1 << 32);
|
||||||
|
|
||||||
// Our 32-bit memory gap starts at 3G.
|
// Our 32-bit memory gap starts at 3G.
|
||||||
const MEM_32BIT_GAP_START: GuestAddress = GuestAddress(0xc000_0000);
|
pub const MEM_32BIT_GAP_START: GuestAddress = GuestAddress(0xc000_0000);
|
||||||
|
|
||||||
// Our 32-bit memory gap size is 1GB.
|
// Our 32-bit memory gap size is 1GB.
|
||||||
const MEM_32BIT_GAP_SIZE: GuestUsize = (1024 << 20);
|
const MEM_32BIT_GAP_SIZE: GuestUsize = (1024 << 20);
|
||||||
|
Loading…
Reference in New Issue
Block a user