1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 07:18:11 +00:00

Kernel: Move Kernel CommandLine parsing to strongly typed API.

Previously all of the CommandLine parsing was spread out around the
Kernel. Instead move it all into the Kernel CommandLine class, and
expose a strongly typed API for querying the state of options.
This commit is contained in:
Brian Gianforcaro 2021-03-03 00:51:55 -08:00 committed by Andreas Kling
parent 74881ac649
commit 84a399de5d
9 changed files with 143 additions and 45 deletions

View file

@ -31,33 +31,17 @@
namespace Kernel {
namespace ACPI {
enum class FeatureLevel {
Enabled,
Limited,
Disabled,
};
UNMAP_AFTER_INIT static FeatureLevel determine_feature_level()
{
auto value = kernel_command_line().lookup("acpi").value_or("on");
if (value == "limited")
return FeatureLevel::Limited;
if (value == "off")
return FeatureLevel::Disabled;
return FeatureLevel::Enabled;
}
UNMAP_AFTER_INIT void initialize()
{
auto feature_level = determine_feature_level();
if (feature_level == FeatureLevel::Disabled)
auto feature_level = kernel_command_line().acpi_feature_level();
if (feature_level == AcpiFeatureLevel::Disabled)
return;
auto rsdp = StaticParsing::find_rsdp();
if (!rsdp.has_value())
return;
if (feature_level == FeatureLevel::Enabled)
if (feature_level == AcpiFeatureLevel::Enabled)
Parser::initialize<DynamicParser>(rsdp.value());
else
Parser::initialize<Parser>(rsdp.value());