~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Linux/include/asm-mips64/stackframe.h

Version: ~ [ 2.4.0 ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* $Id: stackframe.h,v 1.3 1999/12/04 03:59:12 ralf Exp $
  2  *
  3  * This file is subject to the terms and conditions of the GNU General Public
  4  * License.  See the file "COPYING" in the main directory of this archive
  5  * for more details.
  6  *
  7  * Copyright (C) 1994, 1995, 1996, 1999 Ralf Baechle
  8  * Copyright (C) 1994, 1995, 1996 Paul M. Antoine.
  9  * Copyright (C) 1999 Silicon Graphics, Inc.
 10  */
 11 #ifndef _ASM_STACKFRAME_H
 12 #define _ASM_STACKFRAME_H
 13 
 14 #include <linux/config.h>
 15 
 16 #include <asm/asm.h>
 17 #include <asm/offset.h>
 18 #include <asm/processor.h>
 19 #include <asm/addrspace.h>
 20 
 21 #ifdef _LANGUAGE_C
 22 
 23 #define __str2(x) #x
 24 #define __str(x) __str2(x)
 25 
 26 #define save_static(frame)                               \
 27         __asm__ __volatile__(                            \
 28                 "sd\t$16,"__str(PT_R16)"(%0)\n\t"        \
 29                 "sd\t$17,"__str(PT_R17)"(%0)\n\t"        \
 30                 "sd\t$18,"__str(PT_R18)"(%0)\n\t"        \
 31                 "sd\t$19,"__str(PT_R19)"(%0)\n\t"        \
 32                 "sd\t$20,"__str(PT_R20)"(%0)\n\t"        \
 33                 "sd\t$21,"__str(PT_R21)"(%0)\n\t"        \
 34                 "sd\t$22,"__str(PT_R22)"(%0)\n\t"        \
 35                 "sd\t$23,"__str(PT_R23)"(%0)\n\t"        \
 36                 "sd\t$30,"__str(PT_R30)"(%0)\n\t"        \
 37                 : /* No outputs */                       \
 38                 : "r" (frame))
 39 
 40 #endif /* _LANGUAGE_C */
 41 
 42 #ifdef _LANGUAGE_ASSEMBLY
 43 
 44                 .macro  SAVE_AT
 45                 .set    push
 46                 .set    noat
 47                 sd      $1, PT_R1(sp)
 48                 .set    pop
 49                 .endm
 50 
 51                 .macro  SAVE_TEMP
 52                 mfhi    v1
 53                 sd      $8, PT_R8(sp)
 54                 sd      $9, PT_R9(sp)
 55                 sd      v1, PT_HI(sp)
 56                 mflo    v1
 57                 sd      $10, PT_R10(sp)
 58                 sd      $11, PT_R11(sp)
 59                 sd      v1,  PT_LO(sp)
 60                 sd      $12, PT_R12(sp)
 61                 sd      $13, PT_R13(sp)
 62                 sd      $14, PT_R14(sp)
 63                 sd      $15, PT_R15(sp)
 64                 sd      $24, PT_R24(sp)
 65                 .endm
 66 
 67                 .macro  SAVE_STATIC
 68                 sd      $16, PT_R16(sp)
 69                 sd      $17, PT_R17(sp)
 70                 sd      $18, PT_R18(sp)
 71                 sd      $19, PT_R19(sp)
 72                 sd      $20, PT_R20(sp)
 73                 sd      $21, PT_R21(sp)
 74                 sd      $22, PT_R22(sp)
 75                 sd      $23, PT_R23(sp)
 76                 sd      $30, PT_R30(sp)
 77                 .endm
 78 
 79                 .macro  SAVE_SOME
 80                 .set    push
 81                 .set    reorder
 82                 mfc0    k0, CP0_STATUS
 83                 sll     k0, 3           /* extract cu0 bit */
 84                 .set    noreorder
 85                 bltz    k0, 8f
 86                  move   k1, sp
 87                 .set    reorder
 88                 /* Called from user mode, new stack. */
 89 #ifndef CONFIG_SMP
 90                 lui     k1, %hi(kernelsp)
 91                 ld      k1, %lo(kernelsp)(k1)
 92 #else
 93                 mfc0    k0, CP0_WATCHLO
 94                 mfc0    k1, CP0_WATCHHI
 95                 dsll32  k0, k0, 0       /* Get rid of sign extension */
 96                 dsrl32  k0, k0, 0       /* Get rid of sign extension */
 97                 dsll32  k1, k1, 0
 98                 or      k1, k1, k0
 99                 li      k0, K0BASE
100                 or      k1, k1, k0
101                 daddiu  k1, k1, KERNEL_STACK_SIZE-32
102 #endif
103 8:              move    k0, sp
104                 dsubu   sp, k1, PT_SIZE
105                 sd      k0, PT_R29(sp)
106                 sd      $3, PT_R3(sp)
107                 sd      $0, PT_R0(sp)
108                 dmfc0   v1, CP0_STATUS
109                 sd      $2, PT_R2(sp)
110                 sd      v1, PT_STATUS(sp)
111                 sd      $4, PT_R4(sp)
112                 dmfc0   v1, CP0_CAUSE
113                 sd      $5, PT_R5(sp)
114                 sd      v1, PT_CAUSE(sp)
115                 sd      $6, PT_R6(sp)
116                 dmfc0   v1, CP0_EPC
117                 sd      $7, PT_R7(sp)
118                 sd      v1, PT_EPC(sp)
119                 sd      $25, PT_R25(sp)
120                 sd      $28, PT_R28(sp)
121                 sd      $31, PT_R31(sp)
122                 ori     $28, sp, 0x3fff
123                 xori    $28, 0x3fff
124                 .set    pop
125                 .endm
126 
127                 .macro  SAVE_ALL
128                 SAVE_SOME
129                 SAVE_AT
130                 SAVE_TEMP
131                 SAVE_STATIC
132                 .endm
133 
134                 .macro  RESTORE_AT
135                 .set    push
136                 .set    noat
137                 ld      $1,  PT_R1(sp)
138                 .set    pop
139                 .endm
140 
141                 .macro  RESTORE_SP
142                 ld      sp,  PT_R29(sp)
143                 .endm
144 
145                 .macro  RESTORE_TEMP
146                 ld      $24, PT_LO(sp)
147                 ld      $8, PT_R8(sp)
148                 ld      $9, PT_R9(sp)
149                 mtlo    $24
150                 ld      $24, PT_HI(sp)
151                 ld      $10, PT_R10(sp)
152                 ld      $11, PT_R11(sp)
153                 mthi    $24
154                 ld      $12, PT_R12(sp)
155                 ld      $13, PT_R13(sp)
156                 ld      $14, PT_R14(sp)
157                 ld      $15, PT_R15(sp)
158                 ld      $24, PT_R24(sp)
159                 .endm
160 
161                 .macro  RESTORE_STATIC
162                 ld      $16, PT_R16(sp)
163                 ld      $17, PT_R17(sp)
164                 ld      $18, PT_R18(sp)
165                 ld      $19, PT_R19(sp)
166                 ld      $20, PT_R20(sp)
167                 ld      $21, PT_R21(sp)
168                 ld      $22, PT_R22(sp)
169                 ld      $23, PT_R23(sp)
170                 ld      $30, PT_R30(sp)
171                 .endm
172 
173                 .macro  RESTORE_SOME
174                 .set    push
175                 .set    reorder
176                 mfc0    t0, CP0_STATUS
177                 .set    pop
178                 ori     t0, 0x1f
179                 xori    t0, 0x1f
180                 mtc0    t0, CP0_STATUS
181                 li      v1, 0xff00
182                 and     t0, v1
183                 ld      v0, PT_STATUS(sp)
184                 nor     v1, $0, v1
185                 and     v0, v1
186                 or      v0, t0
187                 dmtc0   v0, CP0_STATUS
188                 ld      v1, PT_EPC(sp)
189                 dmtc0   v1, CP0_EPC
190                 ld      $31, PT_R31(sp)
191                 ld      $28, PT_R28(sp)
192                 ld      $25, PT_R25(sp)
193                 ld      $7,  PT_R7(sp)
194                 ld      $6,  PT_R6(sp)
195                 ld      $5,  PT_R5(sp)
196                 ld      $4,  PT_R4(sp)
197                 ld      $3,  PT_R3(sp)
198                 ld      $2,  PT_R2(sp)
199                 .endm
200 
201                 .macro  RESTORE_ALL
202                 RESTORE_SOME
203                 RESTORE_AT
204                 RESTORE_TEMP
205                 RESTORE_STATIC
206                 RESTORE_SP
207                 .endm
208 
209 /*
210  * Move to kernel mode and disable interrupts.
211  * Set cp0 enable bit as sign that we're running on the kernel stack
212  */
213                 .macro  CLI
214                 mfc0    t0, CP0_STATUS
215                 li      t1, ST0_CU0|0x1f
216                 or      t0, t1
217                 xori    t0, 0x1f
218                 mtc0    t0, CP0_STATUS
219                 .endm
220 
221 /*
222  * Move to kernel mode and enable interrupts.
223  * Set cp0 enable bit as sign that we're running on the kernel stack
224  */
225                 .macro  STI
226                 mfc0    t0, CP0_STATUS
227                 li      t1, ST0_CU0 | 0x1f
228                 or      t0, t1
229                 xori    t0, 0x1e
230                 mtc0    t0, CP0_STATUS
231                 .endm
232 
233 /*
234  * Just move to kernel mode and leave interrupts as they are.
235  * Set cp0 enable bit as sign that we're running on the kernel stack
236  */
237                 .macro  KMODE
238                 mfc0    t0, CP0_STATUS
239                 li      t1, ST0_CU0 | 0x1e
240                 or      t0, t1
241                 xori    t0, 0x1e
242                 mtc0    t0, CP0_STATUS
243                 .endm
244 
245 #endif /* _LANGUAGE_ASSEMBLY */
246 
247 #endif /* _ASM_STACKFRAME_H */
248 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.