1 /* $Id: r2300_switch.S,v 1.8 1999/08/18 23:37:44 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/mipsregs.h>
20 #include <asm/offset.h>
22 #include <asm/pgtable.h>
23 #include <asm/processor.h>
24 #include <asm/regdef.h>
25 #include <asm/stackframe.h>
27 #include <asm/asmmacro.h>
33 * task_struct *r4xx0_resume(task_struct *prev,
40 sw t1, THREAD_STATUS(a0)
41 CPU_SAVE_NONSCRATCH(a0)
42 sw ra, THREAD_REG31(a0)
45 * The order of restoring the registers takes care of the race
46 * updating $28, $29 and kernelsp without disabling ints.
49 CPU_RESTORE_NONSCRATCH($28)
50 addiu t0, $28, KERNEL_STACK_SIZE-32
52 mfc0 t1, CP0_STATUS /* Do we really need this? */
55 lw a2, THREAD_STATUS($28)
65 * Do lazy fpu context switch. Saves FPU context to the process in a0
66 * and loads the new context of the current process.
69 #define ST_OFF (KERNEL_STACK_SIZE - 32 - PT_SIZE + PT_STATUS)
72 mfc0 t0, CP0_STATUS # enable cp1
77 beqz a0, 2f # Save floating point state
80 lw t1, ST_OFF(a0) # last thread looses fpu
84 swc1 $f0, (THREAD_FPU + 0x00)(a0)
85 FPU_SAVE_SINGLE(a0, t1) # clobbers t1
88 lwc1 $f0, (THREAD_FPU + 0x00)($28)
90 FPU_RESTORE_SINGLE($28, t0) # clobbers t0
95 * Save a thread's fp context.
99 FPU_SAVE_SINGLE(a0, t1) # clobbers t1
101 swc1 $f0, (THREAD_FPU + 0x00)(a0)
105 * Load the FPU with signalling NANS. This bit pattern we're using has
106 * the property that no matter wether considered as single or as double
107 * precission represents signaling NANS.
109 * We initialize fcr31 to rounding to nearest, no exceptions.
112 #define FPU_DEFAULT 0x00000000