diff options
| author | Felix Morgner <felix.morgner@ost.ch> | 2025-10-29 15:01:43 +0100 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@ost.ch> | 2025-10-29 15:01:43 +0100 |
| commit | b157e2c472d8bd67ac1656404a6a6ee821260f4b (patch) | |
| tree | 9c4ebaee21c9ad3521f86c543dc1f29906305baa /libs/multiboot2 | |
| parent | c2b0bdfe3b725166f16c742cdaca7969052df382 (diff) | |
| download | teachos-b157e2c472d8bd67ac1656404a6a6ee821260f4b.tar.xz teachos-b157e2c472d8bd67ac1656404a6a6ee821260f4b.zip | |
chore: reformat source code
Diffstat (limited to 'libs/multiboot2')
| -rw-r--r-- | libs/multiboot2/include/multiboot2/constants.hpp | 2 | ||||
| -rw-r--r-- | libs/multiboot2/include/multiboot2/impl/data.hpp | 7 | ||||
| -rw-r--r-- | libs/multiboot2/include/multiboot2/impl/iterator.hpp | 19 | ||||
| -rw-r--r-- | libs/multiboot2/include/multiboot2/impl/tag.hpp | 34 | ||||
| -rw-r--r-- | libs/multiboot2/include/multiboot2/information.hpp | 102 |
5 files changed, 117 insertions, 47 deletions
diff --git a/libs/multiboot2/include/multiboot2/constants.hpp b/libs/multiboot2/include/multiboot2/constants.hpp index 30d52d0..0f6b82f 100644 --- a/libs/multiboot2/include/multiboot2/constants.hpp +++ b/libs/multiboot2/include/multiboot2/constants.hpp @@ -13,7 +13,7 @@ namespace multiboot2 using impl::memory_type; using impl::tag_id; - auto constexpr inline header_magic = std::uint32_t{0xe85250d6}; + constexpr auto inline header_magic = std::uint32_t{0xe852'50d6}; } // namespace multiboot2 diff --git a/libs/multiboot2/include/multiboot2/impl/data.hpp b/libs/multiboot2/include/multiboot2/impl/data.hpp index a5f2e14..3cda162 100644 --- a/libs/multiboot2/include/multiboot2/impl/data.hpp +++ b/libs/multiboot2/include/multiboot2/impl/data.hpp @@ -10,7 +10,7 @@ namespace multiboot2::impl template<auto Id> struct tag_data { - auto constexpr inline static id = Id; + constexpr auto static inline id = Id; }; /** @@ -94,7 +94,10 @@ namespace multiboot2::impl /** * @brief Check if the memory described by this region is available for use. */ - auto constexpr available() const noexcept { return type == memory_type::AVAILABLE; } + constexpr auto available() const noexcept + { + return type == memory_type::AVAILABLE; + } /** * @brief Start address of this region diff --git a/libs/multiboot2/include/multiboot2/impl/iterator.hpp b/libs/multiboot2/include/multiboot2/impl/iterator.hpp index e82326d..f8955cb 100644 --- a/libs/multiboot2/include/multiboot2/impl/iterator.hpp +++ b/libs/multiboot2/include/multiboot2/impl/iterator.hpp @@ -23,16 +23,21 @@ namespace multiboot2::impl constexpr explicit information_iterator(impl::tag_header const * offset) : m_current(offset) - { - } + {} - auto constexpr operator==(information_iterator const &) const noexcept -> bool = default; + constexpr auto operator==(information_iterator const &) const noexcept -> bool = default; - auto constexpr operator*() const noexcept -> reference { return *(m_current.value()); } + constexpr auto operator*() const noexcept -> reference + { + return *(m_current.value()); + } - auto constexpr operator->() const noexcept -> pointer { return m_current.value(); } + constexpr auto operator->() const noexcept -> pointer + { + return m_current.value(); + } - auto constexpr operator++() noexcept -> information_iterator & + constexpr auto operator++() noexcept -> information_iterator & { if (m_current) { @@ -48,7 +53,7 @@ namespace multiboot2::impl return *this; } - auto constexpr operator++(int) noexcept -> information_iterator + constexpr auto operator++(int) noexcept -> information_iterator { auto copy = *this; ++(*this); diff --git a/libs/multiboot2/include/multiboot2/impl/tag.hpp b/libs/multiboot2/include/multiboot2/impl/tag.hpp index f7471a4..f151b54 100644 --- a/libs/multiboot2/include/multiboot2/impl/tag.hpp +++ b/libs/multiboot2/include/multiboot2/impl/tag.hpp @@ -18,24 +18,31 @@ namespace multiboot2::impl tag_header() : m_id{} , m_size{} - { - } + {} tag_header(tag_header const * data) : tag_header{*data} + {} + + auto full_size() const noexcept -> std::size_t { + return (m_size + 7) & (~7); } - auto full_size() const noexcept -> std::size_t { return (m_size + 7) & (~7); } - - auto information_id() const noexcept -> impl::information_id const & { return m_id; } + auto information_id() const noexcept -> impl::information_id const & + { + return m_id; + } auto next() const noexcept -> tag_header const * { return std::bit_cast<tag_header const *>(std::bit_cast<std::byte const *>(this) + full_size()); } - auto unaligned_size() const noexcept -> std::uint32_t { return m_size; } + auto unaligned_size() const noexcept -> std::uint32_t + { + return m_size; + } protected: impl::information_id const m_id; @@ -51,22 +58,19 @@ namespace multiboot2::impl tag() : tag_header{} , Data{} - { - } + {} explicit tag(tag_header const * header) requires(sizeof(tag) > sizeof(tag_header)) : tag_header{header} , Data{*std::bit_cast<Data const *>(header + 1)} - { - } + {} explicit tag(tag_header const * header) requires(sizeof(tag) == sizeof(tag_header)) : tag_header{header} , Data{} - { - } + {} }; /** @@ -80,14 +84,12 @@ namespace multiboot2::impl vla_tag() : tag<Data>{} , m_vla{} - { - } + {} explicit vla_tag(tag_header const * header) : tag<Data>{header} , m_vla{vla_start(header), vla_size(header)} - { - } + {} protected: auto static vla_start(tag_header const * header) noexcept -> VlaData * diff --git a/libs/multiboot2/include/multiboot2/information.hpp b/libs/multiboot2/include/multiboot2/information.hpp index 04ba183..ac03069 100644 --- a/libs/multiboot2/include/multiboot2/information.hpp +++ b/libs/multiboot2/include/multiboot2/information.hpp @@ -41,7 +41,10 @@ namespace multiboot2 /** * @brief The command line string */ - auto string() const noexcept -> range_type { return m_vla; } + auto string() const noexcept -> range_type + { + return m_vla; + } }; /** @@ -53,7 +56,10 @@ namespace multiboot2 using iterator = range_type::iterator; - auto data() const noexcept -> range_type { return m_vla; } + auto data() const noexcept -> range_type + { + return m_vla; + } }; /** @@ -66,7 +72,10 @@ namespace multiboot2 /** * @brief The name of the bootloader */ - auto string() const noexcept -> std::string_view { return m_vla; } + auto string() const noexcept -> std::string_view + { + return m_vla; + } }; /** @@ -78,14 +87,23 @@ namespace multiboot2 using iterator = range_type::iterator; - auto begin() const noexcept -> iterator { return regions().begin(); } + auto begin() const noexcept -> iterator + { + return regions().begin(); + } - auto end() const noexcept -> iterator { return regions().end(); } + auto end() const noexcept -> iterator + { + return regions().end(); + } /** * @brief The available memory regions */ - auto regions() const noexcept -> range_type { return m_vla; } + auto regions() const noexcept -> range_type + { + return m_vla; + } }; struct information_view @@ -95,13 +113,22 @@ namespace multiboot2 using pointer = impl::information_iterator::pointer; using reference = impl::information_iterator::reference; - auto size_bytes() const noexcept -> std::size_t { return m_size; } + auto size_bytes() const noexcept -> std::size_t + { + return m_size; + } // Range access - auto begin() const noexcept -> iterator { return iterator{&m_tags}; } + auto begin() const noexcept -> iterator + { + return iterator{&m_tags}; + } - auto end() const noexcept -> iterator { return iterator{}; } + auto end() const noexcept -> iterator + { + return iterator{}; + } // Tag access @@ -111,36 +138,69 @@ namespace multiboot2 return get<Tag>().has_value(); } - auto maybe_basic_memory() const noexcept -> std::optional<basic_memory> { return get<multiboot2::basic_memory>(); } + auto maybe_basic_memory() const noexcept -> std::optional<basic_memory> + { + return get<multiboot2::basic_memory>(); + } - auto basic_memory() const -> basic_memory { return maybe_basic_memory().value(); } + auto basic_memory() const -> basic_memory + { + return maybe_basic_memory().value(); + } auto maybe_bios_boot_device() const noexcept -> std::optional<bios_boot_device> { return get<multiboot2::bios_boot_device>(); } - auto bios_boot_device() const -> bios_boot_device { return maybe_bios_boot_device().value(); } + auto bios_boot_device() const -> bios_boot_device + { + return maybe_bios_boot_device().value(); + } - auto maybe_command_line() const noexcept -> std::optional<command_line> { return get<multiboot2::command_line>(); } + auto maybe_command_line() const noexcept -> std::optional<command_line> + { + return get<multiboot2::command_line>(); + } - auto command_line() const -> command_line { return maybe_command_line().value(); } + auto command_line() const -> command_line + { + return maybe_command_line().value(); + } - auto maybe_elf_symbols() const noexcept -> std::optional<elf_symbols> { return get<multiboot2::elf_symbols>(); } + auto maybe_elf_symbols() const noexcept -> std::optional<elf_symbols> + { + return get<multiboot2::elf_symbols>(); + } - auto elf_symbols() const -> elf_symbols { return maybe_elf_symbols().value(); } + auto elf_symbols() const -> elf_symbols + { + return maybe_elf_symbols().value(); + } - auto maybe_loader_name() const noexcept -> std::optional<loader_name> { return get<multiboot2::loader_name>(); } + auto maybe_loader_name() const noexcept -> std::optional<loader_name> + { + return get<multiboot2::loader_name>(); + } - auto loader_name() const -> loader_name { return maybe_loader_name().value(); } + auto loader_name() const -> loader_name + { + return maybe_loader_name().value(); + } - auto maybe_memory_map() const noexcept -> std::optional<memory_map> { return get<multiboot2::memory_map>(); } + auto maybe_memory_map() const noexcept -> std::optional<memory_map> + { + return get<multiboot2::memory_map>(); + } - auto memory_map() const -> memory_map { return maybe_memory_map().value(); } + auto memory_map() const -> memory_map + { + return maybe_memory_map().value(); + } private: template<typename Tag> - auto constexpr get() const noexcept -> std::optional<Tag> + constexpr auto get() const noexcept -> std::optional<Tag> { if (auto found = std::ranges::find_if(*this, [](auto tag) { return tag.information_id() == Tag::id; }); found != end()) |
