fp.h revision bc0e91320069f0bcaee43e80a7ea686d9efa2d08
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2015 Nexenta Systems, Inc. All rights reserved.
*
*/
/* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */
/* Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T */
/* All Rights Reserved */
#ifndef _SYS_FP_H
#define _SYS_FP_H
#ifdef __cplusplus
extern "C" {
#endif
/*
*/
/*
* values that go into fp_kind
*/
#define FP_NO 0 /* no fp chip, no emulator (no fp support) */
/*
* The following values are bit flags instead of actual values.
* E.g. to know if we are using SSE, test (value & __FP_SSE) instead
* of (value == __FP_SSE).
*/
/*
* values that go into fp_save_mech
*/
/*
* masks for 80387 control word
*/
/*
* (Old symbol compatibility)
*/
/*
* precision, rounding, and infinity options in control word
*/
/*
* masks for 80387 status word
*/
/*
* Exception flags manually cleared during x87 exception handling.
*/
#define FPS_SW_EFLAGS \
/*
* Initial value of FPU control word as per 4th ed. ABI document
* - affine infinity
* - round to nearest or even
* - 64-bit double precision
* - all exceptions masked
*/
#define FPU_CW_INIT 0x133f
/*
*/
#define SSE_MXCSR_EFLAGS \
#define SSE_MXCSR_INIT \
#define SSE_MXCSR_MASK_DEFAULT \
#define SSE_FMT_MXCSR \
"\20\20fz\17ru\16rd\15pm\14um\13om\12zm\11dm" \
"\10im\7daz\6pe\5ue\4oe\3ze\2de\1ie"
/*
* This structure is written to memory by an 'fnsave' instruction
*/
struct fnsave_state {
union {
} f_st[8];
}; /* 108 bytes */
/*
* This structure is written to memory by an 'fxsave' instruction
* Note the variant behaviour of this instruction between long mode
* and legacy environments!
*/
struct fxsave_state {
#if defined(__amd64)
#else
#endif
union {
} fx_st[8];
#if defined(__amd64)
#else
#endif
}; /* 512 bytes */
/*
* This structure is written to memory by an 'xsave' instruction.
* First 512 byte is compatible with the format of an 'fxsave' area.
*/
struct xsave_state {
struct fxsave_state xs_fxsave;
}; /* 832 bytes, asserted in fpnoextflt() */
/*
* Kernel's FPU save area
*/
typedef struct {
union _kfpu_u {
struct fxsave_state kfpu_fx;
#if defined(__i386)
struct fnsave_state kfpu_fn;
#endif
struct xsave_state kfpu_xs;
} kfpu_u;
} kfpu_t;
extern int fp_kind; /* kind of fp support */
extern int fp_save_mech; /* fp save/restore mechanism */
extern int fpu_exists; /* FPU hw exists */
#ifdef _KERNEL
extern int fpu_ignored;
extern int fpu_pentium_fdivbug;
extern uint32_t sse_mxcsr_mask;
extern void fpu_probe(void);
extern uint_t fpu_initial_probe(void);
extern int fpu_probe_pentium_fdivbug(void);
extern void fpnsave_ctxt(void *);
extern void fpxsave_ctxt(void *);
extern void xsave_ctxt(void *);
extern void (*fpsave_ctxt)(void *);
extern void fxsave_insn(struct fxsave_state *);
extern void fpsave(struct fnsave_state *);
extern void fprestore(struct fnsave_state *);
extern void fpxsave(struct fxsave_state *);
extern void fpxrestore(struct fxsave_state *);
extern void fpenable(void);
extern void fpdisable(void);
extern void fpinit(void);
extern uint32_t fperr_reset(void);
extern uint32_t fpxerr_reset(void);
extern uint32_t fpgetmxcsr(void);
struct regs;
extern int fpnoextflt(struct regs *);
extern int fpextovrflt(struct regs *);
extern int fpexterrflt(struct regs *);
extern int fpsimderrflt(struct regs *);
#endif /* _KERNEL */
#ifdef __cplusplus
}
#endif
#endif /* _SYS_FP_H */