From 65ba51c7fdcf09dce6b1d690fe059e71d026d1a6 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Fri, 24 Jul 2026 17:55:14 +0200 Subject: kapi: clean up directory names --- arch/x86_64/kapi/boot_modules.cpp | 4 +- kapi/kapi/boot_module/boot_module.hpp | 25 ----- kapi/kapi/boot_module/boot_module_registry.hpp | 109 --------------------- kapi/kapi/boot_module/bus.hpp | 69 ------------- kapi/kapi/boot_modules.hpp | 6 +- kapi/kapi/boot_modules/boot_module.hpp | 25 +++++ kapi/kapi/boot_modules/boot_module_registry.hpp | 109 +++++++++++++++++++++ kapi/kapi/boot_modules/bus.hpp | 71 ++++++++++++++ kernel/kapi/boot_module/bus.cpp | 2 +- kernel/kernel/devices/storage.cpp | 2 - kernel/kernel/drivers/storage/ram_disk.cpp | 1 - .../filesystem/storage_boot_module_fixture.cpp | 2 - .../filesystem/storage_boot_module_fixture.hpp | 3 +- 13 files changed, 212 insertions(+), 216 deletions(-) delete mode 100644 kapi/kapi/boot_module/boot_module.hpp delete mode 100644 kapi/kapi/boot_module/boot_module_registry.hpp delete mode 100644 kapi/kapi/boot_module/bus.hpp create mode 100644 kapi/kapi/boot_modules/boot_module.hpp create mode 100644 kapi/kapi/boot_modules/boot_module_registry.hpp create mode 100644 kapi/kapi/boot_modules/bus.hpp diff --git a/arch/x86_64/kapi/boot_modules.cpp b/arch/x86_64/kapi/boot_modules.cpp index 9ca867a5..f910bdbc 100644 --- a/arch/x86_64/kapi/boot_modules.cpp +++ b/arch/x86_64/kapi/boot_modules.cpp @@ -4,8 +4,8 @@ #include #include -#include -#include +#include +#include #include #include diff --git a/kapi/kapi/boot_module/boot_module.hpp b/kapi/kapi/boot_module/boot_module.hpp deleted file mode 100644 index 608e5341..00000000 --- a/kapi/kapi/boot_module/boot_module.hpp +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef TEACHOS_KAPI_BOOT_MODULE_BOOT_MODULE_HPP -#define TEACHOS_KAPI_BOOT_MODULE_BOOT_MODULE_HPP - -// IWYU pragma: private, include - -#include - -#include -#include - -namespace kapi::boot_modules -{ - // ! The boot module struct - // ! - // ! The boot module struct represents a module loaded by the bootloader, and contains information about it, such as - // ! its name, virtual start address, and size. - struct boot_module - { - std::string_view name{}; - memory::linear_address start_address{}; - std::size_t size{}; - }; -} // namespace kapi::boot_modules - -#endif \ No newline at end of file diff --git a/kapi/kapi/boot_module/boot_module_registry.hpp b/kapi/kapi/boot_module/boot_module_registry.hpp deleted file mode 100644 index fdffa757..00000000 --- a/kapi/kapi/boot_module/boot_module_registry.hpp +++ /dev/null @@ -1,109 +0,0 @@ -#ifndef TEACHOS_KAPI_BOOT_MODULE_BOOT_MODULE_REGISTRY_HPP -#define TEACHOS_KAPI_BOOT_MODULE_BOOT_MODULE_REGISTRY_HPP - -// IWYU pragma: private, include - -#include - -#include - -#include - -namespace kapi::boot_modules -{ - - // ! The interface of the boot module registry - // ! - // ! The boot module registry is responsible for keeping track of the modules loaded by the bootloader, and - // ! providing access to them for the rest of the kernel. - struct boot_module_registry - { - using range_type = kstd::vector; - using value_type = range_type::value_type; - using const_reference = range_type::const_reference; - - using const_iterator = range_type::const_iterator; - using const_reverse_iterator = range_type::const_reverse_iterator; - using size_type = range_type::size_type; - - [[nodiscard]] auto begin() const noexcept -> const_iterator - { - return m_modules.begin(); - } - - [[nodiscard]] auto end() const noexcept -> const_iterator - { - return m_modules.end(); - } - - [[nodiscard]] auto cbegin() const noexcept -> const_iterator - { - return begin(); - } - - [[nodiscard]] auto cend() const noexcept -> const_iterator - { - return end(); - } - - [[nodiscard]] auto rbegin() const noexcept -> const_reverse_iterator - { - return m_modules.rbegin(); - } - - [[nodiscard]] auto rend() const noexcept -> const_reverse_iterator - { - return m_modules.rend(); - } - - [[nodiscard]] auto crbegin() const noexcept -> const_reverse_iterator - { - return rbegin(); - } - - [[nodiscard]] auto crend() const noexcept -> const_reverse_iterator - { - return rend(); - } - - [[nodiscard]] auto front() const noexcept -> const_reference - { - return m_modules.front(); - } - - [[nodiscard]] auto back() const noexcept -> const_reference - { - return m_modules.back(); - } - - [[nodiscard]] auto size() const noexcept -> std::size_t - { - return m_modules.size(); - } - - [[nodiscard]] auto empty() const noexcept -> bool - { - return m_modules.empty(); - } - - [[nodiscard]] auto at(std::size_t index) const -> const_reference - { - return m_modules.at(index); - } - - [[nodiscard]] auto operator[](std::size_t index) const noexcept -> const_reference - { - return m_modules[index]; - } - - auto add_boot_module(boot_module module) -> void - { - m_modules.push_back(module); - } - - private: - range_type m_modules{}; - }; -} // namespace kapi::boot_modules - -#endif \ No newline at end of file diff --git a/kapi/kapi/boot_module/bus.hpp b/kapi/kapi/boot_module/bus.hpp deleted file mode 100644 index 2dc1e1b7..00000000 --- a/kapi/kapi/boot_module/bus.hpp +++ /dev/null @@ -1,69 +0,0 @@ -#ifndef TEACHOS_KAPI_BOOT_MODULE_BUS_HPP -#define TEACHOS_KAPI_BOOT_MODULE_BUS_HPP - -#include -#include -#include - -#include - -#include -#include -#include - -namespace kapi::boot_modules -{ - - struct boot_module_identification - { - constexpr auto static id = devices::interface{"boot_module_identification"}; - - virtual ~boot_module_identification() = default; - - [[nodiscard]] auto virtual command_line() const -> std::string_view = 0; - - [[nodiscard]] auto virtual module() const -> boot_module const & = 0; - }; - - struct boot_module_driver_identification - { - constexpr auto static id = devices::interface{"boot_module_driver_identification"}; - - virtual ~boot_module_driver_identification() = default; - - [[nodiscard]] virtual auto claimed_parameter() const -> std::pair = 0; - }; - - struct boot_module_device final : kapi::devices::device, boot_module_identification - { - boot_module_device(std::size_t index, boot_module const & module); - - [[nodiscard]] auto command_line() const -> std::string_view override; - - [[nodiscard]] auto module() const -> boot_module const & override; - - protected: - auto query_interface(kapi::devices::interface interface) -> void * override; - - private: - boot_module m_module; - }; - - struct boot_module_bus final : kapi::devices::bus, kapi::devices::bus_protocol - { - explicit boot_module_bus(boot_module_registry const * registry); - - auto enumerate(kapi::devices::bus & self) -> void override; - - [[nodiscard]] auto match(kapi::devices::device const & dev, kapi::devices::driver const & drv) const - -> kstd::result override; - - [[nodiscard]] auto protocol() -> kapi::devices::bus_protocol * override; - - private: - boot_module_registry const * m_registry; - }; - -} // namespace kapi::boot_modules - -#endif \ No newline at end of file diff --git a/kapi/kapi/boot_modules.hpp b/kapi/kapi/boot_modules.hpp index 56fefe4f..18995303 100644 --- a/kapi/kapi/boot_modules.hpp +++ b/kapi/kapi/boot_modules.hpp @@ -1,9 +1,9 @@ #ifndef TEACHOS_KAPI_BOOT_MODULES_HPP #define TEACHOS_KAPI_BOOT_MODULES_HPP -#include // IWYU pragma: export -#include // IWYU pragma: export -#include // IWYU pragma: export +#include // IWYU pragma: export +#include // IWYU pragma: export +#include // IWYU pragma: export namespace kapi::boot_modules { diff --git a/kapi/kapi/boot_modules/boot_module.hpp b/kapi/kapi/boot_modules/boot_module.hpp new file mode 100644 index 00000000..85de7ab0 --- /dev/null +++ b/kapi/kapi/boot_modules/boot_module.hpp @@ -0,0 +1,25 @@ +#ifndef TEACHOS_KAPI_BOOT_MODULES_BOOT_MODULE_HPP +#define TEACHOS_KAPI_BOOT_MODULES_BOOT_MODULE_HPP + +// IWYU pragma: private, include + +#include + +#include +#include + +namespace kapi::boot_modules +{ + // ! The boot module struct + // ! + // ! The boot module struct represents a module loaded by the bootloader, and contains information about it, such as + // ! its name, virtual start address, and size. + struct boot_module + { + std::string_view name{}; + memory::linear_address start_address{}; + std::size_t size{}; + }; +} // namespace kapi::boot_modules + +#endif \ No newline at end of file diff --git a/kapi/kapi/boot_modules/boot_module_registry.hpp b/kapi/kapi/boot_modules/boot_module_registry.hpp new file mode 100644 index 00000000..7f490ae3 --- /dev/null +++ b/kapi/kapi/boot_modules/boot_module_registry.hpp @@ -0,0 +1,109 @@ +#ifndef TEACHOS_KAPI_BOOT_MODULES_BOOT_MODULE_REGISTRY_HPP +#define TEACHOS_KAPI_BOOT_MODULES_BOOT_MODULE_REGISTRY_HPP + +// IWYU pragma: private, include + +#include + +#include + +#include + +namespace kapi::boot_modules +{ + + // ! The interface of the boot module registry + // ! + // ! The boot module registry is responsible for keeping track of the modules loaded by the bootloader, and + // ! providing access to them for the rest of the kernel. + struct boot_module_registry + { + using range_type = kstd::vector; + using value_type = range_type::value_type; + using const_reference = range_type::const_reference; + + using const_iterator = range_type::const_iterator; + using const_reverse_iterator = range_type::const_reverse_iterator; + using size_type = range_type::size_type; + + [[nodiscard]] auto begin() const noexcept -> const_iterator + { + return m_modules.begin(); + } + + [[nodiscard]] auto end() const noexcept -> const_iterator + { + return m_modules.end(); + } + + [[nodiscard]] auto cbegin() const noexcept -> const_iterator + { + return begin(); + } + + [[nodiscard]] auto cend() const noexcept -> const_iterator + { + return end(); + } + + [[nodiscard]] auto rbegin() const noexcept -> const_reverse_iterator + { + return m_modules.rbegin(); + } + + [[nodiscard]] auto rend() const noexcept -> const_reverse_iterator + { + return m_modules.rend(); + } + + [[nodiscard]] auto crbegin() const noexcept -> const_reverse_iterator + { + return rbegin(); + } + + [[nodiscard]] auto crend() const noexcept -> const_reverse_iterator + { + return rend(); + } + + [[nodiscard]] auto front() const noexcept -> const_reference + { + return m_modules.front(); + } + + [[nodiscard]] auto back() const noexcept -> const_reference + { + return m_modules.back(); + } + + [[nodiscard]] auto size() const noexcept -> std::size_t + { + return m_modules.size(); + } + + [[nodiscard]] auto empty() const noexcept -> bool + { + return m_modules.empty(); + } + + [[nodiscard]] auto at(std::size_t index) const -> const_reference + { + return m_modules.at(index); + } + + [[nodiscard]] auto operator[](std::size_t index) const noexcept -> const_reference + { + return m_modules[index]; + } + + auto add_boot_module(boot_module module) -> void + { + m_modules.push_back(module); + } + + private: + range_type m_modules{}; + }; +} // namespace kapi::boot_modules + +#endif \ No newline at end of file diff --git a/kapi/kapi/boot_modules/bus.hpp b/kapi/kapi/boot_modules/bus.hpp new file mode 100644 index 00000000..9cab7edb --- /dev/null +++ b/kapi/kapi/boot_modules/bus.hpp @@ -0,0 +1,71 @@ +#ifndef TEACHOS_KAPI_BOOT_MODULES_BUS_HPP +#define TEACHOS_KAPI_BOOT_MODULES_BUS_HPP + +// IWYU pragma: private, include + +#include +#include +#include + +#include + +#include +#include +#include + +namespace kapi::boot_modules +{ + + struct boot_module_identification + { + constexpr auto static id = devices::interface{"boot_module_identification"}; + + virtual ~boot_module_identification() = default; + + [[nodiscard]] auto virtual command_line() const -> std::string_view = 0; + + [[nodiscard]] auto virtual module() const -> boot_module const & = 0; + }; + + struct boot_module_driver_identification + { + constexpr auto static id = devices::interface{"boot_module_driver_identification"}; + + virtual ~boot_module_driver_identification() = default; + + [[nodiscard]] virtual auto claimed_parameter() const -> std::pair = 0; + }; + + struct boot_module_device final : kapi::devices::device, boot_module_identification + { + boot_module_device(std::size_t index, boot_module const & module); + + [[nodiscard]] auto command_line() const -> std::string_view override; + + [[nodiscard]] auto module() const -> boot_module const & override; + + protected: + auto query_interface(kapi::devices::interface interface) -> void * override; + + private: + boot_module m_module; + }; + + struct boot_module_bus final : kapi::devices::bus, kapi::devices::bus_protocol + { + explicit boot_module_bus(boot_module_registry const * registry); + + auto enumerate(kapi::devices::bus & self) -> void override; + + [[nodiscard]] auto match(kapi::devices::device const & dev, kapi::devices::driver const & drv) const + -> kstd::result override; + + [[nodiscard]] auto protocol() -> kapi::devices::bus_protocol * override; + + private: + boot_module_registry const * m_registry; + }; + +} // namespace kapi::boot_modules + +#endif \ No newline at end of file diff --git a/kernel/kapi/boot_module/bus.cpp b/kernel/kapi/boot_module/bus.cpp index 83c97f8e..aab1403b 100644 --- a/kernel/kapi/boot_module/bus.cpp +++ b/kernel/kapi/boot_module/bus.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include diff --git a/kernel/kernel/devices/storage.cpp b/kernel/kernel/devices/storage.cpp index 1f74b9af..28f96de2 100644 --- a/kernel/kernel/devices/storage.cpp +++ b/kernel/kernel/devices/storage.cpp @@ -1,9 +1,7 @@ #include -#include #include #include -#include #include diff --git a/kernel/kernel/drivers/storage/ram_disk.cpp b/kernel/kernel/drivers/storage/ram_disk.cpp index 69256a56..cd5368cb 100644 --- a/kernel/kernel/drivers/storage/ram_disk.cpp +++ b/kernel/kernel/drivers/storage/ram_disk.cpp @@ -3,7 +3,6 @@ #include #include -#include #include #include #include diff --git a/kernel/kernel/test_support/filesystem/storage_boot_module_fixture.cpp b/kernel/kernel/test_support/filesystem/storage_boot_module_fixture.cpp index fbdb01e0..5bddd956 100644 --- a/kernel/kernel/test_support/filesystem/storage_boot_module_fixture.cpp +++ b/kernel/kernel/test_support/filesystem/storage_boot_module_fixture.cpp @@ -3,8 +3,6 @@ #include #include -#include -#include #include #include #include diff --git a/kernel/kernel/test_support/filesystem/storage_boot_module_fixture.hpp b/kernel/kernel/test_support/filesystem/storage_boot_module_fixture.hpp index 48bddf31..663a8032 100644 --- a/kernel/kernel/test_support/filesystem/storage_boot_module_fixture.hpp +++ b/kernel/kernel/test_support/filesystem/storage_boot_module_fixture.hpp @@ -1,8 +1,7 @@ #ifndef TEACHOS_KERNEL_TEST_SUPPORT_FILESYSTEM_STORAGE_BOOT_MODULE_FIXTURE_HPP #define TEACHOS_KERNEL_TEST_SUPPORT_FILESYSTEM_STORAGE_BOOT_MODULE_FIXTURE_HPP -#include -#include +#include #include -- cgit v1.2.3