Files
serenity/Kernel/Firmware/ACPI/Initialize.cpp
T
Undefine 4ac5026d2c Kernel: Improve error propagation in ACPI code
This should hopefully get rid of a handful of release_value_but_fixme,
while also making it more likely that we boot on systems where ACPI is
doing something weird (cases we cannot handle yet). While this is
unlikely to occur with our currect range of supported ACPI stuff, when
we add AML interpreting it's quite likely that we will encounter a
cursed DSDT at some point that should not crash the entire system
without a meaningful error.
2026-10-21 19:03:12 +02:00

48 lines
1.2 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;
auto facp_table = TRY(Memory::map_typed<::ACPI::Structures::FADT>(facp.value()));
InterruptNumber irq_line = facp_table->sci_int;
TRY(Parser::initialize(rsdp.value(), facp.value(), irq_line));
if (kernel_command_line().acpi_feature_level() == AcpiFeatureLevel::Enabled)
Parser::the()->enable_aml_parsing();
return {};
}
bool is_enabled()
{
return Parser::the();
}
}