Compare commits
No commits in common. "5affc73ee66f78c4c60f6a259ac22932f7ba030f" and "8f2f98b7b4b6457278741daef448ca3d8ebabbe6" have entirely different histories.
5affc73ee6
...
8f2f98b7b4
|
@ -132,6 +132,8 @@ acpi_release_global_lock:
|
|||
}
|
||||
}
|
||||
|
||||
s_instance->m_namespace = AML::initialize_namespace();
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -422,10 +424,11 @@ acpi_release_global_lock:
|
|||
|
||||
BAN::ErrorOr<void> ACPI::enter_acpi_mode(uint8_t mode)
|
||||
{
|
||||
ASSERT(!m_namespace);
|
||||
m_namespace = AML::initialize_namespace();
|
||||
if (!m_namespace)
|
||||
{
|
||||
dwarnln("ACPI namespace not initialized");
|
||||
return BAN::Error::from_errno(EFAULT);
|
||||
}
|
||||
|
||||
// https://uefi.org/htmlspecs/ACPI_Spec_6_4_html/16_Waking_and_Sleeping/initialization.html#placing-the-system-in-acpi-mode
|
||||
auto* fadt = static_cast<const FADT*>(get_header("FACP", 0));
|
||||
|
|
|
@ -6,21 +6,46 @@
|
|||
namespace Kernel::ACPI
|
||||
{
|
||||
|
||||
static void load_all(AML::Namespace& ns, BAN::StringView signature)
|
||||
// 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)
|
||||
{
|
||||
// Only SSDT and PSDT that have unique OEM Table ID are loaded in order they appear in the RSDT/XSDT
|
||||
BAN::Vector<uint64_t> 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);
|
||||
continue;
|
||||
return false;
|
||||
}
|
||||
|
||||
MUST(loaded_oem_table_ids.push_back(header->oem_table_id));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
BAN::RefPtr<AML::Namespace> AML::initialize_namespace()
|
||||
|
@ -41,11 +66,11 @@ namespace Kernel::ACPI
|
|||
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, "SSDT"))
|
||||
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 (!load_all_unique(*ns, "PSDT"))
|
||||
return {};
|
||||
|
||||
#if AML_DEBUG_LEVEL >= 1
|
||||
ns->debug_print(0);
|
||||
|
|
Loading…
Reference in New Issue