From 01549be5c53f74df3df1d7f9de3e702ffb906088 Mon Sep 17 00:00:00 2001 From: Lukas Oesch Date: Wed, 18 Feb 2026 10:35:30 +0100 Subject: add multiboot2 module tag, all modules can be iterated --- libs/multiboot2/include/multiboot2/information.hpp | 29 ++++++++++++++++++++++ .../include/multiboot2/information/data.hpp | 10 ++++++++ 2 files changed, 39 insertions(+) (limited to 'libs/multiboot2') diff --git a/libs/multiboot2/include/multiboot2/information.hpp b/libs/multiboot2/include/multiboot2/information.hpp index 0f48835..fbd534c 100644 --- a/libs/multiboot2/include/multiboot2/information.hpp +++ b/libs/multiboot2/include/multiboot2/information.hpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -106,6 +107,22 @@ namespace multiboot2 } }; + /** + * @copydoc multiboot2::data::module + */ + struct module : vla_tag + { + using vla_tag::vla_tag; + + /** + * @brief The module command line or name. + */ + [[nodiscard]] auto string() const noexcept -> std::string_view + { + return {data(), size()}; + } + }; + struct information_view { using iterator = iterator; @@ -210,6 +227,18 @@ namespace multiboot2 return maybe_memory_map().value(); } + [[nodiscard]] auto modules() const noexcept + { + auto filter_modules = [](auto const & tag) { + return tag.information_id() == module::id; + }; + auto transform_module = [](auto const & tag) { + return module{&tag}; + }; + return std::ranges::subrange(begin(), end()) | std::views::filter(filter_modules) | + std::views::transform(transform_module); + } + private: template [[nodiscard]] constexpr auto get() const noexcept -> std::optional diff --git a/libs/multiboot2/include/multiboot2/information/data.hpp b/libs/multiboot2/include/multiboot2/information/data.hpp index ccd8fbb..8d53448 100644 --- a/libs/multiboot2/include/multiboot2/information/data.hpp +++ b/libs/multiboot2/include/multiboot2/information/data.hpp @@ -127,6 +127,16 @@ namespace multiboot2 std::uint32_t entry_version; }; + //! A module loaded by the bootloader. + struct module : tag_data + { + //! The physical start address of this module. + std::uint32_t start_address; + + //! The physical end address of this module. + std::uint32_t end_address; + }; + } // namespace data } // namespace multiboot2 -- cgit v1.2.3