diff options
| author | Matteo Gmür <matteo.gmuer1@ost.ch> | 2024-10-14 09:55:11 +0000 |
|---|---|---|
| committer | Matteo Gmür <matteo.gmuer1@ost.ch> | 2024-10-14 09:55:11 +0000 |
| commit | e9dd8ea4343b943032f2af87fbae9f46fe1f9328 (patch) | |
| tree | 80616f9633b34270ff76af04b4b0f184f1e5cc86 | |
| parent | 7fc99d55ffff20b49dc4088efc95b68b3d33a45b (diff) | |
| download | teachos-e9dd8ea4343b943032f2af87fbae9f46fe1f9328.tar.xz teachos-e9dd8ea4343b943032f2af87fbae9f46fe1f9328.zip | |
Move 8 byte alignment into seperate method
| -rw-r--r-- | arch/x86_64/src/kernel/main.cpp | 10 |
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) { |
