| 1 | /* |
| 2 | NetWinder Floating Point Emulator |
| 3 | (c) Rebel.com, 1998-1999 |
| 4 | |
| 5 | Direct questions, comments to Scott Bambrough <scottb@netwinder.org> |
| 6 | |
| 7 | This program is free software; you can redistribute it and/or modify |
| 8 | it under the terms of the GNU General Public License as published by |
| 9 | the Free Software Foundation; either version 2 of the License, or |
| 10 | (at your option) any later version. |
| 11 | |
| 12 | This program is distributed in the hope that it will be useful, |
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | GNU General Public License for more details. |
| 16 | |
| 17 | You should have received a copy of the GNU General Public License |
| 18 | along with this program; if not, see <http://www.gnu.org/licenses/>. |
| 19 | */ |
| 20 | |
| 21 | #ifndef FPA11_H |
| 22 | #define FPA11_H |
| 23 | |
| 24 | #include "cpu.h" |
| 25 | |
| 26 | #define GET_FPA11() (qemufpa) |
| 27 | |
| 28 | /* Need task_struct */ |
| 29 | //#include <linux/sched.h> |
| 30 | |
| 31 | /* includes */ |
| 32 | #include "fpsr.h" /* FP control and status register definitions */ |
| 33 | #include "fpu/softfloat.h" |
| 34 | |
| 35 | #define typeNone 0x00 |
| 36 | #define typeSingle 0x01 |
| 37 | #define typeDouble 0x02 |
| 38 | #define typeExtended 0x03 |
| 39 | |
| 40 | /* |
| 41 | * This must be no more and no less than 12 bytes. |
| 42 | */ |
| 43 | typedef union tagFPREG { |
| 44 | floatx80 fExtended; |
| 45 | float64 fDouble; |
| 46 | float32 fSingle; |
| 47 | } FPREG; |
| 48 | |
| 49 | /* |
| 50 | * FPA11 device model. |
| 51 | * |
| 52 | * This structure is exported to user space. Do not re-order. |
| 53 | * Only add new stuff to the end, and do not change the size of |
| 54 | * any element. Elements of this structure are used by user |
| 55 | * space, and must match struct user_fp in include/asm-arm/user.h. |
| 56 | * We include the byte offsets below for documentation purposes. |
| 57 | * |
| 58 | * The size of this structure and FPREG are checked by fpmodule.c |
| 59 | * on initialisation. If the rules have been broken, NWFPE will |
| 60 | * not initialise. |
| 61 | */ |
| 62 | typedef struct tagFPA11 { |
| 63 | /* 0 */ FPREG fpreg[8]; /* 8 floating point registers */ |
| 64 | /* 96 */ FPSR fpsr; /* floating point status register */ |
| 65 | /* 100 */ FPCR fpcr; /* floating point control register */ |
| 66 | /* 104 */ unsigned char fType[8]; /* type of floating point value held in |
| 67 | floating point registers. One of none |
| 68 | single, double or extended. */ |
| 69 | /* 112 */ int initflag; /* this is special. The kernel guarantees |
| 70 | to set it to 0 when a thread is launched, |
| 71 | so we can use it to detect whether this |
| 72 | instance of the emulator needs to be |
| 73 | initialised. */ |
| 74 | float_status fp_status; /* QEMU float emulator status */ |
| 75 | } FPA11; |
| 76 | |
| 77 | extern __thread FPA11* qemufpa; |
| 78 | |
| 79 | void resetFPA11(void); |
| 80 | void SetRoundingMode(const unsigned int); |
| 81 | void SetRoundingPrecision(const unsigned int); |
| 82 | |
| 83 | static inline unsigned int readRegister(unsigned int reg) |
| 84 | { |
| 85 | CPUARMState *env = cpu_env(current_cpu); |
| 86 | return env->regs[reg]; |
| 87 | } |
| 88 | |
| 89 | static inline void writeRegister(unsigned int x, unsigned int y) |
| 90 | { |
| 91 | CPUARMState *env = cpu_env(current_cpu); |
| 92 | env->regs[x] = y; |
| 93 | } |
| 94 | |
| 95 | static inline void writeConditionCodes(unsigned int x) |
| 96 | { |
| 97 | CPUARMState *env = cpu_env(current_cpu); |
| 98 | cpsr_write(env, x, CPSR_NZCV, CPSRWriteByInstr); |
| 99 | } |
| 100 | |
| 101 | #define ARM_REG_PC 15 |
| 102 | |
| 103 | unsigned int EmulateAll(unsigned int opcode, FPA11* qfpa); |
| 104 | |
| 105 | unsigned int EmulateCPDO(const unsigned int); |
| 106 | unsigned int EmulateCPDT(const unsigned int); |
| 107 | unsigned int EmulateCPRT(const unsigned int); |
| 108 | |
| 109 | unsigned int SingleCPDO(const unsigned int opcode); |
| 110 | unsigned int DoubleCPDO(const unsigned int opcode); |
| 111 | unsigned int ExtendedCPDO(const unsigned int opcode); |
| 112 | |
| 113 | |
| 114 | /* included only for get_user/put_user macros */ |
| 115 | #include "qemu.h" |
| 116 | |
| 117 | #endif |