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