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