blob: 80c76129d80f361a371db83c6969c360fa384de7 (
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
#include <kapi/boot_modules/registry.hpp>
#include <kapi/boot_modules.hpp>
#include <kapi/system.hpp>
#include <kapi/test_support/boot_modules.hpp>
#include <cstddef>
#include <optional>
#include <utility>
namespace kapi::boot_modules
{
namespace
{
constinit auto instance = std::optional<registry>{};
}
auto registry::init() -> void
{
if (instance)
{
system::panic("[OS] Boot module registry has already been initialized.");
}
instance.emplace();
}
auto registry::get() -> registry &
{
if (!instance)
{
system::panic("[OS] Boot module registry has not been initialized.");
}
return *instance;
}
auto registry::begin() const noexcept -> const_iterator
{
return m_modules.begin();
}
auto registry::end() const noexcept -> const_iterator
{
return m_modules.end();
}
auto registry::cbegin() const noexcept -> const_iterator
{
return m_modules.cbegin();
}
auto registry::cend() const noexcept -> const_iterator
{
return m_modules.cend();
}
auto registry::rbegin() const noexcept -> const_reverse_iterator
{
return m_modules.rbegin();
}
auto registry::rend() const noexcept -> const_reverse_iterator
{
return m_modules.rend();
}
auto registry::crbegin() const noexcept -> const_reverse_iterator
{
return m_modules.crbegin();
}
auto registry::crend() const noexcept -> const_reverse_iterator
{
return m_modules.crend();
}
auto registry::front() const noexcept -> const_reference
{
return m_modules.front();
}
auto registry::back() const noexcept -> const_reference
{
return m_modules.back();
}
auto registry::size() const noexcept -> std::size_t
{
return m_modules.size();
}
auto registry::empty() const noexcept -> bool
{
return m_modules.empty();
}
auto registry::at(std::size_t index) const -> const_reference
{
return m_modules.at(index);
}
auto registry::operator[](std::size_t index) const noexcept -> const_reference
{
return m_modules[index];
}
auto registry::add(boot_module module) -> void
{
m_modules.push_back(module);
}
} // namespace kapi::boot_modules
namespace kapi::test_support::boot_modules
{
auto deinit_registry() -> void
{
kapi::boot_modules::instance.reset();
}
auto inject_registry(kapi::boot_modules::registry && registry) -> std::optional<kapi::boot_modules::registry>
{
auto old = std::move(kapi::boot_modules::instance);
kapi::boot_modules::instance.emplace(std::move(registry));
return old;
}
} // namespace kapi::test_support::boot_modules
|