aboutsummaryrefslogtreecommitdiff
path: root/kernel/kapi/devices.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/kapi/devices.cpp')
-rw-r--r--kernel/kapi/devices.cpp21
1 files changed, 17 insertions, 4 deletions
diff --git a/kernel/kapi/devices.cpp b/kernel/kapi/devices.cpp
index de4bf9e5..ef72c667 100644
--- a/kernel/kapi/devices.cpp
+++ b/kernel/kapi/devices.cpp
@@ -3,6 +3,7 @@
#include <kernel/devices/root_bus.hpp>
#include <kapi/system.hpp>
+#include <kapi/test_support/devices.hpp>
#include <kstd/flat_map.hpp>
#include <kstd/memory.hpp>
@@ -25,12 +26,13 @@ namespace kapi::devices
auto init() -> void
{
- auto static is_initialized = std::atomic_flag{};
- if (is_initialized.test_and_set())
+ if (root_bus.has_value())
{
- return;
+ kapi::system::panic("[OS:DEV] The device subsystem has already been initialized");
}
+ interface_registry::init();
+
auto & bus = root_bus.emplace();
register_device(bus);
bus.init();
@@ -83,4 +85,15 @@ namespace kapi::devices
return nullptr;
}
-} // namespace kapi::devices \ No newline at end of file
+} // namespace kapi::devices
+
+namespace kapi::test_support::devices
+{
+ auto deinit() -> void
+ {
+ deinit_interface_registry();
+
+ kapi::devices::root_bus.reset();
+ kapi::devices::next_major_number = 1;
+ }
+} // namespace kapi::test_support::devices \ No newline at end of file