aboutsummaryrefslogtreecommitdiff
path: root/kernel/devices/include
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/include
parent59504cfd677dd3e9d9ddb0deea4df7614efedb84 (diff)
downloadteachos-3ace886a9e9f044cd48de51f0a15aceb02bfa9b2.tar.xz
teachos-3ace886a9e9f044cd48de51f0a15aceb02bfa9b2.zip
Clean up project folder structure
Diffstat (limited to 'kernel/devices/include')
-rw-r--r--kernel/devices/include/devices/block_device.hpp101
-rw-r--r--kernel/devices/include/devices/device.hpp61
-rw-r--r--kernel/devices/include/devices/storage/ram_disk/ram_disk_controller.hpp31
-rw-r--r--kernel/devices/include/devices/storage/ram_disk/ram_disk_device.hpp52
-rw-r--r--kernel/devices/include/devices/storage/storage_controller.hpp71
-rw-r--r--kernel/devices/include/devices/storage/storage_management.hpp77
6 files changed, 0 insertions, 393 deletions
diff --git a/kernel/devices/include/devices/block_device.hpp b/kernel/devices/include/devices/block_device.hpp
deleted file mode 100644
index 4831be5..0000000
--- a/kernel/devices/include/devices/block_device.hpp
+++ /dev/null
@@ -1,101 +0,0 @@
-#ifndef TEACH_OS_KERNEL_DEVICES_BLOCK_DEVICE_HPP
-#define TEACH_OS_KERNEL_DEVICES_BLOCK_DEVICE_HPP
-
-#include "devices/device.hpp"
-
-#include <cstddef>
-#include <string_view>
-
-namespace devices
-{
- /**
- * @brief Base interface for block-addressable devices.
- */
- struct block_device : device
- {
- /**
- * @brief Create a block device descriptor.
- * @param major Device major number.
- * @param minor Device minor number.
- * @param name Device name.
- * @param block_size Size of one logical block in bytes.
- */
- block_device(size_t major, size_t minor, std::string_view name, size_t block_size);
-
- /**
- * @brief Virtual destructor for block device.
- */
- virtual ~block_device() = default;
-
- /**
- * @brief Read data from the block at @p block_index into @p buffer.
- * @param block_index Zero-based block index.
- * @param buffer Destination buffer.
- * @warning Panics if @p buffer is null.
- * @note Reads up to one logical block (see constructor @p block_size). Implementations may perform a partial
- * transfer for the final block when fewer than @p block_size bytes remain.
- */
- virtual auto read_block(size_t block_index, void * buffer) const -> void = 0;
-
- /**
- * @brief Write data to the block at @p block_index.
- * @param block_index Zero-based block index.
- * @param buffer Source buffer, must not be null.
- * @warning Panics if @p buffer is null.
- * @note Writes up to one logical block (see constructor @p block_size).
- * Implementations may perform a partial transfer for the final block when
- * fewer than @p block_size bytes remain.
- */
- virtual auto write_block(size_t block_index, void const * buffer) -> void = 0;
-
- /**
- * @brief Return logical block size in bytes.
- * @return One logical block size in bytes.
- */
- [[nodiscard]] auto block_size() const -> size_t;
-
- /**
- * @brief Return device capacity in bytes.
- * @return Total number of addressable bytes.
- */
- [[nodiscard]] auto capacity() const -> size_t;
-
- /**
- * @brief Override to identify block devices.
- * @return true if this device is a block device, false otherwise.
- */
-
- [[nodiscard]] auto is_block_device() const -> bool override
- {
- return true;
- }
-
- protected:
- /**
- * @brief Information describing the transfer window for one block index.
- */
- struct transfer_info
- {
- size_t offset;
- size_t to_transfer;
- size_t remainder;
- };
-
- /**
- * @brief Return total device size in bytes.
- * @return Total number of addressable bytes.
- */
- [[nodiscard]] virtual auto size() const -> size_t = 0;
-
- /**
- * @brief Compute transfer information for @p block_index.
- * @param block_index Zero-based block index.
- * @return Computed transfer information for one logical block access.
- */
- [[nodiscard]] auto calculate_transfer(size_t block_index) const -> transfer_info;
-
- size_t m_block_size;
- };
-} // namespace devices
-
-#endif \ No newline at end of file
diff --git a/kernel/devices/include/devices/device.hpp b/kernel/devices/include/devices/device.hpp
deleted file mode 100644
index d6f520f..0000000
--- a/kernel/devices/include/devices/device.hpp
+++ /dev/null
@@ -1,61 +0,0 @@
-#ifndef TEACH_OS_KERNEL_DEVICES_DEVICE_HPP
-#define TEACH_OS_KERNEL_DEVICES_DEVICE_HPP
-
-#include <cstddef>
-#include <string_view>
-
-namespace devices
-{
- /**
- * @brief Base device identified by a major, minor number and name.
- */
- struct device
- {
- /**
- * @brief Create a device identifier from @p major, @p minor and @p name.
- * @param major Device major number.
- * @param minor Device minor number.
- * @param name Device name.
- */
- device(size_t major, size_t minor, std::string_view name);
-
- /**
- * @brief Virtual destructor for device.
- */
- virtual ~device() = default;
-
- /**
- * @brief Returns the major number of the device.
- * @return Device major number.
- */
- [[nodiscard]] auto major() const -> size_t;
-
- /**
- * @brief Returns the minor number of the device.
- * @return Device minor number.
- */
- [[nodiscard]] auto minor() const -> size_t;
-
- /**
- * @brief Returns the name of the device.
- * @return Device name.
- */
- [[nodiscard]] auto name() const -> std::string_view;
-
- /**
- * @brief Check if the device is a block device.
- * @return true if this device is a block device, false otherwise.
- */
- [[nodiscard]] virtual auto is_block_device() const -> bool
- {
- return false;
- }
-
- private:
- size_t m_major;
- size_t m_minor;
- std::string_view m_name;
- };
-} // namespace devices
-
-#endif \ No newline at end of file
diff --git a/kernel/devices/include/devices/storage/ram_disk/ram_disk_controller.hpp b/kernel/devices/include/devices/storage/ram_disk/ram_disk_controller.hpp
deleted file mode 100644
index f69f8d8..0000000
--- a/kernel/devices/include/devices/storage/ram_disk/ram_disk_controller.hpp
+++ /dev/null
@@ -1,31 +0,0 @@
-#ifndef TEACH_OS_KERNEL_DEVICES_STORAGE_RAM_DISK_CONTROLLER_HPP
-#define TEACH_OS_KERNEL_DEVICES_STORAGE_RAM_DISK_CONTROLLER_HPP
-
-#include "kapi/boot_module/boot_module_registry.hpp"
-
-#include "devices/storage/storage_controller.hpp"
-
-namespace devices::storage::ram_disk
-{
- /**
- * @brief Storage controller that exposes boot modules as RAM-disk devices.
- */
- struct ram_disk_controller : storage_controller
- {
- /**
- * @brief Create a RAM-disk controller.
- * @param registry Boot module registry as device source.
- */
- explicit ram_disk_controller(kapi::boot_modules::boot_module_registry const * registry);
-
- /**
- * @brief Probe boot modules and create RAM-disk devices.
- */
- auto probe() -> void override;
-
- private:
- kapi::boot_modules::boot_module_registry const * m_boot_module_registry;
- };
-} // namespace devices::storage::ram_disk
-
-#endif \ No newline at end of file
diff --git a/kernel/devices/include/devices/storage/ram_disk/ram_disk_device.hpp b/kernel/devices/include/devices/storage/ram_disk/ram_disk_device.hpp
deleted file mode 100644
index 1edf48c..0000000
--- a/kernel/devices/include/devices/storage/ram_disk/ram_disk_device.hpp
+++ /dev/null
@@ -1,52 +0,0 @@
-#ifndef TEACH_OS_KERNEL_DEVICES_STORAGE_RAM_DISK_DEVICE_HPP
-#define TEACH_OS_KERNEL_DEVICES_STORAGE_RAM_DISK_DEVICE_HPP
-
-#include "kapi/boot_module/boot_module.hpp"
-
-#include "devices/block_device.hpp"
-
-#include <cstddef>
-
-namespace devices::storage::ram_disk
-{
- /**
- * @brief Block device for a boot module.
- */
- struct ram_disk_device : block_device
- {
- /**
- * @brief Create a RAM disk for the @p module.
- * @param module Boot module providing the memory region.
- * @param major Device major number.
- * @param minor Device minor number.
- */
- ram_disk_device(kapi::boot_modules::boot_module const & module, size_t major, size_t minor);
-
- /**
- * @brief Read one logical block into @p buffer.
- * @param block_index Zero-based block index.
- * @param buffer Destination buffer, must not be null.
- * @note If the request reaches the module end, only available bytes are copied and the rest of the
- * logical block is filled with zeros.
- */
- auto read_block(size_t block_index, void * buffer) const -> void override;
-
- /**
- * @brief Write one logical block from @p buffer.
- * @param block_index Zero-based block index.
- * @param buffer Source buffer, must not be null.
- * @note If the request reaches the module end, only the bytes in the module range are written.
- */
- auto write_block(size_t block_index, void const * buffer) -> void override;
-
- private:
- /**
- * @brief Return module size in bytes.
- */
- [[nodiscard]] auto size() const -> size_t override;
-
- kapi::boot_modules::boot_module m_boot_module{};
- };
-} // namespace devices::storage::ram_disk
-
-#endif \ No newline at end of file
diff --git a/kernel/devices/include/devices/storage/storage_controller.hpp b/kernel/devices/include/devices/storage/storage_controller.hpp
deleted file mode 100644
index 7760fc9..0000000
--- a/kernel/devices/include/devices/storage/storage_controller.hpp
+++ /dev/null
@@ -1,71 +0,0 @@
-#ifndef TEACH_OS_KERNEL_DEVICES_STORAGE_STORAGE_CONTROLLER_HPP
-#define TEACH_OS_KERNEL_DEVICES_STORAGE_STORAGE_CONTROLLER_HPP
-
-#include "devices/device.hpp"
-
-#include <kstd/memory>
-#include <kstd/vector>
-
-#include <cstddef>
-
-namespace devices::storage
-{
- /**
- * @brief Base interface for storage controllers.
- *
- * A storage controller probes for devices and resolves devices by major/minor
- * numbers.
- */
- struct storage_controller
- {
- /**
- * @brief Virtual destructor.
- */
- virtual ~storage_controller() = default;
-
- /**
- * @brief Probe the controller and register discovered devices.
- */
- virtual auto probe() -> void = 0;
-
- /**
- * @brief Assign the major number and minor stride for this controller.
- * @param major Major number assigned to this controller.
- * @param minors_per_dev Minor number stride between devices.
- */
- auto set_ids(size_t major, size_t minors_per_dev) -> void;
-
- /**
- * @brief Return the assigned major number.
- * @return Assigned major number.
- */
- [[nodiscard]] auto major() const -> size_t;
-
- /**
- * @brief Return the number of devices managed by this controller.
- * @return Number of managed devices.
- */
- [[nodiscard]] auto devices_count() const -> size_t;
-
- /**
- * @brief Return all devices managed by this controller.
- * @return Vector of all managed devices.
- */
- [[nodiscard]] auto all_devices() const -> kstd::vector<kstd::shared_ptr<devices::device>> const &;
-
- /**
- * @brief Find a managed device by major/minor numbers.
- * @param major Device major number.
- * @param minor Device minor number.
- * @return Matching block device, or nullptr if no device matches.
- */
- [[nodiscard]] auto device_by_minor(size_t minor) const -> kstd::shared_ptr<devices::device>;
-
- protected:
- size_t m_major{};
- size_t m_minors_per_device{};
- kstd::vector<kstd::shared_ptr<devices::device>> m_devices{};
- };
-} // namespace devices::storage
-
-#endif \ No newline at end of file
diff --git a/kernel/devices/include/devices/storage/storage_management.hpp b/kernel/devices/include/devices/storage/storage_management.hpp
deleted file mode 100644
index f8ffda8..0000000
--- a/kernel/devices/include/devices/storage/storage_management.hpp
+++ /dev/null
@@ -1,77 +0,0 @@
-#ifndef TEACH_OS_KERNEL_DEVICES_STORAGE_STORAGE_MANAGEMENT_HPP
-#define TEACH_OS_KERNEL_DEVICES_STORAGE_STORAGE_MANAGEMENT_HPP
-
-#include "devices/device.hpp"
-#include "devices/storage/storage_controller.hpp"
-
-#include <kstd/memory>
-#include <kstd/vector>
-
-#include <cstddef>
-
-namespace devices::storage
-{
- /**
- * @brief Global storage subsystem manager.
- *
- * Owns registered storage controllers and provides device lookup by
- * major/minor numbers.
- */
- struct storage_management
- {
- /**
- * @brief Initialize global storage management.
- *
- * Creates the singleton instance, registers controllers and probes
- * them for devices.
- *
- * @warning Panics if called more than once.
- */
- auto static init() -> void;
-
- /**
- * @brief Return the active storage manager singleton.
- * @return Reference to the active storage manager.
- * @warning Panics if storage management has not been initialized.
- */
- auto static get() -> storage_management &;
-
- /**
- * @brief Register a storage controller.
- * @param controller Controller to register.
- *
- * Assigns controller IDs (major number range and minors per device).
- */
- auto add_controller(kstd::shared_ptr<storage_controller> const & controller) -> void;
-
- /**
- * @brief Return all registered storage controllers.
- * @return Vector of all registered storage controllers.
- */
- [[nodiscard]] auto all_controllers() const -> kstd::vector<kstd::shared_ptr<storage_controller>> const &;
-
- /**
- * @brief Find a device by major/minor numbers.
- * @param major Device major number.
- * @param minor Device minor number.
- * @return Matching device, or nullptr if no device matches.
- */
- auto device_by_major_minor(size_t major, size_t minor) -> kstd::shared_ptr<device>;
-
- /**
- * @brief Determine the boot device.
- * @return Boot device, or nullptr if it cannot be determined.
- */
- auto determine_boot_device() -> kstd::shared_ptr<device>;
-
- private:
- /**
- * @brief Private default constructor for storage management singleton.
- */
- storage_management() = default;
-
- kstd::vector<kstd::shared_ptr<storage_controller>> m_controllers{};
- };
-} // namespace devices::storage
-
-#endif \ No newline at end of file