aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64/include
diff options
context:
space:
mode:
authorMatteo Gmür <matteo.gmuer1@ost.ch>2024-11-12 09:26:12 +0000
committerMatteo Gmür <matteo.gmuer1@ost.ch>2024-11-12 09:26:12 +0000
commit13887617b17d9387e218ce702087b6a7140af9bd (patch)
tree8b0f4b32037dd18635c4e2494e4145ce4fe58734 /arch/x86_64/include
parentf45fdae9913a9d8e003cf681621e71516b2054b5 (diff)
downloadteachos-13887617b17d9387e218ce702087b6a7140af9bd.tar.xz
teachos-13887617b17d9387e218ce702087b6a7140af9bd.zip
Remap kernel inplace.
Diffstat (limited to 'arch/x86_64/include')
-rw-r--r--arch/x86_64/include/arch/memory/paging/kernel_mapper.hpp23
1 files changed, 11 insertions, 12 deletions
diff --git a/arch/x86_64/include/arch/memory/paging/kernel_mapper.hpp b/arch/x86_64/include/arch/memory/paging/kernel_mapper.hpp
index f01bd37..f673da4 100644
--- a/arch/x86_64/include/arch/memory/paging/kernel_mapper.hpp
+++ b/arch/x86_64/include/arch/memory/paging/kernel_mapper.hpp
@@ -40,17 +40,17 @@ namespace teachos::arch::memory::paging
*/
auto remap_kernel() -> active_page_table &
{
- temporary_page temporary_page{virtual_page{0xCAFEBABE}, allocator};
+ /*temporary_page temporary_page{virtual_page{0xCAFEBABE}, allocator};*/
auto & active_table = active_page_table::create_or_get();
- auto const frame = allocator.allocate_frame();
+ /*auto const frame = allocator.allocate_frame();
exception_handling::assert(frame.has_value(),
"[Kernel Mapper] Frame could not be allocated and therefore kernel not mapped");
- inactive_page_table new_table{frame.value(), active_table, temporary_page};
- remap_elf_kernel_sections(new_table, temporary_page, active_table);
- auto const old_table = switch_active_page_table(new_table);
+ inactive_page_table new_table{frame.value(), active_table, temporary_page};*/
+ remap_elf_kernel_sections(active_table);
+ /*auto const old_table = switch_active_page_table(new_table);
auto const old_level_4_page =
virtual_page::containing_address(old_table.page_table_level_4_frame.start_address());
- active_table.unmap_page(allocator, old_level_4_page);
+ active_table.unmap_page(allocator, old_level_4_page);*/
return active_table;
}
@@ -72,21 +72,20 @@ namespace teachos::arch::memory::paging
* @param active_table Active level 4 page table that has its recursive mapping overwritten temporarily and then
* restored once the process is finished.
*/
- auto remap_elf_kernel_sections(inactive_page_table inactive_table, temporary_page & temporary_page,
- active_page_table & active_table) -> void
+ auto remap_elf_kernel_sections(active_page_table & active_table) -> void
{
- auto const backup =
+ /*auto const backup =
allocator::physical_frame::containing_address(cpu::read_control_register(cpu::control_register::CR3));
// TODO: This creates invalid page table that points to nothing, is it the frame (current level 4 page table)
auto page_table_level4 = temporary_page.map_table_frame(backup, active_table);
- active_table[511].set_entry(inactive_table.page_table_level_4_frame, entry::PRESENT | entry::WRITABLE);
+ active_table[511].set_entry(inactive_table.page_table_level_4_frame, entry::PRESENT | entry::WRITABLE);*/
cpu::tlb_flush_all();
map_elf_kernel_sections(active_table);
- page_table_level4[511].set_entry(backup, entry::PRESENT | entry::WRITABLE);
+ /*page_table_level4[511].set_entry(backup, entry::PRESENT | entry::WRITABLE);*/
cpu::tlb_flush_all();
- temporary_page.unmap_page(active_table);
+ /*temporary_page.unmap_page(active_table);*/
}
/**