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 ++++++-- src/tcb.c | 8 +++----- 2 files changed, 9 insertions(+), 7 deletions(-) (limited to 'src') 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); } } diff --git a/src/tcb.c b/src/tcb.c index f5b1652..1281da2 100644 --- a/src/tcb.c +++ b/src/tcb.c @@ -107,7 +107,7 @@ static stat_t __init_free_thread(struct tcb *t) if (setup_rpc_stack(t)) { destroy_rpc_stack(t); - destroy_vmem(t->rpc.vmem); + destroy_rpcmem(t->rpc.vmem); destroy_vmem(t->proc.vmem); return ERR_OOMEM; } @@ -135,7 +135,7 @@ static stat_t __init_owned_thread(struct tcb *p, struct tcb *t) if (setup_rpc_stack(t)) { destroy_rpc_stack(t); - destroy_vmem(t->rpc.vmem); + destroy_rpcmem(t->rpc.vmem); return ERR_OOMEM; } @@ -252,9 +252,7 @@ stat_t destroy_thread(struct tcb *t) /* free memory backing rpc stack */ destroy_rpc_stack(t); - - /* free rpc vmem */ - destroy_vmem(t->rpc.vmem); + destroy_rpcmem(t->rpc.vmem); unqueue_ipi(t); -- cgit v1.3