1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 11:37:44 +00:00

ACPI: Reorganize the definitions file

More namespaces have been added to organize the declarations
in a more sensible way.
Also, a namespace StaticParsing has been added to allow early
access to ACPI tables.
This commit is contained in:
Liav A 2020-02-28 22:22:50 +02:00 committed by Andreas Kling
parent 976562307a
commit bf55d83c1f

View file

@ -29,11 +29,12 @@
#include <AK/RefCounted.h>
#include <AK/Types.h>
#include <AK/Vector.h>
#include <LibBareMetal/Memory/PhysicalAddress.h>
namespace Kernel {
namespace ACPI_RAW {
namespace ACPI {
namespace Structures {
struct [[gnu::packed]] RSDPDescriptor
{
char sig[8];
@ -196,7 +197,8 @@ namespace ACPI_RAW {
u8 length;
};
struct [[gnu::packed]] MADT_IOAPIC
namespace MADTEntries {
struct [[gnu::packed]] IOAPIC
{
MADTEntryHeader h;
u8 ioapic_id;
@ -205,7 +207,7 @@ namespace ACPI_RAW {
u32 gsi_base;
};
struct [[gnu::packed]] MADT_InterruptSourceOverride
struct [[gnu::packed]] InterruptSourceOverride
{
MADTEntryHeader h;
u8 bus;
@ -213,6 +215,7 @@ namespace ACPI_RAW {
u32 global_system_interrupt;
u16 flags;
};
}
struct [[gnu::packed]] MADT
{
@ -243,134 +246,22 @@ namespace ACPI_RAW {
u64 reserved;
PCI_MMIO_Descriptor descriptors[];
};
}
class ACPIStaticParser;
namespace ACPI {
class SDT : public RefCounted<SDT> {
};
struct GenericAddressStructure {
u8 address_space;
u8 bit_width;
u8 bit_offset;
u8 access_size;
u64 address;
GenericAddressStructure& operator=(const GenericAddressStructure& other)
{
this->address_space = other.address_space;
this->bit_width = other.bit_width;
this->bit_offset = other.bit_offset;
this->access_size = other.access_size;
this->address = (uintptr_t)other.address;
return *this;
}
GenericAddressStructure& operator=(const ACPI_RAW::GenericAddressStructure& other)
{
this->address_space = other.address_space;
this->bit_width = other.bit_width;
this->bit_offset = other.bit_offset;
this->access_size = other.access_size;
this->address = (uintptr_t)other.address;
return *this;
}
};
class FixedACPIData;
}
class ACPI::FixedACPIData : public ACPI::SDT {
friend ACPIStaticParser;
public:
explicit FixedACPIData(ACPI_RAW::FADT&);
ACPI_RAW::SDTHeader* get_dsdt();
private:
u8 m_revision;
u32 m_dsdt_ptr;
u64 m_x_dsdt_ptr;
u8 m_preferred_pm_profile;
u16 m_sci_int;
u32 m_smi_cmd;
u8 m_acpi_enable_value;
u8 m_acpi_disable_value;
u8 m_s4bios_req;
u8 m_pstate_cnt;
u32 m_PM1a_EVT_BLK;
u32 m_PM1b_EVT_BLK;
u32 m_PM1a_CNT_BLK;
u32 m_PM1b_CNT_BLK;
u32 m_PM2_CNT_BLK;
u32 m_PM_TMR_BLK;
u32 m_GPE0_BLK;
u32 m_GPE1_BLK;
u8 m_PM1_EVT_LEN;
u8 m_PM1_CNT_LEN;
u8 m_PM2_CNT_LEN;
u8 m_PM_TMR_LEN;
u8 m_GPE0_BLK_LEN;
u8 m_GPE1_BLK_LEN;
u8 m_GPE1_BASE;
u8 m_cst_cnt;
u16 m_P_LVL2_LAT;
u16 m_P_LVL3_LAT;
u16 m_flush_size;
u16 m_flush_stride;
u8 m_duty_offset;
u8 m_duty_width;
u8 m_day_alrm;
u8 m_mon_alrm;
u8 m_century;
u16 m_ia_pc_boot_arch_flags;
u32 m_flags;
ACPI::GenericAddressStructure m_reset_reg;
u8 m_reset_value;
ACPI::GenericAddressStructure m_x_pm1a_evt_blk;
ACPI::GenericAddressStructure m_x_pm1b_evt_blk;
ACPI::GenericAddressStructure m_x_pm1a_cnt_blk;
ACPI::GenericAddressStructure m_x_pm1b_cnt_blk;
ACPI::GenericAddressStructure m_x_pm2_cnt_blk;
ACPI::GenericAddressStructure m_x_pm_tmr_blk;
ACPI::GenericAddressStructure m_x_gpe0_blk;
ACPI::GenericAddressStructure m_x_gpe1_blk;
ACPI::GenericAddressStructure m_sleep_control;
ACPI::GenericAddressStructure m_sleep_status;
u64 m_hypervisor_vendor_identity;
};
namespace ACPI {
class MainSystemDescriptionTable : public SDT {
public:
explicit MainSystemDescriptionTable(Vector<ACPI_RAW::SDTHeader*>&& sdt_pointers);
Vector<ACPI_RAW::SDTHeader*>& get_sdt_pointers();
private:
Vector<ACPI_RAW::SDTHeader*> m_sdt_pointers;
};
class MCFG : public SDT {
public:
MCFG(ACPI_RAW::MCFG&);
};
class FACS : public SDT {
public:
private:
u32 hardware_sig;
u32 waking_vector;
u32 global_lock;
u32 flags;
u64 x_waking_vector;
u32 ospm_flags;
};
class MADT : public SDT {
};
}
}
class StaticParser;
class DynamicParser;
class Parser;
namespace StaticParsing {
PhysicalAddress search_rsdp_in_ebda(u16 ebda_segment);
PhysicalAddress search_rsdp_in_bios_area();
PhysicalAddress search_rsdp();
bool match_table_signature(PhysicalAddress table_header, const char*);
PhysicalAddress search_table(PhysicalAddress rsdp, const char*);
PhysicalAddress search_table_in_xsdt(PhysicalAddress xsdt, const char*);
PhysicalAddress search_table_in_rsdt(PhysicalAddress rsdt, const char*);
inline bool validate_table(Structures::SDTHeader&, size_t length);
};
}
}