Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
[linux/fpc-iii.git] / arch / mips / math-emu / kernel_linkage.c
blob3aeae07ed5b8db9eef5f697b93ebcef3e6856cf3
1 /*
2 * Kevin D. Kissell, kevink@mips and Carsten Langgaard, carstenl@mips.com
3 * Copyright (C) 2000 MIPS Technologies, Inc. All rights reserved.
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.
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.
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.
18 * Routines corresponding to Linux kernel FP context
19 * manipulation primitives for the Algorithmics MIPS
20 * FPU Emulator
22 #include <linux/sched.h>
23 #include <asm/processor.h>
24 #include <asm/signal.h>
25 #include <asm/uaccess.h>
27 #include <asm/fpu.h>
28 #include <asm/fpu_emulator.h>
30 #define SIGNALLING_NAN 0x7ff800007ff80000LL
32 void fpu_emulator_init_fpu(void)
34 static int first = 1;
35 int i;
37 if (first) {
38 first = 0;
39 printk("Algorithmics/MIPS FPU Emulator v1.5\n");
42 current->thread.fpu.fcr31 = 0;
43 for (i = 0; i < 32; i++) {
44 current->thread.fpu.fpr[i] = SIGNALLING_NAN;
50 * Emulator context save/restore to/from a signal context
51 * presumed to be on the user stack, and therefore accessed
52 * with appropriate macros from uaccess.h
55 int fpu_emulator_save_context(struct sigcontext __user *sc)
57 int i;
58 int err = 0;
60 for (i = 0; i < 32; i++) {
61 err |=
62 __put_user(current->thread.fpu.fpr[i], &sc->sc_fpregs[i]);
64 err |= __put_user(current->thread.fpu.fcr31, &sc->sc_fpc_csr);
66 return err;
69 int fpu_emulator_restore_context(struct sigcontext __user *sc)
71 int i;
72 int err = 0;
74 for (i = 0; i < 32; i++) {
75 err |=
76 __get_user(current->thread.fpu.fpr[i], &sc->sc_fpregs[i]);
78 err |= __get_user(current->thread.fpu.fcr31, &sc->sc_fpc_csr);
80 return err;
83 #ifdef CONFIG_64BIT
85 * This is the o32 version
88 int fpu_emulator_save_context32(struct sigcontext32 __user *sc)
90 int i;
91 int err = 0;
92 int inc = test_thread_flag(TIF_32BIT_FPREGS) ? 2 : 1;
94 for (i = 0; i < 32; i += inc) {
95 err |=
96 __put_user(current->thread.fpu.fpr[i], &sc->sc_fpregs[i]);
98 err |= __put_user(current->thread.fpu.fcr31, &sc->sc_fpc_csr);
100 return err;
103 int fpu_emulator_restore_context32(struct sigcontext32 __user *sc)
105 int i;
106 int err = 0;
107 int inc = test_thread_flag(TIF_32BIT_FPREGS) ? 2 : 1;
109 for (i = 0; i < 32; i += inc) {
110 err |=
111 __get_user(current->thread.fpu.fpr[i], &sc->sc_fpregs[i]);
113 err |= __get_user(current->thread.fpu.fcr31, &sc->sc_fpc_csr);
115 return err;
117 #endif