From: Alan Cox Date: Tue, 6 Dec 2016 19:05:30 +0000 (+0000) Subject: bank: propogate some changes X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=fd369130b2bfb86b5b08ccfb8bb0188328dc3a05;p=FUZIX.git bank: propogate some changes --- diff --git a/Kernel/bank16k.c b/Kernel/bank16k.c index e6f4f52e..799ae8f0 100644 --- a/Kernel/bank16k.c +++ b/Kernel/bank16k.c @@ -129,6 +129,7 @@ int pagemap_realloc(usize_t size) irq = __hard_di(); if (have > want) { + /* FIXME: swapout handling is needed ahead of this */ for (i = want; i < have; i++) { pfree[pfptr++] = ptr[i - 1]; ptr[i - 1] = ptr[3]; diff --git a/Kernel/bank32k.c b/Kernel/bank32k.c index 24ff8968..13fb15f6 100644 --- a/Kernel/bank32k.c +++ b/Kernel/bank32k.c @@ -120,6 +120,7 @@ int pagemap_realloc(usize_t size) { int have = maps_needed(udata.u_top); int want = maps_needed(size); uint8_t *ptr = (uint8_t *) & udata.u_page; + irqflags_t irq; /* If we are shrinking then free pages and propogate the common page into the freed spaces */ @@ -127,6 +128,7 @@ int pagemap_realloc(usize_t size) { return 0; if (have > want) { pfree[pfptr++] = ptr[1]; + ptr[1] = *ptr; udata.u_ptab->p_page = udata.u_page; return 0; } @@ -137,15 +139,16 @@ int pagemap_realloc(usize_t size) { /* We don't want to take an interrupt here while our page mappings are incomplete. We may restore bogus mappings and then take a second IRQ into hyperspace */ - __critical { - ptr[0] = pfree[--pfptr]; - /* Copy the updated allocation into the ptab */ - udata.u_ptab->p_page = udata.u_page; - /* Now fix the vectors up - they've potentially teleported up to 32K up - the user address space, we need to put a copy back in low memory before - we switch to this memory map */ - program_vectors(&udata.u_page); - } + + irq = __hard_di(); + ptr[0] = pfree[--pfptr]; + /* Copy the updated allocation into the ptab */ + udata.u_ptab->p_page = udata.u_page; + /* Now fix the vectors up - they've potentially teleported up to 32K up + the user address space, we need to put a copy back in low memory before + we switch to this memory map */ + program_vectors(&udata.u_page); + __hard_irqrestore(irq); return 0; }