diff options
author | Andreas Kling <kling@serenityos.org> | 2020-04-09 14:31:47 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-04-09 17:19:11 +0200 |
commit | 46442170942caf2e4e31cf3a6a1499c8af2b3ec6 (patch) | |
tree | a9d4643874c98c9cdf20f30fda11c9b537458a7c /Kernel/ACPI | |
parent | d95362d8cd9e4d3eee0c9e036455fc1e2ebcd480 (diff) | |
download | serenity-46442170942caf2e4e31cf3a6a1499c8af2b3ec6.zip |
Kernel: Remove "non-operational" ACPI parser state
If we don't support ACPI, just don't instantiate an ACPI parser.
This is way less confusing than having a special parser class whose
only purpose is to do nothing.
We now search for the RSDP in ACPI::initialize() instead of letting
the parser constructor do it. This allows us to defer the decision
to create a parser until we're sure we can make a useful one.
Diffstat (limited to 'Kernel/ACPI')
-rw-r--r-- | Kernel/ACPI/ACPIDynamicParser.cpp | 6 | ||||
-rw-r--r-- | Kernel/ACPI/ACPIDynamicParser.h | 3 | ||||
-rw-r--r-- | Kernel/ACPI/ACPIParser.cpp | 34 | ||||
-rw-r--r-- | Kernel/ACPI/ACPIParser.h | 25 | ||||
-rw-r--r-- | Kernel/ACPI/ACPIStaticParser.cpp | 18 | ||||
-rw-r--r-- | Kernel/ACPI/ACPIStaticParser.h | 4 | ||||
-rw-r--r-- | Kernel/ACPI/Initialize.cpp | 28 | ||||
-rw-r--r-- | Kernel/ACPI/Initialize.h | 1 |
8 files changed, 35 insertions, 84 deletions
diff --git a/Kernel/ACPI/ACPIDynamicParser.cpp b/Kernel/ACPI/ACPIDynamicParser.cpp index 19658f56bb..30b5cf94ff 100644 --- a/Kernel/ACPI/ACPIDynamicParser.cpp +++ b/Kernel/ACPI/ACPIDynamicParser.cpp @@ -30,12 +30,6 @@ namespace Kernel { namespace ACPI { -DynamicParser::DynamicParser() - : IRQHandler(9) -{ - klog() << "ACPI: Dynamic Parsing Enabled, Can parse AML"; -} - DynamicParser::DynamicParser(PhysicalAddress rsdp) : IRQHandler(9) , StaticParser(rsdp) diff --git a/Kernel/ACPI/ACPIDynamicParser.h b/Kernel/ACPI/ACPIDynamicParser.h index 97e35d33b6..f7b80f4953 100644 --- a/Kernel/ACPI/ACPIDynamicParser.h +++ b/Kernel/ACPI/ACPIDynamicParser.h @@ -51,8 +51,7 @@ public: virtual const char* purpose() const override { return "ACPI Parser"; } protected: - DynamicParser(); - explicit DynamicParser(PhysicalAddress); + explicit DynamicParser(PhysicalAddress rsdp); private: void build_namespace(); diff --git a/Kernel/ACPI/ACPIParser.cpp b/Kernel/ACPI/ACPIParser.cpp index f72d49176c..3ea46756ba 100644 --- a/Kernel/ACPI/ACPIParser.cpp +++ b/Kernel/ACPI/ACPIParser.cpp @@ -32,10 +32,9 @@ namespace ACPI { static Parser* s_acpi_parser; -Parser& Parser::the() +Parser* Parser::the() { - ASSERT(s_acpi_parser); - return *s_acpi_parser; + return s_acpi_parser; } void Parser::set_the(Parser& parser) @@ -44,31 +43,6 @@ void Parser::set_the(Parser& parser) s_acpi_parser = &parser; } -Parser::Parser(bool usable) -{ - if (usable) { - klog() << "ACPI: Setting up a functional parser"; - } else { - klog() << "ACPI: Limited Initialization. Vital functions are disabled by a request"; - } -} - -PhysicalAddress Parser::find_table(const char*) -{ - klog() << "ACPI: Requested to search for a table, Abort!"; - return {}; -} - -void Parser::try_acpi_reboot() -{ - klog() << "ACPI: Cannot invoke reboot!"; -} - -void Parser::try_acpi_shutdown() -{ - klog() << "ACPI: Cannot invoke shutdown!"; -} - void Parser::enable_aml_interpretation() { klog() << "ACPI: No AML Interpretation Allowed"; @@ -99,9 +73,5 @@ 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; -} } } diff --git a/Kernel/ACPI/ACPIParser.h b/Kernel/ACPI/ACPIParser.h index 133c29d786..0fb09fd337 100644 --- a/Kernel/ACPI/ACPIParser.h +++ b/Kernel/ACPI/ACPIParser.h @@ -28,6 +28,7 @@ #include <AK/Types.h> #include <Kernel/ACPI/Definitions.h> +#include <Kernel/ACPI/Initialize.h> #include <Kernel/FileSystem/File.h> #include <Kernel/VM/Region.h> #include <LibBareMetal/Memory/PhysicalAddress.h> @@ -38,33 +39,31 @@ namespace ACPI { class Parser { public: - static Parser& the(); + static Parser* the(); template<typename ParserType> - static void initialize() + static void initialize(PhysicalAddress rsdp) { - set_the(*new ParserType); + set_the(*new ParserType(rsdp)); } - virtual PhysicalAddress find_table(const char* sig); + virtual PhysicalAddress find_table(const char* sig) = 0; - virtual void try_acpi_reboot(); - virtual bool can_reboot() { return false; } - virtual void try_acpi_shutdown(); - virtual bool can_shutdown() { return false; } + virtual void try_acpi_reboot() = 0; + virtual bool can_reboot() = 0; + virtual void try_acpi_shutdown() = 0; + virtual bool can_shutdown() = 0; - virtual const FADTFlags::HardwareFeatures& hardware_features() const; - virtual const FADTFlags::x86_Specific_Flags& x86_specific_flags() const; + virtual const FADTFlags::HardwareFeatures& hardware_features() const = 0; + virtual const FADTFlags::x86_Specific_Flags& x86_specific_flags() const = 0; virtual void enable_aml_interpretation(); virtual void enable_aml_interpretation(File&); virtual void enable_aml_interpretation(u8*, u32); virtual void disable_aml_interpretation(); - virtual bool is_operable(); protected: - explicit Parser(bool usable = false); - bool m_operable; + Parser() {} private: static void set_the(Parser&); diff --git a/Kernel/ACPI/ACPIStaticParser.cpp b/Kernel/ACPI/ACPIStaticParser.cpp index 64828c672e..994df7053f 100644 --- a/Kernel/ACPI/ACPIStaticParser.cpp +++ b/Kernel/ACPI/ACPIStaticParser.cpp @@ -324,26 +324,10 @@ void StaticParser::locate_main_system_description_table() } } -StaticParser::StaticParser() - : Parser(true) - , m_rsdp(StaticParsing::search_rsdp()) -{ - if (!m_rsdp.is_null()) { - klog() << "ACPI: Using RSDP @ " << m_rsdp; - m_operable = true; - locate_static_data(); - } else { - m_operable = false; - klog() << "ACPI: Disabled, due to RSDP being absent"; - } -} - StaticParser::StaticParser(PhysicalAddress rsdp) - : Parser(true) - , m_rsdp(rsdp) + : m_rsdp(rsdp) { klog() << "ACPI: Using RSDP @ " << rsdp; - m_operable = true; locate_static_data(); } diff --git a/Kernel/ACPI/ACPIStaticParser.h b/Kernel/ACPI/ACPIStaticParser.h index 613ba6a8d6..905995b16e 100644 --- a/Kernel/ACPI/ACPIStaticParser.h +++ b/Kernel/ACPI/ACPIStaticParser.h @@ -41,14 +41,12 @@ public: virtual bool can_reboot() override; virtual bool can_shutdown() override { return false; } 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); + explicit StaticParser(PhysicalAddress rsdp); private: void locate_static_data(); diff --git a/Kernel/ACPI/Initialize.cpp b/Kernel/ACPI/Initialize.cpp index 4b7f68f7ce..a64ebea97b 100644 --- a/Kernel/ACPI/Initialize.cpp +++ b/Kernel/ACPI/Initialize.cpp @@ -49,17 +49,23 @@ static FeatureLevel determine_feature_level() void initialize() { - switch (determine_feature_level()) { - case FeatureLevel::Enabled: - Parser::initialize<DynamicParser>(); - break; - case FeatureLevel::Limited: - Parser::initialize<StaticParser>(); - break; - case FeatureLevel::Disabled: - Parser::initialize<Parser>(); - break; - } + auto feature_level = determine_feature_level(); + if (feature_level == FeatureLevel::Disabled) + return; + + auto rsdp = StaticParsing::search_rsdp(); + if (rsdp.is_null()) + return; + + if (feature_level == FeatureLevel::Enabled) + Parser::initialize<DynamicParser>(rsdp); + else + Parser::initialize<StaticParser>(rsdp); +} + +bool is_enabled() +{ + return Parser::the(); } } diff --git a/Kernel/ACPI/Initialize.h b/Kernel/ACPI/Initialize.h index f7d8b158d9..1ff2f6cbb4 100644 --- a/Kernel/ACPI/Initialize.h +++ b/Kernel/ACPI/Initialize.h @@ -29,6 +29,7 @@ namespace Kernel { namespace ACPI { +bool is_enabled(); void initialize(); } |