diff options
author | Freya Murphy <freya@freyacat.org> | 2025-04-25 10:59:49 -0400 |
---|---|---|
committer | Freya Murphy <freya@freyacat.org> | 2025-04-25 10:59:49 -0400 |
commit | 03ce2cd514ee2c87528cff12591241963fde3ffe (patch) | |
tree | 7f3343c1587f849e331507c626399087cdaf0704 | |
parent | change start vitaddr (diff) | |
download | comus-03ce2cd514ee2c87528cff12591241963fde3ffe.tar.gz comus-03ce2cd514ee2c87528cff12591241963fde3ffe.tar.bz2 comus-03ce2cd514ee2c87528cff12591241963fde3ffe.zip |
fix physalloc edge case
Diffstat (limited to '')
-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..833c995 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++) { |