From: Alan Cox Date: Sun, 16 Sep 2018 22:23:20 +0000 (+0100) Subject: bank8K: document assumptions better X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=b1329d1e181313c89858323c0d03f95651516404;p=FUZIX.git bank8K: document assumptions better --- diff --git a/Kernel/bank8k.c b/Kernel/bank8k.c index b88a2fab..809fced6 100644 --- a/Kernel/bank8k.c +++ b/Kernel/bank8k.c @@ -26,6 +26,10 @@ * Page numbers must not include 0 (0 is taken as swapped) * * FIXME: currently requires that PROGTOP aligns to an 8K boundary + * if using swap. + * + * Also we kind of assume that program space starts at 0x0000. That + * needs fixing. */ #include #include @@ -109,11 +113,20 @@ void pagemap_free(ptptr p) } } -static int maps_needed(uint16_t top) +/* + * We are passed the number of bytes that are needed for this + * process. On top of that we require the extra space between + * the top of space and PROGTOP which is reserved for the common + * space and udata. If you have no need for this then it'll come out + * as size - 1, which is correct. + * + * The code assumes that the program base is within the first bank + */ +static int maps_needed(uint16_t size) { /* On many platforms if you touch this or PROGTOP you must touch tricks.s */ - uint16_t needed = top + 0xFFFF - PROGTOP; + uint16_t needed = size + 0xFFFF - PROGTOP; /* Usually we have 0x1000 common - 1 for shift and inc */ needed >>= 13; /* in banks */ needed++; /* rounded */