From 9fac5f94ba4c4e9cdd63351e7a2deae85173fa97 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Mon, 15 Apr 2024 15:05:48 +0300 Subject: [PATCH] Kernel: Fix entering ACPI mode My condition to check wheter to enter ACPI mode was incorrect. I only entered ACPI mode if I already was in ACPI mode :DD --- kernel/include/kernel/ACPI/ACPI.h | 3 +++ kernel/kernel/ACPI/ACPI.cpp | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/kernel/include/kernel/ACPI/ACPI.h b/kernel/include/kernel/ACPI/ACPI.h index e43600df15..20d3abb1d5 100644 --- a/kernel/include/kernel/ACPI/ACPI.h +++ b/kernel/include/kernel/ACPI/ACPI.h @@ -17,6 +17,8 @@ namespace Kernel::ACPI static void acquire_global_lock(); static void release_global_lock(); + bool hardware_reduced() const { return m_hardware_reduced; } + const SDTHeader* get_header(BAN::StringView signature, uint32_t index); // mode @@ -47,6 +49,7 @@ namespace Kernel::ACPI }; BAN::Vector m_mapped_headers; + bool m_hardware_reduced { false }; BAN::RefPtr m_namespace; }; diff --git a/kernel/kernel/ACPI/ACPI.cpp b/kernel/kernel/ACPI/ACPI.cpp index 2ba5088561..0e2dd0c90e 100644 --- a/kernel/kernel/ACPI/ACPI.cpp +++ b/kernel/kernel/ACPI/ACPI.cpp @@ -314,6 +314,8 @@ acpi_release_global_lock: .paddr = dsdt_paddr, .vaddr = dsdt_vaddr })); + + m_hardware_reduced = fadt->flags & (1 << 20); } } @@ -431,7 +433,7 @@ acpi_release_global_lock: auto* fadt = static_cast(get_header("FACP", 0)); // If not hardware-reduced ACPI and SCI_EN is not set - if (!(fadt->flags & (1 << 20)) && IO::inw(fadt->pm1a_cnt_blk) & PM1_CNT_SCI_EN) + if (!hardware_reduced() && !(IO::inw(fadt->pm1a_cnt_blk) & PM1_CNT_SCI_EN)) { // https://uefi.org/htmlspecs/ACPI_Spec_6_4_html/04_ACPI_Hardware_Specification/ACPI_Hardware_Specification.html#legacy-acpi-select-and-the-sci-interrupt IO::outb(fadt->smi_cmd, fadt->acpi_enable);