From 027016ddae1b3c41c053219a21566ea2c35b8185 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Fri, 12 Apr 2024 16:45:00 +0300 Subject: [PATCH] Kernel: Load all SSDTs and PSDTs Spec says to load all tables with unique OEM table IDs but that seem wrong. --- kernel/kernel/ACPI/AML.cpp | 37 ++++++------------------------------- 1 file changed, 6 insertions(+), 31 deletions(-) diff --git a/kernel/kernel/ACPI/AML.cpp b/kernel/kernel/ACPI/AML.cpp index 351203e367..9aa1adbd2e 100644 --- a/kernel/kernel/ACPI/AML.cpp +++ b/kernel/kernel/ACPI/AML.cpp @@ -6,46 +6,21 @@ namespace Kernel::ACPI { - // https://uefi.org/htmlspecs/ACPI_Spec_6_4_html/05_ACPI_Software_Programming_Model/ACPI_Software_Programming_Model.html#secondary-system-description-table-ssdt - // https://uefi.org/htmlspecs/ACPI_Spec_6_4_html/05_ACPI_Software_Programming_Model/ACPI_Software_Programming_Model.html#persistent-system-description-table-psdt - static bool load_all_unique(AML::Namespace& ns, BAN::StringView signature) + static void load_all(AML::Namespace& ns, BAN::StringView signature) { - // Only SSDT and PSDT that have unique OEM Table ID are loaded in order they appear in the RSDT/XSDT - BAN::Vector loaded_oem_table_ids; - for (uint32_t i = 0;; i++) { auto* header = ACPI::ACPI::get().get_header(signature, i); if (!header) break; - bool need_to_parse = true; - for (uint64_t id : loaded_oem_table_ids) - { - if (id == header->oem_table_id) - { - need_to_parse = false; - break; - } - } - - if (!need_to_parse) - { - dprintln("Skipping {}{} ({} bytes)", signature, i, header->length); - continue; - } - dprintln("Parsing {}{} ({} bytes)", signature, i, header->length); if (!ns.parse(*header)) { dwarnln("Failed to parse {}", signature); - return false; + continue; } - - MUST(loaded_oem_table_ids.push_back(header->oem_table_id)); } - - return true; } BAN::RefPtr AML::initialize_namespace() @@ -66,11 +41,11 @@ namespace Kernel::ACPI return {}; } - if (!load_all_unique(*ns, "SSDT")) - return {}; + // https://uefi.org/htmlspecs/ACPI_Spec_6_4_html/05_ACPI_Software_Programming_Model/ACPI_Software_Programming_Model.html#secondary-system-description-table-ssdt + load_all(*ns, "SSDT"); - if (!load_all_unique(*ns, "PSDT")) - return {}; + // https://uefi.org/htmlspecs/ACPI_Spec_6_4_html/05_ACPI_Software_Programming_Model/ACPI_Software_Programming_Model.html#persistent-system-description-table-psdt + load_all(*ns, "PSDT"); #if AML_DEBUG_LEVEL >= 1 ns->debug_print(0);