The Pedigree Project  0.1
fpu_regs.h
1 /*
2  * Copyright (c) 2008-2014, Pedigree Developers
3  *
4  * Please see the CONTRIB file in the root of the source tree for a full
5  * list of contributors.
6  *
7  * Permission to use, copy, modify, and distribute this software for any
8  * purpose with or without fee is hereby granted, provided that the above
9  * copyright notice and this permission notice appear in all copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 #ifndef __X86EMU_FPU_REGS_H
21 #define __X86EMU_FPU_REGS_H
22 
23 #ifdef X86_FPU_SUPPORT
24 
25 #ifdef PACK
26 #pragma PACK
27 #endif
28 
29 /* Basic 8087 register can hold any of the following values: */
30 
31 union x86_fpu_reg_u
32 {
33  s8 tenbytes[10];
34  double dval;
35  float fval;
36  s16 sval;
37  s32 lval;
38 };
39 
40 struct x86_fpu_reg
41 {
42  union x86_fpu_reg_u reg;
43  char tag;
44 };
45 
46 /*
47  * Since we are not going to worry about the problems of aliasing
48  * registers, every time a register is modified, its result type is
49  * set in the tag fields for that register. If some operation
50  * attempts to access the type in a way inconsistent with its current
51  * storage format, then we flag the operation. If common, we'll
52  * attempt the conversion.
53  */
54 
55 #define X86_FPU_VALID 0x80
56 #define X86_FPU_REGTYP(r) ((r) &0x7F)
57 
58 #define X86_FPU_WORD 0x0
59 #define X86_FPU_SHORT 0x1
60 #define X86_FPU_LONG 0x2
61 #define X86_FPU_FLOAT 0x3
62 #define X86_FPU_DOUBLE 0x4
63 #define X86_FPU_LDBL 0x5
64 #define X86_FPU_BSD 0x6
65 
66 #define X86_FPU_STKTOP 0
67 
68 struct x86_fpu_registers
69 {
70  struct x86_fpu_reg x86_fpu_stack[8];
71  int x86_fpu_flags;
72  int x86_fpu_config; /* rounding modes, etc. */
73  short x86_fpu_tos, x86_fpu_bos;
74 };
75 
76 #ifdef END_PACK
77 #pragma END_PACK
78 #endif
79 
80 /*
81  * There are two versions of the following macro.
82  *
83  * One version is for opcode D9, for which there are more than 32
84  * instructions encoded in the second byte of the opcode.
85  *
86  * The other version, deals with all the other 7 i87 opcodes, for
87  * which there are only 32 strings needed to describe the
88  * instructions.
89  */
90 
91 #endif /* X86_FPU_SUPPORT */
92 
93 #ifdef DEBUG
94 #define DECODE_PRINTINSTR32(t, mod, rh, rl) DECODE_PRINTF(t[(mod << 3) + (rh)]);
95 #define DECODE_PRINTINSTR256(t, mod, rh, rl) \
96  DECODE_PRINTF(t[(mod << 6) + (rh << 3) + (rl)]);
97 #else
98 #define DECODE_PRINTINSTR32(t, mod, rh, rl)
99 #define DECODE_PRINTINSTR256(t, mod, rh, rl)
100 #endif
101 
102 #endif /* __X86EMU_FPU_REGS_H */