#include #include #include #include #include #include #include #include namespace kapi::devices { namespace { auto constinit root_bus = kstd::shared_ptr{}; auto constinit device_tree = kstd::flat_map>{}; } // namespace auto init() -> void { if (root_bus) { kapi::system::panic("[OS:DEV] The device subsystem has already been initialized"); } device_registry::init(); facet_registry::init(); root_bus = kstd::make_shared(); device_registry::get().add(root_bus); } auto get_root_bus() -> kstd::shared_ptr { if (!root_bus) { kapi::system::panic("[OS:DEV] Root bus not initialized!"); } return root_bus; } auto remove_device(device & device) -> bool { auto parent = device.parent(); if (!parent) { return false; } return parent->remove_child(device); } } // namespace kapi::devices namespace kapi::test_support::devices { auto deinit() -> void { kapi::devices::root_bus.reset(); deinit_driver_registry(); deinit_facet_registry(); deinit_device_registry(); } } // namespace kapi::test_support::devices