Kernel: Reorder ACPI initialization method calls
This commit is contained in:
parent
53c356a940
commit
00b0dcd306
|
@ -624,16 +624,6 @@ acpi_release_global_lock:
|
||||||
{
|
{
|
||||||
ASSERT(!m_namespace);
|
ASSERT(!m_namespace);
|
||||||
|
|
||||||
TRY(AML::Namespace::prepare_root_namespace());
|
|
||||||
m_namespace = &AML::Namespace::root_namespace();
|
|
||||||
|
|
||||||
if (auto ret = load_aml_tables("DSDT"_sv, false); ret.is_error())
|
|
||||||
dwarnln("Could not load DSDT: {}", ret.error());
|
|
||||||
if (auto ret = load_aml_tables("SSDT"_sv, true); ret.is_error())
|
|
||||||
dwarnln("Could not load all SSDTs: {}", ret.error());
|
|
||||||
if (auto ret = load_aml_tables("PSDT"_sv, true); ret.is_error())
|
|
||||||
dwarnln("Could not load all PSDTs: {}", ret.error());
|
|
||||||
|
|
||||||
// https://uefi.org/htmlspecs/ACPI_Spec_6_4_html/16_Waking_and_Sleeping/initialization.html#placing-the-system-in-acpi-mode
|
// https://uefi.org/htmlspecs/ACPI_Spec_6_4_html/16_Waking_and_Sleeping/initialization.html#placing-the-system-in-acpi-mode
|
||||||
|
|
||||||
// If not hardware-reduced ACPI and SCI_EN is not set
|
// If not hardware-reduced ACPI and SCI_EN is not set
|
||||||
|
@ -663,6 +653,18 @@ acpi_release_global_lock:
|
||||||
|
|
||||||
dprintln("Entered ACPI mode");
|
dprintln("Entered ACPI mode");
|
||||||
|
|
||||||
|
TRY(AML::Namespace::prepare_root_namespace());
|
||||||
|
m_namespace = &AML::Namespace::root_namespace();
|
||||||
|
|
||||||
|
if (auto ret = load_aml_tables("DSDT"_sv, false); ret.is_error())
|
||||||
|
dwarnln("Could not load DSDT: {}", ret.error());
|
||||||
|
if (auto ret = load_aml_tables("SSDT"_sv, true); ret.is_error())
|
||||||
|
dwarnln("Could not load all SSDTs: {}", ret.error());
|
||||||
|
if (auto ret = load_aml_tables("PSDT"_sv, true); ret.is_error())
|
||||||
|
dwarnln("Could not load all PSDTs: {}", ret.error());
|
||||||
|
|
||||||
|
dprintln("Loaded ACPI tables");
|
||||||
|
|
||||||
if (auto ret = m_namespace->post_load_initialize(); ret.is_error())
|
if (auto ret = m_namespace->post_load_initialize(); ret.is_error())
|
||||||
dwarnln("Failed to initialize ACPI namespace: {}", ret.error());
|
dwarnln("Failed to initialize ACPI namespace: {}", ret.error());
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
#include <kernel/ACPI/AML/Node.h>
|
#include <kernel/ACPI/AML/Node.h>
|
||||||
#include <kernel/ACPI/Headers.h>
|
#include <kernel/ACPI/Headers.h>
|
||||||
|
|
||||||
#define STA_PRESENT 0x01
|
#define STA_PRESENT 0x01
|
||||||
#define STA_FUNCTION 0x08
|
#define STA_FUNCTIONAL 0x08
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
|
@ -150,6 +150,10 @@ namespace Kernel::ACPI::AML
|
||||||
|
|
||||||
BAN::ErrorOr<void> Namespace::post_load_initialize()
|
BAN::ErrorOr<void> Namespace::post_load_initialize()
|
||||||
{
|
{
|
||||||
|
auto [sb_path, sb_ref] = TRY(find_named_object({}, TRY(NameString::from_string("\\_SB_"_sv))));
|
||||||
|
if (sb_ref != nullptr)
|
||||||
|
TRY(evaluate_ini(sb_path));
|
||||||
|
|
||||||
BAN::Vector<Scope> to_init;
|
BAN::Vector<Scope> to_init;
|
||||||
TRY(to_init.push_back({}));
|
TRY(to_init.push_back({}));
|
||||||
|
|
||||||
|
@ -176,20 +180,6 @@ namespace Kernel::ACPI::AML
|
||||||
return BAN::Iteration::Continue;
|
return BAN::Iteration::Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto sta_ret = evaluate_sta(child_path);
|
|
||||||
if (sta_ret.is_error())
|
|
||||||
return BAN::Iteration::Continue;
|
|
||||||
|
|
||||||
if (sta_ret.value() & STA_PRESENT)
|
|
||||||
(void)evaluate_ini(child_path);
|
|
||||||
|
|
||||||
if ((sta_ret.value() & STA_PRESENT) || (sta_ret.value() & STA_FUNCTION))
|
|
||||||
{
|
|
||||||
auto child_path_copy = child_path.copy();
|
|
||||||
if (!child_path_copy.is_error())
|
|
||||||
(void)to_init_next.push_back(child_path_copy.release_value());
|
|
||||||
}
|
|
||||||
|
|
||||||
(void)for_each_child(current,
|
(void)for_each_child(current,
|
||||||
[&](const Scope& opregion_path, Reference* opregion_ref) -> BAN::Iteration
|
[&](const Scope& opregion_path, Reference* opregion_ref) -> BAN::Iteration
|
||||||
{
|
{
|
||||||
|
@ -199,6 +189,20 @@ namespace Kernel::ACPI::AML
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
auto sta_ret = evaluate_sta(child_path);
|
||||||
|
if (sta_ret.is_error())
|
||||||
|
return BAN::Iteration::Continue;
|
||||||
|
|
||||||
|
if (sta_ret.value() & STA_PRESENT)
|
||||||
|
(void)evaluate_ini(child_path);
|
||||||
|
|
||||||
|
if ((sta_ret.value() & STA_PRESENT) || (sta_ret.value() & STA_FUNCTIONAL))
|
||||||
|
{
|
||||||
|
auto child_path_copy = child_path.copy();
|
||||||
|
if (!child_path_copy.is_error())
|
||||||
|
(void)to_init_next.push_back(child_path_copy.release_value());
|
||||||
|
}
|
||||||
|
|
||||||
return BAN::Iteration::Continue;
|
return BAN::Iteration::Continue;
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
|
|
Loading…
Reference in New Issue