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, 1998, 1999, 2002, 2003 Ralf Baechle
7 * Copyright (C) 1996 David S. Miller (davem@davemloft.net)
8 * Copyright (C) 1994, 1995, 1996, by Andreas Busse
9 * Copyright (C) 1999 Silicon Graphics, Inc.
10 * Copyright (C) 2000 MIPS Technologies, Inc.
11 * written by Carsten Langgaard, carstenl@mips.com
14 #include <asm/cachectl.h>
15 #include <asm/fpregdef.h>
16 #include <asm/mipsregs.h>
17 #include <asm/asm-offsets.h>
18 #include <asm/pgtable-bits.h>
19 #include <asm/regdef.h>
20 #include <asm/stackframe.h>
21 #include <asm/thread_info.h>
23 #include <asm/asmmacro.h>
25 /* preprocessor replaces the fp in ".set fp=64" with $30 otherwise */
29 * Offset to the current process status flags, the first 32 bytes of the
32 #define ST_OFF (_THREAD_SIZE - 32 - PT_SIZE + PT_STATUS)
34 #ifndef USE_ALTERNATE_RESUME_IMPL
36 * task_struct *resume(task_struct *prev, task_struct *next,
37 * struct thread_info *next_ti)
42 LONG_S t1, THREAD_STATUS(a0)
43 cpu_save_nonscratch a0
44 LONG_S ra, THREAD_REG31(a0)
46 #if defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_SMP)
47 PTR_LA t8, __stack_chk_guard
48 LONG_L t9, TASK_STACK_CANARY(a1)
53 * The order of restoring the registers takes care of the race
54 * updating $28, $29 and kernelsp without disabling ints.
57 cpu_restore_nonscratch a1
59 PTR_ADDU t0, $28, _THREAD_SIZE - 32
60 set_saved_sp t0, t1, t2
61 mfc0 t1, CP0_STATUS /* Do we really need this? */
64 LONG_L a2, THREAD_STATUS(a1)
73 #endif /* USE_ALTERNATE_RESUME_IMPL */
76 * Save a thread's fp context.
79 #if defined(CONFIG_64BIT) || defined(CONFIG_CPU_MIPS32_R2) || \
80 defined(CONFIG_CPU_MIPS32_R6)
83 fpu_save_double a0 t0 t1 # clobbers t1
88 * Restore a thread's fp context.
91 #if defined(CONFIG_64BIT) || defined(CONFIG_CPU_MIPS32_R2) || \
92 defined(CONFIG_CPU_MIPS32_R6)
95 fpu_restore_double a0 t0 t1 # clobbers t1
99 #ifdef CONFIG_CPU_HAS_MSA
102 * Save a thread's MSA vector context.
110 * Restore a thread's MSA vector context.
117 LEAF(_init_msa_upper)
125 * Load the FPU with signalling NANS. This bit pattern we're using has
126 * the property that no matter whether considered as single or as double
127 * precision represents signaling NANS.
129 * The value to initialize fcr31 to comes in $a0.
148 bgez t0, 1f # 16 / 32 register mode?
169 #ifdef CONFIG_CPU_MIPS32
203 #if defined(CONFIG_CPU_MIPS32_R2) || defined(CONFIG_CPU_MIPS32_R6)
205 .set MIPS_ISA_LEVEL_RAW
207 sll t0, t0, 5 # is Status.FR set?
208 bgez t0, 1f # no: skip setting upper 32b
243 #endif /* CONFIG_CPU_MIPS32_R2 || CONFIG_CPU_MIPS32_R6 */
245 .set MIPS_ISA_ARCH_LEVEL_RAW
266 .set pop /* SET_HARDFLOAT */