diff --git a/src/hello/hello.d b/src/hello/hello.d index 4ad3198..f1f4007 100644 --- a/src/hello/hello.d +++ b/src/hello/hello.d @@ -399,6 +399,33 @@ private void jump_to_hulk() hulk_header().entry, hulk_virt_stack_top()); } +/** + * Find the ACPI XSDT. + * + * @return Whether it was found. + */ +private bool find_acpi_xsdt() +{ + for (size_t i = 0u; i < st.NumberOfTableEntries; i++) + { + if ((st.ConfigurationTable[i].VendorGuid == EFI_ACPI_TABLE_GUID) || + (st.ConfigurationTable[i].VendorGuid == ACPI_TABLE_GUID)) + { + enum ulong rsdp_magic = 0x20525450_20445352u; + const(EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER) * rdsp = cast(const(EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER) *)st.ConfigurationTable[i].VendorTable; + if (rdsp.Signature == rsdp_magic) + { + if (rdsp.Revision >= EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER_REVISION) + { + bootinfo().acpi_xsdt_phys = rdsp.XsdtAddress; + return true; + } + } + } + } + return false; +} + /** * EFI application entry point. * @@ -414,6 +441,13 @@ extern (C) EFI_STATUS efi_main(EFI_HANDLE image_handle, EFI_SYSTEM_TABLE * st) console.writeln("Welcome to HELLO, HOS EFI Lightweight LOader, v0.1.0"); console.writeln("Firmware vendor: '%S', version: 0x%x", st.FirmwareVendor, st.FirmwareVendor); + if (!find_acpi_xsdt()) + { + console.writeln("Error: Could not locate ACPI XSDT"); + console.wait_key(); + return EFI_SUCCESS; + } + bootinfo().pt_phys = cast(ulong)scratch.current(); if (!set_graphics_mode()) diff --git a/src/hulk/bootinfo.d b/src/hulk/bootinfo.d index f6c415f..3c4cfb5 100644 --- a/src/hulk/bootinfo.d +++ b/src/hulk/bootinfo.d @@ -73,4 +73,7 @@ struct BootInfo /* Size of page tables while jumping to HULK. */ ulong pt_size; + + /* Physical address of ACPI XSDT table. */ + ulong acpi_xsdt_phys; }