#include "devices/storage/StorageManagement.hpp" #include "kapi/boot_modules.hpp" #include "kapi/system.hpp" #include "devices/BlockDevice.hpp" #include "devices/storage/RAMDisk/RAMDiskController.hpp" #include "devices/storage/StorageController.hpp" #include namespace devices::storage { namespace { constinit auto static active_storage_management = std::optional{}; constinit auto static active_ram_disk_controller = std::optional{}; } // namespace auto storage_management::init() -> void { if (active_storage_management) { kapi::system::panic("[DEVICES] Storage management has already been initialized."); } active_storage_management.emplace(storage_management{}); active_ram_disk_controller.emplace(&kapi::boot_modules::get_boot_module_registry()); active_storage_management->add_controller(&active_ram_disk_controller.value()); for (auto controller : active_storage_management->m_controllers) { controller->probe(); } } auto storage_management::get() -> storage_management & { if (!active_storage_management) { kapi::system::panic("[DEVICES] Storage management has not been initialized."); } return *active_storage_management; } auto storage_management::add_controller(storage_controller * controller) -> void { m_controllers.at(0) = controller; // TODO BA-FS26 use push_back from kstd:vector } auto storage_management::add_device(block_device * device) -> void { m_devices.at(0) = device; // TODO BA-FS26 use push_back from kstd:vector } } // namespace devices::storage