Skip to content

Commit

Permalink
efi: Populate EFI configuration table as much as possible
Browse files Browse the repository at this point in the history
Populate with FDT if available, ACPI if available and falling back to the
zero vendor data if neither are available.

Signed-off-by: Rob Bradford <rbradford@rivosinc.com>
  • Loading branch information
rbradford committed Mar 14, 2023
1 parent 49f7c02 commit a9c168e
Showing 1 changed file with 29 additions and 8 deletions.
37 changes: 29 additions & 8 deletions src/efi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1067,8 +1067,28 @@ pub fn efi_exec(
) {
let vendor_data = 0u32;

let ct_entry = if let Some(acpi_rsdp_ptr) = info.rsdp_addr() {
efi::ConfigurationTable {
let ct = unsafe { &mut CT };
let mut ct_index = 0;

// Populate with FDT table if present
if let Some(fdt_addr) = info.fdt_addr() {
ct[ct_index] = efi::ConfigurationTable {
vendor_guid: Guid::from_fields(
0xb1b621d5,
0xf19c,
0x41a5,
0x83,
0x0b,
&[0xd9, 0x15, 0x2c, 0x69, 0xaa, 0xe0],
),
vendor_table: fdt_addr as *const u64 as *mut _,
};
ct_index += 1;
}

// Populate with ACPI RSDP table if present
if let Some(acpi_rsdp_ptr) = info.rsdp_addr() {
ct[ct_index] = efi::ConfigurationTable {
vendor_guid: Guid::from_fields(
0x8868_e871,
0xe4f1,
Expand All @@ -1078,9 +1098,13 @@ pub fn efi_exec(
&[0x00, 0x80, 0xc7, 0x3c, 0x88, 0x81],
),
vendor_table: acpi_rsdp_ptr as *mut _,
}
} else {
efi::ConfigurationTable {
};
ct_index += 1;
}

// Othwerwise fill with zero vendor data
if ct_index == 0 {
ct[ct_index] = efi::ConfigurationTable {
vendor_guid: Guid::from_fields(
0x678a_9665,
0x9957,
Expand All @@ -1093,9 +1117,6 @@ pub fn efi_exec(
}
};

let ct = unsafe { &mut CT };
ct[0] = ct_entry;

let mut stdin = console::STDIN;
let mut stdout = console::STDOUT;
let mut st = unsafe { &mut ST };
Expand Down

0 comments on commit a9c168e

Please sign in to comment.