1
2
3
4
5
6
7
8
9
10
11 #ifndef _FPU_EMU_H_
12 #define _FPU_EMU_H_
13
14
15
16
17
18
19
20 #define DENORM_OPERAND
21
22
23
24
25
26
27
28
29 #define PECULIAR_486
30
31 #ifdef __ASSEMBLY__
32 #include "fpu_asm.h"
33 #define Const(x) $##x
34 #else
35 #define Const(x) x
36 #endif
37
38 #define EXP_BIAS Const(0)
39 #define EXP_OVER Const(0x4000)
40 #define EXP_UNDER Const(-0x3fff)
41 #define EXP_Infinity EXP_OVER
42 #define EXP_NaN EXP_OVER
43
44 #define SIGN_POS Const(0)
45 #define SIGN_NEG Const(1)
46
47
48 #define TW_Valid Const(0)
49 #define TW_Zero Const(1)
50
51
52 #define TW_Infinity Const(5)
53 #define TW_NaN Const(6)
54
55 #define TW_Empty Const(7)
56
57
58 #ifndef __ASSEMBLY__
59
60 #include <asm/sigcontext.h>
61 #include <linux/math_emu.h>
62 #include <linux/linkage.h>
63
64
65
66
67
68 #ifdef RE_ENTRANT_CHECKING
69 extern char emulating;
70 # define RE_ENTRANT_CHECK_OFF emulating = 0
71 # define RE_ENTRANT_CHECK_ON emulating = 1
72 #else
73 # define RE_ENTRANT_CHECK_OFF
74 # define RE_ENTRANT_CHECK_ON
75 #endif RE_ENTRANT_CHECKING
76
77 #define FWAIT_OPCODE 0x9b
78 #define OP_SIZE_PREFIX 0x66
79 #define ADDR_SIZE_PREFIX 0x67
80 #define PREFIX_CS 0x2e
81 #define PREFIX_DS 0x3e
82 #define PREFIX_ES 0x26
83 #define PREFIX_SS 0x36
84 #define PREFIX_FS 0x64
85 #define PREFIX_GS 0x65
86 #define PREFIX_REPE 0xf3
87 #define PREFIX_REPNE 0xf2
88 #define PREFIX_LOCK 0xf0
89 #define PREFIX_CS_ 1
90 #define PREFIX_DS_ 2
91 #define PREFIX_ES_ 3
92 #define PREFIX_FS_ 4
93 #define PREFIX_GS_ 5
94 #define PREFIX_SS_ 6
95 #define PREFIX_DEFAULT 7
96
97 struct address {
98 unsigned int offset;
99 unsigned int selector:16;
100 unsigned int opcode:11;
101 unsigned int empty:5;
102 };
103 typedef void (*FUNC)(void);
104 typedef struct fpu_reg FPU_REG;
105 typedef void (*FUNC_ST0)(FPU_REG *st0_ptr);
106 typedef struct { unsigned char address_size, operand_size, segment; }
107 overrides;
108
109 typedef struct { overrides override;
110 unsigned char default_mode; } fpu_addr_modes;
111
112
113
114 #define PROTECTED 4
115 #define SIXTEEN 1
116 #define VM86 SIXTEEN
117 #define PM16 (SIXTEEN | PROTECTED)
118 #define SEG32 PROTECTED
119 extern unsigned char const data_sizes_16[32];
120
121 #define st(x) ( regs[((top+x) &7 )] )
122
123 #define STACK_OVERFLOW (st_new_ptr = &st(-1), st_new_ptr->tag != TW_Empty)
124 #define NOT_EMPTY(i) (st(i).tag != TW_Empty)
125 #define NOT_EMPTY_ST0 (st0_tag ^ TW_Empty)
126
127 #define pop() { regs[(top++ & 7 )].tag = TW_Empty; }
128 #define poppop() { regs[((top + 1) & 7 )].tag \
129 = regs[(top & 7 )].tag = TW_Empty; \
130 top += 2; }
131
132
133 #define push() { top--; }
134
135
136 #define reg_move(x, y) { \
137 *(short *)&((y)->sign) = *(const short *)&((x)->sign); \
138 *(long *)&((y)->exp) = *(const long *)&((x)->exp); \
139 *(long long *)&((y)->sigl) = *(const long long *)&((x)->sigl); }
140
141 #define significand(x) ( ((unsigned long long *)&((x)->sigl))[0] )
142
143
144
145
146
147 asmlinkage void normalize(FPU_REG *x);
148 asmlinkage void normalize_nuo(FPU_REG *x);
149 asmlinkage int reg_div(FPU_REG const *arg1, FPU_REG const *arg2,
150 FPU_REG *answ, unsigned int control_w);
151 asmlinkage int reg_u_sub(FPU_REG const *arg1, FPU_REG const *arg2,
152 FPU_REG *answ, unsigned int control_w);
153 asmlinkage int reg_u_mul(FPU_REG const *arg1, FPU_REG const *arg2,
154 FPU_REG *answ, unsigned int control_w);
155 asmlinkage int reg_u_div(FPU_REG const *arg1, FPU_REG const *arg2,
156 FPU_REG *answ, unsigned int control_w);
157 asmlinkage int reg_u_add(FPU_REG const *arg1, FPU_REG const *arg2,
158 FPU_REG *answ, unsigned int control_w);
159 asmlinkage int wm_sqrt(FPU_REG *n, unsigned int control_w);
160 asmlinkage unsigned shrx(void *l, unsigned x);
161 asmlinkage unsigned shrxs(void *v, unsigned x);
162 asmlinkage unsigned long div_small(unsigned long long *x, unsigned long y);
163 asmlinkage void round_reg(FPU_REG *arg, unsigned int extent,
164 unsigned int control_w);
165
166 #ifndef MAKING_PROTO
167 #include "fpu_proto.h"
168 #endif
169
170 #endif __ASSEMBLY__
171
172 #endif _FPU_EMU_H_