diff --git a/mm/memory.c b/mm/memory.c index 7168e8e9..1e352bf1 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -33,7 +33,7 @@ * 0 => free * 1 => occupied */ -static uint8_t bitmap[BITMAP_SIZE]; +static uint8_t bitmap[BITMAP_SIZE] = {[0 ... BITMAP_SIZE-1] = 0xFF}; static spinlock_t bitmap_lock = SPINLOCK_INIT; static size_t alloc_start; atomic_int32_t total_pages = ATOMIC_INIT(0); @@ -85,18 +85,20 @@ int mmu_init(void) size_t addr; /* set whole address space as occupied */ - memset(bitmap, 0xFF, sizeof(uint8_t)*BITMAP_SIZE); + // array is already initialized (see declaration) + //memset(bitmap, 0xFF, sizeof(uint8_t)*BITMAP_SIZE); #ifdef CONFIG_MULTIBOOT if (mb_info && (mb_info->flags & (1 << (6)))) { multiboot_memory_map_t* mmap = (multiboot_memory_map_t*) mb_info->mmap_addr; multiboot_memory_map_t* mmap_end = (void*) ((size_t) mb_info->mmap_addr + mb_info->mmap_length); + size_t end_addr; while (mmap < mmap_end) { if (mmap->type == MULTIBOOT_MEMORY_AVAILABLE) { /* set the available memory as "unused" */ - size_t end_addr = addr + mmap->len; - addr = mmap->addr; + addr = mmap->addr; + end_addr = addr + mmap->len; while (addr < end_addr) { page_clear_mark(addr / PAGE_SIZE);