root/arch/sparc/kernel/switch.S

/* [previous][next][first][last][top][bottom][index][help] */
   1 /* $Id: switch.S,v 1.9 1995/11/25 00:58:32 davem Exp $
   2  * switch.S: Sparc task switch code.
   3  *
   4  * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
   5  */
   6 
   7 #include <asm/head.h>
   8 #include <asm/asi.h>
   9 #include <asm/contregs.h>
  10 #include <asm/cprefix.h>
  11 #include <asm/psr.h>
  12 #include <asm/ptrace.h>
  13 #include <asm/winmacro.h>
  14 
  15 #define sw_ntask     g1
  16 #define sw_sp        g2
  17 #define sw_pc        g3
  18 #define sw_psr       g4
  19 #define sw_wim       g5
  20 #define sw_tmp       g6
  21 #define sw_ctx       g7
  22 
  23 /* Context switch code.  The new process's task_struct
  24  * ptr is passed as the first parameter.
  25  *
  26  * First successful task switch 05/13/95 21:52:37
  27  */
  28         .align 4
  29         .globl  C_LABEL(sparc_switch_to), C_LABEL(mmu_switch_lowlevel)
  30 C_LABEL(sparc_switch_to):
  31         mov     %o0, %sw_ntask
  32 
  33         /* Save kernel state. */
  34         FLUSH_ALL_KERNEL_WINDOWS; 
  35         STORE_WINDOW(sp)
  36         rd      %psr, %sw_psr
  37         sethi   %hi(PSR_EF), %sw_tmp
  38         andn    %sw_psr, %sw_tmp, %sw_psr
  39         LOAD_CURRENT(sw_tmp)
  40         rd      %wim, %sw_wim
  41         std     %sw_psr, [%sw_tmp + THREAD_KPSR]
  42         std     %sp, [%sw_tmp + THREAD_KSP]
  43 
  44         /* Load new kernel state. */
  45         wr      %sw_psr, PSR_ET, %psr
  46         sethi   %hi(C_LABEL(current_set)), %sw_tmp
  47         st      %sw_ntask, [%sw_tmp + %lo(C_LABEL(current_set))]
  48         ldd     [%sw_ntask + THREAD_KPSR], %sw_psr
  49         ldd     [%sw_ntask + THREAD_KSP], %sw_sp
  50         wr      %sw_psr, PSR_ET, %psr
  51         WRITE_PAUSE
  52         wr      %sw_wim, 0x0, %wim
  53         WRITE_PAUSE
  54         mov     %sw_sp, %sp
  55         LOAD_WINDOW(sp)
  56         mov     %sw_pc, %o7
  57 
  58         /* Jump into the proper context. */
  59         ld      [%sw_ntask + THREAD_CONTEXT], %sw_ctx
  60         tst     %sw_ctx
  61         bneg    1f                      ! this must be swapper
  62          nop
  63 
  64 C_LABEL(mmu_switch_lowlevel):
  65         sethi   %hi(AC_CONTEXT), %sw_tmp        ! else set new context
  66         stba    %sw_ctx, [%sw_tmp] ASI_CONTROL
  67 1:
  68         wr      %sw_psr, 0x0, %psr              ! traps back on
  69         WRITE_PAUSE
  70 
  71         retl
  72          nop

/* [previous][next][first][last][top][bottom][index][help] */