mirror of
https://github.com/SerenityOS/serenity.git
synced 2026-11-07 12:38:38 -10:00
Splitting it off allows initializing the later than right after Parser creation, which allows us to move more resposibility to the Parser instead of mapping the FADT twice.
45 lines
1.1 KiB
C++
45 lines
1.1 KiB
C++
/*
|
|
* Copyright (c) 2020-2021, Liav A. <[email protected]>
|
|
* Copyright (c) 2020, Andreas Kling <[email protected]>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <Kernel/Boot/BootInfo.h>
|
|
#include <Kernel/Boot/CommandLine.h>
|
|
#include <Kernel/Firmware/ACPI/Parser.h>
|
|
#include <Kernel/Firmware/ACPI/StaticParsing.h>
|
|
#include <Kernel/Memory/TypedMapping.h>
|
|
#include <Kernel/Sections.h>
|
|
|
|
namespace Kernel::ACPI {
|
|
|
|
UNMAP_AFTER_INIT ErrorOr<void> initialize()
|
|
{
|
|
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 ENOENT;
|
|
|
|
auto facp = TRY(StaticParsing::find_table(rsdp.value(), "FACP"sv));
|
|
if (!facp.has_value())
|
|
return ENOENT;
|
|
|
|
TRY(Parser::initialize(rsdp.value(), facp.value()));
|
|
|
|
if (kernel_command_line().acpi_feature_level() == AcpiFeatureLevel::Enabled)
|
|
Parser::the()->enable_aml_parsing();
|
|
|
|
return {};
|
|
}
|
|
|
|
bool is_enabled()
|
|
{
|
|
return Parser::the();
|
|
}
|
|
|
|
}
|