]> git.saurik.com Git - apple/xnu.git/blob - EXTERNAL_HEADERS/architecture/i386/fpu.h
xnu-792.6.56.tar.gz
[apple/xnu.git] / EXTERNAL_HEADERS / architecture / i386 / fpu.h
1 /*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23 /*
24 * Copyright (c) 1992 NeXT Computer, Inc.
25 *
26 * Intel386 Family: Floating Point unit.
27 *
28 * HISTORY
29 *
30 * 5 October 1992 ? at NeXT
31 * Added names to previously unamed fields in the mantissa.
32 *
33 * 5 April 1992 ? at NeXT
34 * Created.
35 */
36
37 /*
38 * Data register.
39 */
40
41 typedef struct fp_data_reg {
42 unsigned short mant;
43 unsigned short mant1 :16,
44 mant2 :16,
45 mant3 :16;
46 unsigned short exp :15,
47 sign :1;
48 } fp_data_reg_t;
49
50 /*
51 * Data register stack.
52 */
53
54 typedef struct fp_stack {
55 fp_data_reg_t ST[8];
56 } fp_stack_t;
57
58 /*
59 * Register stack tag word.
60 */
61
62 typedef struct fp_tag {
63 unsigned short tag0 :2,
64 tag1 :2,
65 tag2 :2,
66 tag3 :2,
67 tag4 :2,
68 tag5 :2,
69 tag6 :2,
70 tag7 :2;
71 #define FP_TAG_VALID 0
72 #define FP_TAG_ZERO 1
73 #define FP_TAG_SPEC 2
74 #define FP_TAG_EMPTY 3
75 } fp_tag_t;
76
77 /*
78 * Status word.
79 */
80
81 typedef struct fp_status {
82 unsigned short invalid :1,
83 denorm :1,
84 zdiv :1,
85 ovrfl :1,
86 undfl :1,
87 precis :1,
88 stkflt :1,
89 errsumm :1,
90 c0 :1,
91 c1 :1,
92 c2 :1,
93 tos :3,
94 c3 :1,
95 busy :1;
96 } fp_status_t;
97
98 /*
99 * Control word.
100 */
101
102 typedef struct fp_control {
103 unsigned short invalid :1,
104 denorm :1,
105 zdiv :1,
106 ovrfl :1,
107 undfl :1,
108 precis :1,
109 :2,
110 pc :2,
111 #define FP_PREC_24B 0
112 #define FP_PREC_53B 2
113 #define FP_PREC_64B 3
114 rc :2,
115 #define FP_RND_NEAR 0
116 #define FP_RND_DOWN 1
117 #define FP_RND_UP 2
118 #define FP_CHOP 3
119 /*inf*/ :1,
120 :3;
121 } fp_control_t;
122
123 #include <architecture/i386/sel.h>
124
125 /*
126 * Floating point 'environment'
127 * used by FSTENV/FLDENV instructions.
128 */
129
130 typedef struct fp_env {
131 fp_control_t control;
132 unsigned short :16;
133 fp_status_t status;
134 unsigned short :16;
135 fp_tag_t tag;
136 unsigned short :16;
137 unsigned int ip;
138 sel_t cs;
139 unsigned short opcode;
140 unsigned int dp;
141 sel_t ds;
142 unsigned short :16;
143 } fp_env_t;
144
145 /*
146 * Floating point state
147 * used by FSAVE/FRSTOR instructions.
148 */
149
150 typedef struct fp_state {
151 fp_env_t environ;
152 fp_stack_t stack;
153 } fp_state_t;