Kernel: Actually parse the DSDT

This commit is contained in:
Undefine authored and Sönke Holz committed 2026-11-07 13:27:30 +01:00
1 parent 53b4ea3d31
commit b2c515561a
3 files changed
+25 -5

No files matched your search

+7
View File
@@ -640,7 +640,14 @@ set(AK_SOURCES
)
set(ACPI_SOURCES
../Userland/Libraries/LibACPI/Interpreter.cpp
../Userland/Libraries/LibACPI/NameString.cpp
../Userland/Libraries/LibACPI/Node.cpp
../Userland/Libraries/LibACPI/Object.cpp
../Userland/Libraries/LibACPI/OpcodeFilters.cpp
../Userland/Libraries/LibACPI/OpcodeFrame.cpp
../Userland/Libraries/LibACPI/Table.cpp
../Userland/Libraries/LibACPI/TableStream.cpp
)
set(DT_SOURCES
+15 -5
View File
@@ -2,6 +2,7 @@
* Copyright (c) 2020-2021, Liav A. <[email protected]>
* Copyright (c) 2020-2021, Andreas Kling <[email protected]>
* Copyright (c) 2022, the SerenityOS developers.
* Copyright (c) 2026, Undefine <[email protected]>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -151,12 +152,21 @@ UNMAP_AFTER_INIT ErrorOr<void> Parser::process_dsdt()
// Add DSDT-pointer to expose the full table in /sys/firmware/acpi/
TRY(m_sdt_pointers.try_append(PhysicalAddress(sdt->dsdt_ptr)));
auto dsdt_or_error = Memory::map_typed<::ACPI::Structures::DSDT>(PhysicalAddress(sdt->dsdt_ptr));
if (dsdt_or_error.is_error()) {
dmesgln("ACPI: DSDT is unmappable");
return {};
if (kernel_command_line().acpi_feature_level() == AcpiFeatureLevel::Enabled) {
m_aml_interpreter = TRY(::ACPI::AML::Interpreter::create());
ArmedScopeGuard guard = [&]() {
// Ensure the AML interpreter is cleaned up if an error occurs.
m_aml_interpreter = nullptr;
};
auto dsdt = TRY(Memory::map_typed<::ACPI::Structures::DSDT>(PhysicalAddress(sdt->dsdt_ptr)));
dsdt = TRY(Memory::map_typed<::ACPI::Structures::DSDT>(PhysicalAddress(sdt->dsdt_ptr), dsdt->h.length));
dmesgln("ACPI: Using DSDT @ {} with {} bytes", PhysicalAddress(sdt->dsdt_ptr), dsdt->h.length);
TRY(m_aml_interpreter->load(ReadonlyBytes { dsdt.ptr(), dsdt->h.length }));
guard.disarm();
}
dmesgln("ACPI: Using DSDT @ {} with {} bytes", PhysicalAddress(sdt->dsdt_ptr), dsdt_or_error.value()->h.length);
return {};
}
+3
View File
@@ -16,6 +16,7 @@
#include <Kernel/Memory/TypedMapping.h>
#include <Kernel/Memory/VirtualAddress.h>
#include <LibACPI/Definitions.h>
#include <LibACPI/Interpreter.h>
namespace Kernel::ACPI {
@@ -97,6 +98,8 @@ private:
bool m_xsdt_supported { false };
::ACPI::FADTFlags::HardwareFeatures m_hardware_flags;
::ACPI::FADTFlags::x86_Specific_Flags m_x86_specific_flags;
OwnPtr<::ACPI::AML::Interpreter> m_aml_interpreter;
};
}