2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
6 * Copyright (C) 1994, 95, 96, 99, 2001 Ralf Baechle
7 * Copyright (C) 1994, 1995, 1996 Paul M. Antoine.
8 * Copyright (C) 1999 Silicon Graphics, Inc.
10 #ifndef _ASM_STACKFRAME_H
11 #define _ASM_STACKFRAME_H
13 #include <linux/config.h>
14 #include <linux/threads.h>
17 #include <asm/mipsregs.h>
18 #include <asm/asm-offsets.h>
35 LONG_S $10, PT_R10(sp)
36 LONG_S $11, PT_R11(sp)
38 LONG_S $12, PT_R12(sp)
39 LONG_S $13, PT_R13(sp)
40 LONG_S $14, PT_R14(sp)
41 LONG_S $15, PT_R15(sp)
42 LONG_S $24, PT_R24(sp)
46 LONG_S $16, PT_R16(sp)
47 LONG_S $17, PT_R17(sp)
48 LONG_S $18, PT_R18(sp)
49 LONG_S $19, PT_R19(sp)
50 LONG_S $20, PT_R20(sp)
51 LONG_S $21, PT_R21(sp)
52 LONG_S $22, PT_R22(sp)
53 LONG_S $23, PT_R23(sp)
54 LONG_S $30, PT_R30(sp)
58 .macro get_saved_sp /* SMP variation */
64 LONG_L k1, %lo(kernelsp)(k1)
66 #if defined(CONFIG_64BIT) && !defined(CONFIG_BUILD_ELF64)
69 lui k0, %hi(pgd_current)
70 addiu k0, %lo(pgd_current)
74 LONG_L k1, %lo(kernelsp)(k1)
76 #if defined(CONFIG_64BIT) && defined(CONFIG_BUILD_ELF64)
78 lui k0, %highest(kernelsp)
80 daddiu k0, %higher(kernelsp)
82 daddiu k0, %hi(kernelsp)
85 LONG_L k1, %lo(kernelsp)(k1)
89 .macro set_saved_sp stackp temp temp2
91 mfc0 \temp, CP0_CONTEXT
94 #if defined(CONFIG_64BIT) && !defined(CONFIG_BUILD_ELF64)
98 #if defined(CONFIG_64BIT) && defined(CONFIG_BUILD_ELF64)
99 MFC0 \temp, CP0_CONTEXT
102 LONG_S \stackp, kernelsp(\temp)
105 .macro get_saved_sp /* Uniprocessor variation */
106 #if defined(CONFIG_64BIT) && defined(CONFIG_BUILD_ELF64)
107 lui k1, %highest(kernelsp)
108 daddiu k1, %higher(kernelsp)
110 daddiu k1, %hi(kernelsp)
113 lui k1, %hi(kernelsp)
115 LONG_L k1, %lo(kernelsp)(k1)
118 .macro set_saved_sp stackp temp temp2
119 LONG_S \stackp, kernelsp
128 sll k0, 3 /* extract cu0 bit */
133 /* Called from user mode, new stack. */
136 PTR_SUBU sp, k1, PT_SIZE
137 LONG_S k0, PT_R29(sp)
142 LONG_S v1, PT_STATUS(sp)
146 LONG_S v1, PT_CAUSE(sp)
154 LONG_S v1, PT_EPC(sp)
155 LONG_S $25, PT_R25(sp)
156 LONG_S $28, PT_R28(sp)
157 LONG_S $31, PT_R31(sp)
158 ori $28, sp, _THREAD_MASK
159 xori $28, _THREAD_MASK
178 LONG_L $24, PT_LO(sp)
184 LONG_L $24, PT_HI(sp)
185 LONG_L $10, PT_R10(sp)
186 LONG_L $11, PT_R11(sp)
188 LONG_L $12, PT_R12(sp)
189 LONG_L $13, PT_R13(sp)
190 LONG_L $14, PT_R14(sp)
191 LONG_L $15, PT_R15(sp)
192 LONG_L $24, PT_R24(sp)
195 .macro RESTORE_STATIC
196 LONG_L $16, PT_R16(sp)
197 LONG_L $17, PT_R17(sp)
198 LONG_L $18, PT_R18(sp)
199 LONG_L $19, PT_R19(sp)
200 LONG_L $20, PT_R20(sp)
201 LONG_L $21, PT_R21(sp)
202 LONG_L $22, PT_R22(sp)
203 LONG_L $23, PT_R23(sp)
204 LONG_L $30, PT_R30(sp)
207 #if defined(CONFIG_CPU_R3000) || defined(CONFIG_CPU_TX39XX)
219 LONG_L v0, PT_STATUS(sp)
224 LONG_L $31, PT_R31(sp)
225 LONG_L $28, PT_R28(sp)
226 LONG_L $25, PT_R25(sp)
240 .macro RESTORE_SP_AND_RET
243 LONG_L k0, PT_EPC(sp)
244 LONG_L sp, PT_R29(sp)
262 LONG_L v0, PT_STATUS(sp)
267 LONG_L v1, PT_EPC(sp)
269 LONG_L $31, PT_R31(sp)
270 LONG_L $28, PT_R28(sp)
271 LONG_L $25, PT_R25(sp)
285 .macro RESTORE_SP_AND_RET
286 LONG_L sp, PT_R29(sp)
295 LONG_L sp, PT_R29(sp)
306 .macro RESTORE_ALL_AND_RET
315 * Move to kernel mode and disable interrupts.
316 * Set cp0 enable bit as sign that we're running on the kernel stack
320 li t1, ST0_CU0 | 0x1f
328 * Move to kernel mode and enable interrupts.
329 * Set cp0 enable bit as sign that we're running on the kernel stack
333 li t1, ST0_CU0 | 0x1f
341 * Just move to kernel mode and leave interrupts as they are.
342 * Set cp0 enable bit as sign that we're running on the kernel stack
346 li t1, ST0_CU0 | 0x1e
353 #endif /* _ASM_STACKFRAME_H */