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/regdef.h>
19 #include <asm/stackframe.h>
20 #include <asm/thread_info.h>
22 #include <asm/asmmacro.h>
24 /* preprocessor replaces the fp in ".set fp=64" with $30 otherwise */
28 * Offset to the current process status flags, the first 32 bytes of the
31 #define ST_OFF (_THREAD_SIZE - 32 - PT_SIZE + PT_STATUS)
33 #ifndef USE_ALTERNATE_RESUME_IMPL
35 * task_struct *resume(task_struct *prev, task_struct *next,
36 * struct thread_info *next_ti)
41 LONG_S t1, THREAD_STATUS(a0)
42 cpu_save_nonscratch a0
43 LONG_S ra, THREAD_REG31(a0)
45 #if defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_SMP)
46 PTR_LA t8, __stack_chk_guard
47 LONG_L t9, TASK_STACK_CANARY(a1)
52 * The order of restoring the registers takes care of the race
53 * updating $28, $29 and kernelsp without disabling ints.
56 cpu_restore_nonscratch a1
58 PTR_ADDU t0, $28, _THREAD_SIZE - 32
59 set_saved_sp t0, t1, t2
60 mfc0 t1, CP0_STATUS /* Do we really need this? */
63 LONG_L a2, THREAD_STATUS(a1)
72 #endif /* USE_ALTERNATE_RESUME_IMPL */
75 * Save a thread's fp context.
78 #if defined(CONFIG_64BIT) || defined(CONFIG_CPU_MIPS32_R2) || \
79 defined(CONFIG_CPU_MIPS32_R6)
82 fpu_save_double a0 t0 t1 # clobbers t1
87 * Restore a thread's fp context.
90 #if defined(CONFIG_64BIT) || defined(CONFIG_CPU_MIPS32_R2) || \
91 defined(CONFIG_CPU_MIPS32_R6)
94 fpu_restore_double a0 t0 t1 # clobbers t1
98 #ifdef CONFIG_CPU_HAS_MSA
101 * Save a thread's MSA vector context.
109 * Restore a thread's MSA vector context.
116 LEAF(_init_msa_upper)
124 * Load the FPU with signalling NANS. This bit pattern we're using has
125 * the property that no matter whether considered as single or as double
126 * precision represents signaling NANS.
128 * The value to initialize fcr31 to comes in $a0.
147 bgez t0, 1f # 16 / 32 register mode?
168 #ifdef CONFIG_CPU_MIPS32
202 #if defined(CONFIG_CPU_MIPS32_R2) || defined(CONFIG_CPU_MIPS32_R6)
204 .set MIPS_ISA_LEVEL_RAW
206 sll t0, t0, 5 # is Status.FR set?
207 bgez t0, 1f # no: skip setting upper 32b
242 #endif /* CONFIG_CPU_MIPS32_R2 || CONFIG_CPU_MIPS32_R6 */
244 .set MIPS_ISA_ARCH_LEVEL_RAW
265 .set pop /* SET_HARDFLOAT */