Ver Fonte

ACPI: Keep common flags in structures for later usage

Liav A há 5 anos atrás
pai
commit
5d7855adea

+ 10 - 0
Kernel/ACPI/ACPIParser.cpp

@@ -94,6 +94,16 @@ namespace ACPI {
         klog() << "ACPI Limited: No AML Interpretation Allowed";
         ASSERT_NOT_REACHED();
     }
+    const FADTFlags::HardwareFeatures& Parser::hardware_features() const
+    {
+        klog() << "ACPI Limited: Hardware features cannot be obtained";
+        ASSERT_NOT_REACHED();
+    }
+    const FADTFlags::x86_Specific_Flags& Parser::x86_specific_flags() const
+    {
+        klog() << "ACPI Limited: x86 specific features cannot be obtained";
+        ASSERT_NOT_REACHED();
+    }
     bool Parser::is_operable()
     {
         return false;

+ 3 - 0
Kernel/ACPI/ACPIParser.h

@@ -48,6 +48,9 @@ public:
     virtual void try_acpi_shutdown();
     virtual bool can_shutdown() { return false; }
 
+    virtual const FADTFlags::HardwareFeatures& hardware_features() const;
+    virtual const FADTFlags::x86_Specific_Flags& x86_specific_flags() const;
+
     virtual void enable_aml_interpretation();
     virtual void enable_aml_interpretation(File&);
     virtual void enable_aml_interpretation(u8*, u32);

+ 41 - 3
Kernel/ACPI/ACPIStaticParser.cpp

@@ -87,6 +87,15 @@ namespace ACPI {
         m_facs = find_table("FACS");
     }
 
+    const FADTFlags::HardwareFeatures& StaticParser::hardware_features() const
+    {
+        return m_hardware_flags;
+    }
+    const FADTFlags::x86_Specific_Flags& StaticParser::x86_specific_flags() const
+    {
+        return m_x86_specific_flags;
+    }
+
     void StaticParser::init_fadt()
     {
         klog() << "ACPI: Initializing Fixed ACPI data";
@@ -96,11 +105,40 @@ namespace ACPI {
         ASSERT(!m_fadt.is_null());
 
         auto checkup_region = MM.allocate_kernel_region(m_fadt.page_base(), (PAGE_SIZE * 2), "ACPI Static Parser", Region::Access::Read);
-        auto* sdt = (const Structures::SDTHeader*)checkup_region->vaddr().offset(m_fadt.offset_in_page()).as_ptr();
+        auto* sdt = (const Structures::FADT*)checkup_region->vaddr().offset(m_fadt.offset_in_page()).as_ptr();
 #ifdef ACPI_DEBUG
         dbg() << "ACPI: FADT @ V " << sdt << ", P " << (void*)fadt.as_ptr();
 #endif
-        klog() << "ACPI: Fixed ACPI data, Revision " << sdt->revision << ", Length " << sdt->length << " bytes";
+        klog() << "ACPI: Fixed ACPI data, Revision " << sdt->h.revision << ", Length " << sdt->h.length << " bytes";
+        klog() << "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);
+        m_x86_specific_flags.keyboard_8042 = (sdt->ia_pc_boot_arch_flags & (u8)FADTFlags::IA_PC_Flags::PS2_8042);
+        m_x86_specific_flags.legacy_devices = (sdt->ia_pc_boot_arch_flags & (u8)FADTFlags::IA_PC_Flags::Legacy_Devices);
+        m_x86_specific_flags.msi_not_supported = (sdt->ia_pc_boot_arch_flags & (u8)FADTFlags::IA_PC_Flags::MSI_Not_Supported);
+        m_x86_specific_flags.vga_not_present = (sdt->ia_pc_boot_arch_flags & (u8)FADTFlags::IA_PC_Flags::VGA_Not_Present);
+
+        m_hardware_flags.cpu_software_sleep = (sdt->flags & (u32)FADTFlags::FeatureFlags::CPU_SW_SLP);
+        m_hardware_flags.docking_capability = (sdt->flags & (u32)FADTFlags::FeatureFlags::DCK_CAP);
+        m_hardware_flags.fix_rtc = (sdt->flags & (u32)FADTFlags::FeatureFlags::FIX_RTC);
+        m_hardware_flags.force_apic_cluster_model = (sdt->flags & (u32)FADTFlags::FeatureFlags::FORCE_APIC_CLUSTER_MODEL);
+        m_hardware_flags.force_apic_physical_destination_mode = (sdt->flags & (u32)FADTFlags::FeatureFlags::FORCE_APIC_PHYSICAL_DESTINATION_MODE);
+        m_hardware_flags.hardware_reduced_acpi = (sdt->flags & (u32)FADTFlags::FeatureFlags::HW_REDUCED_ACPI);
+        m_hardware_flags.headless = (sdt->flags & (u32)FADTFlags::FeatureFlags::HEADLESS);
+        m_hardware_flags.low_power_s0_idle_capable = (sdt->flags & (u32)FADTFlags::FeatureFlags::LOW_POWER_S0_IDLE_CAPABLE);
+        m_hardware_flags.multiprocessor_c2 = (sdt->flags & (u32)FADTFlags::FeatureFlags::P_LVL2_UP);
+        m_hardware_flags.pci_express_wake = (sdt->flags & (u32)FADTFlags::FeatureFlags::PCI_EXP_WAK);
+        m_hardware_flags.power_button = (sdt->flags & (u32)FADTFlags::FeatureFlags::PWR_BUTTON);
+        m_hardware_flags.processor_c1 = (sdt->flags & (u32)FADTFlags::FeatureFlags::PROC_C1);
+        m_hardware_flags.remote_power_on_capable = (sdt->flags & (u32)FADTFlags::FeatureFlags::REMOTE_POWER_ON_CAPABLE);
+        m_hardware_flags.reset_register_supported = (sdt->flags & (u32)FADTFlags::FeatureFlags::RESET_REG_SUPPORTED);
+        m_hardware_flags.rtc_s4 = (sdt->flags & (u32)FADTFlags::FeatureFlags::RTC_s4);
+        m_hardware_flags.s4_rtc_status_valid = (sdt->flags & (u32)FADTFlags::FeatureFlags::S4_RTC_STS_VALID);
+        m_hardware_flags.sealed_case = (sdt->flags & (u32)FADTFlags::FeatureFlags::SEALED_CASE);
+        m_hardware_flags.sleep_button = (sdt->flags & (u32)FADTFlags::FeatureFlags::SLP_BUTTON);
+        m_hardware_flags.timer_value_extension = (sdt->flags & (u32)FADTFlags::FeatureFlags::TMR_VAL_EXT);
+        m_hardware_flags.use_platform_clock = (sdt->flags & (u32)FADTFlags::FeatureFlags::USE_PLATFORM_CLOCK);
+        m_hardware_flags.wbinvd = (sdt->flags & (u32)FADTFlags::FeatureFlags::WBINVD);
+        m_hardware_flags.wbinvd_flush = (sdt->flags & (u32)FADTFlags::FeatureFlags::WBINVD_FLUSH);
     }
 
     bool StaticParser::can_reboot()
@@ -109,7 +147,7 @@ namespace ACPI {
         auto* fadt = (const Structures::FADT*)region->vaddr().offset(m_fadt.offset_in_page()).as_ptr();
         if (fadt->h.revision < 2)
             return false;
-        return (fadt->flags & (u32)FADTFeatureFlags::RESET_REG_SUPPORTED) != 0;
+        return m_hardware_flags.reset_register_supported;
     }
 
     void StaticParser::access_generic_address(const Structures::GenericAddressStructure& structure, u32 value)

+ 6 - 1
Kernel/ACPI/ACPIStaticParser.h

@@ -26,8 +26,8 @@
 
 #pragma once
 
-#include <Kernel/ACPI/ACPIParser.h>
 #include <AK/OwnPtr.h>
+#include <Kernel/ACPI/ACPIParser.h>
 
 namespace Kernel {
 namespace ACPI {
@@ -45,6 +45,9 @@ namespace ACPI {
         virtual void try_acpi_shutdown() override;
         virtual bool is_operable() override { return m_operable; }
 
+        virtual const FADTFlags::HardwareFeatures& hardware_features() const override;
+        virtual const FADTFlags::x86_Specific_Flags& x86_specific_flags() const override;
+
     protected:
         StaticParser();
         explicit StaticParser(PhysicalAddress);
@@ -69,6 +72,8 @@ namespace ACPI {
         PhysicalAddress m_facs;
 
         bool m_xsdt_supported;
+        FADTFlags::HardwareFeatures m_hardware_flags;
+        FADTFlags::x86_Specific_Flags m_x86_specific_flags;
     };
 }
 }

+ 68 - 23
Kernel/ACPI/Definitions.h

@@ -35,29 +35,74 @@ namespace Kernel {
 
 namespace ACPI {
 
-    enum class FADTFeatureFlags : u32 {
-        WBINVD = 1 << 0,
-        WBINVD_FLUSH = 1 << 1,
-        PROC_C1 = 1 << 2,
-        P_LVL2_UP = 1 << 3,
-        PWR_BUTTON = 1 << 4,
-        SLP_BUTTON = 1 << 5,
-        FIX_RTC = 1 << 6,
-        RTC_s4 = 1 << 7,
-        TMR_VAL_EXT = 1 << 8,
-        DCK_CAP = 1 << 9,
-        RESET_REG_SUPPORTED = 1 << 10,
-        SEALED_CASE = 1 << 11,
-        HEADLESS = 1 << 12,
-        CPU_SW_SLP = 1 << 13,
-        PCI_EXP_WAK = 1 << 14,
-        USE_PLATFORM_CLOCK = 1 << 15,
-        S4_RTC_STS_VALID = 1 << 16,
-        REMOTE_POWER_ON_CAPABLE = 1 << 17,
-        FORCE_APIC_CLUSTER_MODEL = 1 << 18,
-        FORCE_APIC_PHYSICAL_DESTINATION_MODE = 1 << 19,
-        HW_REDUCED_ACPI = 1 << 20,
-        LOW_POWER_S0_IDLE_CAPABLE = 1 << 21
+    namespace FADTFlags {
+        enum class FeatureFlags : u32 {
+            WBINVD = 1 << 0,
+            WBINVD_FLUSH = 1 << 1,
+            PROC_C1 = 1 << 2,
+            P_LVL2_UP = 1 << 3,
+            PWR_BUTTON = 1 << 4,
+            SLP_BUTTON = 1 << 5,
+            FIX_RTC = 1 << 6,
+            RTC_s4 = 1 << 7,
+            TMR_VAL_EXT = 1 << 8,
+            DCK_CAP = 1 << 9,
+            RESET_REG_SUPPORTED = 1 << 10,
+            SEALED_CASE = 1 << 11,
+            HEADLESS = 1 << 12,
+            CPU_SW_SLP = 1 << 13,
+            PCI_EXP_WAK = 1 << 14,
+            USE_PLATFORM_CLOCK = 1 << 15,
+            S4_RTC_STS_VALID = 1 << 16,
+            REMOTE_POWER_ON_CAPABLE = 1 << 17,
+            FORCE_APIC_CLUSTER_MODEL = 1 << 18,
+            FORCE_APIC_PHYSICAL_DESTINATION_MODE = 1 << 19,
+            HW_REDUCED_ACPI = 1 << 20,
+            LOW_POWER_S0_IDLE_CAPABLE = 1 << 21
+        };
+
+        enum class IA_PC_Flags : u8 {
+            Legacy_Devices = 1 << 0,
+            PS2_8042 = 1 << 1,
+            VGA_Not_Present = 1 << 2,
+            MSI_Not_Supported = 1 << 3,
+            PCIe_ASPM_Controls = 1 << 4,
+            CMOS_RTC_Not_Present = 1 << 5
+        };
+
+        struct [[gnu::packed]] HardwareFeatures
+        {
+            bool wbinvd : 1;
+            bool wbinvd_flush : 1;
+            bool processor_c1 : 1;
+            bool multiprocessor_c2 : 1;
+            bool power_button : 1;
+            bool sleep_button : 1;
+            bool fix_rtc : 1;
+            bool rtc_s4 : 1;
+            bool timer_value_extension : 1;
+            bool docking_capability : 1;
+            bool reset_register_supported : 1;
+            bool sealed_case : 1;
+            bool headless : 1;
+            bool cpu_software_sleep : 1;
+            bool pci_express_wake : 1;
+            bool use_platform_clock : 1;
+            bool s4_rtc_status_valid : 1;
+            bool remote_power_on_capable : 1;
+            bool force_apic_cluster_model : 1;
+            bool force_apic_physical_destination_mode : 1;
+            bool hardware_reduced_acpi : 1;
+            bool low_power_s0_idle_capable : 1;
+        };
+        struct [[gnu::packed]] x86_Specific_Flags
+        {
+            bool legacy_devices : 1;
+            bool keyboard_8042 : 1;
+            bool vga_not_present : 1;
+            bool msi_not_supported : 1;
+            bool cmos_rtc_not_present : 1;
+        };
     };
 
     namespace GenericAddressStructure {