|
|
1.1.1.2 ! root 1: |* ctxsw.s - ctxsw 1.1 root 2: 1.1.1.2 ! root 3: |*----------------------------------------------------------------------------- ! 4: |* ctxsw -- actually perform context switch, saving and loading registers ! 5: |* This routine is executed in kernel mode. ! 6: |* ! 7: |* Upon entry, d0-d7, a0-a6, the ssp, the sr, and the pc are ! 8: |* saved. The usp is ignored. ! 9: |* ! 10: |* Upon exit, all registers saved are restored, and the value ! 11: |* of the supervisor stack pointer is copied into the user ! 12: |* stack pointer. ! 13: |*----------------------------------------------------------------------------- 1.1 root 14: 1.1.1.2 ! root 15: .data 1.1 root 16: .text 1.1.1.2 ! root 17: .globl _ctxsw ! 18: _ctxsw: ! 19: movl a0, sp@- | Save A0 onto old stack ! 20: movl sp@(8), a0 | Move address of old area into A0 ! 21: moveml #0xffff,a0@ | Save all registers ! 22: movl sp@, a0@(32) | Put original A0 in old savearea ! 23: addql #8, a0@(60) | Move SP beyond return address ! 24: | as if a return has occured ! 25: addl #64, a0 | Skip past registers d0-7,a0-7 ! 26: movw #0, a0@+ | Pad SR savearea, since SR is a word ! 27: movw sr, a0@+ | Save SR in old savearea ! 28: movl sp@(4), a0@+ | Save PC in old savearea ! 29: ! 30: |Save image:d0,d1,d2,d3,d4,d5,d6,d7,a0,a1,a2,a3,a4,a5,a6,ssp,0x00, sr, pc ! 31: | 0 4 8 12 16 20 24 28 32 36 40 44 48 52 56 60 64 66 68 ! 32: ! 33: movl sp@(12),a0 | Move address of new area into A0 ! 34: moveml a0@,#0x7fff | Restore all regs (even A0) except SP ! 35: movl sp@(12),a0 | Move address of new area into A0 again ! 36: movl a0@(60),sp | Put SSP into both kernel stack ! 37: movl sp, usp | and user stack ! 38: movl a0@(68),sp@- | Move PC onto current stack ! 39: movw a0@(66),sp@- | Move SR onto current stack ! 40: movl a0@(32),a0 | Restore A0 from new area ! 41: | rte ! 42: movw sp@+,sr | (rte works differently on 68010) ! 43: rts | so do 68000-rte in effect this way ! 44: .data
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.