aboutsummaryrefslogtreecommitdiff
path: root/kernel/devices/src/storage/storage_management.cpp
diff options
context:
space:
mode:
authormarcel.braun <marcel.braun@ost.ch>2026-03-17 19:36:20 +0100
committermarcel.braun <marcel.braun@ost.ch>2026-03-17 19:36:20 +0100
commit3ace886a9e9f044cd48de51f0a15aceb02bfa9b2 (patch)
tree1dc00e8802ab8fb60809b1f55ae7baadf9e430e1 /kernel/devices/src/storage/storage_management.cpp
parent59504cfd677dd3e9d9ddb0deea4df7614efedb84 (diff)
downloadkernel-3ace886a9e9f044cd48de51f0a15aceb02bfa9b2.tar.xz
kernel-3ace886a9e9f044cd48de51f0a15aceb02bfa9b2.zip
Clean up project folder structure
Diffstat (limited to 'kernel/devices/src/storage/storage_management.cpp')
-rw-r--r--kernel/devices/src/storage/storage_management.cpp85
1 files changed, 0 insertions, 85 deletions
diff --git a/kernel/devices/src/storage/storage_management.cpp b/kernel/devices/src/storage/storage_management.cpp
deleted file mode 100644
index 25885ad..0000000
--- a/kernel/devices/src/storage/storage_management.cpp
+++ /dev/null
@@ -1,85 +0,0 @@
-#include "devices/storage/storage_management.hpp"
-
-#include "kapi/boot_modules.hpp"
-#include "kapi/system.hpp"
-
-#include "devices/device.hpp"
-#include "devices/storage/ram_disk/ram_disk_controller.hpp"
-#include "devices/storage/storage_controller.hpp"
-
-#include <kstd/memory>
-#include <kstd/vector>
-
-#include <algorithm>
-#include <cstddef>
-#include <optional>
-
-namespace devices::storage
-{
- namespace
- {
- constexpr size_t static MINORS_PER_DEVICE = 16;
- constexpr size_t static START_MAJOR = 1;
- constinit size_t static next_free_major = START_MAJOR;
-
- constinit auto static active_storage_management = std::optional<storage_management>{};
- } // 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{});
-
- auto current_ram_disk_controller =
- kstd::make_shared<ram_disk::ram_disk_controller>(&kapi::boot_modules::get_boot_module_registry());
- active_storage_management->add_controller(current_ram_disk_controller);
-
- std::ranges::for_each(active_storage_management->m_controllers, [](auto controller) { 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(kstd::shared_ptr<storage_controller> const & controller) -> void
- {
- controller->set_ids(next_free_major++, MINORS_PER_DEVICE);
- m_controllers.push_back(controller);
- }
-
- auto storage_management::all_controllers() const -> kstd::vector<kstd::shared_ptr<storage_controller>> const &
- {
- return m_controllers;
- }
-
- auto storage_management::device_by_major_minor(size_t major, size_t minor) -> kstd::shared_ptr<device>
- {
- kstd::shared_ptr<device> found = nullptr;
-
- std::ranges::find_if(m_controllers, [&](auto const & controller) {
- if (controller != nullptr && controller->major() == major)
- {
- found = controller->device_by_minor(minor);
- return found != nullptr;
- }
- return false;
- });
-
- return found;
- }
-
- auto storage_management::determine_boot_device() -> kstd::shared_ptr<device>
- {
- return device_by_major_minor(START_MAJOR, 0);
- }
-
-} // namespace devices::storage \ No newline at end of file