1 /* $Id: r4k_switch.S,v 1.4 1998/07/14 09:15:33 ralf Exp $
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
7 * Copyright (C) 1994, 1995, 1996, 1998 by Ralf Baechle
8 * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com)
9 * Copyright (C) 1994, 1995, 1996, by Andreas Busse
12 #include <asm/bootinfo.h>
13 #include <asm/cachectl.h>
14 #include <asm/current.h>
15 #include <asm/fpregdef.h>
16 #include <asm/mipsconfig.h>
17 #include <asm/mipsregs.h>
18 #include <asm/offset.h>
20 #include <asm/pgtable.h>
21 #include <asm/processor.h>
22 #include <asm/regdef.h>
23 #include <asm/stackframe.h>
25 #include <asm/asmmacro.h>
32 sw t1, THREAD_STATUS($28)
33 CPU_SAVE_NONSCRATCH($28)
34 sw ra, THREAD_REG31($28)
37 * The order of restoring the registers takes care of the race
38 * updating $28, $29 and kernelsp without disabling ints.
41 CPU_RESTORE_NONSCRATCH($28)
42 addiu t0, $28, KERNEL_STACK_SIZE-32
45 lw a2, THREAD_STATUS($28)
54 * Do lazy fpu context switch. Saves FPU context to the process in a0
55 * and loads the new context of the current process.
58 #define ST_OFF (KERNEL_STACK_SIZE - 32 - PT_SIZE + PT_STATUS)
60 LEAF(r4xx0_lazy_fpu_switch)
61 mfc0 t0, CP0_STATUS # enable cp1
66 beqz a0, 2f # Save floating point state
68 lw t1, ST_OFF(a0) # last thread looses fpu
73 sdc1 $f0, (THREAD_FPU + 0x00)(a0)
76 FPU_SAVE_16EVEN(a0, t1) # clobbers t1
79 sll t0, t0, 5 # load new fp state
81 ldc1 $f0, (THREAD_FPU + 0x00)($28)
82 FPU_RESTORE_16ODD($28)
85 FPU_RESTORE_16EVEN($28, t0) # clobbers t0
87 END(r4xx0_lazy_fpu_switch)
90 * Save a thread's fp context.
96 bgez t1, 1f # 16 register mode?
100 FPU_SAVE_16EVEN(a0, t1) # clobbers t1
102 sdc1 $f0, (THREAD_FPU + 0x00)(a0)
106 * Load the FPU with signalling NANS. This bit pattern we're using has
107 * the property that no matter wether considered as single or as double
108 * precission represents signaling NANS.
110 * We initialize fcr31 to rounding to nearest, no exceptions.
113 #define FPU_DEFAULT 0x00000000
125 bgez t0, 1f # 16 / 32 register mode?