Annotation of xinu/sys/.ctxsw.s, revision 1.1.1.1

1.1       root        1: |* ctxsw.s - ctxsw
                      2: 
                      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: |*-----------------------------------------------------------------------------
                     14: 
                     15:        .data
                     16:        .text
                     17:        .globl  _ctxsw
                     18: _ctxsw:
                     19:        movl    a0,     sp@(-4)         ; Save A0 onto old stack        
                     20:        movl    sp@(4), a0              ; Move address of old area into A0 
                     21:        moveml  #0xffff,a0@             ; Save all registers            
                     22:        movl    sp@(-4),a0@(32)         ; Put original A0 in old savearea       
                     23:        addl    #64,    a0              ; Skip past registers d0-7,a0-7
                     24:        movw    #0,     a0@+            ; Pad SR savearea, since SR is a word
                     25:        movw    sr,     a0@+            ; Save SR in old savearea       
                     26:        movl    sp@,    a0@+            ; Save PC in old savearea       
                     27: 
                     28: |Save image:d0,d1,d2,d3,d4,d5,d6,d7,a0,a1,a2,a3,a4,a5,a6,ssp,0x00, sr, pc
                     29: |            0  4  8 12 16 20 24 28 32 36 40 44 48 52 56  60  64   66  68 
                     30: 
                     31:        movl    sp@(8), a0              ; Move address of new area into A0
                     32:        moveml  a0@,#0x7fff             ; Restore all regs (even A0) except SP
                     33:        movl    sp@(8), a0              ; Move address of new area into A0 again
                     34:        movl    a0@(60),sp              ; Put  SSP into both kernel stack
                     35:        movl    sp,     usp             ;      and            user  stack
                     36:        movw    a0@(66),sr              ; Restore SR from new area      
                     37:        movl    a0@(68),sp@             ; Move PC onto current stack    
                     38:        movl    a0@(32),a0              ; Restore A0 from new area      
                     39:        rts
                     40:        .data

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.