Skip to content

Commit

Permalink
config_tables: Let ACPI tag type depend on config table entry type in…
Browse files Browse the repository at this point in the history
…stead of RSDP revision
  • Loading branch information
fruhland committed Oct 11, 2024
1 parent e31632c commit fbd7cf8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 19 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ If you want to compile towboot yourself, here are the instructions:

You'll need a nightly Rust compiler.
The version doesn't really matter,
though `1.83.0-nightly (bd53aa3bf 2024-09-02)` definitely works.
though `1.83.0-nightly (52fd99839 2024-10-10)` definitely works.
If you don't know how to install one,
please take a look at [rustup.rs](https://rustup.rs/).

Expand Down
40 changes: 22 additions & 18 deletions towboot/src/boot/config_tables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ use uefi::table::cfg::{
SMBIOS3_GUID,
};

static mut RSDP_V2_SET: bool = false;

/// Go through all of the configuration tables.
/// Some of them are interesting for Multiboot2.
pub(super) fn parse_for_multiboot(info_builder: &mut InfoBuilder) {
Expand Down Expand Up @@ -50,24 +48,30 @@ fn handle_acpi(table: &ConfigTableEntry, info_builder: &mut InfoBuilder) {
warn!("the RSDP is invalid");
return;
}
if rsdp.revision() == 0 {
info_builder.set_rsdp_v1(
rsdp.signature(), rsdp.checksum(),
rsdp.oem_id().as_bytes()[0..6].try_into().unwrap(),
rsdp.revision(), rsdp.rsdt_address(),
);
} else {
unsafe {
if !RSDP_V2_SET {
info_builder.set_rsdp_v2(
rsdp.signature(), rsdp.checksum(),
rsdp.oem_id().as_bytes()[0..6].try_into().unwrap(),
rsdp.revision(), rsdp.rsdt_address(), rsdp.length(),
rsdp.xsdt_address(), rsdp.ext_checksum(),
);
RSDP_V2_SET = true;

match table.guid {
ACPI_GUID => {
if rsdp.revision() != 0 {
warn!("expected RSDP version 0, but got {}", rsdp.revision());
}
info_builder.set_rsdp_v1(
rsdp.signature(), rsdp.checksum(),
rsdp.oem_id().as_bytes()[0..6].try_into().unwrap(),
rsdp.revision(), rsdp.rsdt_address(),
);
}
ACPI2_GUID => {
if rsdp.revision() == 0 {
warn!("expected RSDP version > 0, but got {}", rsdp.revision());
}
info_builder.set_rsdp_v2(
rsdp.signature(), rsdp.checksum(),
rsdp.oem_id().as_bytes()[0..6].try_into().unwrap(),
rsdp.revision(), rsdp.rsdt_address(), rsdp.length(),
rsdp.xsdt_address(), rsdp.ext_checksum(),
);
}
_ => warn!("'handle_acpi()' called with wrong config table entry")
}
}

Expand Down

0 comments on commit fbd7cf8

Please sign in to comment.