Ok. I didn't make 2.4.0 in 2000. Tough. I tried, but we had some
[davej-history.git] / arch / mips / kernel / r2300_switch.S
blobc94037a2445aa0f1263e9b8a046321dd98ad0d9a
1 /* $Id: r2300_switch.S,v 1.8 1999/08/18 23:37:44 ralf Exp $
2  *
3  * r2300_switch.S: R2300 specific task switching code.
4  *
5  * Copyright (C) 1994, 1995, 1996, 1999 by Ralf Baechle
6  * Copyright (C) 1994, 1995, 1996 by Andreas Busse
7  *
8  * Multi-cpu abstraction and macros for easier reading:
9  * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com)
10  *
11  * Further modifications to make this work:
12  * Copyright (c) 1998 Harald Koerfgen
13  */
14 #include <asm/asm.h>
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>
21 #include <asm/page.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>
29         .set    mips1
30         .align  5
33  * task_struct *r4xx0_resume(task_struct *prev,
34  *                           task_struct *next)
35  */
36 LEAF(resume)
37         .set    reorder
38         mfc0    t1, CP0_STATUS
39         .set    noreorder
40         sw      t1, THREAD_STATUS(a0)
41         CPU_SAVE_NONSCRATCH(a0)
42         sw      ra, THREAD_REG31(a0)
44         /*
45          * The order of restoring the registers takes care of the race
46          * updating $28, $29 and kernelsp without disabling ints.
47          */
48         move    $28, a1
49         CPU_RESTORE_NONSCRATCH($28)
50         addiu   t0, $28, KERNEL_STACK_SIZE-32
51         sw      t0, kernelsp
52         mfc0    t1, CP0_STATUS          /* Do we really need this? */
53         li      a3, 0xff00
54         and     t1, a3
55         lw      a2, THREAD_STATUS($28)
56         nor     a3, $0, a3
57         and     a2, a3
58         or      a2, t1
59         mtc0    a2, CP0_STATUS
60         jr      ra
61          move   v0, a0
62         END(resume)
65  * Do lazy fpu context switch.  Saves FPU context to the process in a0
66  * and loads the new context of the current process.
67  */
69 #define ST_OFF (KERNEL_STACK_SIZE - 32 - PT_SIZE + PT_STATUS)
71 LEAF(lazy_fpu_switch)
72         mfc0    t0, CP0_STATUS                  # enable cp1
73         li      t3, 0x20000000
74         or      t0, t3
75         mtc0    t0, CP0_STATUS
77         beqz    a0, 2f                          # Save floating point state
78          nor    t3, zero, t3
79         .set    reorder
80         lw      t1, ST_OFF(a0)                  # last thread looses fpu
81         .set    noreorder
82         and     t1, t3
83         sw      t1, ST_OFF(a0)
84         swc1    $f0, (THREAD_FPU + 0x00)(a0)
85         FPU_SAVE_SINGLE(a0, t1)                 # clobbers t1
88         lwc1    $f0, (THREAD_FPU + 0x00)($28)
89         .set    reorder
90         FPU_RESTORE_SINGLE($28, t0)             # clobbers t0
91         jr      ra
92         END(lazy_fpu_switch)
95  * Save a thread's fp context.
96  */
97         .set    noreorder
98 LEAF(save_fp)
99         FPU_SAVE_SINGLE(a0, t1)                 # clobbers t1
100         jr      ra
101          swc1   $f0, (THREAD_FPU + 0x00)(a0)
102         END(save_fp)
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.
110  */
112 #define FPU_DEFAULT  0x00000000
114 LEAF(init_fpu)
115         mfc0    t0, CP0_STATUS
116         li      t1, 0x20000000
117         or      t0, t1
118         mtc0    t0, CP0_STATUS
120         li      t1, FPU_DEFAULT
121         ctc1    t1, fcr31
123         li      t0, -1
125         mtc1    t0, $f0
126         mtc1    t0, $f1
127         mtc1    t0, $f2
128         mtc1    t0, $f3
129         mtc1    t0, $f4
130         mtc1    t0, $f5
131         mtc1    t0, $f6
132         mtc1    t0, $f7
133         mtc1    t0, $f8
134         mtc1    t0, $f9
135         mtc1    t0, $f10
136         mtc1    t0, $f11
137         mtc1    t0, $f12
138         mtc1    t0, $f13
139         mtc1    t0, $f14
140         mtc1    t0, $f15
141         mtc1    t0, $f16
142         mtc1    t0, $f17
143         mtc1    t0, $f18
144         mtc1    t0, $f19
145         mtc1    t0, $f20
146         mtc1    t0, $f21
147         mtc1    t0, $f22
148         mtc1    t0, $f23
149         mtc1    t0, $f24
150         mtc1    t0, $f25
151         mtc1    t0, $f26
152         mtc1    t0, $f27
153         mtc1    t0, $f28
154         mtc1    t0, $f29
155         mtc1    t0, $f30
156         jr      ra
157          mtc1   t0, $f31
158         END(init_fpu)