#include "../kernel-68000.def"
-.globl switchout,switchin,dofork
+.globl switchout,switchin,dofork,udata_shadow
.mri 1
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
; 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
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