aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64/src/kernel/main.cpp
diff options
context:
space:
mode:
authorMatteo Gmür <matteo.gmuer1@ost.ch>2024-11-02 14:08:55 +0000
committerMatteo Gmür <matteo.gmuer1@ost.ch>2024-11-02 14:08:55 +0000
commit4d76f412b071a05f0aae1d1307f2b58cb2778569 (patch)
tree2b5dc70e9b85ae6b435a2c281615cee0e85fd88b /arch/x86_64/src/kernel/main.cpp
parent5ade8e0d5f190f2e439f81232b38b90c49c0cd1e (diff)
downloadteachos-4d76f412b071a05f0aae1d1307f2b58cb2778569.tar.xz
teachos-4d76f412b071a05f0aae1d1307f2b58cb2778569.zip
Attempt to fix crashes
Diffstat (limited to 'arch/x86_64/src/kernel/main.cpp')
-rw-r--r--arch/x86_64/src/kernel/main.cpp76
1 files changed, 37 insertions, 39 deletions
diff --git a/arch/x86_64/src/kernel/main.cpp b/arch/x86_64/src/kernel/main.cpp
index 59e453a..5cfd9b3 100644
--- a/arch/x86_64/src/kernel/main.cpp
+++ b/arch/x86_64/src/kernel/main.cpp
@@ -20,44 +20,42 @@ namespace teachos::arch::kernel
auto const memory_information = memory::multiboot::read_multiboot2();
memory::allocator::area_frame_allocator allocator(memory_information);
- size_t address = 42 * memory::paging::PAGE_TABLE_ENTRY_COUNT * memory::paging::PAGE_TABLE_ENTRY_COUNT *
- memory::allocator::PAGE_FRAME_SIZE; // 42th P3 entry
- auto const page = memory::paging::virtual_page::containing_address(address);
-
- auto & active_table = memory::paging::active_page_table::create_or_get();
- memory::paging::temporary_page temp_page{page, allocator};
- temp_page.zero_entries(active_table);
-
- memory::paging::kernel_mapper kernel(allocator, memory_information);
- kernel.remap_kernel();
-
- // memory::paging::map_next_free_page_to_frame(allocator, page, 0U);
- // auto optional_frame = memory::paging::translate_page(page);
- // video::vga::text::newline();
- // video::vga::text::write("Mapped physical frame: ", video::vga::text::common_attributes::green_on_black);
- // video::vga::text::write_number(optional_frame.value().frame_number,
- // video::vga::text::common_attributes::green_on_black);
- // video::vga::text::write(" to virtual page: ", video::vga::text::common_attributes::green_on_black);
- // video::vga::text::write_number(page.page_number, video::vga::text::common_attributes::green_on_black);
-
- // memory::paging::unmap_page(allocator, page);
- // video::vga::text::newline();
- // video::vga::text::write("Unapped virtual page from physical frame: ",
- // video::vga::text::common_attributes::green_on_black);
- // optional_frame = memory::paging::translate_page(page);
- // exception_handling::assert(!optional_frame.has_value(), "[Main] Ummapping failed");
- // video::vga::text::write_number(page.page_number, video::vga::text::common_attributes::green_on_black);
-
- auto last_allocated = allocator.allocate_frame();
- auto allocated = last_allocated;
- do
- {
- last_allocated = allocated;
- allocated = allocator.allocate_frame();
- } while (allocated);
- video::vga::text::newline();
- video::vga::text::write("Allocated Frames: ", video::vga::text::common_attributes::green_on_black);
- video::vga::text::write_number(last_allocated.value().frame_number,
- video::vga::text::common_attributes::green_on_black);
+ memory::paging::kernel_mapper kernel(memory_information);
+ kernel.remap_kernel(allocator);
+ video::vga::text::write("Kernel remapping successfull", video::vga::text::common_attributes::green_on_black);
+
+ /*
+ size_t address = 42 * memory::paging::PAGE_TABLE_ENTRY_COUNT * memory::paging::PAGE_TABLE_ENTRY_COUNT *
+ memory::allocator::PAGE_FRAME_SIZE; // 42th P3 entry
+ auto const page = memory::paging::virtual_page::containing_address(address);
+ memory::paging::map_next_free_page_to_frame(allocator, page, 0U);
+ auto optional_frame = memory::paging::translate_page(page);
+ video::vga::text::newline();
+ video::vga::text::write("Mapped physical frame: ", video::vga::text::common_attributes::green_on_black);
+ video::vga::text::write_number(optional_frame.value().frame_number,
+ video::vga::text::common_attributes::green_on_black);
+ video::vga::text::write(" to virtual page: ", video::vga::text::common_attributes::green_on_black);
+ video::vga::text::write_number(page.page_number, video::vga::text::common_attributes::green_on_black);
+
+ memory::paging::unmap_page(allocator, page);
+ video::vga::text::newline();
+ video::vga::text::write("Unapped virtual page from physical frame: ",
+ video::vga::text::common_attributes::green_on_black);
+ optional_frame = memory::paging::translate_page(page);
+ exception_handling::assert(!optional_frame.has_value(), "[Main] Ummapping failed");
+ video::vga::text::write_number(page.page_number, video::vga::text::common_attributes::green_on_black);
+
+ auto last_allocated = allocator.allocate_frame();
+ auto allocated = last_allocated;
+ do
+ {
+ last_allocated = allocated;
+ allocated = allocator.allocate_frame();
+ } while (allocated);
+ video::vga::text::newline();
+ video::vga::text::write("Allocated Frames: ", video::vga::text::common_attributes::green_on_black);
+ video::vga::text::write_number(last_allocated.value().frame_number,
+ video::vga::text::common_attributes::green_on_black);
+ */
}
} // namespace teachos::arch::kernel