1 /**************************************************************************
3 * arch/mips/math_emu/kernel_linkage.c
5 * Kevin D. Kissell, kevink@mips and Carsten Langgaard, carstenl@mips.com
6 * Copyright (C) 2000 MIPS Technologies, Inc. All rights reserved.
8 * ########################################################################
10 * This program is free software; you can distribute it and/or modify it
11 * under the terms of the GNU General Public License (Version 2) as
12 * published by the Free Software Foundation.
14 * This program is distributed in the hope it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
23 * Routines corresponding to Linux kernel FP context
24 * manipulation primitives for the Algorithmics MIPS
27 #include <linux/sched.h>
28 #include <asm/processor.h>
29 #include <asm/signal.h>
30 #include <asm/uaccess.h>
32 #include <asm/fpu_emulator.h>
34 extern struct mips_fpu_emulator_private fpuemuprivate;
36 #define SIGNALLING_NAN 0x7ff800007ff80000LL
38 void fpu_emulator_init_fpu(void)
45 printk("Algorithmics/MIPS FPU Emulator v1.5\n");
48 current->thread.fpu.soft.sr = 0;
49 for (i = 0; i < 32; i++) {
50 current->thread.fpu.soft.regs[i] = SIGNALLING_NAN;
56 * Emulator context save/restore to/from a signal context
57 * presumed to be on the user stack, and therefore accessed
58 * with appropriate macros from uaccess.h
61 int fpu_emulator_save_context(struct sigcontext *sc)
66 for (i = 0; i < 32; i++) {
68 __put_user(current->thread.fpu.soft.regs[i],
71 err |= __put_user(current->thread.fpu.soft.sr, &sc->sc_fpc_csr);
72 err |= __put_user(fpuemuprivate.eir, &sc->sc_fpc_eir);
77 int fpu_emulator_restore_context(struct sigcontext *sc)
82 for (i = 0; i < 32; i++) {
84 __get_user(current->thread.fpu.soft.regs[i],
87 err |= __get_user(current->thread.fpu.soft.sr, &sc->sc_fpc_csr);
88 err |= __get_user(fpuemuprivate.eir, &sc->sc_fpc_eir);
95 * This is the o32 version
98 int fpu_emulator_save_context32(struct sigcontext32 *sc)
103 for (i = 0; i < 32; i+=2) {
105 __put_user(current->thread.fpu.soft.regs[i],
108 err |= __put_user(current->thread.fpu.soft.sr, &sc->sc_fpc_csr);
109 err |= __put_user(fpuemuprivate.eir, &sc->sc_fpc_eir);
114 int fpu_emulator_restore_context32(struct sigcontext32 *sc)
119 for (i = 0; i < 32; i+=2) {
121 __get_user(current->thread.fpu.soft.regs[i],
124 err |= __get_user(current->thread.fpu.soft.sr, &sc->sc_fpc_csr);
125 err |= __get_user(fpuemuprivate.eir, &sc->sc_fpc_eir);