aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@ost.ch>2025-12-15 11:34:30 +0100
committerFelix Morgner <felix.morgner@ost.ch>2025-12-15 11:34:30 +0100
commit40804526a58ddf2cc0df0750550c8dcfa7b7c57c (patch)
treea0dff1f6a51c8819ccc6b81a3648e869c2e80bf8
parent2846867da7e88c3a665d0a8bed6ccec60e6476a1 (diff)
downloadteachos-40804526a58ddf2cc0df0750550c8dcfa7b7c57c.tar.xz
teachos-40804526a58ddf2cc0df0750550c8dcfa7b7c57c.zip
x86_64/boot: use high-mem address of MBI
-rw-r--r--arch/x86_64/include/x86_64/boot/boot.hpp3
-rw-r--r--arch/x86_64/src/boot/entry64.s1
-rw-r--r--arch/x86_64/src/kapi/memory.cpp6
-rw-r--r--arch/x86_64/src/memory/recursive_page_mapper.cpp3
-rw-r--r--kapi/include/kapi/boot.hpp2
5 files changed, 8 insertions, 7 deletions
diff --git a/arch/x86_64/include/x86_64/boot/boot.hpp b/arch/x86_64/include/x86_64/boot/boot.hpp
index 6dcd2de..2c44659 100644
--- a/arch/x86_64/include/x86_64/boot/boot.hpp
+++ b/arch/x86_64/include/x86_64/boot/boot.hpp
@@ -56,7 +56,10 @@ namespace teachos::boot
struct information
{
+ //! A pointer to the loader provided Multiboot2 Information structure.
multiboot2::information_view const * mbi;
+
+ //! The index of the next character to be written in the VGA text buffer after handoff.
std::size_t vga_buffer_index;
};
diff --git a/arch/x86_64/src/boot/entry64.s b/arch/x86_64/src/boot/entry64.s
index 2932354..657b0a8 100644
--- a/arch/x86_64/src/boot/entry64.s
+++ b/arch/x86_64/src/boot/entry64.s
@@ -33,6 +33,7 @@ _entry64:
mov %rsp, %rbp
mov multiboot_information_pointer, %rax
+ or $TEACHOS_VMA, %rax
mov vga_buffer_pointer, %rdx
sub $0xb8000, %rdx
mov %rax, (bootstrap_information)
diff --git a/arch/x86_64/src/kapi/memory.cpp b/arch/x86_64/src/kapi/memory.cpp
index ae0401e..748893a 100644
--- a/arch/x86_64/src/kapi/memory.cpp
+++ b/arch/x86_64/src/kapi/memory.cpp
@@ -138,8 +138,8 @@ namespace teachos::memory
{
auto mbi_base = std::bit_cast<std::uintptr_t>(boot::bootstrap_information.mbi);
auto mbi_size = boot::bootstrap_information.mbi->size_bytes();
- auto mbi_physical_start = physical_address{mbi_base};
- auto mbi_virtual_start = linear_address{mbi_base + std::bit_cast<std::uintptr_t>(&boot::x86_64::TEACHOS_VMA)};
+ auto mbi_physical_start = physical_address{mbi_base & ~std::bit_cast<std::uintptr_t>(&boot::x86_64::TEACHOS_VMA)};
+ auto mbi_virtual_start = linear_address{mbi_base};
auto mbi_block_count = (mbi_size + PLATFORM_FRAME_SIZE - 1) / PLATFORM_FRAME_SIZE;
for (auto i = 0uz; i < mbi_block_count; ++i)
@@ -148,8 +148,6 @@ namespace teachos::memory
auto frame = frame::containing(mbi_physical_start) + 1;
mapper.map(page, frame, page_mapper::flags::empty);
}
-
- boot::bootstrap_information.mbi = std::bit_cast<multiboot2::information_view const *>(mbi_virtual_start.raw());
}
} // namespace
diff --git a/arch/x86_64/src/memory/recursive_page_mapper.cpp b/arch/x86_64/src/memory/recursive_page_mapper.cpp
index 798233a..ef234ad 100644
--- a/arch/x86_64/src/memory/recursive_page_mapper.cpp
+++ b/arch/x86_64/src/memory/recursive_page_mapper.cpp
@@ -14,8 +14,7 @@ namespace teachos::memory::x86_64
//! On any level above PML1, the entries need to not be no_execute, because the image is densely packed. The entries
//! also need to be writable, since the mapping is being performed through the recursive page map hierarchy. When
//! setting the final entry in the PML1, the actually desired flags are set as is, with the present bit
- //! added, thus
- //! still enforcing non-writability and non-execution of the affected page.
+ //! added, thus still enforcing non-writability and non-execution of the affected page.
template<std::size_t Level>
requires(Level > 1uz && Level <= PLATFORM_PAGING_LEVELS)
auto do_map(recursive_page_table<Level> * pml, page page, frame_allocator & allocator, page_mapper::flags flags)
diff --git a/kapi/include/kapi/boot.hpp b/kapi/include/kapi/boot.hpp
index dd99198..9c344cf 100644
--- a/kapi/include/kapi/boot.hpp
+++ b/kapi/include/kapi/boot.hpp
@@ -11,7 +11,7 @@ namespace teachos::boot
//! @qualifier platform-defined
//! An object passed from the early pre-main stage to the kernel executable.
- extern "C" information bootstrap_information;
+ extern "C" information const bootstrap_information;
} // namespace teachos::boot
#endif