diff options
| author | Felix Morgner <felix.morgner@ost.ch> | 2026-07-24 23:12:23 +0200 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@ost.ch> | 2026-07-24 23:12:23 +0200 |
| commit | 8ac3b7c5dfd6917eac1ffb117ee48231032ce754 (patch) | |
| tree | cd1203a908b6f449db2e321207b6e0e77962fa57 /kapi | |
| parent | a1f1ddabf24fb6dfb1bcfc6257c44b6a2bfba8ab (diff) | |
| download | kernel-8ac3b7c5dfd6917eac1ffb117ee48231032ce754.tar.xz kernel-8ac3b7c5dfd6917eac1ffb117ee48231032ce754.zip | |
kernel: remove boot modules registry
Diffstat (limited to 'kapi')
| -rw-r--r-- | kapi/kapi/boot_modules.hpp | 21 | ||||
| -rw-r--r-- | kapi/kapi/boot_modules/bus.hpp | 71 | ||||
| -rw-r--r-- | kapi/kapi/boot_modules/device.hpp | 64 | ||||
| -rw-r--r-- | kapi/kapi/boot_modules/module.hpp | 10 | ||||
| -rw-r--r-- | kapi/kapi/boot_modules/registry.hpp | 76 | ||||
| -rw-r--r-- | kapi/kapi/test_support/boot_modules.hpp | 17 |
6 files changed, 81 insertions, 178 deletions
diff --git a/kapi/kapi/boot_modules.hpp b/kapi/kapi/boot_modules.hpp index 7f47c628..7f7d5727 100644 --- a/kapi/kapi/boot_modules.hpp +++ b/kapi/kapi/boot_modules.hpp @@ -1,21 +1,20 @@ #ifndef TEACHOS_KAPI_BOOT_MODULES_HPP #define TEACHOS_KAPI_BOOT_MODULES_HPP -#include <kapi/boot_modules/bus.hpp> // IWYU pragma: export -#include <kapi/boot_modules/module.hpp> // IWYU pragma: export -#include <kapi/boot_modules/registry.hpp> // IWYU pragma: export +#include <kapi/boot_modules/device.hpp> // IWYU pragma: export +#include <kapi/boot_modules/module.hpp> // IWYU pragma: export +#include <kapi/devices/device.hpp> namespace kapi::boot_modules { - //! @qualifier platform-defined - //! Initialize the boot module registry. - //! - //! @note This function must be implemented by the target platform. - //! - //! This function initializes the boot module registry, which is responsible for keeping track of the modules loaded - //! by the bootloader, and providing access to them for the rest of the kernel. - auto init() -> void; + //! @addtogroup kapi-boot_modules-platform-defined + //! @{ + + //! Attach all boot modules to the boot module bus. + auto init(kapi::devices::bus & bus) -> void; + + //! @} } // 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 deleted file mode 100644 index 3e982d85..00000000 --- a/kapi/kapi/boot_modules/bus.hpp +++ /dev/null @@ -1,71 +0,0 @@ -#ifndef TEACHOS_KAPI_BOOT_MODULES_BUS_HPP -#define TEACHOS_KAPI_BOOT_MODULES_BUS_HPP - -// IWYU pragma: private, include <kapi/boot_modules.hpp> - -#include <kapi/boot_modules/module.hpp> -#include <kapi/boot_modules/registry.hpp> -#include <kapi/devices.hpp> - -#include <kstd/result.hpp> - -#include <cstddef> -#include <string_view> -#include <utility> - -namespace kapi::boot_modules -{ - - struct boot_module_identification - { - constexpr auto static id = devices::interface_id{"boot_module_identification"}; - - virtual ~boot_module_identification() = default; - - [[nodiscard]] auto virtual command_line() const -> std::string_view = 0; - - [[nodiscard]] auto virtual module() const -> module const & = 0; - }; - - struct boot_module_driver_identification - { - constexpr auto static id = devices::interface_id{"boot_module_driver_identification"}; - - virtual ~boot_module_driver_identification() = default; - - [[nodiscard]] virtual auto claimed_parameter() const -> std::pair<std::string_view, std::string_view> = 0; - }; - - struct boot_module_device final : kapi::devices::device, boot_module_identification - { - boot_module_device(std::size_t index, struct module const & module); - - [[nodiscard]] auto command_line() const -> std::string_view override; - - [[nodiscard]] auto module() const -> struct module const & override; - - protected: - auto query_interface(kapi::devices::interface_id interface) -> void * override; - - private: - struct module m_module; - }; - - struct boot_module_bus final : kapi::devices::bus, kapi::devices::bus_protocol - { - explicit boot_module_bus(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<unsigned> override; - - [[nodiscard]] auto protocol() -> kapi::devices::bus_protocol * override; - - private: - registry const * m_registry; - }; - -} // namespace kapi::boot_modules - -#endif
\ No newline at end of file diff --git a/kapi/kapi/boot_modules/device.hpp b/kapi/kapi/boot_modules/device.hpp new file mode 100644 index 00000000..a6aba9b0 --- /dev/null +++ b/kapi/kapi/boot_modules/device.hpp @@ -0,0 +1,64 @@ +#ifndef TEACHOS_KAPI_BOOT_MODULES_DEVICE_HPP +#define TEACHOS_KAPI_BOOT_MODULES_DEVICE_HPP + +#include <kapi/boot_modules/module.hpp> +#include <kapi/devices.hpp> +#include <kapi/memory.hpp> + +#include <cstddef> +#include <string_view> + +namespace kapi::boot_modules +{ + + //! @addtogroup kapi-boot_modules-kernel-defined + //! @{ + + //! The signature interface of a boot module device. + //! + //! Boot module devices are "virtual" devices that get attached to the boot module bus. The purpose is to allow them + //! to materialize as "real" devices, e.g. a ram disk, and have a driver bound to them. + struct boot_module_signature + { + constexpr auto static id = kapi::devices::interface_id{"boot_module_signature"}; + + virtual ~boot_module_signature() = default; + + //! The command line associated with this module device. + [[nodiscard]] auto virtual command_line() const -> std::string_view = 0; + + //! The in-memory boot module associated with this device. + [[nodiscard]] auto virtual module() const -> kapi::boot_modules::module const & = 0; + }; + + //! The claim interface of a boot module driver. + struct boot_module_claim + { + constexpr auto static id = kapi::devices::interface_id{"boot_module_claim"}; + + virtual ~boot_module_claim() = default; + + //! The parameter this driver claims. + [[nodiscard]] virtual auto parameter() const -> std::pair<std::string_view, std::string_view> = 0; + }; + + //! A generic boot module device. + struct device final : kapi::devices::device, boot_module_signature + { + device(std::size_t index, struct module const & module); + + [[nodiscard]] auto command_line() const -> std::string_view override; + + [[nodiscard]] auto module() const -> struct module const & override; + + protected: + auto query_interface(kapi::devices::interface_id interface) -> void * override; + + private: + struct module m_module; + }; + + //! @} + +} // namespace kapi::boot_modules +#endif
\ No newline at end of file diff --git a/kapi/kapi/boot_modules/module.hpp b/kapi/kapi/boot_modules/module.hpp index 14898132..99e7b2ca 100644 --- a/kapi/kapi/boot_modules/module.hpp +++ b/kapi/kapi/boot_modules/module.hpp @@ -1,8 +1,6 @@ #ifndef TEACHOS_KAPI_BOOT_MODULES_MODULE_HPP #define TEACHOS_KAPI_BOOT_MODULES_MODULE_HPP -// IWYU pragma: private, include <kapi/boot_modules.hpp> - #include <kapi/memory.hpp> #include <cstddef> @@ -10,6 +8,10 @@ namespace kapi::boot_modules { + + //! @addtogroup 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 @@ -20,6 +22,8 @@ namespace kapi::boot_modules memory::linear_address start_address{}; std::size_t size{}; }; -} // namespace kapi::boot_modules + //! @} + +} // namespace kapi::boot_modules #endif
\ No newline at end of file diff --git a/kapi/kapi/boot_modules/registry.hpp b/kapi/kapi/boot_modules/registry.hpp deleted file mode 100644 index 33dc2169..00000000 --- a/kapi/kapi/boot_modules/registry.hpp +++ /dev/null @@ -1,76 +0,0 @@ -#ifndef TEACHOS_KAPI_BOOT_MODULES_REGISTRY_HPP -#define TEACHOS_KAPI_BOOT_MODULES_REGISTRY_HPP - -// IWYU pragma: private, include <kapi/boot_modules.hpp> - -#include <kapi/boot_modules/module.hpp> - -#include <kstd/vector.hpp> - -#include <cstddef> - -namespace kapi::boot_modules -{ - - //! @addtogroup kapi-boot_modules-kernel-defined - //! @{ - - //! 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 registry - { - using container = kstd::vector<module>; - using value_type = container::value_type; - using const_reference = container::const_reference; - - using const_iterator = container::const_iterator; - using const_reverse_iterator = container::const_reverse_iterator; - using size_type = container::size_type; - - auto static init() -> void; - - auto static get() -> registry &; - - registry() = default; - - [[nodiscard]] auto begin() const noexcept -> const_iterator; - - [[nodiscard]] auto end() const noexcept -> const_iterator; - - [[nodiscard]] auto cbegin() const noexcept -> const_iterator; - - [[nodiscard]] auto cend() const noexcept -> const_iterator; - - [[nodiscard]] auto rbegin() const noexcept -> const_reverse_iterator; - - [[nodiscard]] auto rend() const noexcept -> const_reverse_iterator; - - [[nodiscard]] auto crbegin() const noexcept -> const_reverse_iterator; - - [[nodiscard]] auto crend() const noexcept -> const_reverse_iterator; - - [[nodiscard]] auto front() const noexcept -> const_reference; - - [[nodiscard]] auto back() const noexcept -> const_reference; - - [[nodiscard]] auto size() const noexcept -> std::size_t; - - [[nodiscard]] auto empty() const noexcept -> bool; - - [[nodiscard]] auto at(std::size_t index) const -> const_reference; - - [[nodiscard]] auto operator[](std::size_t index) const noexcept -> const_reference; - - auto add(module module) -> void; - - private: - container m_modules{}; - }; - - //! @} - -} // namespace kapi::boot_modules - -#endif
\ No newline at end of file diff --git a/kapi/kapi/test_support/boot_modules.hpp b/kapi/kapi/test_support/boot_modules.hpp deleted file mode 100644 index 86a81307..00000000 --- a/kapi/kapi/test_support/boot_modules.hpp +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef KAPI_TEST_SUPPORT_BOOT_MODULES_HPP -#define KAPI_TEST_SUPPORT_BOOT_MODULES_HPP - -#include <kapi/boot_modules.hpp> - -#include <optional> - -namespace kapi::test_support::boot_modules -{ - - auto deinit_registry() -> void; - - auto inject_registry(kapi::boot_modules::registry && registry) -> std::optional<kapi::boot_modules::registry>; - -} // namespace kapi::test_support::boot_modules - -#endif |
