10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*3446Smrj * Common Development and Distribution License (the "License"). 6*3446Smrj * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 22*3446Smrj * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate /* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */ 270Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T */ 280Sstevel@tonic-gate /* All Rights Reserved */ 290Sstevel@tonic-gate 300Sstevel@tonic-gate #ifndef _SYS_FP_H 310Sstevel@tonic-gate #define _SYS_FP_H 320Sstevel@tonic-gate 330Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 340Sstevel@tonic-gate 350Sstevel@tonic-gate #ifdef __cplusplus 360Sstevel@tonic-gate extern "C" { 370Sstevel@tonic-gate #endif 380Sstevel@tonic-gate 390Sstevel@tonic-gate /* 400Sstevel@tonic-gate * 80287/80387 and SSE/SSE2 floating point processor definitions 410Sstevel@tonic-gate */ 420Sstevel@tonic-gate 430Sstevel@tonic-gate /* 440Sstevel@tonic-gate * values that go into fp_kind 450Sstevel@tonic-gate */ 460Sstevel@tonic-gate #define FP_NO 0 /* no fp chip, no emulator (no fp support) */ 470Sstevel@tonic-gate #define FP_SW 1 /* no fp chip, using software emulator */ 480Sstevel@tonic-gate #define FP_HW 2 /* chip present bit */ 490Sstevel@tonic-gate #define FP_287 2 /* 80287 chip present */ 500Sstevel@tonic-gate #define FP_387 3 /* 80387 chip present */ 510Sstevel@tonic-gate #define FP_487 6 /* 80487 chip present */ 520Sstevel@tonic-gate #define FP_486 6 /* 80486 chip present */ 530Sstevel@tonic-gate #define __FP_SSE 0x103 /* x87 plus SSE-capable CPU */ 540Sstevel@tonic-gate 550Sstevel@tonic-gate /* 560Sstevel@tonic-gate * masks for 80387 control word 570Sstevel@tonic-gate */ 580Sstevel@tonic-gate #define FPIM 0x00000001 /* invalid operation */ 590Sstevel@tonic-gate #define FPDM 0x00000002 /* denormalized operand */ 600Sstevel@tonic-gate #define FPZM 0x00000004 /* zero divide */ 610Sstevel@tonic-gate #define FPOM 0x00000008 /* overflow */ 620Sstevel@tonic-gate #define FPUM 0x00000010 /* underflow */ 630Sstevel@tonic-gate #define FPPM 0x00000020 /* precision */ 640Sstevel@tonic-gate #define FPPC 0x00000300 /* precision control */ 650Sstevel@tonic-gate #define FPRC 0x00000C00 /* rounding control */ 660Sstevel@tonic-gate #define FPIC 0x00001000 /* infinity control */ 670Sstevel@tonic-gate #define WFPDE 0x00000080 /* data chain exception */ 680Sstevel@tonic-gate 690Sstevel@tonic-gate /* 700Sstevel@tonic-gate * (Old symbol compatibility) 710Sstevel@tonic-gate */ 720Sstevel@tonic-gate #define FPINV FPIM 730Sstevel@tonic-gate #define FPDNO FPDM 740Sstevel@tonic-gate #define FPZDIV FPZM 750Sstevel@tonic-gate #define FPOVR FPOM 760Sstevel@tonic-gate #define FPUNR FPUM 770Sstevel@tonic-gate #define FPPRE FPPM 780Sstevel@tonic-gate 790Sstevel@tonic-gate /* 800Sstevel@tonic-gate * precision, rounding, and infinity options in control word 810Sstevel@tonic-gate */ 820Sstevel@tonic-gate #define FPSIG24 0x00000000 /* 24-bit significand precision (short) */ 830Sstevel@tonic-gate #define FPSIG53 0x00000200 /* 53-bit significand precision (long) */ 840Sstevel@tonic-gate #define FPSIG64 0x00000300 /* 64-bit significand precision (temp) */ 850Sstevel@tonic-gate #define FPRTN 0x00000000 /* round to nearest or even */ 860Sstevel@tonic-gate #define FPRD 0x00000400 /* round down */ 870Sstevel@tonic-gate #define FPRU 0x00000800 /* round up */ 880Sstevel@tonic-gate #define FPCHOP 0x00000C00 /* chop (truncate toward zero) */ 890Sstevel@tonic-gate #define FPP 0x00000000 /* projective infinity */ 900Sstevel@tonic-gate #define FPA 0x00001000 /* affine infinity */ 910Sstevel@tonic-gate #define WFPB17 0x00020000 /* bit 17 */ 920Sstevel@tonic-gate #define WFPB24 0x00040000 /* bit 24 */ 930Sstevel@tonic-gate 940Sstevel@tonic-gate /* 950Sstevel@tonic-gate * masks for 80387 status word 960Sstevel@tonic-gate */ 970Sstevel@tonic-gate #define FPS_IE 0x00000001 /* invalid operation */ 980Sstevel@tonic-gate #define FPS_DE 0x00000002 /* denormalized operand */ 99*3446Smrj #define FPS_ZE 0x00000004 /* zero divide */ 1000Sstevel@tonic-gate #define FPS_OE 0x00000008 /* overflow */ 1010Sstevel@tonic-gate #define FPS_UE 0x00000010 /* underflow */ 1020Sstevel@tonic-gate #define FPS_PE 0x00000020 /* precision */ 1030Sstevel@tonic-gate #define FPS_SF 0x00000040 /* stack fault */ 1040Sstevel@tonic-gate #define FPS_ES 0x00000080 /* error summary bit */ 1050Sstevel@tonic-gate #define FPS_C0 0x00000100 /* C0 bit */ 1060Sstevel@tonic-gate #define FPS_C1 0x00000200 /* C1 bit */ 1070Sstevel@tonic-gate #define FPS_C2 0x00000400 /* C2 bit */ 1080Sstevel@tonic-gate #define FPS_TOP 0x00003800 /* top of stack pointer */ 1090Sstevel@tonic-gate #define FPS_C3 0x00004000 /* C3 bit */ 1100Sstevel@tonic-gate #define FPS_B 0x00008000 /* busy bit */ 1110Sstevel@tonic-gate 1120Sstevel@tonic-gate /* 1130Sstevel@tonic-gate * Exception flags manually cleared during x87 exception handling. 1140Sstevel@tonic-gate */ 1150Sstevel@tonic-gate #define FPS_SW_EFLAGS \ 1160Sstevel@tonic-gate (FPS_IE|FPS_DE|FPS_ZE|FPS_OE|FPS_UE|FPS_PE|FPS_SF|FPS_ES|FPS_B) 1170Sstevel@tonic-gate 1180Sstevel@tonic-gate /* 1190Sstevel@tonic-gate * Initial value of FPU control word as per 4th ed. ABI document 1200Sstevel@tonic-gate * - affine infinity 1210Sstevel@tonic-gate * - round to nearest or even 1220Sstevel@tonic-gate * - 64-bit double precision 1230Sstevel@tonic-gate * - all exceptions masked 1240Sstevel@tonic-gate */ 1250Sstevel@tonic-gate #define FPU_CW_INIT 0x133f 1260Sstevel@tonic-gate 1270Sstevel@tonic-gate /* 1280Sstevel@tonic-gate * masks and flags for SSE/SSE2 MXCSR 1290Sstevel@tonic-gate */ 1300Sstevel@tonic-gate #define SSE_IE 0x00000001 /* invalid operation */ 1310Sstevel@tonic-gate #define SSE_DE 0x00000002 /* denormalized operand */ 1320Sstevel@tonic-gate #define SSE_ZE 0x00000004 /* zero divide */ 1330Sstevel@tonic-gate #define SSE_OE 0x00000008 /* overflow */ 1340Sstevel@tonic-gate #define SSE_UE 0x00000010 /* underflow */ 1350Sstevel@tonic-gate #define SSE_PE 0x00000020 /* precision */ 1360Sstevel@tonic-gate #define SSE_DAZ 0x00000040 /* denormals are zero */ 1370Sstevel@tonic-gate #define SSE_IM 0x00000080 /* invalid op exception mask */ 1380Sstevel@tonic-gate #define SSE_DM 0x00000100 /* denormalize exception mask */ 1390Sstevel@tonic-gate #define SSE_ZM 0x00000200 /* zero-divide exception mask */ 1400Sstevel@tonic-gate #define SSE_OM 0x00000400 /* overflow exception mask */ 1410Sstevel@tonic-gate #define SSE_UM 0x00000800 /* underflow exception mask */ 1420Sstevel@tonic-gate #define SSE_PM 0x00001000 /* precision exception mask */ 1430Sstevel@tonic-gate #define SSE_RC 0x00006000 /* rounding control */ 1440Sstevel@tonic-gate #define SSE_RD 0x00002000 /* rounding control: round down */ 1450Sstevel@tonic-gate #define SSE_RU 0x00004000 /* rounding control: round up */ 1460Sstevel@tonic-gate #define SSE_FZ 0x00008000 /* flush to zero for masked underflow */ 1470Sstevel@tonic-gate 1480Sstevel@tonic-gate #define SSE_MXCSR_EFLAGS \ 1490Sstevel@tonic-gate (SSE_IE|SSE_DE|SSE_ZE|SSE_OE|SSE_UE|SSE_PE) /* 0x3f */ 1500Sstevel@tonic-gate 1510Sstevel@tonic-gate #define SSE_MXCSR_INIT \ 1520Sstevel@tonic-gate (SSE_IM|SSE_DM|SSE_ZM|SSE_OM|SSE_UM|SSE_PM) /* 0x1f80 */ 1530Sstevel@tonic-gate 1540Sstevel@tonic-gate #define SSE_MXCSR_MASK_DEFAULT \ 1550Sstevel@tonic-gate (0xffff & ~SSE_DAZ) /* 0xffbf */ 1560Sstevel@tonic-gate 1570Sstevel@tonic-gate #define SSE_FMT_MXCSR \ 1580Sstevel@tonic-gate "\20\20fz\17ru\16rd\15pm\14um\13om\12zm\11dm" \ 1590Sstevel@tonic-gate "\10im\7daz\6pe\5ue\4oe\3ze\2de\1ie" 1600Sstevel@tonic-gate 1610Sstevel@tonic-gate extern int fp_kind; /* kind of fp support */ 1620Sstevel@tonic-gate extern int fpu_exists; /* FPU hw exists */ 1630Sstevel@tonic-gate 1640Sstevel@tonic-gate #ifdef _KERNEL 1650Sstevel@tonic-gate 166*3446Smrj extern int fpu_ignored; 167*3446Smrj extern int fpu_pentium_fdivbug; 168*3446Smrj 1690Sstevel@tonic-gate extern uint32_t sse_mxcsr_mask; 1700Sstevel@tonic-gate 1710Sstevel@tonic-gate extern void fpu_probe(void); 172*3446Smrj extern uint_t fpu_initial_probe(void); 173*3446Smrj extern int fpu_probe_pentium_fdivbug(void); 1740Sstevel@tonic-gate 175*3446Smrj extern void fpnsave_ctxt(void *); 176*3446Smrj extern void fpxsave_ctxt(void *); 177*3446Smrj extern void (*fpsave_ctxt)(void *); 1780Sstevel@tonic-gate 179*3446Smrj struct fnsave_state; 180*3446Smrj struct fxsave_state; 181*3446Smrj extern void fxsave_insn(struct fxsave_state *); 1820Sstevel@tonic-gate extern void fpsave(struct fnsave_state *); 1830Sstevel@tonic-gate extern void fprestore(struct fnsave_state *); 1840Sstevel@tonic-gate extern void fpxsave(struct fxsave_state *); 1850Sstevel@tonic-gate extern void fpxrestore(struct fxsave_state *); 1860Sstevel@tonic-gate 1870Sstevel@tonic-gate extern void fpenable(void); 1880Sstevel@tonic-gate extern void fpdisable(void); 1890Sstevel@tonic-gate extern void fpinit(void); 1900Sstevel@tonic-gate 1910Sstevel@tonic-gate extern uint32_t fperr_reset(void); 1920Sstevel@tonic-gate extern uint32_t fpxerr_reset(void); 1930Sstevel@tonic-gate 1940Sstevel@tonic-gate extern uint32_t fpgetcwsw(void); 1950Sstevel@tonic-gate extern uint32_t fpgetmxcsr(void); 1960Sstevel@tonic-gate 1970Sstevel@tonic-gate struct regs; 1980Sstevel@tonic-gate extern int fpnoextflt(struct regs *); 1990Sstevel@tonic-gate extern int fpextovrflt(struct regs *); 2000Sstevel@tonic-gate extern int fpexterrflt(struct regs *); 2010Sstevel@tonic-gate extern int fpsimderrflt(struct regs *); 2020Sstevel@tonic-gate extern void fpsetcw(uint16_t, uint32_t); 2030Sstevel@tonic-gate 2040Sstevel@tonic-gate #endif /* _KERNEL */ 2050Sstevel@tonic-gate 2060Sstevel@tonic-gate #ifdef __cplusplus 2070Sstevel@tonic-gate } 2080Sstevel@tonic-gate #endif 2090Sstevel@tonic-gate 2100Sstevel@tonic-gate #endif /* _SYS_FP_H */ 211