aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64/src
diff options
context:
space:
mode:
authorMatteo Gmür <matteo.gmuer1@ost.ch>2024-10-14 09:55:11 +0000
committerMatteo Gmür <matteo.gmuer1@ost.ch>2024-10-14 09:55:11 +0000
commite9dd8ea4343b943032f2af87fbae9f46fe1f9328 (patch)
tree80616f9633b34270ff76af04b4b0f184f1e5cc86 /arch/x86_64/src
parent7fc99d55ffff20b49dc4088efc95b68b3d33a45b (diff)
downloadteachos-e9dd8ea4343b943032f2af87fbae9f46fe1f9328.tar.xz
teachos-e9dd8ea4343b943032f2af87fbae9f46fe1f9328.zip
Move 8 byte alignment into seperate method
Diffstat (limited to 'arch/x86_64/src')
-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)
{