diff options
| author | Lukas Oesch <lukasoesch20@gmail.com> | 2026-02-18 10:35:30 +0100 |
|---|---|---|
| committer | Lukas Oesch <lukasoesch20@gmail.com> | 2026-03-17 16:39:38 +0100 |
| commit | 01549be5c53f74df3df1d7f9de3e702ffb906088 (patch) | |
| tree | 14af67a1d372ba1144fb6c0672508502ff809953 /libs | |
| parent | e32c889764b56aa0ed5373c07d0225c95ed502bb (diff) | |
| download | teachos-01549be5c53f74df3df1d7f9de3e702ffb906088.tar.xz teachos-01549be5c53f74df3df1d7f9de3e702ffb906088.zip | |
add multiboot2 module tag, all modules can be iterated
Diffstat (limited to 'libs')
| -rw-r--r-- | libs/multiboot2/include/multiboot2/information.hpp | 29 | ||||
| -rw-r--r-- | libs/multiboot2/include/multiboot2/information/data.hpp | 10 |
2 files changed, 39 insertions, 0 deletions
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 <cstdint> #include <cstdlib> #include <optional> +#include <ranges> #include <span> #include <string_view> @@ -106,6 +107,22 @@ namespace multiboot2 } }; + /** + * @copydoc multiboot2::data::module + */ + struct module : vla_tag<data::module, char, std::basic_string_view> + { + 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<typename Tag> [[nodiscard]] constexpr auto get() const noexcept -> std::optional<Tag> 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<information_id::module> + { + //! 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 |
