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.
This commit is contained in:
minus 2022-09-25 17:29:44 +02:00 committed by Andrew Kaster
parent 8c5fa95ba3
commit cf48200e7b
Notes: sideshowbarker 2024-07-17 06:01:50 +09:00
3 changed files with 22 additions and 1 deletions

View file

@ -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;

View file

@ -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);

View file

@ -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);