summaryrefslogtreecommitdiff
path: root/Kernel/ACPI/Initialize.cpp
blob: dd1d0e11fd47822959646040f93019d83628a87d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*
 * Copyright (c) 2020, Liav A. <liavalb@hotmail.co.il>
 * Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#include <Kernel/ACPI/DynamicParser.h>
#include <Kernel/CommandLine.h>
#include <Kernel/Sections.h>

namespace Kernel::ACPI {

UNMAP_AFTER_INIT 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;

    if (feature_level == AcpiFeatureLevel::Enabled)
        Parser::initialize<DynamicParser>(rsdp.value());
    else
        Parser::initialize<Parser>(rsdp.value());
}

bool is_enabled()
{
    return Parser::the();
}

}