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 __ASSEMBLER__
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 __ASSEMBLER__
59
60 #include <linux/math_emu.h>
61 #include <linux/linkage.h>
62
63
64
65
66
67 #ifdef RE_ENTRANT_CHECKING
68 extern char emulating;
69 # define RE_ENTRANT_CHECK_OFF emulating = 0
70 # define RE_ENTRANT_CHECK_ON emulating = 1
71 #else
72 # define RE_ENTRANT_CHECK_OFF
73 # define RE_ENTRANT_CHECK_ON
74 #endif RE_ENTRANT_CHECKING
75
76 #define FWAIT_OPCODE 0x9b
77 #define OP_SIZE_PREFIX 0x66
78 #define ADDR_SIZE_PREFIX 0x67
79 #define PREFIX_CS 0x2e
80 #define PREFIX_DS 0x3e
81 #define PREFIX_ES 0x26
82 #define PREFIX_SS 0x36
83 #define PREFIX_FS 0x64
84 #define PREFIX_GS 0x65
85 #define PREFIX_REPE 0xf3
86 #define PREFIX_REPNE 0xf2
87 #define PREFIX_LOCK 0xf0
88 #define PREFIX_CS_ 1
89 #define PREFIX_DS_ 2
90 #define PREFIX_ES_ 3
91 #define PREFIX_FS_ 4
92 #define PREFIX_GS_ 5
93 #define PREFIX_SS_ 6
94 #define PREFIX_DEFAULT 7
95
96 struct address {
97 unsigned int offset;
98 unsigned int selector:16;
99 unsigned int opcode:11;
100 unsigned int empty:5;
101 };
102 typedef void (*FUNC)(void);
103 typedef struct fpu_reg FPU_REG;
104 typedef void (*FUNC_ST0)(FPU_REG *st0_ptr);
105 typedef struct { unsigned char address_size, operand_size, segment; }
106 overrides;
107
108 typedef struct { overrides override;
109 unsigned char default_mode; } fpu_addr_modes;
110
111
112
113 #define PROTECTED 4
114 #define SIXTEEN 1
115 #define VM86 SIXTEEN
116 #define PM16 (SIXTEEN | PROTECTED)
117 #define SEG32 PROTECTED
118 extern unsigned char const data_sizes_16[32];
119
120 #define st(x) ( regs[((top+x) &7 )] )
121
122 #define STACK_OVERFLOW (st_new_ptr = &st(-1), st_new_ptr->tag != TW_Empty)
123 #define NOT_EMPTY(i) (st(i).tag != TW_Empty)
124 #define NOT_EMPTY_ST0 (st0_tag ^ TW_Empty)
125
126 #define pop() { regs[(top++ & 7 )].tag = TW_Empty; }
127 #define poppop() { regs[((top + 1) & 7 )].tag \
128 = regs[(top & 7 )].tag = TW_Empty; \
129 top += 2; }
130
131
132 #define push() { top--; }
133
134
135 #define reg_move(x, y) { \
136 *(short *)&((y)->sign) = *(short *)&((x)->sign); \
137 *(long *)&((y)->exp) = *(long *)&((x)->exp); \
138 *(long long *)&((y)->sigl) = *(long long *)&((x)->sigl); }
139
140 #define significand(x) ( ((unsigned long long *)&((x)->sigl))[0] )
141
142
143
144
145
146 asmlinkage void normalize(FPU_REG *x);
147 asmlinkage void normalize_nuo(FPU_REG *x);
148 asmlinkage int reg_div(FPU_REG const *arg1, FPU_REG const *arg2,
149 FPU_REG *answ, unsigned int control_w);
150 asmlinkage int reg_u_sub(FPU_REG const *arg1, FPU_REG const *arg2,
151 FPU_REG *answ, unsigned int control_w);
152 asmlinkage int reg_u_mul(FPU_REG const *arg1, FPU_REG const *arg2,
153 FPU_REG *answ, unsigned int control_w);
154 asmlinkage int reg_u_div(FPU_REG const *arg1, FPU_REG const *arg2,
155 FPU_REG *answ, unsigned int control_w);
156 asmlinkage int reg_u_add(FPU_REG const *arg1, FPU_REG const *arg2,
157 FPU_REG *answ, unsigned int control_w);
158 asmlinkage int wm_sqrt(FPU_REG *n, unsigned int control_w);
159 asmlinkage unsigned shrx(void *l, unsigned x);
160 asmlinkage unsigned shrxs(void *v, unsigned x);
161 asmlinkage unsigned long div_small(unsigned long long *x, unsigned long y);
162 asmlinkage void round_reg(FPU_REG *arg, unsigned int extent,
163 unsigned int control_w);
164
165 #ifndef MAKING_PROTO
166 #include "fpu_proto.h"
167 #endif
168
169 #endif __ASSEMBLER__
170
171 #endif _FPU_EMU_H_