From fee7c96ef0981bfd054bf1da725a810e7cda76aa Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Sun, 16 Sep 2018 23:13:18 +0100 Subject: [PATCH] Revert "bank8k: Fix program size/top confusion" This reverts commit 90a1fcf7d46e10e3e163d11785badda0c8f5ba2a. The original logic is actually correct I believe on review. The top is turned into a size, biased by the need to keep space for the common copy and correctly calculated --- Kernel/bank8k.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel/bank8k.c b/Kernel/bank8k.c index bc1d0eea..b88a2fab 100644 --- a/Kernel/bank8k.c +++ b/Kernel/bank8k.c @@ -109,11 +109,11 @@ void pagemap_free(ptptr p) } } -static int maps_needed(uint16_t size) +static int maps_needed(uint16_t top) { /* On many platforms if you touch this or PROGTOP you must touch tricks.s */ - uint16_t needed = size - 1; + uint16_t needed = top + 0xFFFF - PROGTOP; /* Usually we have 0x1000 common - 1 for shift and inc */ needed >>= 13; /* in banks */ needed++; /* rounded */ @@ -130,7 +130,7 @@ static int maps_needed(uint16_t size) int pagemap_alloc(ptptr p) { uint8_t *ptr; - int needed = maps_needed(p->p_top - MAPBASE); + int needed = maps_needed(p->p_top); int i; /* Cheapest way to keep it non zero */ @@ -165,7 +165,7 @@ int pagemap_alloc(ptptr p) */ int pagemap_realloc(usize_t code, usize_t size, usize_t stack) { - int8_t have = maps_needed(udata.u_top - MAPBASE); + int8_t have = maps_needed(udata.u_top); int8_t want = maps_needed(size); uint8_t *ptr = (uint8_t *)udata.u_page; -- 2.34.1