aboutsummaryrefslogtreecommitdiff
path: root/kernel/kapi/acpi.cpp
blob: df2bf057c5ec575c12aba18b036778c92d3f4bef (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
36
37
38
39
40
#include "kapi/acpi.hpp"

#include "kapi/system.hpp"

#include "kernel/acpi/manager.hpp"

#include <kstd/memory>

#include <acpi/acpi.hpp>

#include <atomic>
#include <optional>
#include <string_view>

namespace kapi::acpi
{

  namespace
  {
    auto constinit manager = std::optional<kernel::acpi::manager>{};
  }  // namespace

  auto init(::acpi::rsdp const & sdp) -> bool
  {
    auto static constinit initialized = std::atomic_flag{};
    if (initialized.test_and_set())
    {
      system::panic("[OS:ACPI] The ACPI manager has already been initialized!");
    }

    manager.emplace(sdp);
    return manager->load_tables();
  }

  auto get_table(std::string_view signature) -> kstd::observer_ptr<::acpi::sdt const>
  {
    return manager->get_table(signature);
  }

};  // namespace kapi::acpi