aboutsummaryrefslogtreecommitdiff
path: root/kernel/kapi/boot_modules.cpp
blob: 0549368633233ef959e1519df1906bc0164edcc3 (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
41
#include "kapi/boot_modules.hpp"

#include "kapi/system.hpp"

#include <optional>

namespace
{
  constinit auto static registry = std::optional<kapi::boot_modules::boot_module_registry>{};
}  // namespace

namespace kapi::boot_modules
{
  auto set_boot_module_registry(boot_module_registry & new_registry) -> void
  {
    if (registry)
    {
      system::panic("[x86_64] Boot module registry has already been set.");
    }

    registry = new_registry;
  }

  auto get_boot_module_registry() -> boot_module_registry &
  {
    if (!registry)
    {
      system::panic("[x86_64] Boot module registry has not been initialized.");
    }

    return *registry;
  }
}  // namespace kapi::boot_modules

namespace kernel::tests::boot_modules
{
  auto deinit() -> void
  {
    registry.reset();
  }
}  // namespace kernel::tests::boot_modules