The swap case is ok as it always runs on the swap stack. The non swap case
restores the process kernel stack underneath the curent sp. That in itself is
fine as we have interrupts off. However we then called map_kernel which if
the current sp was above the sp of the save would corrupt the stack.
Instead restore sp first so that we push and pop data below the saved stack
content
call map_kernel
- push de
ld hl, #P_TAB__P_PAGE_OFFSET
add hl, de ; process ptr
- pop de
.ifne CONFIG_SWAP
.globl _swapper
ldir
exx
+ ; In the non swap case we must set so before we use the stack
+ ; otherwise we risk corrupting the restored stack frame
+ ld sp, (U_DATA__U_SP)
call map_kernel
; check u_data->u_ptab matches what we wanted