aboutsummaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
Diffstat (limited to 'arch')
-rw-r--r--arch/x86_64/src/kernel/main.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/arch/x86_64/src/kernel/main.cpp b/arch/x86_64/src/kernel/main.cpp
index 1c6aa55..106ca2a 100644
--- a/arch/x86_64/src/kernel/main.cpp
+++ b/arch/x86_64/src/kernel/main.cpp
@@ -94,6 +94,13 @@ namespace teachos::arch::kernel
assert(dynamic_section_count <= 1U);
}
+ template<typename T>
+ requires std::is_pointer<T>::value
+ auto align_to_8_byte_boundary(T ptr, uint32_t size) -> T
+ {
+ return reinterpret_cast<T>(reinterpret_cast<uint8_t *>(ptr) + ((size + 7) & ~7));
+ }
+
auto main() -> void
{
using namespace video::vga;
@@ -121,8 +128,7 @@ namespace teachos::arch::kernel
* The increment part aligns the size to an 8-byte address.
*/
for (auto tag = multiboot_tag; tag->type != arch::memory::multi_boot_tag_type::END;
- tag = reinterpret_cast<arch::memory::multi_boot_tag *>((reinterpret_cast<uint8_t *>(tag)) +
- ((tag->size + 7) & ~7)))
+ tag = align_to_8_byte_boundary(tag, tag->size))
{
switch (tag->type)
{