Path: blob/master/arch/mips/math-emu/kernel_linkage.c
10817 views
/*1* Kevin D. Kissell, kevink@mips and Carsten Langgaard, [email protected]2* Copyright (C) 2000 MIPS Technologies, Inc. All rights reserved.3*4* This program is free software; you can distribute it and/or modify it5* under the terms of the GNU General Public License (Version 2) as6* published by the Free Software Foundation.7*8* This program is distributed in the hope it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* for more details.12*13* You should have received a copy of the GNU General Public License along14* with this program; if not, write to the Free Software Foundation, Inc.,15* 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.16*17* Routines corresponding to Linux kernel FP context18* manipulation primitives for the Algorithmics MIPS19* FPU Emulator20*/21#include <linux/sched.h>22#include <asm/processor.h>23#include <asm/signal.h>24#include <asm/uaccess.h>2526#include <asm/fpu.h>27#include <asm/fpu_emulator.h>2829#define SIGNALLING_NAN 0x7ff800007ff80000LL3031void fpu_emulator_init_fpu(void)32{33static int first = 1;34int i;3536if (first) {37first = 0;38printk("Algorithmics/MIPS FPU Emulator v1.5\n");39}4041current->thread.fpu.fcr31 = 0;42for (i = 0; i < 32; i++) {43current->thread.fpu.fpr[i] = SIGNALLING_NAN;44}45}464748/*49* Emulator context save/restore to/from a signal context50* presumed to be on the user stack, and therefore accessed51* with appropriate macros from uaccess.h52*/5354int fpu_emulator_save_context(struct sigcontext __user *sc)55{56int i;57int err = 0;5859for (i = 0; i < 32; i++) {60err |=61__put_user(current->thread.fpu.fpr[i], &sc->sc_fpregs[i]);62}63err |= __put_user(current->thread.fpu.fcr31, &sc->sc_fpc_csr);6465return err;66}6768int fpu_emulator_restore_context(struct sigcontext __user *sc)69{70int i;71int err = 0;7273for (i = 0; i < 32; i++) {74err |=75__get_user(current->thread.fpu.fpr[i], &sc->sc_fpregs[i]);76}77err |= __get_user(current->thread.fpu.fcr31, &sc->sc_fpc_csr);7879return err;80}8182#ifdef CONFIG_64BIT83/*84* This is the o32 version85*/8687int fpu_emulator_save_context32(struct sigcontext32 __user *sc)88{89int i;90int err = 0;9192for (i = 0; i < 32; i+=2) {93err |=94__put_user(current->thread.fpu.fpr[i], &sc->sc_fpregs[i]);95}96err |= __put_user(current->thread.fpu.fcr31, &sc->sc_fpc_csr);9798return err;99}100101int fpu_emulator_restore_context32(struct sigcontext32 __user *sc)102{103int i;104int err = 0;105106for (i = 0; i < 32; i+=2) {107err |=108__get_user(current->thread.fpu.fpr[i], &sc->sc_fpregs[i]);109}110err |= __get_user(current->thread.fpu.fcr31, &sc->sc_fpc_csr);111112return err;113}114#endif115116117