From: Alan Cox Date: Fri, 19 Dec 2014 01:30:26 +0000 (+0000) Subject: z80fixedbank: Always use the swapstack X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=6ffb384b5583c819cb53ccfdc30db632a486e5d7;p=FUZIX.git z80fixedbank: Always use the swapstack If we don't then when we call map_kernel after copying the udata back we will scribble somewhere on the stack of the process. We could potentially move the switch back to the point we've fixed up sp, but as we have a swap stack we might as well use it. If we get banked boxes without swap then it may be worth looking at the other path for a lib/z80fixedbanknswap.s --- diff --git a/Kernel/lib/z80fixedbank.s b/Kernel/lib/z80fixedbank.s index 5d8f71d6..ea1c68eb 100644 --- a/Kernel/lib/z80fixedbank.s +++ b/Kernel/lib/z80fixedbank.s @@ -99,16 +99,21 @@ _switchin: add hl, de ; process ptr pop de + ; + ; Always use the swapstack, otherwise when we call map_kernel + ; having copied the udata stash back to udata we will crap + ; somewhere up the stackframe and it's then down to luck + ; if those bytes are discarded or not. + ; + ; Yes - this was a bitch to debug, please don't break it ! + ; + ld sp, #_swapstack + ld a, (hl) or a jr nz, not_swapped - ; - ; We are still on the departing processes stack, which is - ; fine for now. - ; - ld sp, #_swapstack push hl push de call _swapper