diff options
Diffstat (limited to 'arch/x86_64/src/kernel')
| -rw-r--r-- | arch/x86_64/src/kernel/main.cpp | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/arch/x86_64/src/kernel/main.cpp b/arch/x86_64/src/kernel/main.cpp index 8e5aa05..3e25d2d 100644 --- a/arch/x86_64/src/kernel/main.cpp +++ b/arch/x86_64/src/kernel/main.cpp @@ -10,6 +10,7 @@ namespace teachos::arch::kernel { + auto main() -> void { video::vga::text::clear(); @@ -19,6 +20,25 @@ namespace teachos::arch::kernel auto 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 page = memory::paging::virtual_page::containing_address(address); + auto frame = allocator.allocate_frame(); + exception_handling::assert(frame.has_value(), "[Main] Out of memory exception"); + auto optional_frame = memory::paging::translate_page(page); + memory::paging::map_page_to_frame(allocator, page, frame.value(), 0U); + 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); + + memory::paging::unmap_page(allocator, page); + video::vga::text::write("Unapped physical page: ", 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 @@ -26,12 +46,9 @@ namespace teachos::arch::kernel last_allocated = allocated; allocated = allocator.allocate_frame(); } while (allocated); - video::vga::text::write("Allocated Frames", video::vga::text::common_attributes::green_on_black); + 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::map_page_to_frame(allocator, memory::paging::virtual_page{0U}, last_allocated.value(), 0U); - memory::paging::map_next_free_page_to_frame(allocator, memory::paging::virtual_page{0U}, 0U); - memory::paging::identity_map(allocator, last_allocated.value(), 0U); - memory::paging::unmap_page(allocator, memory::paging::virtual_page{0U}); } } // namespace teachos::arch::kernel |
