summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorminus <minus@toneby.com>2022-09-25 17:29:44 +0200
committerAndrew Kaster <andrewdkaster@gmail.com>2022-10-12 00:11:36 -0600
commitcf48200e7b0c5e7c309ae35472e13f3ff40067e1 (patch)
tree28aeeda1c5114b10bb7eb30a0374e6bba44fc382
parent8c5fa95ba351c690b6cd0a1d8edfc8a2314ce46c (diff)
downloadserenity-cf48200e7b0c5e7c309ae35472e13f3ff40067e1.zip
Kernel: Make the ACPI DSDT table accessible
Expose the DSDT table in ACPI::Parser and in /sys/firmware/acpi as a first little step toward interpreting the AML bytecode from ACPI.
-rw-r--r--Kernel/Firmware/ACPI/Definitions.h5
-rw-r--r--Kernel/Firmware/ACPI/Parser.cpp17
-rw-r--r--Kernel/Firmware/ACPI/Parser.h1
3 files changed, 22 insertions, 1 deletions
diff --git a/Kernel/Firmware/ACPI/Definitions.h b/Kernel/Firmware/ACPI/Definitions.h
index 4375651ca1..9c432ece87 100644
--- a/Kernel/Firmware/ACPI/Definitions.h
+++ b/Kernel/Firmware/ACPI/Definitions.h
@@ -320,6 +320,11 @@ struct [[gnu::packed]] MCFG {
u64 reserved;
PCI_MMIO_Descriptor descriptors[];
};
+
+struct [[gnu::packed]] DSDT {
+ SDTHeader h;
+ unsigned char definition_block[];
+};
}
class Parser;
diff --git a/Kernel/Firmware/ACPI/Parser.cpp b/Kernel/Firmware/ACPI/Parser.cpp
index b9cd91f41a..34084723f0 100644
--- a/Kernel/Firmware/ACPI/Parser.cpp
+++ b/Kernel/Firmware/ACPI/Parser.cpp
@@ -130,6 +130,7 @@ UNMAP_AFTER_INIT void Parser::locate_static_data()
locate_main_system_description_table();
initialize_main_system_description_table();
process_fadt_data();
+ process_dsdt();
}
UNMAP_AFTER_INIT Optional<PhysicalAddress> Parser::find_table(StringView signature)
@@ -170,7 +171,6 @@ UNMAP_AFTER_INIT void Parser::process_fadt_data()
auto sdt = Memory::map_typed<Structures::FADT>(m_fadt).release_value_but_fixme_should_propagate_errors();
dmesgln("ACPI: Fixed ACPI data, Revision {}, length: {} bytes", (size_t)sdt->h.revision, (size_t)sdt->h.length);
- dmesgln("ACPI: DSDT {}", PhysicalAddress(sdt->dsdt_ptr));
m_x86_specific_flags.cmos_rtc_not_present = (sdt->ia_pc_boot_arch_flags & (u8)FADTFlags::IA_PC_Flags::CMOS_RTC_Not_Present);
// FIXME: QEMU doesn't report that we have an i8042 controller in these flags, even if it should (when FADT revision is 3),
@@ -205,6 +205,21 @@ UNMAP_AFTER_INIT void Parser::process_fadt_data()
m_hardware_flags.wbinvd_flush = (sdt->flags & (u32)FADTFlags::FeatureFlags::WBINVD_FLUSH);
}
+UNMAP_AFTER_INIT void Parser::process_dsdt()
+{
+ auto sdt = Memory::map_typed<Structures::FADT>(m_fadt).release_value_but_fixme_should_propagate_errors();
+
+ // Add DSDT-pointer to expose the full table in /sys/firmware/acpi/
+ m_sdt_pointers.append(PhysicalAddress(sdt->dsdt_ptr));
+
+ auto dsdt_or_error = Memory::map_typed<Structures::DSDT>(PhysicalAddress(sdt->dsdt_ptr));
+ if (dsdt_or_error.is_error()) {
+ dmesgln("ACPI: DSDT is unmappable");
+ return;
+ }
+ dmesgln("ACPI: Using DSDT @ {} with {} bytes", PhysicalAddress(sdt->dsdt_ptr), dsdt_or_error.value()->h.length);
+}
+
bool Parser::can_reboot()
{
auto fadt_or_error = Memory::map_typed<Structures::FADT>(m_fadt);
diff --git a/Kernel/Firmware/ACPI/Parser.h b/Kernel/Firmware/ACPI/Parser.h
index 25239f8a93..9f90320ec9 100644
--- a/Kernel/Firmware/ACPI/Parser.h
+++ b/Kernel/Firmware/ACPI/Parser.h
@@ -89,6 +89,7 @@ private:
size_t get_table_size(PhysicalAddress);
u8 get_table_revision(PhysicalAddress);
void process_fadt_data();
+ void process_dsdt();
bool validate_reset_register(Memory::TypedMapping<Structures::FADT> const&);
void access_generic_address(Structures::GenericAddressStructure const&, u32 value);