Article View: comp.os.xinu
Article #117Re: ctxsw routine for M68000
From: John Reed
Date: Mon, 05 Oct 1992 16:49
Date: Mon, 05 Oct 1992 16:49
77 lines
3025 bytes
3025 bytes
In article <1992Oct2.195944.772@nntpd2.cxo.dec.com> kgibsonkgibson@cxcad%decwrl.dec.com (Ken Gibson) writes:
>
> Can someone post an M68000 version of the assembly language context switch
>routine _ctxsw for Xinu?
>
>Many Thanks
*-----------------------------------------------------------------------------
* ctxsw -- actually perform context switch, saving and loading registers
* This routine is executed in kernel mode.
*
* Upon entry, d0-d7, a0-a6, the usp, the sr, and the pc are
* saved.
*
* Upon exit, all registers saved are restored, and the value
* of the user stack pointer is copied into the user
* stack pointer.
*-----------------------------------------------------------------------------
section 14
xdef .cnt_ctxsw
.cnt_ctxsw dc.l 0
section 9
xdef .ctxsw
.ctxsw:
addq.l #1,.cnt_ctxsw
move.l a0,-(sp) ; Save A0 onto old stack
move.l 8(sp),a0 ; Move address of old area into A0
movem.l d0-d7/a0-a7,(a0) ; Save all registers
move.l (sp),32(a0) ; Put original A0 in old savearea
addq.l #8,60(a0) ; Move SP beyond return address
; as if a return has occured
add.l #64,a0 ; Skip past registers d0-7,a0-7
move.w #0,(a0)+ ; Pad SR savearea, since SR is a word
move.w sr,(a0)+ ; Save SR in old savearea
move.l 4(sp),(a0)+ ; Save PC in old savearea
*Save image:d0,d1,d2,d3,d4,d5,d6,d7,a0,a1,a2,a3,a4,a5,a6,ssp,0x00, sr, pc
* 0 4 8 12 16 20 24 28 32 36 40 44 48 52 56 60 64 66 68
move.l 12(sp),a0 ; Move address of new area into A0
movem.l (a0),d0-d7/a0-a6 ; Restore all regs (even A0) except SP
move.l 12(sp),a0 ; Move address of new area into A0 again
move.l 60(a0),sp ; Put SSP into kernel stack
move.l 68(a0),-(sp) ; Move PC onto current stack
move.w 66(a0),sr ; Restore the status register
move.l 32(a0),a0 ; Restore A0 from new area
rts ; since we pushed the pc onto the stack,
; we just pretend to return
---JR---
--
/------------------------------------------------------------------\
| John Reed {ucsd,uunet}!pacdata!johnr |
| Pacific Data Products johnr@pacdata.com |
| --------------------- |
| George Herbert Walker Bush, with the letters re-arranged spells: |
| |
| Huge Berserk Rebel Warthog |
| -- From Cosmic Trigger II |
\------------------------------------------------------------------/
Technical Details
Message-ID:
<1992Oct5.164946.19346@pacdata.uucp>Path:
arc1-ca.pugleaf.net!sparky!uunet!pacdata!johnrReferences:
<1992Oct2.195944.772@nntpd2.cxo.dec.com>Show Full Headers
Complete Article Headers
Newsgroups: comp.os.xinu Path: arc1-ca.pugleaf.net!sparky!uunet!pacdata!johnr From: johnr@pacdata.uucp (John Reed) Subject: Re: ctxsw routine for M68000 Message-ID: <1992Oct5.164946.19346@pacdata.uucp> Organization: Pacific Data Products References: <1992Oct2.195944.772@nntpd2.cxo.dec.com> Date: Mon, 5 Oct 1992 16:49:46 GMT Lines: 77