2020-04-09 13:39:10 +02:00
|
|
|
/*
|
2021-09-10 16:45:12 +03:00
|
|
|
* Copyright (c) 2020-2021, Liav A. <liavalb@hotmail.co.il>
|
2020-04-09 13:39:10 +02:00
|
|
|
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-04-09 13:39:10 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <Kernel/CommandLine.h>
|
2021-09-11 10:39:47 +03:00
|
|
|
#include <Kernel/Firmware/ACPI/Parser.h>
|
2021-09-10 16:45:12 +03:00
|
|
|
#include <Kernel/Memory/TypedMapping.h>
|
2021-06-22 17:40:16 +02:00
|
|
|
#include <Kernel/Sections.h>
|
2020-04-09 13:39:10 +02:00
|
|
|
|
2021-07-11 01:36:30 +02:00
|
|
|
namespace Kernel::ACPI {
|
2020-04-09 13:39:10 +02:00
|
|
|
|
2021-02-19 21:29:46 +01:00
|
|
|
UNMAP_AFTER_INIT void initialize()
|
2020-04-09 13:39:10 +02:00
|
|
|
{
|
2021-03-03 00:51:55 -08:00
|
|
|
auto feature_level = kernel_command_line().acpi_feature_level();
|
|
|
|
|
if (feature_level == AcpiFeatureLevel::Disabled)
|
2020-04-09 14:31:47 +02:00
|
|
|
return;
|
|
|
|
|
|
2020-04-09 17:12:58 +02:00
|
|
|
auto rsdp = StaticParsing::find_rsdp();
|
2020-05-22 13:34:53 +02:00
|
|
|
if (!rsdp.has_value())
|
2020-04-09 14:31:47 +02:00
|
|
|
return;
|
|
|
|
|
|
2021-09-10 16:45:12 +03:00
|
|
|
auto facp = StaticParsing::find_table(rsdp.value(), "FACP");
|
|
|
|
|
if (!facp.has_value())
|
|
|
|
|
return;
|
|
|
|
|
auto facp_table = Memory::map_typed<Structures::FADT>(facp.value());
|
|
|
|
|
u8 irq_line = facp_table->sci_int;
|
|
|
|
|
|
|
|
|
|
Parser::must_initialize(rsdp.value(), facp.value(), irq_line);
|
|
|
|
|
if (kernel_command_line().acpi_feature_level() == AcpiFeatureLevel::Enabled)
|
|
|
|
|
Parser::the()->enable_aml_parsing();
|
2020-04-09 14:31:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool is_enabled()
|
|
|
|
|
{
|
|
|
|
|
return Parser::the();
|
2020-04-09 13:39:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|