aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@ost.ch>2025-12-23 13:09:28 +0100
committerFelix Morgner <felix.morgner@ost.ch>2025-12-23 13:09:28 +0100
commit54079f9b8dab6a70a0826d4b4f86d46765cf63f9 (patch)
treef893c25c9d75b3d542c4583a4a80b495638364e8
parent7508c25af63d9298f67a01ff2001373801b07a1d (diff)
downloadteachos-54079f9b8dab6a70a0826d4b4f86d46765cf63f9.tar.xz
teachos-54079f9b8dab6a70a0826d4b4f86d46765cf63f9.zip
libs/multiboot2: clean up file structure
-rw-r--r--libs/multiboot2/include/multiboot2/constants.hpp7
-rw-r--r--libs/multiboot2/include/multiboot2/constants/architecture_id.hpp22
-rw-r--r--libs/multiboot2/include/multiboot2/constants/information_id.hpp (renamed from libs/multiboot2/include/multiboot2/impl/ids.hpp)49
-rw-r--r--libs/multiboot2/include/multiboot2/constants/memory_type.hpp25
-rw-r--r--libs/multiboot2/include/multiboot2/constants/tag_id.hpp31
-rw-r--r--libs/multiboot2/include/multiboot2/information.hpp46
-rw-r--r--libs/multiboot2/include/multiboot2/information/data.hpp (renamed from libs/multiboot2/include/multiboot2/impl/data.hpp)17
-rw-r--r--libs/multiboot2/include/multiboot2/information/iterator.hpp (renamed from libs/multiboot2/include/multiboot2/impl/iterator.hpp)32
-rw-r--r--libs/multiboot2/include/multiboot2/information/tag.hpp (renamed from libs/multiboot2/include/multiboot2/impl/tag.hpp)16
9 files changed, 141 insertions, 104 deletions
diff --git a/libs/multiboot2/include/multiboot2/constants.hpp b/libs/multiboot2/include/multiboot2/constants.hpp
index 0f6b82f..2198210 100644
--- a/libs/multiboot2/include/multiboot2/constants.hpp
+++ b/libs/multiboot2/include/multiboot2/constants.hpp
@@ -1,18 +1,13 @@
#ifndef MULTIBOOT2_CONSTANTS_HPP
#define MULTIBOOT2_CONSTANTS_HPP
-#include "impl/ids.hpp" // IWYU pragma: export
+#include "constants/architecture_id.hpp" // IWYU pragma: export
#include <cstdint>
namespace multiboot2
{
- using impl::architecture_id;
- using impl::information_id;
- using impl::memory_type;
- using impl::tag_id;
-
constexpr auto inline header_magic = std::uint32_t{0xe852'50d6};
} // namespace multiboot2
diff --git a/libs/multiboot2/include/multiboot2/constants/architecture_id.hpp b/libs/multiboot2/include/multiboot2/constants/architecture_id.hpp
new file mode 100644
index 0000000..3d560da
--- /dev/null
+++ b/libs/multiboot2/include/multiboot2/constants/architecture_id.hpp
@@ -0,0 +1,22 @@
+#ifndef MULTIBOOT2_CONSTANTS_ARCHITECTURE_ID_HPP
+#define MULTIBOOT2_CONSTANTS_ARCHITECTURE_ID_HPP
+
+// IWYU pragma: private, include <multiboot2/constants.hpp>
+
+#include <cstdint>
+
+namespace multiboot2
+{
+
+ //! The IDs of the supported system architectures.
+ enum struct architecture_id : std::uint32_t
+ {
+ //! 32-bit protected mode i386
+ i386 = 0,
+ //! 32-bit MIPS
+ MIPS32 = 4,
+ };
+
+} // namespace multiboot2
+
+#endif \ No newline at end of file
diff --git a/libs/multiboot2/include/multiboot2/impl/ids.hpp b/libs/multiboot2/include/multiboot2/constants/information_id.hpp
index 98bc1f2..7b0fd55 100644
--- a/libs/multiboot2/include/multiboot2/impl/ids.hpp
+++ b/libs/multiboot2/include/multiboot2/constants/information_id.hpp
@@ -1,11 +1,11 @@
-#ifndef MULTIBOOT2_IMPL_IDS_HPP
-#define MULTIBOOT2_IMPL_IDS_HPP
+#ifndef MULTIBOOT2_CONSTANTS_INFORMATION_ID_HPP
+#define MULTIBOOT2_CONSTANTS_INFORMATION_ID_HPP
-// IWYU pragma: private
+// IWYU pragma: private, include <multiboot2/constants.hpp>
#include <cstdint>
-namespace multiboot2::impl
+namespace multiboot2
{
/**
@@ -37,45 +37,6 @@ namespace multiboot2::impl
LOAD_BASE_ADDRESS ///< Contains image load base physical address.
};
- /**
- * @brief Header tag IDs.
- */
- enum struct tag_id : std::uint32_t
- {
- END,
- INFORMATION_REQUEST,
- ADDRESSES,
- ENTRY_ADDRESS,
- CONSOLE_FLAGS,
- PREFERRED_FRAMEBUFFER_MODE,
- PAGE_ALIGN_MODULES,
- EFI_BOOT_SERVICES_SUPPORTED,
- EFI32_ENTRY_ADDRESS,
- EFI64_ENTRY_ADDRESS,
- RELOCATABLE,
- };
-
- /**
- * @brief System architecture IDs.
- */
- enum struct architecture_id : std::uint32_t
- {
- I386 = 0,
- MIPS32 = 4,
- };
-
- /**
- * @brief Memory type IDs.
- */
- enum struct memory_type : std::uint32_t
- {
- AVAILABLE = 1,
- RESERVED,
- ACPI_RECLAIMABLE,
- NON_VOLATILE_STORAGE,
- BAD_RAM,
- };
-
-} // namespace multiboot2::impl
+} // namespace multiboot2
#endif \ No newline at end of file
diff --git a/libs/multiboot2/include/multiboot2/constants/memory_type.hpp b/libs/multiboot2/include/multiboot2/constants/memory_type.hpp
new file mode 100644
index 0000000..56fd0b8
--- /dev/null
+++ b/libs/multiboot2/include/multiboot2/constants/memory_type.hpp
@@ -0,0 +1,25 @@
+#ifndef MULTIBOOT2_CONSTANTS_MEMORY_TYPE_HPP
+#define MULTIBOOT2_CONSTANTS_MEMORY_TYPE_HPP
+
+// IWYU pragma: private, include <multiboot2/constants.hpp>
+
+#include <cstdint>
+
+namespace multiboot2
+{
+
+ /**
+ * @brief Memory type IDs.
+ */
+ enum struct memory_type : std::uint32_t
+ {
+ AVAILABLE = 1,
+ RESERVED,
+ ACPI_RECLAIMABLE,
+ NON_VOLATILE_STORAGE,
+ BAD_RAM,
+ };
+
+} // namespace multiboot2
+
+#endif \ No newline at end of file
diff --git a/libs/multiboot2/include/multiboot2/constants/tag_id.hpp b/libs/multiboot2/include/multiboot2/constants/tag_id.hpp
new file mode 100644
index 0000000..378c2b6
--- /dev/null
+++ b/libs/multiboot2/include/multiboot2/constants/tag_id.hpp
@@ -0,0 +1,31 @@
+#ifndef MULTIBOOT2_CONSTANTS_TAG_ID_HPP
+#define MULTIBOOT2_CONSTANTS_TAG_ID_HPP
+
+// IWYU pragma: private, include <multiboot2/constants.hpp>
+
+#include <cstdint>
+
+namespace multiboot2
+{
+
+ /**
+ * @brief Header tag IDs.
+ */
+ enum struct tag_id : std::uint32_t
+ {
+ END,
+ INFORMATION_REQUEST,
+ ADDRESSES,
+ ENTRY_ADDRESS,
+ CONSOLE_FLAGS,
+ PREFERRED_FRAMEBUFFER_MODE,
+ PAGE_ALIGN_MODULES,
+ EFI_BOOT_SERVICES_SUPPORTED,
+ EFI32_ENTRY_ADDRESS,
+ EFI64_ENTRY_ADDRESS,
+ RELOCATABLE,
+ };
+
+} // namespace multiboot2
+
+#endif \ No newline at end of file
diff --git a/libs/multiboot2/include/multiboot2/information.hpp b/libs/multiboot2/include/multiboot2/information.hpp
index 2d60a6d..abb0826 100644
--- a/libs/multiboot2/include/multiboot2/information.hpp
+++ b/libs/multiboot2/include/multiboot2/information.hpp
@@ -1,9 +1,9 @@
-#ifndef JOS_MULTIBOOT2_INFORMATION_HPP
-#define JOS_MULTIBOOT2_INFORMATION_HPP
+#ifndef MULTIBOOT2_INFORMATION_HPP
+#define MULTIBOOT2_INFORMATION_HPP
-#include "impl/data.hpp"
-#include "impl/iterator.hpp"
-#include "impl/tag.hpp"
+#include "information/data.hpp" // IWYU pragma: export
+#include "information/iterator.hpp" // IWYU pragma: export
+#include "information/tag.hpp" // IWYU pragma: export
#include <elf/format.hpp>
#include <elf/section_header.hpp>
@@ -20,25 +20,25 @@ namespace multiboot2
{
/**
- * @copydoc multiboot2::impl::basic_memory_data
+ * @copydoc multiboot2::basic_memory_data
*/
- struct basic_memory : impl::tag<impl::basic_memory_data>
+ struct basic_memory : tag<basic_memory_data>
{
using tag::tag;
};
/**
- * @copydoc multiboot2::impl::bios_boot_device_data
+ * @copydoc multiboot2::bios_boot_device_data
*/
- struct bios_boot_device : impl::tag<impl::bios_boot_device_data>
+ struct bios_boot_device : tag<bios_boot_device_data>
{
using tag::tag;
};
/**
- * @copydoc multiboot2::impl::command_line_data
+ * @copydoc multiboot2::command_line_data
*/
- struct command_line : impl::vla_tag<impl::command_line_data, char, std::basic_string_view>
+ struct command_line : vla_tag<command_line_data, char, std::basic_string_view>
{
using vla_tag::vla_tag;
@@ -52,12 +52,12 @@ namespace multiboot2
};
/**
- * @copydoc multiboot2::impl::elf_symbols_data
+ * @copydoc multiboot2::elf_symbols_data
*/
template<elf::format Format>
- struct elf_symbols : impl::vla_tag<impl::elf_symbols_data, elf::section_header<Format> const, std::span>
+ struct elf_symbols : vla_tag<elf_symbols_data, elf::section_header<Format> const, std::span>
{
- using base = impl::vla_tag<impl::elf_symbols_data, elf::section_header<Format> const, std::span>;
+ using base = vla_tag<elf_symbols_data, elf::section_header<Format> const, std::span>;
using base::base;
[[nodiscard]] auto name(elf::section_header<Format> const & section) const noexcept -> std::string_view
@@ -75,9 +75,9 @@ namespace multiboot2
};
/**
- * @copydoc multiboot2::impl::loader_name_data
+ * @copydoc multiboot2::loader_name_data
*/
- struct loader_name : impl::vla_tag<impl::loader_name_data, char, std::basic_string_view>
+ struct loader_name : vla_tag<loader_name_data, char, std::basic_string_view>
{
using vla_tag::vla_tag;
@@ -91,9 +91,9 @@ namespace multiboot2
};
/**
- * @copydoc multiboot2::impl::memory_map_data
+ * @copydoc multiboot2::memory_map_data
*/
- struct memory_map : impl::vla_tag<impl::memory_map_data, impl::memory_map_data::region, std::span>
+ struct memory_map : vla_tag<memory_map_data, memory_map_data::region, std::span>
{
using vla_tag::vla_tag;
@@ -108,10 +108,10 @@ namespace multiboot2
struct information_view
{
- using iterator = impl::information_iterator;
- using value_type = impl::information_iterator::value_type;
- using pointer = impl::information_iterator::pointer;
- using reference = impl::information_iterator::reference;
+ using iterator = iterator;
+ using value_type = iterator::value_type;
+ using pointer = iterator::pointer;
+ using reference = iterator::reference;
[[nodiscard]] auto size_bytes() const noexcept -> std::size_t
{
@@ -224,7 +224,7 @@ namespace multiboot2
uint32_t m_size{};
uint32_t : 32;
- impl::tag_header m_tags{};
+ tag_header m_tags{};
};
} // namespace multiboot2
diff --git a/libs/multiboot2/include/multiboot2/impl/data.hpp b/libs/multiboot2/include/multiboot2/information/data.hpp
index 733ce3a..38280f8 100644
--- a/libs/multiboot2/include/multiboot2/impl/data.hpp
+++ b/libs/multiboot2/include/multiboot2/information/data.hpp
@@ -1,17 +1,20 @@
-#ifndef MULTIBOOT2_IMPL_DATA_HPP
-#define MULTIBOOT2_IMPL_DATA_HPP
+#ifndef MULTIBOOT2_INFORMATION_DATA_HPP
+#define MULTIBOOT2_INFORMATION_DATA_HPP
-// IWYU pragma: private
+// IWYU pragma: private, include <multiboot2/information.hpp>
-#include "multiboot2/impl/ids.hpp"
+#include "multiboot2/constants/information_id.hpp"
+#include "multiboot2/constants/memory_type.hpp"
#include <cstdint>
-namespace multiboot2::impl
+namespace multiboot2
{
+ //! A simple base mixin providing all data classes with an ID accessor.
template<auto Id>
struct tag_data
{
+ //! The ID of this data class.
constexpr auto static inline id = Id;
};
@@ -51,7 +54,7 @@ namespace multiboot2::impl
std::uint32_t partition_number;
/**
- * @brief Number the sub-partion on the primary partition.
+ * @brief Number the sub-partition on the primary partition.
*/
std::uint32_t sub_partition_number;
};
@@ -130,6 +133,6 @@ namespace multiboot2::impl
std::uint32_t entry_version;
};
-} // namespace multiboot2::impl
+} // namespace multiboot2
#endif \ No newline at end of file
diff --git a/libs/multiboot2/include/multiboot2/impl/iterator.hpp b/libs/multiboot2/include/multiboot2/information/iterator.hpp
index 5651f22..c771933 100644
--- a/libs/multiboot2/include/multiboot2/impl/iterator.hpp
+++ b/libs/multiboot2/include/multiboot2/information/iterator.hpp
@@ -1,33 +1,33 @@
-#ifndef MULTIBOOT2_IMPL_INFORMATION_ITERATOR_HPP
-#define MULTIBOOT2_IMPL_INFORMATION_ITERATOR_HPP
+#ifndef MULTIBOOT2_INFORMATION_ITERATOR_HPP
+#define MULTIBOOT2_INFORMATION_ITERATOR_HPP
-// IWYU pragma: private
+// IWYU pragma: private, include <multiboot2/information.hpp>
-#include "multiboot2/impl/ids.hpp"
-#include "multiboot2/impl/tag.hpp"
+#include "multiboot2/constants/information_id.hpp"
+#include "tag.hpp"
#include <cstddef>
#include <iterator>
#include <optional>
-namespace multiboot2::impl
+namespace multiboot2
{
- struct information_iterator
+ struct iterator
{
using iterator_category = std::forward_iterator_tag;
- using value_type = impl::tag_header;
+ using value_type = tag_header;
using pointer = value_type const *;
using reference = value_type const &;
using difference_type = std::ptrdiff_t;
- constexpr information_iterator() = default;
+ constexpr iterator() = default;
- constexpr explicit information_iterator(impl::tag_header const * offset)
+ constexpr explicit iterator(tag_header const * offset)
: m_current(offset)
{}
- constexpr auto operator==(information_iterator const &) const noexcept -> bool = default;
+ constexpr auto operator==(iterator const &) const noexcept -> bool = default;
constexpr auto operator*() const noexcept -> reference
{
@@ -39,7 +39,7 @@ namespace multiboot2::impl
return m_current.value();
}
- constexpr auto operator++() noexcept -> information_iterator &
+ constexpr auto operator++() noexcept -> iterator &
{
if (m_current)
{
@@ -55,7 +55,7 @@ namespace multiboot2::impl
return *this;
}
- constexpr auto operator++(int) noexcept -> information_iterator
+ constexpr auto operator++(int) noexcept -> iterator
{
auto copy = *this;
++(*this);
@@ -63,11 +63,11 @@ namespace multiboot2::impl
}
private:
- std::optional<impl::tag_header const *> m_current{};
+ std::optional<tag_header const *> m_current{};
};
- static_assert(std::input_or_output_iterator<information_iterator>);
+ static_assert(std::input_or_output_iterator<iterator>);
-} // namespace multiboot2::impl
+} // namespace multiboot2
#endif \ No newline at end of file
diff --git a/libs/multiboot2/include/multiboot2/impl/tag.hpp b/libs/multiboot2/include/multiboot2/information/tag.hpp
index 708cda4..cd1fc0e 100644
--- a/libs/multiboot2/include/multiboot2/impl/tag.hpp
+++ b/libs/multiboot2/include/multiboot2/information/tag.hpp
@@ -1,16 +1,16 @@
-#ifndef MULTIBOOT2_IMPL_TAG_HPP
-#define MULTIBOOT2_IMPL_TAG_HPP
+#ifndef MULTIBOOT2_INFORMATION_TAG_HPP
+#define MULTIBOOT2_INFORMATION_TAG_HPP
-// IWYU pragma: private
+// IWYU pragma: private, include <multiboot2/information.hpp>
-#include "multiboot2/impl/ids.hpp"
+#include "multiboot2/constants/information_id.hpp"
#include <bit>
#include <cstddef>
#include <cstdint>
#include <string_view>
-namespace multiboot2::impl
+namespace multiboot2
{
/**
@@ -32,7 +32,7 @@ namespace multiboot2::impl
return (m_size + 7) & (~7);
}
- [[nodiscard]] auto information_id() const noexcept -> impl::information_id const &
+ [[nodiscard]] auto information_id() const noexcept -> information_id const &
{
return m_id;
}
@@ -48,7 +48,7 @@ namespace multiboot2::impl
}
private:
- impl::information_id m_id;
+ enum information_id m_id;
std::uint32_t m_size;
};
@@ -201,6 +201,6 @@ namespace multiboot2::impl
range_type m_vla;
};
-} // namespace multiboot2::impl
+} // namespace multiboot2
#endif \ No newline at end of file