mirror of
https://github.com/hermitcore/libhermit.git
synced 2025-03-09 00:00:03 +01:00
fix bug in the calculation of the free memory regions
This commit is contained in:
parent
83f185980a
commit
7b6e3dce13
1 changed files with 2 additions and 21 deletions
|
@ -295,9 +295,8 @@ int memory_init(void)
|
|||
atomic_int64_add(&total_pages, (limit-base) >> PAGE_BITS);
|
||||
atomic_int64_add(&total_available_pages, (limit-base) >> PAGE_BITS);
|
||||
|
||||
//initialize free list, at first we use onyl memory below kernel_start
|
||||
init_list.start = 0x100000;
|
||||
init_list.end = (size_t) &kernel_start;
|
||||
init_list.start = PAGE_2M_FLOOR(base + image_size);
|
||||
init_list.end = limit;
|
||||
}
|
||||
|
||||
// determine allocated memory, we use 2MB pages to map the kernel
|
||||
|
@ -360,26 +359,8 @@ int memory_init(void)
|
|||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
free_list_t* last = &init_list;
|
||||
size_t start_addr = PAGE_2M_FLOOR((size_t) &kernel_start + image_size);
|
||||
size_t end_addr = limit;
|
||||
|
||||
last->next = kmalloc(sizeof(free_list_t));
|
||||
if (BUILTIN_EXPECT(!last->next, 0))
|
||||
goto oom;
|
||||
|
||||
// add memory above image size
|
||||
LOG_INFO("Add region 0x%zx - 0x%zx\n", start_addr, end_addr);
|
||||
|
||||
last->next->prev = last;
|
||||
last = last->next;
|
||||
last->next = NULL;
|
||||
last->start = start_addr;
|
||||
last->end = end_addr;
|
||||
}
|
||||
|
||||
|
||||
return ret;
|
||||
|
||||
oom:
|
||||
|
|
Loading…
Add table
Reference in a new issue