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