Fix braces + init_paging args
This commit is contained in:
@@ -38,12 +38,10 @@ static void pmm_find_biggest_usable_region(struct limine_memmap_response* memmap
|
||||
uint64_t offset = hhdm->offset;
|
||||
|
||||
DEBUG("Usable Memory:");
|
||||
for (size_t i=0; i<memmap->entry_count; i++)
|
||||
{
|
||||
for (size_t i=0; i<memmap->entry_count; i++) {
|
||||
struct limine_memmap_entry* entry = memmap->entries[i];
|
||||
|
||||
if (entry->type == LIMINE_MEMMAP_USABLE)
|
||||
{
|
||||
if (entry->type == LIMINE_MEMMAP_USABLE) {
|
||||
DEBUG("0x%p-0x%p mapped at 0x%p-0x%p", entry->base, entry->base+entry->length,
|
||||
entry->base+offset, entry->base+entry->length+offset);
|
||||
if (entry->length > length_max)
|
||||
@@ -66,8 +64,7 @@ static uintptr_t g_freelist = 0;
|
||||
|
||||
uintptr_t pmm_alloc()
|
||||
{
|
||||
if (!g_freelist)
|
||||
{
|
||||
if (!g_freelist) {
|
||||
panic(NULL, "PMM is out of memory!");
|
||||
}
|
||||
uintptr_t addr = g_freelist;
|
||||
@@ -89,19 +86,17 @@ static void pmm_init_freelist()
|
||||
uint64_t end = ALIGN_DOWN(biggest_entry->base + biggest_entry->length, PAGE_SIZE);
|
||||
|
||||
uint64_t page_count=0;
|
||||
for (uint64_t addr = base; addr < end; addr += PAGE_SIZE)
|
||||
{
|
||||
for (uint64_t addr = base; addr < end; addr += PAGE_SIZE) {
|
||||
pmm_free(addr);
|
||||
//DEBUG("page %u lives at phys 0x%p (virt 0x%p)", page_count, addr, PHYS_TO_VIRT(addr));
|
||||
page_count++;
|
||||
}
|
||||
DEBUG("%u frames in freelist, available for use (%u bytes)", page_count, page_count*PAGE_SIZE);
|
||||
}
|
||||
|
||||
void pmm_init(struct limine_memmap_response* memmap, struct limine_hhdm_response* hhdm)
|
||||
void pmm_init(struct boot_context boot_ctx)
|
||||
{
|
||||
hhdm_off = hhdm->offset;
|
||||
pmm_find_biggest_usable_region(memmap, hhdm);
|
||||
hhdm_off = boot_ctx.hhdm->offset;
|
||||
pmm_find_biggest_usable_region(boot_ctx.mmap, boot_ctx.hhdm);
|
||||
|
||||
// Now we have biggest USABLE region,
|
||||
// so to populate the free list we just iterate through it
|
||||
|
||||
Reference in New Issue
Block a user