#include "arch/memory.hpp" #include "kern/error.hpp" #include "arch/asm_pointer.hpp" #include "x86_64/memory/region_allocator.hpp" #include #include extern "C" teachos::arch::asm_pointer multiboot_information_pointer; namespace teachos::arch::memory { namespace { auto constinit is_initialized = std::atomic_flag{}; // auto create_memory_information() -> x86_64::memory::region_allocator::memory_information { // }; } // namespace auto init() -> void { if (is_initialized.test_and_set()) { teachos::panic("[x86_64] Memory management has already been initialized."); } auto memory_map = multiboot_information_pointer->maybe_memory_map(); if (!memory_map) { teachos::panic("[x86_64] No memory map available."); } // auto mem_info = x86_64::memory::region_allocator::memory_information{}; // auto allocator = x86_64::memory::region_allocator{mem_info}; // kernel::cpu::set_cr0_bit(kernel::cpu::cr0_flags::WRITE_PROTECT); // kernel::cpu::set_efer_bit(kernel::cpu::efer_flags::NXE); // paging::kernel_mapper kernel(allocator, memory_information); // kernel.remap_kernel(); // video::vga::text::write("Kernel remapping successful", video::vga::text::common_attributes::green_on_black); // video::vga::text::newline(); // remap_heap(heap::KERNEL_HEAP_START, heap::KERNEL_HEAP_SIZE); // video::vga::text::write("Heap remapping successful", video::vga::text::common_attributes::green_on_black); // video::vga::text::newline(); } } // namespace teachos::arch::memory