From e7b5881903ad81efee63966e7d2c42524d465dfc Mon Sep 17 00:00:00 2001 From: Kimplul Date: Wed, 30 Oct 2024 02:18:12 +0200 Subject: tests pass --- src/pmem.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/pmem.c') diff --git a/src/pmem.c b/src/pmem.c index 9c839f1..bb9d326 100644 --- a/src/pmem.c +++ b/src/pmem.c @@ -277,7 +277,7 @@ static pm_t __alloc_page(enum mm_order order) __get_bit(bucket, a, &set, &bit); bmap = __get_set(bucket, set); - bmap->size = order_width(order + 1); + assert(bmap->size != 0 && bmap->size <= order_width(order + 1)); bmap->next = NULL; bmap->prev = NULL; @@ -491,6 +491,9 @@ static void __mark_area_used(pm_t base, pm_t top) return; } + top = align_up(top, BASE_PAGE_SIZE); + base = align_down(base, BASE_PAGE_SIZE); + size_t area_left = top - base; pm_t runner = base; while (area_left >= BASE_PAGE_SIZE) { @@ -501,6 +504,8 @@ static void __mark_area_used(pm_t base, pm_t top) if (area_left != 0) mark_used(BASE_PAGE, runner); + + info("marked [%lx - %lx] reserved\n", base, top); } /** Helper for keeping track of which memory regions to avoid placing data into. */ @@ -548,7 +553,6 @@ static void __mark_reserved(pm_t ram_base, pm_t ram_size, size_t avoid_count, pm_t top = base + size; __mark_area_used(base, top); - info("marked [%lx - %lx] reserved\n", base, top); } } -- cgit v1.3