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 #ifdef PARANOID
64 extern char emulating;
65 # define RE_ENTRANT_CHECK_OFF emulating = 0
66 # define RE_ENTRANT_CHECK_ON emulating = 1
67 #else
68 # define RE_ENTRANT_CHECK_OFF
69 # define RE_ENTRANT_CHECK_ON
70 #endif PARANOID
71
72 #define FWAIT_OPCODE 0x9b
73 #define OP_SIZE_PREFIX 0x66
74 #define ADDR_SIZE_PREFIX 0x67
75 #define PREFIX_CS 0x2e
76 #define PREFIX_DS 0x3e
77 #define PREFIX_ES 0x26
78 #define PREFIX_SS 0x36
79 #define PREFIX_FS 0x64
80 #define PREFIX_GS 0x65
81 #define PREFIX_REPE 0xf3
82 #define PREFIX_REPNE 0xf2
83 #define PREFIX_LOCK 0xf0
84
85
86
87 #define NO_NET_DATA_EFFECT \
88 { FPU_data_address = (void *)data_operand_offset; \
89 FPU_data_selector = operand_selector; }
90 #define NO_NET_INSTR_EFFECT \
91 { FPU_entry_eip = ip_offset; \
92 FPU_entry_op_cs = cs_selector; }
93
94
95 typedef void (*FUNC)(void);
96 typedef struct fpu_reg FPU_REG;
97 typedef struct { unsigned char address_size, segment; } overrides;
98
99 #define st(x) ( regs[((top+x) &7 )] )
100
101 #define STACK_OVERFLOW (st_new_ptr = &st(-1), st_new_ptr->tag != TW_Empty)
102 #define NOT_EMPTY(i) (st(i).tag != TW_Empty)
103 #define NOT_EMPTY_0 (FPU_st0_tag ^ TW_Empty)
104
105 extern unsigned char FPU_rm;
106
107 extern char FPU_st0_tag;
108 extern FPU_REG *FPU_st0_ptr;
109
110
111
112 extern unsigned short FPU_data_selector;
113 extern unsigned long FPU_entry_op_cs;
114
115 extern FPU_REG FPU_loaded_data;
116
117 #define pop() { FPU_st0_ptr->tag = TW_Empty; top++; }
118
119
120 #define push() { top--; FPU_st0_ptr = st_new_ptr; }
121
122
123 #define reg_move(x, y) { \
124 *(short *)&((y)->sign) = *(short *)&((x)->sign); \
125 *(long *)&((y)->exp) = *(long *)&((x)->exp); \
126 *(long long *)&((y)->sigl) = *(long long *)&((x)->sigl); }
127
128 #define significand(x) ( ((unsigned long long *)&((x)->sigl))[0] )
129
130
131
132
133
134 asmlinkage void mul64(unsigned long long const *a, unsigned long long const *b,
135 unsigned long long *result);
136 asmlinkage void poly_div2(unsigned long long *x);
137 asmlinkage void poly_div4(unsigned long long *x);
138 asmlinkage void poly_div16(unsigned long long *x);
139 asmlinkage void polynomial(unsigned accum[], unsigned const x[],
140 unsigned short const terms[][4], int const n);
141 asmlinkage void normalize(FPU_REG *x);
142 asmlinkage void normalize_nuo(FPU_REG *x);
143 asmlinkage int reg_div(FPU_REG const *arg1, FPU_REG const *arg2,
144 FPU_REG *answ, unsigned int control_w);
145 asmlinkage int reg_u_sub(FPU_REG const *arg1, FPU_REG const *arg2,
146 FPU_REG *answ, unsigned int control_w);
147 asmlinkage int reg_u_mul(FPU_REG const *arg1, FPU_REG const *arg2,
148 FPU_REG *answ, unsigned int control_w);
149 asmlinkage int reg_u_div(FPU_REG const *arg1, FPU_REG const *arg2,
150 FPU_REG *answ, unsigned int control_w);
151 asmlinkage int reg_u_add(FPU_REG const *arg1, FPU_REG const *arg2,
152 FPU_REG *answ, unsigned int control_w);
153 asmlinkage int wm_sqrt(FPU_REG *n, unsigned int control_w);
154 asmlinkage unsigned shrx(void *l, unsigned x);
155 asmlinkage unsigned shrxs(void *v, unsigned x);
156 asmlinkage unsigned long div_small(unsigned long long *x, unsigned long y);
157 asmlinkage void round_reg(FPU_REG *arg, unsigned int extent,
158 unsigned int control_w);
159
160 #ifndef MAKING_PROTO
161 #include "fpu_proto.h"
162 #endif
163
164 #endif __ASSEMBLER__
165
166 #endif _FPU_EMU_H_