xref: /openbmc/qemu/linux-user/arm/nwfpe/fpa11.h (revision 7c08eefc)
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 /*
29  * The processes registers are always at the very top of the 8K
30  * stack+task struct.  Use the same method as 'current' uses to
31  * reach them.
32  */
33 extern CPUARMState *user_registers;
34 
35 #define GET_USERREG() (user_registers)
36 
37 /* Need task_struct */
38 //#include <linux/sched.h>
39 
40 /* includes */
41 #include "fpsr.h"		/* FP control and status register definitions */
42 #include "fpu/softfloat.h"
43 
44 #define		typeNone		0x00
45 #define		typeSingle		0x01
46 #define		typeDouble		0x02
47 #define		typeExtended		0x03
48 
49 /*
50  * This must be no more and no less than 12 bytes.
51  */
52 typedef union tagFPREG {
53    floatx80 fExtended;
54    float64  fDouble;
55    float32  fSingle;
56 } FPREG;
57 
58 /*
59  * FPA11 device model.
60  *
61  * This structure is exported to user space.  Do not re-order.
62  * Only add new stuff to the end, and do not change the size of
63  * any element.  Elements of this structure are used by user
64  * space, and must match struct user_fp in include/asm-arm/user.h.
65  * We include the byte offsets below for documentation purposes.
66  *
67  * The size of this structure and FPREG are checked by fpmodule.c
68  * on initialisation.  If the rules have been broken, NWFPE will
69  * not initialise.
70  */
71 typedef struct tagFPA11 {
72 /*   0 */  FPREG fpreg[8];		/* 8 floating point registers */
73 /*  96 */  FPSR fpsr;			/* floating point status register */
74 /* 100 */  FPCR fpcr;			/* floating point control register */
75 /* 104 */  unsigned char fType[8];	/* type of floating point value held in
76 					   floating point registers.  One of none
77 					   single, double or extended. */
78 /* 112 */  int initflag;		/* this is special.  The kernel guarantees
79 					   to set it to 0 when a thread is launched,
80 					   so we can use it to detect whether this
81 					   instance of the emulator needs to be
82 					   initialised. */
83     float_status fp_status;      /* QEMU float emulator status */
84 } FPA11;
85 
86 extern FPA11* qemufpa;
87 
88 void resetFPA11(void);
89 void SetRoundingMode(const unsigned int);
90 void SetRoundingPrecision(const unsigned int);
91 
92 static inline unsigned int readRegister(unsigned int reg)
93 {
94     return (user_registers->regs[(reg)]);
95 }
96 
97 static inline void writeRegister(unsigned int x, unsigned int y)
98 {
99 #if 0
100 	printf("writing %d to r%d\n",y,x);
101 #endif
102         user_registers->regs[(x)]=(y);
103 }
104 
105 static inline void writeConditionCodes(unsigned int x)
106 {
107     cpsr_write(user_registers, x, CPSR_NZCV, CPSRWriteByInstr);
108 }
109 
110 #define ARM_REG_PC 15
111 
112 unsigned int EmulateAll(unsigned int opcode, FPA11* qfpa, CPUARMState* qregs);
113 
114 unsigned int EmulateCPDO(const unsigned int);
115 unsigned int EmulateCPDT(const unsigned int);
116 unsigned int EmulateCPRT(const unsigned int);
117 
118 unsigned int SingleCPDO(const unsigned int opcode);
119 unsigned int DoubleCPDO(const unsigned int opcode);
120 unsigned int ExtendedCPDO(const unsigned int opcode);
121 
122 
123 /* included only for get_user/put_user macros */
124 #include "qemu.h"
125 
126 #endif
127