diff --git a/kernel/src/arch/x86_64/MMU.cpp b/kernel/src/arch/x86_64/MMU.cpp index 474e648d..613fcacb 100644 --- a/kernel/src/arch/x86_64/MMU.cpp +++ b/kernel/src/arch/x86_64/MMU.cpp @@ -196,7 +196,7 @@ namespace MMU auto& l4 = l4_entry(virt); if (!l4.present) { - u64 addr = TRY(MemoryManager::alloc_physical_page()); + u64 addr = TRY(MemoryManager::alloc_frame()); l4.present = true; l4.set_address(addr); memset(l3_table(virt), 0, PAGE_SIZE); @@ -208,7 +208,7 @@ namespace MMU auto& l3 = l3_entry(virt); if (!l3.present) { - u64 addr = TRY(MemoryManager::alloc_physical_page()); + u64 addr = TRY(MemoryManager::alloc_frame()); l3.present = true; l3.set_address(addr); memset(l2_table(virt), 0, PAGE_SIZE); @@ -222,7 +222,7 @@ namespace MMU auto& l2 = l2_entry(virt); if (!l2.present) { - u64 addr = TRY(MemoryManager::alloc_physical_page()); + u64 addr = TRY(MemoryManager::alloc_frame()); l2.present = true; l2.set_address(addr); memset(l1_table(virt), 0, PAGE_SIZE); diff --git a/kernel/src/main.cpp b/kernel/src/main.cpp index 4442ceef..6229e480 100644 --- a/kernel/src/main.cpp +++ b/kernel/src/main.cpp @@ -29,7 +29,7 @@ extern "C" [[noreturn]] void _start() Serial::printf("Mapping address 0x%lx\n", address); - u64 physical = MemoryManager::alloc_physical_page().release_value(); + u64 physical = MemoryManager::alloc_frame().release_value(); Serial::printf("Allocated physical frame %#lx\n", physical); diff --git a/kernel/src/memory/MemoryManager.cpp b/kernel/src/memory/MemoryManager.cpp index fd2c4ac5..57222223 100644 --- a/kernel/src/memory/MemoryManager.cpp +++ b/kernel/src/memory/MemoryManager.cpp @@ -104,7 +104,7 @@ namespace MemoryManager ptr++; } - lock_pages((u64)page_bitmap_addr, page_bitmap_size / ARCH_PAGE_SIZE + 1); + lock_frames((u64)page_bitmap_addr, page_bitmap_size / ARCH_PAGE_SIZE + 1); } void init() @@ -113,21 +113,21 @@ namespace MemoryManager MMU::setup_initial_page_directory(); } - void lock_page(u64 page) + void lock_frame(u64 frame) { - uint64_t index = ((uint64_t)page) / ARCH_PAGE_SIZE; + const u64 index = ((u64)frame) / ARCH_PAGE_SIZE; if (page_bitmap_read(index)) return; page_bitmap_set(index, true); used_mem += ARCH_PAGE_SIZE; free_mem -= ARCH_PAGE_SIZE; } - void lock_pages(u64 pages, u64 count) + void lock_frames(u64 frames, u64 count) { - for (u64 index = 0; index < count; index++) { lock_page(pages + (index * ARCH_PAGE_SIZE)); } + for (u64 index = 0; index < count; index++) { lock_frame(frames + (index * ARCH_PAGE_SIZE)); } } - Result alloc_physical_page() + Result alloc_frame() { for (u64 index = start_index; index < (page_bitmap_size * 8); index++) { @@ -142,9 +142,9 @@ namespace MemoryManager return err; // FIXME: ENOMEM. } - Result free_physical_page(u64 page) + Result free_frame(u64 frame) { - u64 index = page / ARCH_PAGE_SIZE; + const u64 index = frame / ARCH_PAGE_SIZE; if (index > (page_bitmap_size * 8)) return err; if (!page_bitmap_read(index)) return err; page_bitmap_set(index, false); diff --git a/kernel/src/memory/MemoryManager.h b/kernel/src/memory/MemoryManager.h index 6250b863..21ab26f8 100644 --- a/kernel/src/memory/MemoryManager.h +++ b/kernel/src/memory/MemoryManager.h @@ -8,11 +8,11 @@ namespace MemoryManager Result protect_kernel_sections(); - Result alloc_physical_page(); - Result free_physical_page(u64 page); + Result alloc_frame(); + Result free_frame(u64 frame); - void lock_page(u64 page); - void lock_pages(u64 pages, u64 count); + void lock_frame(u64 frame); + void lock_frames(u64 frames, u64 count); Result remap(u64 address, usize count, int flags); Result remap_unaligned(u64 address, usize count, int flags);