mirror of
https://github.com/hermitcore/libhermit.git
synced 2025-03-09 00:00:03 +01:00
revise the init routine of the memory management
=> fix bug in the calculation of free / used page frames
This commit is contained in:
parent
1b11ecb5b1
commit
f2f9a3cbf0
3 changed files with 17 additions and 11 deletions
|
@ -41,7 +41,7 @@ extern "C" {
|
|||
#define CACHE_LINE 64
|
||||
#define KERNEL_STACK_SIZE (8<<10) /* 8 KiB */
|
||||
#define DEFAULT_STACK_SIZE (16*1024) /* 16 KiB */
|
||||
#define BITMAP_SIZE (16<<5) /* for 16 MiB of RAM */
|
||||
#define BITMAP_SIZE (128<<5) /* for 128 MiB of RAM */
|
||||
#define KMSG_SIZE (8*1024)
|
||||
#define INT_SYSCALL 0x80
|
||||
#define MAILBOX_SIZE 32
|
||||
|
|
|
@ -35,8 +35,8 @@
|
|||
#include <asm/multiboot.h>
|
||||
#include <asm/page.h>
|
||||
|
||||
extern size_t base;
|
||||
extern size_t limit;
|
||||
extern uint32_t base;
|
||||
extern uint32_t limit;
|
||||
|
||||
/*
|
||||
* Note that linker symbols are not variables, they have no memory allocated for
|
||||
|
@ -283,22 +283,28 @@ int memory_init(void)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// mark kernel as used, we use 2MB pages to map the kernel
|
||||
for(addr=(size_t) &kernel_start; addr<(((size_t) &kernel_end + 0x200000ULL) & 0xFFFFFFFFFFE00000ULL); addr+=PAGE_SIZE) {
|
||||
page_set_mark(addr >> PAGE_BITS);
|
||||
atomic_int32_inc(&total_allocated_pages);
|
||||
atomic_int32_dec(&total_available_pages);
|
||||
}
|
||||
|
||||
} else {
|
||||
//kprintf("base 0x%lx, limit 0x%lx\n", base, limit);
|
||||
|
||||
// mark available memory as free
|
||||
for(addr=base; addr<limit; addr+=PAGE_SIZE) {
|
||||
for(addr=base+0x200000ULL; (addr<limit) && (addr < (BITMAP_SIZE*8*PAGE_SIZE)); addr+=PAGE_SIZE) {
|
||||
if (page_marked(addr >> PAGE_BITS)) {
|
||||
page_clear_mark(addr >> PAGE_BITS);
|
||||
atomic_int32_inc(&total_pages);
|
||||
atomic_int32_inc(&total_available_pages);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// mark kernel as used, we use 2MB pages to map the kernel
|
||||
for(addr=(size_t) &kernel_start; addr<(((size_t) &kernel_end + 0x200000ULL) & 0xFFFFFFFFFFE00000ULL); addr+=PAGE_SIZE) {
|
||||
page_set_mark(addr >> PAGE_BITS);
|
||||
atomic_int32_inc(&total_allocated_pages);
|
||||
atomic_int32_dec(&total_available_pages);
|
||||
atomic_int32_add(&total_allocated_pages, 0x200000 / PAGE_SIZE);
|
||||
atomic_int32_add(&total_pages, 0x200000 / PAGE_SIZE);
|
||||
}
|
||||
|
||||
ret = vma_init();
|
||||
|
|
|
@ -58,7 +58,7 @@ int vma_init(void)
|
|||
|
||||
// add Kernel
|
||||
ret = vma_add(PAGE_CEIL((size_t) &kernel_start),
|
||||
(((size_t) &kernel_end + 0x200000ULL) & 0xFFFFFFFFFFE00000ULL), /* we use 2MB pages to map the kernel */
|
||||
PAGE_FLOOR((size_t) &kernel_end),
|
||||
VMA_READ|VMA_WRITE|VMA_EXECUTE|VMA_CACHEABLE);
|
||||
if (BUILTIN_EXPECT(ret, 0))
|
||||
goto out;
|
||||
|
|
Loading…
Add table
Reference in a new issue