diff options
Diffstat (limited to 'src/memory/physalloc.c')
-rw-r--r-- | src/memory/physalloc.c | 44 |
1 files changed, 11 insertions, 33 deletions
diff --git a/src/memory/physalloc.c b/src/memory/physalloc.c index dccd980..1140258 100644 --- a/src/memory/physalloc.c +++ b/src/memory/physalloc.c @@ -163,13 +163,11 @@ void memory_init(struct memory_map *map) { page_free_start = 0; page_start = NULL; - uintptr_t end = (uintptr_t) map; - end += map->size; - - struct memory_segment *segment = &map->entries[0]; segment_count = 0; - - for(; (uintptr_t) segment < end; segment++) { + + for(uint32_t i = 0; i < map->entry_count; i++) { + struct memory_segment *segment = &map->entries[i]; + if (segment_invalid(segment)) continue; @@ -189,16 +187,17 @@ void memory_init(struct memory_map *map) { char *page_area_addr = (char *)bitmap + bitmap_size; bitmap = mmap(bitmap, bitmap_size); memset(bitmap, 0, bitmap_size); - + memory_start = page_align(kaddr(kernel_end) + bitmap_size + page_area_size); page_area_addr = mmap(page_area_addr, page_area_size); page_start = (struct memory_area *) page_area_addr; - + struct memory_area *area = page_start; - segment = &map->entries[0]; - - for(; (uintptr_t) segment < end; segment++) { + + for(uint32_t i = 0; i < map->entry_count; i++) { + struct memory_segment *segment = &map->entries[i]; + if (segment_invalid(segment)) continue; @@ -206,7 +205,7 @@ void memory_init(struct memory_map *map) { *area = temp; area++; } - + page_count -= bitmap_pages; memory_unlock(); @@ -229,24 +228,3 @@ uint64_t memory_used(void) { return total_memory - free_memory; } -// stubs -// simon do these ik you want to -// :3 - -void *malloc(size_t size) { - //TODO: implement - (void)size; - return NULL; -} - -void *realloc(void *ptr, size_t size) { - //TODO: implement - (void)ptr; - (void)size; - return NULL; -} - -void free(void *ptr) { - //TODO: implement - (void)ptr; -} |