diff options
| author | marcel.braun <marcel.braun@ost.ch> | 2026-02-28 15:18:56 +0100 |
|---|---|---|
| committer | Lukas Oesch <lukasoesch20@gmail.com> | 2026-03-17 16:42:16 +0100 |
| commit | 7a9bdbc58361ff22491785d778474571035ad697 (patch) | |
| tree | 6b3d39464a3ae4f570caf6a0af1123e88061ac27 /kernel/devices | |
| parent | 296d58550e8e1202d83e66034c24e9454a1b67dc (diff) | |
| download | teachos-7a9bdbc58361ff22491785d778474571035ad697.tar.xz teachos-7a9bdbc58361ff22491785d778474571035ad697.zip | |
Implement basic structure of storage management
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 |
