00001 /*- 00002 * Copyright (c) 1990 The Regents of the University of California. 00003 * All rights reserved. 00004 * 00005 * This code is derived from software contributed to Berkeley by 00006 * William Jolitz. 00007 * 00008 * Redistribution and use in source and binary forms, with or without 00009 * modification, are permitted provided that the following conditions 00010 * are met: 00011 * 1. Redistributions of source code must retain the above copyright 00012 * notice, this list of conditions and the following disclaimer. 00013 * 2. Redistributions in binary form must reproduce the above copyright 00014 * notice, this list of conditions and the following disclaimer in the 00015 * documentation and/or other materials provided with the distribution. 00016 * 3. All advertising materials mentioning features or use of this software 00017 * must display the following acknowledgement: 00018 * This product includes software developed by the University of 00019 * California, Berkeley and its contributors. 00020 * 4. Neither the name of the University nor the names of its contributors 00021 * may be used to endorse or promote products derived from this software 00022 * without specific prior written permission. 00023 * 00024 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 00025 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00026 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00027 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 00028 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00029 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 00030 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00031 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00032 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 00033 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00034 * SUCH DAMAGE. 00035 * 00036 * @(#)npx.h 5.3 (Berkeley) 1/18/91 00037 */ 00038 #ifndef __MACHDEP_NPX_H__ 00039 #define __MACHDEP_NPX_H__ 00040 00041 /* 00042 * 287/387 NPX Coprocessor Data Structures and Constants 00043 * W. Jolitz 1/90 00044 */ 00045 00046 /* Environment information of floating point unit */ 00047 struct env87 { 00048 long en_cw; /* control word (16bits) */ 00049 long en_sw; /* status word (16bits) */ 00050 long en_tw; /* tag word (16bits) */ 00051 long en_fip; /* floating point instruction pointer */ 00052 u_short en_fcs; /* floating code segment selector */ 00053 u_short en_opcode; /* opcode last executed (11 bits ) */ 00054 long en_foo; /* floating operand offset */ 00055 long en_fos; /* floating operand segment selector */ 00056 }; 00057 00058 /* Contents of each floating point accumulator */ 00059 struct fpacc87 { 00060 #ifdef dontdef /* too unportable */ 00061 u_long fp_mantlo; /* mantissa low (31:0) */ 00062 u_long fp_manthi; /* mantissa high (63:32) */ 00063 int fp_exp:15; /* exponent */ 00064 int fp_sgn:1; /* mantissa sign */ 00065 #else 00066 u_char fp_bytes[10]; 00067 #endif 00068 }; 00069 00070 /* Floating point context */ 00071 struct save87 { 00072 struct env87 sv_env; /* floating point control/status */ 00073 struct fpacc87 sv_ac[8]; /* accumulator contents, 0-7 */ 00074 #ifndef dontdef 00075 u_long sv_ex_sw; /* status word for last exception (was pad) */ 00076 u_long sv_ex_tw; /* tag word for last exception (was pad) */ 00077 u_char sv_pad[8 * 2 - 2 * 4]; /* bogus historical padding */ 00078 #endif 00079 }; 00080 00081 /* Environment of FPU/MMX/SSE/SSE2. */ 00082 struct envxmm { 00083 /*0*/ uint16_t en_cw; /* FPU Control Word */ 00084 uint16_t en_sw; /* FPU Status Word */ 00085 uint8_t en_rsvd0; 00086 uint8_t en_tw; /* FPU Tag Word (abridged) */ 00087 uint16_t en_opcode; /* FPU Opcode */ 00088 uint32_t en_fip; /* FPU Instruction Pointer */ 00089 uint16_t en_fcs; /* FPU IP selector */ 00090 uint16_t en_rsvd1; 00091 /*16*/ uint32_t en_foo; /* FPU Data pointer */ 00092 uint16_t en_fos; /* FPU Data pointer selector */ 00093 uint16_t en_rsvd2; 00094 uint32_t en_mxcsr; /* MXCSR Register State */ 00095 uint32_t en_rsvd3; 00096 }; 00097 00098 /* FPU regsters in the extended save format. */ 00099 struct fpaccxmm { 00100 uint8_t fp_bytes[10]; 00101 uint8_t fp_rsvd[6]; 00102 }; 00103 00104 /* SSE/SSE2 registers. */ 00105 struct xmmreg { 00106 uint8_t sse_bytes[16]; 00107 }; 00108 00109 /* FPU/MMX/SSE/SSE2 context */ 00110 struct savexmm { 00111 struct envxmm sv_env; /* control/status context */ 00112 struct fpaccxmm sv_ac[8]; /* ST/MM regs */ 00113 struct xmmreg sv_xmmregs[8]; /* XMM regs */ 00114 uint8_t sv_rsvd[16 * 14]; 00115 /* 512-bytes --- end of hardware portion of save area */ 00116 uint32_t sv_ex_sw; /* saved SW from last exception */ 00117 uint32_t sv_ex_tw; /* saved TW from last exception */ 00118 }; 00119 00120 union savefpu { 00121 struct save87 sv_87; 00122 struct savexmm sv_xmm; 00123 }; 00124 00125 /* Cyrix EMC memory - mapped coprocessor context switch information */ 00126 struct emcsts { 00127 long em_msw; /* memory mapped status register when swtched */ 00128 long em_tar; /* memory mapped temp A register when swtched */ 00129 long em_dl; /* memory mapped D low register when swtched */ 00130 }; 00131 00132 /* 00133 * The i387 defaults to Intel extended precision mode and round to nearest, 00134 * with all exceptions masked. 00135 */ 00136 #define __INITIAL_NPXCW__ 0x037f 00137 /* NetBSD uses IEEE double precision. */ 00138 #define __NetBSD_NPXCW__ 0x127f 00139 /* FreeBSD leaves some exceptions unmasked as well. */ 00140 #define __FreeBSD_NPXCW__ 0x1272 00141 /* iBCS2 goes a bit further and leaves the underflow exception unmasked. */ 00142 #define __iBCS2_NPXCW__ 0x0262 00143 /* Linux just uses the default control word. */ 00144 #define __Linux_NPXCW__ 0x037f 00145 /* SVR4 uses the same control word as iBCS2. */ 00146 #define __SVR4_NPXCW__ 0x0262 00147 00148 /* 00149 * The default MXCSR value at reset is 0x1f80, IA-32 Instruction 00150 * Set Reference, pg. 3-369. 00151 */ 00152 #define __INITIAL_MXCSR__ 0x1f80 00153 00154 /* 00155 * The standard control word from finit is 0x37F, giving: 00156 * round to nearest 00157 * 64-bit precision 00158 * all exceptions masked. 00159 * 00160 * Now we want: 00161 * affine mode (if we decide to support 287's) 00162 * round to nearest 00163 * 53-bit precision 00164 * all exceptions masked. 00165 * 00166 * 64-bit precision often gives bad results with high level languages 00167 * because it makes the results of calculations depend on whether 00168 * intermediate values are stored in memory or in FPU registers. 00169 * 00170 * The iBCS control word has underflow, overflow, zero divide, and invalid 00171 * operation exceptions unmasked. But that causes an unexpected exception 00172 * in the test program 'paranoia' and makes denormals useless (DBL_MIN / 2 00173 * underflows). It doesn't make a lot of sense to trap underflow without 00174 * trapping denormals. 00175 */ 00176 00177 #endif