aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/math-emu/kernel_linkage.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/mips/math-emu/kernel_linkage.c')
-rw-r--r--arch/mips/math-emu/kernel_linkage.c125
1 files changed, 125 insertions, 0 deletions
diff --git a/arch/mips/math-emu/kernel_linkage.c b/arch/mips/math-emu/kernel_linkage.c
new file mode 100644
index 000000000000..04397fec30fc
--- /dev/null
+++ b/arch/mips/math-emu/kernel_linkage.c
@@ -0,0 +1,125 @@
1/*
2 * Kevin D. Kissell, kevink@mips and Carsten Langgaard, carstenl@mips.com
3 * Copyright (C) 2000 MIPS Technologies, Inc. All rights reserved.
4 *
5 * This program is free software; you can distribute it and/or modify it
6 * under the terms of the GNU General Public License (Version 2) as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
17 *
18 * Routines corresponding to Linux kernel FP context
19 * manipulation primitives for the Algorithmics MIPS
20 * FPU Emulator
21 */
22#include <linux/config.h>
23#include <linux/sched.h>
24#include <asm/processor.h>
25#include <asm/signal.h>
26#include <asm/uaccess.h>
27
28#include <asm/fpu_emulator.h>
29
30extern struct mips_fpu_emulator_private fpuemuprivate;
31
32#define SIGNALLING_NAN 0x7ff800007ff80000LL
33
34void fpu_emulator_init_fpu(void)
35{
36 static int first = 1;
37 int i;
38
39 if (first) {
40 first = 0;
41 printk("Algorithmics/MIPS FPU Emulator v1.5\n");
42 }
43
44 current->thread.fpu.soft.fcr31 = 0;
45 for (i = 0; i < 32; i++) {
46 current->thread.fpu.soft.fpr[i] = SIGNALLING_NAN;
47 }
48}
49
50
51/*
52 * Emulator context save/restore to/from a signal context
53 * presumed to be on the user stack, and therefore accessed
54 * with appropriate macros from uaccess.h
55 */
56
57int fpu_emulator_save_context(struct sigcontext *sc)
58{
59 int i;
60 int err = 0;
61
62 for (i = 0; i < 32; i++) {
63 err |=
64 __put_user(current->thread.fpu.soft.fpr[i],
65 &sc->sc_fpregs[i]);
66 }
67 err |= __put_user(current->thread.fpu.soft.fcr31, &sc->sc_fpc_csr);
68 err |= __put_user(fpuemuprivate.eir, &sc->sc_fpc_eir);
69
70 return err;
71}
72
73int fpu_emulator_restore_context(struct sigcontext *sc)
74{
75 int i;
76 int err = 0;
77
78 for (i = 0; i < 32; i++) {
79 err |=
80 __get_user(current->thread.fpu.soft.fpr[i],
81 &sc->sc_fpregs[i]);
82 }
83 err |= __get_user(current->thread.fpu.soft.fcr31, &sc->sc_fpc_csr);
84 err |= __get_user(fpuemuprivate.eir, &sc->sc_fpc_eir);
85
86 return err;
87}
88
89#ifdef CONFIG_MIPS64
90/*
91 * This is the o32 version
92 */
93
94int fpu_emulator_save_context32(struct sigcontext32 *sc)
95{
96 int i;
97 int err = 0;
98
99 for (i = 0; i < 32; i+=2) {
100 err |=
101 __put_user(current->thread.fpu.soft.fpr[i],
102 &sc->sc_fpregs[i]);
103 }
104 err |= __put_user(current->thread.fpu.soft.fcr31, &sc->sc_fpc_csr);
105 err |= __put_user(fpuemuprivate.eir, &sc->sc_fpc_eir);
106
107 return err;
108}
109
110int fpu_emulator_restore_context32(struct sigcontext32 *sc)
111{
112 int i;
113 int err = 0;
114
115 for (i = 0; i < 32; i+=2) {
116 err |=
117 __get_user(current->thread.fpu.soft.fpr[i],
118 &sc->sc_fpregs[i]);
119 }
120 err |= __get_user(current->thread.fpu.soft.fcr31, &sc->sc_fpc_csr);
121 err |= __get_user(fpuemuprivate.eir, &sc->sc_fpc_eir);
122
123 return err;
124}
125#endif