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, 1995, 1996, 2001 Ralf Baechle
7 * Copyright (C) 1994, 1995, 1996 Paul M. Antoine.
9 #ifndef __ASM_STACKFRAME_H
10 #define __ASM_STACKFRAME_H
12 #include <linux/config.h>
13 #include <asm/addrspace.h>
14 #include <asm/mipsregs.h>
15 #include <asm/processor.h>
17 #include <asm/offset.h>
52 # define GET_SAVED_SP \
53 mfc0 k0, CP0_CONTEXT; \
54 lui k1, %hi(kernelsp); \
58 lw k1, %lo(kernelsp)(k1);
61 # define GET_SAVED_SP \
62 lui k1, %hi(kernelsp); \
63 lw k1, %lo(kernelsp)(k1);
69 mfc0 k0, CP0_STATUS; \
70 sll k0, 3; /* extract cu0 bit */ \
75 /* Called from user mode, new stack. */ \
79 subu sp, k1, PT_SIZE; \
83 mfc0 v1, CP0_STATUS; \
85 sw v1, PT_STATUS(sp); \
89 sw v1, PT_CAUSE(sp); \
97 ori $28, sp, 0x1fff; \
113 #define RESTORE_TEMP \
120 lw $11, PT_R11(sp); \
122 lw $12, PT_R12(sp); \
123 lw $13, PT_R13(sp); \
124 lw $14, PT_R14(sp); \
125 lw $15, PT_R15(sp); \
128 #define RESTORE_STATIC \
129 lw $16, PT_R16(sp); \
130 lw $17, PT_R17(sp); \
131 lw $18, PT_R18(sp); \
132 lw $19, PT_R19(sp); \
133 lw $20, PT_R20(sp); \
134 lw $21, PT_R21(sp); \
135 lw $22, PT_R22(sp); \
136 lw $23, PT_R23(sp); \
139 #if defined(CONFIG_CPU_R3000) || defined(CONFIG_CPU_TX39XX)
141 #define RESTORE_SOME \
144 mfc0 t0, CP0_STATUS; \
148 mtc0 t0, CP0_STATUS; \
151 lw v0, PT_STATUS(sp); \
155 mtc0 v0, CP0_STATUS; \
156 lw $31, PT_R31(sp); \
157 lw $28, PT_R28(sp); \
158 lw $25, PT_R25(sp); \
166 #define RESTORE_SP_AND_RET \
177 #define RESTORE_SOME \
180 mfc0 t0, CP0_STATUS; \
184 mtc0 t0, CP0_STATUS; \
187 lw v0, PT_STATUS(sp); \
191 mtc0 v0, CP0_STATUS; \
194 lw $31, PT_R31(sp); \
195 lw $28, PT_R28(sp); \
196 lw $25, PT_R25(sp); \
204 #define RESTORE_SP_AND_RET \
215 #define RESTORE_ALL \
222 #define RESTORE_ALL_AND_RET \
231 * Move to kernel mode and disable interrupts.
232 * Set cp0 enable bit as sign that we're running on the kernel stack
235 mfc0 t0,CP0_STATUS; \
236 li t1,ST0_CU0|0x1f; \
242 * Move to kernel mode and enable interrupts.
243 * Set cp0 enable bit as sign that we're running on the kernel stack
246 mfc0 t0,CP0_STATUS; \
247 li t1,ST0_CU0|0x1f; \
253 * Just move to kernel mode and leave interrupts as they are.
254 * Set cp0 enable bit as sign that we're running on the kernel stack
257 mfc0 t0,CP0_STATUS; \
258 li t1,ST0_CU0|0x1e; \
263 #endif /* __ASM_STACKFRAME_H */