13ebdd119Saurel32 /*
23ebdd119Saurel32 NetWinder Floating Point Emulator
33ebdd119Saurel32 (c) Rebel.com, 1998-1999
43ebdd119Saurel32
53ebdd119Saurel32 Direct questions, comments to Scott Bambrough <scottb@netwinder.org>
63ebdd119Saurel32
73ebdd119Saurel32 This program is free software; you can redistribute it and/or modify
83ebdd119Saurel32 it under the terms of the GNU General Public License as published by
93ebdd119Saurel32 the Free Software Foundation; either version 2 of the License, or
103ebdd119Saurel32 (at your option) any later version.
113ebdd119Saurel32
123ebdd119Saurel32 This program is distributed in the hope that it will be useful,
133ebdd119Saurel32 but WITHOUT ANY WARRANTY; without even the implied warranty of
143ebdd119Saurel32 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
153ebdd119Saurel32 GNU General Public License for more details.
163ebdd119Saurel32
173ebdd119Saurel32 You should have received a copy of the GNU General Public License
1870539e18SBlue Swirl along with this program; if not, see <http://www.gnu.org/licenses/>.
193ebdd119Saurel32 */
203ebdd119Saurel32
21*2a6a4076SMarkus Armbruster #ifndef FPA11_H
22*2a6a4076SMarkus Armbruster #define FPA11_H
233ebdd119Saurel32
24a9c94277SMarkus Armbruster #include "cpu.h"
253ebdd119Saurel32
263ebdd119Saurel32 #define GET_FPA11() (qemufpa)
273ebdd119Saurel32
283ebdd119Saurel32 /*
293ebdd119Saurel32 * The processes registers are always at the very top of the 8K
303ebdd119Saurel32 * stack+task struct. Use the same method as 'current' uses to
313ebdd119Saurel32 * reach them.
323ebdd119Saurel32 */
333ebdd119Saurel32 extern CPUARMState *user_registers;
343ebdd119Saurel32
353ebdd119Saurel32 #define GET_USERREG() (user_registers)
363ebdd119Saurel32
373ebdd119Saurel32 /* Need task_struct */
383ebdd119Saurel32 //#include <linux/sched.h>
393ebdd119Saurel32
403ebdd119Saurel32 /* includes */
413ebdd119Saurel32 #include "fpsr.h" /* FP control and status register definitions */
426b4c305cSPaolo Bonzini #include "fpu/softfloat.h"
433ebdd119Saurel32
443ebdd119Saurel32 #define typeNone 0x00
453ebdd119Saurel32 #define typeSingle 0x01
463ebdd119Saurel32 #define typeDouble 0x02
473ebdd119Saurel32 #define typeExtended 0x03
483ebdd119Saurel32
493ebdd119Saurel32 /*
503ebdd119Saurel32 * This must be no more and no less than 12 bytes.
513ebdd119Saurel32 */
523ebdd119Saurel32 typedef union tagFPREG {
533ebdd119Saurel32 floatx80 fExtended;
543ebdd119Saurel32 float64 fDouble;
553ebdd119Saurel32 float32 fSingle;
563ebdd119Saurel32 } FPREG;
573ebdd119Saurel32
583ebdd119Saurel32 /*
593ebdd119Saurel32 * FPA11 device model.
603ebdd119Saurel32 *
613ebdd119Saurel32 * This structure is exported to user space. Do not re-order.
623ebdd119Saurel32 * Only add new stuff to the end, and do not change the size of
633ebdd119Saurel32 * any element. Elements of this structure are used by user
643ebdd119Saurel32 * space, and must match struct user_fp in include/asm-arm/user.h.
653ebdd119Saurel32 * We include the byte offsets below for documentation purposes.
663ebdd119Saurel32 *
673ebdd119Saurel32 * The size of this structure and FPREG are checked by fpmodule.c
683ebdd119Saurel32 * on initialisation. If the rules have been broken, NWFPE will
693ebdd119Saurel32 * not initialise.
703ebdd119Saurel32 */
713ebdd119Saurel32 typedef struct tagFPA11 {
723ebdd119Saurel32 /* 0 */ FPREG fpreg[8]; /* 8 floating point registers */
733ebdd119Saurel32 /* 96 */ FPSR fpsr; /* floating point status register */
743ebdd119Saurel32 /* 100 */ FPCR fpcr; /* floating point control register */
753ebdd119Saurel32 /* 104 */ unsigned char fType[8]; /* type of floating point value held in
763ebdd119Saurel32 floating point registers. One of none
773ebdd119Saurel32 single, double or extended. */
783ebdd119Saurel32 /* 112 */ int initflag; /* this is special. The kernel guarantees
793ebdd119Saurel32 to set it to 0 when a thread is launched,
803ebdd119Saurel32 so we can use it to detect whether this
813ebdd119Saurel32 instance of the emulator needs to be
823ebdd119Saurel32 initialised. */
833ebdd119Saurel32 float_status fp_status; /* QEMU float emulator status */
843ebdd119Saurel32 } FPA11;
853ebdd119Saurel32
863ebdd119Saurel32 extern FPA11* qemufpa;
873ebdd119Saurel32
8864b85a8fSBlue Swirl void resetFPA11(void);
8964b85a8fSBlue Swirl void SetRoundingMode(const unsigned int);
9064b85a8fSBlue Swirl void SetRoundingPrecision(const unsigned int);
913ebdd119Saurel32
readRegister(unsigned int reg)923ebdd119Saurel32 static inline unsigned int readRegister(unsigned int reg)
933ebdd119Saurel32 {
943ebdd119Saurel32 return (user_registers->regs[(reg)]);
953ebdd119Saurel32 }
963ebdd119Saurel32
writeRegister(unsigned int x,unsigned int y)973ebdd119Saurel32 static inline void writeRegister(unsigned int x, unsigned int y)
983ebdd119Saurel32 {
993ebdd119Saurel32 #if 0
1003ebdd119Saurel32 printf("writing %d to r%d\n",y,x);
1013ebdd119Saurel32 #endif
1023ebdd119Saurel32 user_registers->regs[(x)]=(y);
1033ebdd119Saurel32 }
1043ebdd119Saurel32
writeConditionCodes(unsigned int x)1053ebdd119Saurel32 static inline void writeConditionCodes(unsigned int x)
1063ebdd119Saurel32 {
10750866ba5SPeter Maydell cpsr_write(user_registers, x, CPSR_NZCV, CPSRWriteByInstr);
1083ebdd119Saurel32 }
1093ebdd119Saurel32
1107cb4db8fSPeter Maydell #define ARM_REG_PC 15
1113ebdd119Saurel32
1123ebdd119Saurel32 unsigned int EmulateAll(unsigned int opcode, FPA11* qfpa, CPUARMState* qregs);
1133ebdd119Saurel32
11465a650c2SPaul Brook unsigned int EmulateCPDO(const unsigned int);
11565a650c2SPaul Brook unsigned int EmulateCPDT(const unsigned int);
11665a650c2SPaul Brook unsigned int EmulateCPRT(const unsigned int);
11765a650c2SPaul Brook
11865a650c2SPaul Brook unsigned int SingleCPDO(const unsigned int opcode);
11965a650c2SPaul Brook unsigned int DoubleCPDO(const unsigned int opcode);
12065a650c2SPaul Brook unsigned int ExtendedCPDO(const unsigned int opcode);
12165a650c2SPaul Brook
12265a650c2SPaul Brook
1233ebdd119Saurel32 /* included only for get_user/put_user macros */
1243ebdd119Saurel32 #include "qemu.h"
1253ebdd119Saurel32
1263ebdd119Saurel32 #endif
127