From: Alan Cox Date: Mon, 12 Sep 2016 23:16:51 +0000 (+0100) Subject: v68: fix tricks handling for 68000 X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=46338ea66aa0bc228acd22d960ad4c5a07a9ace6;p=FUZIX.git v68: fix tricks handling for 68000 --- diff --git a/Kernel/platform-v68/tricks.S b/Kernel/platform-v68/tricks.S index a73349a7..95819f2e 100644 --- a/Kernel/platform-v68/tricks.S +++ b/Kernel/platform-v68/tricks.S @@ -1,7 +1,7 @@ #include "../kernel-68000.def" -.globl switchout,switchin,dofork +.globl switchout,switchin,dofork,udata_shadow .mri 1 @@ -19,30 +19,26 @@ switchout: clr.w -(sp) ; return code set here is ignored, but _switchin can ; return from either _switchout OR _dofork, so they must both write ; U_DATA__U_SP with the following on the stack: - movem.l a0-a4/a6/d0-d7,-(sp) ; FIXME: trim to callee saves + movem.l a2-a4/a6/d2-d7,-(sp) move.l sp,U_DATA__U_SP(a5) ; this is where the SP is restored in _switchin - ; set _inint to false - clr.b inint - ; find another process to run (may select this one again) bsr getproc - move.l a0,-(sp) ; CHECK compiler call/return rules + move.l d0,-(sp) bsr switchin ; we should never get here bra trap_monitor -badswitchmsg: ascii "_switchin: FAIL" - byte 13,10,0 -swapped: ascii "_switchin: SWAPPED" - byte 13,10,0 - switchin: or #$0700,sr move.l 4(sp),a0 ; task to switch to move.l P_TAB__P_UDATA_OFFSET(a0),a5 + move.l a5,udata_shadow ; update the saved copy used for IRQ + ; handling etc + + move.l U_DATA__U_PTAB(a5),a0 ; check u_data->u_ptab matches what we wanted move.l 4(sp),d0 @@ -57,10 +53,11 @@ switchin: ; restore machine state move.l U_DATA__U_SP(a5),sp - movem.l (sp)+,a0-a4/a6/d0-d7 ; FIXME: trim to callee saves here too + movem.l (sp)+,a2-a4/a6/d2-d7 + move.w (sp)+,d0 ; FIXME: can we merge ? - tst.b inint - beq keepoff ; in ISR, leave interrupts off + tst.b U_DATA__U_ININTERRUPT(a5) + bne keepoff ; in ISR, leave interrupts off and #$F8FF,sr keepoff: rts ; return with interrupts on @@ -71,3 +68,9 @@ switchinfail: bsr outstring ; something went wrong and we didn't switch in what we asked for bra trap_monitor + +badswitchmsg: ascii "_switchin: FAIL" + byte 13,10,0 +swapped: ascii "_switchin: SWAPPED" + byte 13,10,0 +.even