1 /* $Id: r2300_switch.S,v 1.6 1999/06/13 16:30:32 ralf Exp $
3 * r2300_switch.S: R2300 specific task switching code.
5 * Copyright (C) 1994, 1995, 1996, 1999 by Ralf Baechle
6 * Copyright (C) 1994, 1995, 1996 by Andreas Busse
8 * Multi-cpu abstraction and macros for easier reading:
9 * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com)
11 * Further modifications to make this work:
12 * Copyright (c) 1998 Harald Koerfgen
15 #include <asm/bootinfo.h>
16 #include <asm/cachectl.h>
17 #include <asm/current.h>
18 #include <asm/fpregdef.h>
19 #include <asm/mipsconfig.h>
20 #include <asm/mipsregs.h>
21 #include <asm/offset.h>
23 #include <asm/pgtable.h>
24 #include <asm/processor.h>
25 #include <asm/regdef.h>
26 #include <asm/stackframe.h>
28 #include <asm/asmmacro.h>
34 * task_struct *r4xx0_resume(task_struct *prev,
41 sw t1, THREAD_STATUS(a0)
42 CPU_SAVE_NONSCRATCH(a0)
43 sw ra, THREAD_REG31(a0)
46 * The order of restoring the registers takes care of the race
47 * updating $28, $29 and kernelsp without disabling ints.
50 CPU_RESTORE_NONSCRATCH($28)
51 addiu t0, $28, KERNEL_STACK_SIZE-32
53 mfc0 t1, CP0_STATUS /* Do we really need this? */
56 lw a2, THREAD_STATUS($28)
70 * Do lazy fpu context switch. Saves FPU context to the process in a0
71 * and loads the new context of the current process.
74 #define ST_OFF (KERNEL_STACK_SIZE - 32 - PT_SIZE + PT_STATUS)
76 LEAF(r2300_lazy_fpu_switch)
77 mfc0 t0, CP0_STATUS # enable cp1
82 beqz a0, 2f # Save floating point state
85 lw t1, ST_OFF(a0) # last thread looses fpu
89 swc1 $f0, (THREAD_FPU + 0x00)(a0)
90 FPU_SAVE(a0, t1) # clobbers t1
93 lwc1 $f0, (THREAD_FPU + 0x00)($28)
95 FPU_RESTORE($28, t0) # clobbers t0
97 END(r2300_lazy_fpu_switch)
100 * Save a thread's fp context.
104 FPU_SAVE(a0, t1) # clobbers t1
106 swc1 $f0, (THREAD_FPU + 0x00)(a0)
110 * Load the FPU with signalling NANS. This bit pattern we're using has
111 * the property that no matter wether considered as single or as double
112 * precission represents signaling NANS.
114 * We initialize fcr31 to rounding to nearest, no exceptions.
117 #define FPU_DEFAULT 0x00000000