diff options
| author | Lukas Oesch <lukasoesch20@gmail.com> | 2026-02-26 11:21:18 +0100 |
|---|---|---|
| committer | Lukas Oesch <lukasoesch20@gmail.com> | 2026-03-17 16:42:04 +0100 |
| commit | ea8172296fa5b56137f97c01650b8d392bdb897f (patch) | |
| tree | 6a88f043034c59abdc1b1f9dd7a2b8977de64692 /arch/x86_64/kapi | |
| parent | 9d568ef3e785ce3d6028fa60bd59eaac2e85900a (diff) | |
| download | teachos-ea8172296fa5b56137f97c01650b8d392bdb897f.tar.xz teachos-ea8172296fa5b56137f97c01650b8d392bdb897f.zip | |
implemented remapping of bootloader modules
Diffstat (limited to 'arch/x86_64/kapi')
| -rw-r--r-- | arch/x86_64/kapi/memory.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/arch/x86_64/kapi/memory.cpp b/arch/x86_64/kapi/memory.cpp index a9e1216..3a2d66b 100644 --- a/arch/x86_64/kapi/memory.cpp +++ b/arch/x86_64/kapi/memory.cpp @@ -118,6 +118,27 @@ namespace kapi::memory mapper.map(page, frame, page_mapper::flags::supervisor_only); } } + + [[maybe_unused]] auto remap_bootloader_modules(page_mapper & mapper) -> void + { + auto modules = boot::bootstrap_information.mbi->modules(); + + for (auto module : modules) + { + auto module_physical_start = physical_address{module.start_address}; + auto module_virtual_start = + linear_address{module.start_address + std::bit_cast<std::uintptr_t>(&arch::boot::TEACHOS_VMA)}; + auto module_size = module.end_address - module.start_address; + auto module_block_count = (module_size + PLATFORM_FRAME_SIZE - 1) / PLATFORM_FRAME_SIZE; + + for (auto i = 0uz; i < module_block_count; ++i) + { + auto page = page::containing(module_virtual_start) + i; + auto frame = frame::containing(module_physical_start) + i; + mapper.map(page, frame, page_mapper::flags::empty); // TODO BA-FS26 make writable? + } + } + } [[maybe_unused]] auto handoff_to_kernel_pmm(frame_allocator & new_allocator) -> void { @@ -196,6 +217,7 @@ namespace kapi::memory remap_kernel(*higher_half_mapper); remap_vga_text_mode_buffer(*higher_half_mapper); remap_multiboot_information(*higher_half_mapper); + remap_bootloader_modules(*recursive_page_mapper); auto current_cr3 = arch::cpu::cr3::read(); auto old_pml4 = static_cast<arch::memory::page_table *>(current_cr3.address()); |
