00001 /* 00002 NetWinder Floating Point Emulator 00003 (c) Rebel.com, 1998-1999 00004 00005 Direct questions, comments to Scott Bambrough <scottb@netwinder.org> 00006 00007 This program is free software; you can redistribute it and/or modify 00008 it under the terms of the GNU General Public License as published by 00009 the Free Software Foundation; either version 2 of the License, or 00010 (at your option) any later version. 00011 00012 This program is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with this program; if not, write to the Free Software 00019 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00020 */ 00021 00022 #ifndef __FPA11_H__ 00023 #define __FPA11_H__ 00024 00025 #include <stdlib.h> 00026 #include <stdio.h> 00027 #include <errno.h> 00028 00029 #include <cpu.h> 00030 00031 #define GET_FPA11() (qemufpa) 00032 00033 /* 00034 * The processes registers are always at the very top of the 8K 00035 * stack+task struct. Use the same method as 'current' uses to 00036 * reach them. 00037 */ 00038 extern CPUARMState *user_registers; 00039 00040 #define GET_USERREG() (user_registers) 00041 00042 /* Need task_struct */ 00043 //#include <linux/sched.h> 00044 00045 /* includes */ 00046 #include "fpsr.h" /* FP control and status register definitions */ 00047 #include "softfloat.h" 00048 00049 #define typeNone 0x00 00050 #define typeSingle 0x01 00051 #define typeDouble 0x02 00052 #define typeExtended 0x03 00053 00054 /* 00055 * This must be no more and no less than 12 bytes. 00056 */ 00057 typedef union tagFPREG { 00058 floatx80 fExtended; 00059 float64 fDouble; 00060 float32 fSingle; 00061 } FPREG; 00062 00063 /* 00064 * FPA11 device model. 00065 * 00066 * This structure is exported to user space. Do not re-order. 00067 * Only add new stuff to the end, and do not change the size of 00068 * any element. Elements of this structure are used by user 00069 * space, and must match struct user_fp in include/asm-arm/user.h. 00070 * We include the byte offsets below for documentation purposes. 00071 * 00072 * The size of this structure and FPREG are checked by fpmodule.c 00073 * on initialisation. If the rules have been broken, NWFPE will 00074 * not initialise. 00075 */ 00076 typedef struct tagFPA11 { 00077 /* 0 */ FPREG fpreg[8]; /* 8 floating point registers */ 00078 /* 96 */ FPSR fpsr; /* floating point status register */ 00079 /* 100 */ FPCR fpcr; /* floating point control register */ 00080 /* 104 */ unsigned char fType[8]; /* type of floating point value held in 00081 floating point registers. One of none 00082 single, double or extended. */ 00083 /* 112 */ int initflag; /* this is special. The kernel guarantees 00084 to set it to 0 when a thread is launched, 00085 so we can use it to detect whether this 00086 instance of the emulator needs to be 00087 initialised. */ 00088 float_status fp_status; /* QEMU float emulator status */ 00089 } FPA11; 00090 00091 extern FPA11* qemufpa; 00092 00093 extern void resetFPA11(void); 00094 extern void SetRoundingMode(const unsigned int); 00095 extern void SetRoundingPrecision(const unsigned int); 00096 00097 static inline unsigned int readRegister(unsigned int reg) 00098 { 00099 return (user_registers->regs[(reg)]); 00100 } 00101 00102 static inline void writeRegister(unsigned int x, unsigned int y) 00103 { 00104 #if 0 00105 printf("writing %d to r%d\n",y,x); 00106 #endif 00107 user_registers->regs[(x)]=(y); 00108 } 00109 00110 static inline void writeConditionCodes(unsigned int x) 00111 { 00112 cpsr_write(user_registers,x,CPSR_NZCV); 00113 } 00114 00115 #define REG_PC 15 00116 00117 unsigned int EmulateAll(unsigned int opcode, FPA11* qfpa, CPUARMState* qregs); 00118 00119 /* included only for get_user/put_user macros */ 00120 #include "qemu.h" 00121 00122 #endif