From 263e8087cfbd94d4ee08091956d1b9c60511a247 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Fri, 21 Nov 2014 15:05:04 +0000 Subject: [PATCH] bank16/32k: compute common area allowance We propogate the common into each high bank so must allow for it. Remove the hardcoded 4K assumption as it's trivial to do so, and also socz80 at least doesn't need 0xF000 to be the common base. --- Kernel/bank16k.c | 6 ++++-- Kernel/bank32k.c | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Kernel/bank16k.c b/Kernel/bank16k.c index a575ff64..cfb8059a 100644 --- a/Kernel/bank16k.c +++ b/Kernel/bank16k.c @@ -40,8 +40,10 @@ void pagemap_free(ptptr p) static int maps_needed(uint16_t top) { - /* FIXME: unhardwire the 0x1000 common assumption ! */ - uint16_t needed = top + 0xFFF; /* 0x1000 common - 1 for shift and inc */ + /* On many platforms if you touch this or PROGTOP you must + touch tricks.s */ + uint16_t needed = top + 0xFFFF - PROGTOP; + /* Usually we have 0x1000 common - 1 for shift and inc */ needed >>= 14; /* in banks */ needed++; /* rounded */ return needed; diff --git a/Kernel/bank32k.c b/Kernel/bank32k.c index 5b193fb4..e9b388de 100644 --- a/Kernel/bank32k.c +++ b/Kernel/bank32k.c @@ -67,8 +67,10 @@ void pagemap_free(ptptr p) static int maps_needed(uint16_t top) { - /* FIXME: unhardwire the 4K common assumption */ - uint16_t needed = top + 0xFFF; /* 0x1000 common - 1 for shift and inc */ + /* On many platforms if you touch this or PROGTOP you must + touch tricks.s */ + uint16_t needed = top + 0xFFFF - PROGTOP; + /* Usually we have 0x1000 common - 1 for shift and inc */ if (needed & 0x8000) return 2; return return 1; -- 2.34.1