Rename physical "pages" to "frames"
AFAIK, this is the proper naming scheme. "Pages" are virtual, and "frames" physical.
This commit is contained in:
parent
847f2b4f4c
commit
d96cb73995
@ -196,7 +196,7 @@ namespace MMU
|
|||||||
auto& l4 = l4_entry(virt);
|
auto& l4 = l4_entry(virt);
|
||||||
if (!l4.present)
|
if (!l4.present)
|
||||||
{
|
{
|
||||||
u64 addr = TRY(MemoryManager::alloc_physical_page());
|
u64 addr = TRY(MemoryManager::alloc_frame());
|
||||||
l4.present = true;
|
l4.present = true;
|
||||||
l4.set_address(addr);
|
l4.set_address(addr);
|
||||||
memset(l3_table(virt), 0, PAGE_SIZE);
|
memset(l3_table(virt), 0, PAGE_SIZE);
|
||||||
@ -208,7 +208,7 @@ namespace MMU
|
|||||||
auto& l3 = l3_entry(virt);
|
auto& l3 = l3_entry(virt);
|
||||||
if (!l3.present)
|
if (!l3.present)
|
||||||
{
|
{
|
||||||
u64 addr = TRY(MemoryManager::alloc_physical_page());
|
u64 addr = TRY(MemoryManager::alloc_frame());
|
||||||
l3.present = true;
|
l3.present = true;
|
||||||
l3.set_address(addr);
|
l3.set_address(addr);
|
||||||
memset(l2_table(virt), 0, PAGE_SIZE);
|
memset(l2_table(virt), 0, PAGE_SIZE);
|
||||||
@ -222,7 +222,7 @@ namespace MMU
|
|||||||
auto& l2 = l2_entry(virt);
|
auto& l2 = l2_entry(virt);
|
||||||
if (!l2.present)
|
if (!l2.present)
|
||||||
{
|
{
|
||||||
u64 addr = TRY(MemoryManager::alloc_physical_page());
|
u64 addr = TRY(MemoryManager::alloc_frame());
|
||||||
l2.present = true;
|
l2.present = true;
|
||||||
l2.set_address(addr);
|
l2.set_address(addr);
|
||||||
memset(l1_table(virt), 0, PAGE_SIZE);
|
memset(l1_table(virt), 0, PAGE_SIZE);
|
||||||
|
@ -29,7 +29,7 @@ extern "C" [[noreturn]] void _start()
|
|||||||
|
|
||||||
Serial::printf("Mapping address 0x%lx\n", address);
|
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);
|
Serial::printf("Allocated physical frame %#lx\n", physical);
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ namespace MemoryManager
|
|||||||
ptr++;
|
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()
|
void init()
|
||||||
@ -113,21 +113,21 @@ namespace MemoryManager
|
|||||||
MMU::setup_initial_page_directory();
|
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;
|
if (page_bitmap_read(index)) return;
|
||||||
page_bitmap_set(index, true);
|
page_bitmap_set(index, true);
|
||||||
used_mem += ARCH_PAGE_SIZE;
|
used_mem += ARCH_PAGE_SIZE;
|
||||||
free_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++)
|
for (u64 index = start_index; index < (page_bitmap_size * 8); index++)
|
||||||
{
|
{
|
||||||
@ -142,9 +142,9 @@ namespace MemoryManager
|
|||||||
return err; // FIXME: ENOMEM.
|
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 (index > (page_bitmap_size * 8)) return err;
|
||||||
if (!page_bitmap_read(index)) return err;
|
if (!page_bitmap_read(index)) return err;
|
||||||
page_bitmap_set(index, false);
|
page_bitmap_set(index, false);
|
||||||
|
@ -8,11 +8,11 @@ namespace MemoryManager
|
|||||||
|
|
||||||
Result<void> protect_kernel_sections();
|
Result<void> protect_kernel_sections();
|
||||||
|
|
||||||
Result<u64> alloc_physical_page();
|
Result<u64> alloc_frame();
|
||||||
Result<void> free_physical_page(u64 page);
|
Result<void> free_frame(u64 frame);
|
||||||
|
|
||||||
void lock_page(u64 page);
|
void lock_frame(u64 frame);
|
||||||
void lock_pages(u64 pages, u64 count);
|
void lock_frames(u64 frames, u64 count);
|
||||||
|
|
||||||
Result<void> remap(u64 address, usize count, int flags);
|
Result<void> remap(u64 address, usize count, int flags);
|
||||||
Result<void> remap_unaligned(u64 address, usize count, int flags);
|
Result<void> remap_unaligned(u64 address, usize count, int flags);
|
||||||
|
Loading…
Reference in New Issue
Block a user