Interface cleanup

This commit is contained in:
2018-02-15 14:20:10 +01:00
parent 9a479b1132
commit 8711fee390
4 changed files with 36 additions and 19 deletions

View File

@@ -0,0 +1,30 @@
#include <memory.h>
#include <multiboot.h>
#include <debug.h>
void memory_init()
{
uintptr_t start, end;
uint32_t type, i = 0;
debug_info("Parsing memory map\n");
while(!multiboot_get_memory_area(i++, &start, &end, &type))
{
debug("0x%016x-0x%016x (%d)\n", start, end, type);
for(uintptr_t p = start; p < end; p += PAGE_SIZE)
{
if(p >= V2P(&kernel_start) && p < V2P(&kernel_end))
continue;
uintptr_t page = vmm_get_page(&BootP4, (uintptr_t)P2V(p));
if(page == (uintptr_t)-1 || !(page & PAGE_PRESENT))
{
uint16_t flags = PAGE_GLOBAL | PAGE_HUGE | PAGE_WRITE;
touch_page(&BootP4, (uintptr_t)P2V(p), flags);
vmm_set_page(&BootP4, (uintptr_t)P2V(p), p, flags | PAGE_PRESENT);
}
if(type == MMAP_FREE)
pmm_free(p);
}
}
}