diff options
Diffstat (limited to 'kernel/devices')
| -rw-r--r-- | kernel/devices/CMakeLists.txt | 4 | ||||
| -rw-r--r-- | kernel/devices/include/devices/storage/StorageManagement.hpp | 20 | ||||
| -rw-r--r-- | kernel/devices/src/storage/StorageManagement.cpp | 39 |
3 files changed, 59 insertions, 4 deletions
diff --git a/kernel/devices/CMakeLists.txt b/kernel/devices/CMakeLists.txt index 80b89bf..8022dee 100644 --- a/kernel/devices/CMakeLists.txt +++ b/kernel/devices/CMakeLists.txt @@ -24,4 +24,8 @@ target_sources("kernel_devices" PUBLIC target_include_directories("kernel_devices" PUBLIC "include" +) + +target_link_libraries("kernel_devices" PRIVATE + "os::kapi" )
\ No newline at end of file diff --git a/kernel/devices/include/devices/storage/StorageManagement.hpp b/kernel/devices/include/devices/storage/StorageManagement.hpp index 2b2eb22..9098312 100644 --- a/kernel/devices/include/devices/storage/StorageManagement.hpp +++ b/kernel/devices/include/devices/storage/StorageManagement.hpp @@ -1,15 +1,29 @@ #ifndef TEACH_OS_KERNEL_DEVICES_STORAGE_STORAGE_MANAGEMENT_HPP #define TEACH_OS_KERNEL_DEVICES_STORAGE_STORAGE_MANAGEMENT_HPP +#include "devices/BlockDevice.hpp" +#include "devices/storage/StorageController.hpp" + +#include <array> + namespace devices::storage { struct storage_management { - //! @qualifier kernel-defined - //! Initialize the storage management subsystem. - auto init() -> void; + // TODO BA-FS26 add documentation + + auto static init() -> void; + auto static get() -> storage_management &; + + auto add_controller(storage_controller * controller) -> void; + + auto add_device(block_device * device) -> void; private: + storage_management() = default; + + std::array<storage_controller *, 1> m_controllers{}; // TODO BA-FS26 use kstd::vector + std::array<block_device *, 1> m_devices{}; // TODO BA-FS26 use kstd::vector }; } // namespace devices::storage diff --git a/kernel/devices/src/storage/StorageManagement.cpp b/kernel/devices/src/storage/StorageManagement.cpp index f34fa15..14c59ac 100644 --- a/kernel/devices/src/storage/StorageManagement.cpp +++ b/kernel/devices/src/storage/StorageManagement.cpp @@ -1,9 +1,46 @@ #include "devices/storage/StorageManagement.hpp" +#include "kapi/system.hpp" + +#include "devices/BlockDevice.hpp" +#include "devices/storage/StorageController.hpp" + +#include <optional> + namespace devices::storage { + namespace + { + constinit auto static active_storage_management = std::optional<storage_management>{}; + } // namespace + auto storage_management::init() -> void { - // TODO BA-FS26 implement storage management initialization + if (active_storage_management) + { + kapi::system::panic("[DEVICES] Storage management has already been initialized."); + } + active_storage_management.emplace(storage_management{}); + } + + 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
\ No newline at end of file |
