Rename physical "pages" to "frames"

AFAIK, this is the proper naming scheme. "Pages" are virtual, and "frames" physical.
This commit is contained in:
apio 2022-11-19 22:27:08 +01:00
parent 847f2b4f4c
commit d96cb73995
4 changed files with 16 additions and 16 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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<u64> alloc_physical_page()
Result<u64> alloc_frame()
{
for (u64 index = start_index; index < (page_bitmap_size * 8); index++)
{
@ -142,9 +142,9 @@ namespace MemoryManager
return err; // FIXME: ENOMEM.
}
Result<void> free_physical_page(u64 page)
Result<void> 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);

View File

@ -8,11 +8,11 @@ namespace MemoryManager
Result<void> protect_kernel_sections();
Result<u64> alloc_physical_page();
Result<void> free_physical_page(u64 page);
Result<u64> alloc_frame();
Result<void> 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<void> remap(u64 address, usize count, int flags);
Result<void> remap_unaligned(u64 address, usize count, int flags);