diff options
author | Ian McFarlane <i.mcfarlane2002@gmail.com> | 2025-04-25 11:51:09 -0400 |
---|---|---|
committer | Ian McFarlane <i.mcfarlane2002@gmail.com> | 2025-04-25 11:51:09 -0400 |
commit | 25359ed1cb1a6131e9d3d26c8f2c8634670ed864 (patch) | |
tree | 559750220ff5084e33a2e1f5bc4f0c90b959a4f8 /kernel/memory/physalloc.c | |
parent | fix freeing of virtual memory (diff) | |
parent | poweroff syscall (diff) | |
download | comus-25359ed1cb1a6131e9d3d26c8f2c8634670ed864.tar.gz comus-25359ed1cb1a6131e9d3d26c8f2c8634670ed864.tar.bz2 comus-25359ed1cb1a6131e9d3d26c8f2c8634670ed864.zip |
resolve format conflict
Diffstat (limited to 'kernel/memory/physalloc.c')
-rw-r--r-- | kernel/memory/physalloc.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/kernel/memory/physalloc.c b/kernel/memory/physalloc.c index 856a627..9fcbe8f 100644 --- a/kernel/memory/physalloc.c +++ b/kernel/memory/physalloc.c @@ -1,3 +1,4 @@ +#include "lib/kio.h" #include <lib.h> #include <comus/memory.h> #include <comus/asm.h> @@ -11,13 +12,13 @@ extern char kernel_end; // between memory_start and kernel_start will be the bitmap static uintptr_t memory_start = 0; -static uint64_t *bitmap; +static uint64_t *bitmap = NULL; static uint64_t total_memory; static uint64_t free_memory; static uint64_t page_count; static uint64_t segment_count; struct memory_map phys_mmap; -struct memory_segment *page_start; +struct memory_segment *page_start = NULL; static const char *segment_type_str[] = { [SEG_TYPE_FREE] = "Free", [SEG_TYPE_RESERVED] = "Reserved", @@ -84,6 +85,13 @@ void *alloc_phys_pages_exact(size_t pages) if (pages < 1) return NULL; + if (bitmap == NULL || page_start == NULL) { + // temporary bump allocator + void *addr = (void *)memory_start; + memory_start += PAGE_SIZE; + return addr; + } + size_t n_contiguous = 0; size_t free_region_start = 0; for (size_t i = 0; i < page_count; i++) { |