xref: /onnv-gate/usr/src/uts/sparc/sys/fpu/fpu_simulator.h (revision 10271:7c80b70bb8de)
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
51772Sjl139090  * Common Development and Distribution License (the "License").
61772Sjl139090  * 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 /*
228829SSree.Vemuri@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #ifndef	_SYS_FPU_FPU_SIMULATOR_H
270Sstevel@tonic-gate #define	_SYS_FPU_FPU_SIMULATOR_H
280Sstevel@tonic-gate 
290Sstevel@tonic-gate /* SunOS-4.0 1.10	*/
300Sstevel@tonic-gate 
310Sstevel@tonic-gate /*
320Sstevel@tonic-gate  * sparc floating-point simulator definitions.
330Sstevel@tonic-gate  */
340Sstevel@tonic-gate 
350Sstevel@tonic-gate #ifndef	_ASM
360Sstevel@tonic-gate #include <sys/types.h>
370Sstevel@tonic-gate #include <sys/ieeefp.h>
380Sstevel@tonic-gate #include <vm/seg.h>
390Sstevel@tonic-gate #include <sys/kstat.h>
400Sstevel@tonic-gate #endif /* _ASM */
410Sstevel@tonic-gate 
420Sstevel@tonic-gate #ifdef	__cplusplus
430Sstevel@tonic-gate extern "C" {
440Sstevel@tonic-gate #endif
450Sstevel@tonic-gate 
460Sstevel@tonic-gate /*
470Sstevel@tonic-gate  * Constants to decode/extract "fitos" instruction fields
480Sstevel@tonic-gate  */
490Sstevel@tonic-gate #define	FITOS_INSTR_MASK	0xc1f83fe0
500Sstevel@tonic-gate #define	FITOS_INSTR		0x81a01880
510Sstevel@tonic-gate #define	FITOS_RS2_SHIFT		0
520Sstevel@tonic-gate #define	FITOS_RD_SHIFT		25
530Sstevel@tonic-gate #define	FITOS_REG_MASK		0x1f
540Sstevel@tonic-gate 
550Sstevel@tonic-gate #ifndef _ASM
560Sstevel@tonic-gate /*	PUBLIC TYPES	*/
570Sstevel@tonic-gate 
580Sstevel@tonic-gate enum fcc_type {			/* relationships */
590Sstevel@tonic-gate 	fcc_equal	= 0,
600Sstevel@tonic-gate 	fcc_less	= 1,
610Sstevel@tonic-gate 	fcc_greater	= 2,
620Sstevel@tonic-gate 	fcc_unordered	= 3
630Sstevel@tonic-gate };
640Sstevel@tonic-gate 
650Sstevel@tonic-gate enum cc_type {			/* icc/fcc number */
660Sstevel@tonic-gate 	fcc_0	= 0,
670Sstevel@tonic-gate 	fcc_1	= 1,
680Sstevel@tonic-gate 	fcc_2	= 2,
690Sstevel@tonic-gate 	fcc_3	= 3,
700Sstevel@tonic-gate 	icc	= 4,
710Sstevel@tonic-gate 	xcc	= 6
720Sstevel@tonic-gate };
730Sstevel@tonic-gate 
740Sstevel@tonic-gate /* FSR types. */
750Sstevel@tonic-gate 
760Sstevel@tonic-gate enum ftt_type {			/* types of traps */
770Sstevel@tonic-gate 	ftt_none	= 0,
780Sstevel@tonic-gate 	ftt_ieee	= 1,
790Sstevel@tonic-gate 	ftt_unfinished	= 2,
800Sstevel@tonic-gate 	ftt_unimplemented = 3,
810Sstevel@tonic-gate 	ftt_sequence	= 4,
820Sstevel@tonic-gate 	ftt_alignment	= 5,	/* defined by software convention only */
830Sstevel@tonic-gate 	ftt_fault	= 6,	/* defined by software convention only */
840Sstevel@tonic-gate 	ftt_7		= 7
850Sstevel@tonic-gate };
860Sstevel@tonic-gate 
870Sstevel@tonic-gate typedef	struct {		/* sparc V9 FSR. */
880Sstevel@tonic-gate 	unsigned int			: 26;
890Sstevel@tonic-gate 	unsigned int		fcc3	: 2;	/* fp condition code 3 */
900Sstevel@tonic-gate 	unsigned int		fcc2	: 2;	/* fp condition code 2 */
910Sstevel@tonic-gate 	unsigned int		fcc1	: 2;	/* fp condition code 1 */
920Sstevel@tonic-gate 						/* enum fp_direction_type */
930Sstevel@tonic-gate 	unsigned int		rnd	: 2;	/* rounding direction */
940Sstevel@tonic-gate 	unsigned int		rnp	: 2;	/* for v7 compatibility only */
950Sstevel@tonic-gate 	unsigned int		tem	: 5;	/* trap enable mask */
960Sstevel@tonic-gate 	unsigned int		 ns	: 1;	/* non-standard */
970Sstevel@tonic-gate 	unsigned int			: 5;
980Sstevel@tonic-gate 						/* enum ftt_type */
990Sstevel@tonic-gate 	unsigned int 		ftt	: 3;	/* FPU trap type */
1000Sstevel@tonic-gate 	unsigned int		qne	: 1;	/* FPQ not empty */
1010Sstevel@tonic-gate 	unsigned int		 pr	: 1;	/* partial result */
1020Sstevel@tonic-gate 						/* enum fcc_type */
1030Sstevel@tonic-gate 	unsigned int 		fcc	: 2;	/* fp condition code 0 */
1040Sstevel@tonic-gate 	unsigned int		aexc	: 5;	/* accumulated exceptions */
1050Sstevel@tonic-gate 	unsigned int		cexc	: 5;	/* current exception */
1060Sstevel@tonic-gate } fsr_types;
1070Sstevel@tonic-gate 
1080Sstevel@tonic-gate /*
1090Sstevel@tonic-gate  * The C compiler and the C spec do not support bitfields in a long long,
1100Sstevel@tonic-gate  * as per fsr_types above, so don't hold your breath waiting for this
1110Sstevel@tonic-gate  * workaround cruft to disappear.
1120Sstevel@tonic-gate  */
1130Sstevel@tonic-gate 
1140Sstevel@tonic-gate typedef union {
1150Sstevel@tonic-gate 	fsr_types	fsr;
1160Sstevel@tonic-gate 	uint64_t	ll;
1170Sstevel@tonic-gate } fsr_type;
1180Sstevel@tonic-gate 
1190Sstevel@tonic-gate #define	fcc3	fsr.fcc3
1200Sstevel@tonic-gate #define	fcc2	fsr.fcc2
1210Sstevel@tonic-gate #define	fcc1	fsr.fcc1
1220Sstevel@tonic-gate #define	fcc0	fsr.fcc
1230Sstevel@tonic-gate #define	rnd	fsr.rnd
1240Sstevel@tonic-gate #define	rnp	fsr.rnp
1250Sstevel@tonic-gate #define	tem	fsr.tem
1260Sstevel@tonic-gate #define	aexc	fsr.aexc
1270Sstevel@tonic-gate #define	cexc	fsr.cexc
1280Sstevel@tonic-gate 
1290Sstevel@tonic-gate typedef			/* FPU register viewed as single components. */
1300Sstevel@tonic-gate 	struct {
1310Sstevel@tonic-gate 	uint32_t sign :		1;
1320Sstevel@tonic-gate 	uint32_t exponent :	8;
1330Sstevel@tonic-gate 	uint32_t significand : 23;
1340Sstevel@tonic-gate } single_type;
1350Sstevel@tonic-gate 
1360Sstevel@tonic-gate typedef			/* FPU register viewed as double components. */
1370Sstevel@tonic-gate 	struct {
1380Sstevel@tonic-gate 	uint32_t sign :		1;
1390Sstevel@tonic-gate 	uint32_t exponent :    11;
1400Sstevel@tonic-gate 	uint32_t significand : 20;
1410Sstevel@tonic-gate } double_type;
1420Sstevel@tonic-gate 
1430Sstevel@tonic-gate typedef			/* FPU register viewed as extended components. */
1440Sstevel@tonic-gate 	struct {
1450Sstevel@tonic-gate 	uint32_t sign :		 1;
1460Sstevel@tonic-gate 	uint32_t exponent :	15;
1470Sstevel@tonic-gate 	uint32_t significand :	16;
1480Sstevel@tonic-gate } extended_type;
1490Sstevel@tonic-gate 
1500Sstevel@tonic-gate typedef			/* FPU register with multiple data views. */
1510Sstevel@tonic-gate 	union {
1520Sstevel@tonic-gate 	int32_t		int32_reg;
1530Sstevel@tonic-gate 	int64_t		int64_reg;
1540Sstevel@tonic-gate 	uint32_t	uint32_reg;
1550Sstevel@tonic-gate 	uint64_t	uint64_reg;
1560Sstevel@tonic-gate 	float		float_reg;
1570Sstevel@tonic-gate 	single_type	single_reg;
1580Sstevel@tonic-gate 	double_type	double_reg;
1590Sstevel@tonic-gate 	extended_type	extended_reg;
1600Sstevel@tonic-gate } freg_type;
1610Sstevel@tonic-gate 
1620Sstevel@tonic-gate enum fp_op_type {		/* Type specifiers in FPU instructions. */
1630Sstevel@tonic-gate 	fp_op_int32	= 0,	/* Not in hardware, but convenient to define. */
1640Sstevel@tonic-gate 	fp_op_single	= 1,
1650Sstevel@tonic-gate 	fp_op_double	= 2,
1660Sstevel@tonic-gate 	fp_op_extended	= 3,
1670Sstevel@tonic-gate 	fp_op_int64	= 4
1680Sstevel@tonic-gate };
1690Sstevel@tonic-gate 
1700Sstevel@tonic-gate enum fp_opcode {	/* FPU op codes, minus precision and leading 0. */
1710Sstevel@tonic-gate 	fmovs		= 0x0,
1720Sstevel@tonic-gate 	fnegs		= 0x1,
1730Sstevel@tonic-gate 	fabss		= 0x2,
1740Sstevel@tonic-gate 	fp_op_3 = 3, fp_op_4 = 4, fp_op_5 = 5, fp_op_6 = 6, fp_op_7 = 7,
1750Sstevel@tonic-gate 	fp_op_8		= 0x8,
1760Sstevel@tonic-gate 	fp_op_9		= 0x9,
1770Sstevel@tonic-gate 	fsqrt		= 0xa,
1780Sstevel@tonic-gate 	fp_op_b = 0xb, fp_op_c = 0xc, fp_op_d = 0xd,
1790Sstevel@tonic-gate 	fp_op_e = 0xe, fp_op_f = 0xf,
1800Sstevel@tonic-gate 	fadd		= 0x10,
1810Sstevel@tonic-gate 	fsub		= 0x11,
1820Sstevel@tonic-gate 	fmul		= 0x12,
1830Sstevel@tonic-gate 	fdiv		= 0x13,
1840Sstevel@tonic-gate 	fcmp		= 0x14,
1850Sstevel@tonic-gate 	fcmpe		= 0x15,
1860Sstevel@tonic-gate 	fp_op_16 = 0x16, fp_op_17 = 0x17,
1870Sstevel@tonic-gate 	fp_op_18	= 0x18,
1880Sstevel@tonic-gate 	fp_op_19	= 0x19,
1890Sstevel@tonic-gate 	fsmuld		= 0x1a,
1900Sstevel@tonic-gate 	fdmulx		= 0x1b,
1910Sstevel@tonic-gate 	ftoll		= 0x20,
1920Sstevel@tonic-gate 	flltos		= 0x21,
1930Sstevel@tonic-gate 	flltod		= 0x22,
1940Sstevel@tonic-gate 	flltox		= 0x23,
1950Sstevel@tonic-gate 	fp_op_24 = 0x24, fp_op_25 = 0x25, fp_op_26 = 0x26, fp_op_27 = 0x27,
1960Sstevel@tonic-gate 	fp_op_28 = 0x28, fp_op_29 = 0x29, fp_op_2a = 0x2a, fp_op_2b = 0x2b,
1970Sstevel@tonic-gate 	fp_op_2c = 0x2c, fp_op_2d = 0x2d, fp_op_2e = 0x2e, fp_op_2f = 0x2f,
1980Sstevel@tonic-gate 	fp_op_30	= 0x30,
1990Sstevel@tonic-gate 	fitos		= 0x31,
2000Sstevel@tonic-gate 	fitod		= 0x32,
2010Sstevel@tonic-gate 	fitox		= 0x33,
2020Sstevel@tonic-gate 	ftoi		= 0x34,
2030Sstevel@tonic-gate 	fp_op_35 = 0x35, fp_op_36 = 0x36, fp_op_37 = 0x37,
2040Sstevel@tonic-gate 	ft_op_38	= 0x38,
2050Sstevel@tonic-gate 	fp_op_39 = 0x39, fp_op_3a = 0x3a, fp_op_3b = 0x3b,
2060Sstevel@tonic-gate 	fp_op_3c	= 0x3c,
207*10271SJason.Beloro@Sun.COM 	fp_op_3d = 0x3d, fp_op_3e = 0x3e, fp_op_3f = 0x3f
2080Sstevel@tonic-gate };
2090Sstevel@tonic-gate 
2100Sstevel@tonic-gate typedef			/* FPU instruction. */
2110Sstevel@tonic-gate 	struct {
2120Sstevel@tonic-gate 	uint32_t		hibits	: 2;	/* Top two bits. */
2130Sstevel@tonic-gate 	uint32_t		rd	: 5;	/* Destination. */
2140Sstevel@tonic-gate 	uint32_t		op3	: 6;	/* Main op code. */
2150Sstevel@tonic-gate 	uint32_t		rs1	: 5;	/* First operand. */
2160Sstevel@tonic-gate 	uint32_t		ibit	: 1;	/* I format bit. */
2170Sstevel@tonic-gate 	uint32_t /* enum fp_opcode */  opcode : 6; /* Floating-point op code. */
2180Sstevel@tonic-gate 	uint32_t /* enum fp_op_type */ prec   : 2; /* Precision. */
2190Sstevel@tonic-gate 	uint32_t		rs2	: 5;	/* Second operand. */
2200Sstevel@tonic-gate } fp_inst_type;
2210Sstevel@tonic-gate 
222*10271SJason.Beloro@Sun.COM enum fp_op_fma_var {	/* IMPDEP2B FMA-fused instr. variations */
2231772Sjl139090 	fmadd	=	0,
2241772Sjl139090 	fmsub	=	1,
2251772Sjl139090 	fnmsub	=	2,
2261772Sjl139090 	fnmadd	=	3
2271772Sjl139090 };
2281772Sjl139090 
229*10271SJason.Beloro@Sun.COM typedef		/* IMPDEP2B FPU FMA-fused instruction. */
2301772Sjl139090 	struct {
2311772Sjl139090 	uint32_t		hibits	: 2;	/* Top two bits. */
2321772Sjl139090 	uint32_t		rd	: 5;	/* Destination. */
2331772Sjl139090 	uint32_t		op3	: 6;	/* Main op code. */
2341772Sjl139090 	uint32_t		rs1	: 5;	/* First operand. */
2351772Sjl139090 	uint32_t		rs3	: 5;	/* Third operand */
2361772Sjl139090 	uint32_t /* enum fp_op_fma_var */ var : 2; /* Instr. variation */
2371772Sjl139090 	uint32_t		sz	: 2;	/* Size */
2381772Sjl139090 	uint32_t		rs2	: 5;	/* Second operand. */
2391772Sjl139090 } fp_fma_inst_type;
2401772Sjl139090 
2410Sstevel@tonic-gate typedef			/* Integer condition code. */
2420Sstevel@tonic-gate 	struct {
2430Sstevel@tonic-gate 	uint32_t			: 28;	/* the unused part */
2440Sstevel@tonic-gate 	uint32_t		n	: 1;	/* Negative bit. */
2450Sstevel@tonic-gate 	uint32_t		z	: 1;	/* Zero bit. */
2460Sstevel@tonic-gate 	uint32_t		v	: 1;	/* Overflow bit. */
2470Sstevel@tonic-gate 	uint32_t		c	: 1;	/* Carry bit. */
2480Sstevel@tonic-gate } ccr_type;
2490Sstevel@tonic-gate 
2500Sstevel@tonic-gate typedef			/* FPU data used by simulator. */
2510Sstevel@tonic-gate 	struct {
2520Sstevel@tonic-gate 	uint_t			fp_fsrtem;
2530Sstevel@tonic-gate 	enum fp_direction_type	fp_direction;
2540Sstevel@tonic-gate 	enum fp_precision_type	fp_precision;
2550Sstevel@tonic-gate 	uint_t			fp_current_exceptions;
2560Sstevel@tonic-gate 	kfpu_t			*fp_current_pfregs;
2570Sstevel@tonic-gate 	void			(*fp_current_read_freg) ();
2580Sstevel@tonic-gate 	void			(*fp_current_write_freg) ();
2590Sstevel@tonic-gate 	void			(*fp_current_read_dreg) ();
2600Sstevel@tonic-gate 	void			(*fp_current_write_dreg) ();
2617Sdf157793 	uint64_t		(*fp_current_read_gsr) (kfpu_t *);
2627Sdf157793 	void			(*fp_current_write_gsr) (uint64_t, kfpu_t *);
2630Sstevel@tonic-gate 	int			fp_trapcode;
2640Sstevel@tonic-gate 	char			*fp_trapaddr;
2650Sstevel@tonic-gate 	struct	regs		*fp_traprp;
2660Sstevel@tonic-gate 	enum	seg_rw		fp_traprw;
2670Sstevel@tonic-gate } fp_simd_type;
2680Sstevel@tonic-gate 
2690Sstevel@tonic-gate /*
2700Sstevel@tonic-gate  * FPU related kstat structures
2710Sstevel@tonic-gate  */
2720Sstevel@tonic-gate struct fpustat_kstat  {
2730Sstevel@tonic-gate 	struct kstat_named		fpu_ieee_traps;
2740Sstevel@tonic-gate 	struct kstat_named		fpu_unfinished_traps;
2750Sstevel@tonic-gate 	struct kstat_named		fpu_unimplemented_traps;
2760Sstevel@tonic-gate };
2770Sstevel@tonic-gate 
2780Sstevel@tonic-gate struct fpuinfo_kstat {
2790Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fmovs;
2800Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fmovd;
2810Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fmovq;
2820Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fnegs;
2830Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fnegd;
2840Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fnegq;
2850Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fabss;
2860Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fabsd;
2870Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fabsq;
2880Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fsqrts;
2890Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fsqrtd;
2900Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fsqrtq;
2910Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fadds;
2920Sstevel@tonic-gate 	struct kstat_named		fpu_sim_faddd;
2930Sstevel@tonic-gate 	struct kstat_named		fpu_sim_faddq;
2940Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fsubs;
2950Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fsubd;
2960Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fsubq;
2970Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fmuls;
2980Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fmuld;
2990Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fmulq;
3000Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fdivs;
3010Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fdivd;
3020Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fdivq;
3030Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fcmps;
3040Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fcmpd;
3050Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fcmpq;
3060Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fcmpes;
3070Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fcmped;
3080Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fcmpeq;
3090Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fsmuld;
3100Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fdmulx;
3110Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fstox;
3120Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fdtox;
3130Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fqtox;
3140Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fxtos;
3150Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fxtod;
3160Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fxtoq;
3170Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fitos;
3180Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fitod;
3190Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fitoq;
3200Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fstoi;
3210Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fdtoi;
3220Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fqtoi;
3230Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fmovcc;
3240Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fmovr;
3251772Sjl139090 	struct kstat_named		fpu_sim_fmadds;
3261772Sjl139090 	struct kstat_named		fpu_sim_fmaddd;
3271772Sjl139090 	struct kstat_named		fpu_sim_fmsubs;
3281772Sjl139090 	struct kstat_named		fpu_sim_fmsubd;
3291772Sjl139090 	struct kstat_named		fpu_sim_fnmadds;
3301772Sjl139090 	struct kstat_named		fpu_sim_fnmaddd;
3311772Sjl139090 	struct kstat_named		fpu_sim_fnmsubs;
3321772Sjl139090 	struct kstat_named		fpu_sim_fnmsubd;
3331772Sjl139090 	struct kstat_named		fpu_sim_invalid;
3340Sstevel@tonic-gate };
3350Sstevel@tonic-gate 
3360Sstevel@tonic-gate struct visinfo_kstat {
3370Sstevel@tonic-gate 	struct kstat_named		vis_edge8;
3380Sstevel@tonic-gate 	struct kstat_named		vis_edge8n;
3390Sstevel@tonic-gate 	struct kstat_named		vis_edge8l;
3400Sstevel@tonic-gate 	struct kstat_named		vis_edge8ln;
3410Sstevel@tonic-gate 	struct kstat_named		vis_edge16;
3420Sstevel@tonic-gate 	struct kstat_named		vis_edge16n;
3430Sstevel@tonic-gate 	struct kstat_named		vis_edge16l;
3440Sstevel@tonic-gate 	struct kstat_named		vis_edge16ln;
3450Sstevel@tonic-gate 	struct kstat_named		vis_edge32;
3460Sstevel@tonic-gate 	struct kstat_named		vis_edge32n;
3470Sstevel@tonic-gate 	struct kstat_named		vis_edge32l;
3480Sstevel@tonic-gate 	struct kstat_named		vis_edge32ln;
3490Sstevel@tonic-gate 	struct kstat_named		vis_array8;
3500Sstevel@tonic-gate 	struct kstat_named		vis_array16;
3510Sstevel@tonic-gate 	struct kstat_named		vis_array32;
3520Sstevel@tonic-gate 	struct kstat_named		vis_bmask;
3530Sstevel@tonic-gate 	struct kstat_named		vis_fcmple16;
3540Sstevel@tonic-gate 	struct kstat_named		vis_fcmpne16;
3550Sstevel@tonic-gate 	struct kstat_named		vis_fcmpgt16;
3560Sstevel@tonic-gate 	struct kstat_named		vis_fcmpeq16;
3570Sstevel@tonic-gate 	struct kstat_named		vis_fcmple32;
3580Sstevel@tonic-gate 	struct kstat_named		vis_fcmpne32;
3590Sstevel@tonic-gate 	struct kstat_named		vis_fcmpgt32;
3600Sstevel@tonic-gate 	struct kstat_named		vis_fcmpeq32;
3610Sstevel@tonic-gate 	struct kstat_named		vis_fmul8x16;
3620Sstevel@tonic-gate 	struct kstat_named		vis_fmul8x16au;
3630Sstevel@tonic-gate 	struct kstat_named		vis_fmul8x16al;
3640Sstevel@tonic-gate 	struct kstat_named		vis_fmul8sux16;
3650Sstevel@tonic-gate 	struct kstat_named		vis_fmul8ulx16;
3660Sstevel@tonic-gate 	struct kstat_named		vis_fmuld8sux16;
3670Sstevel@tonic-gate 	struct kstat_named		vis_fmuld8ulx16;
3680Sstevel@tonic-gate 	struct kstat_named		vis_fpack16;
3690Sstevel@tonic-gate 	struct kstat_named		vis_fpack32;
3700Sstevel@tonic-gate 	struct kstat_named		vis_fpackfix;
3710Sstevel@tonic-gate 	struct kstat_named		vis_fexpand;
3720Sstevel@tonic-gate 	struct kstat_named		vis_fpmerge;
3730Sstevel@tonic-gate 	struct kstat_named		vis_pdist;
3748829SSree.Vemuri@Sun.COM 	struct kstat_named		vis_pdistn;
3750Sstevel@tonic-gate 	struct kstat_named		vis_bshuffle;
3760Sstevel@tonic-gate };
3770Sstevel@tonic-gate 
3780Sstevel@tonic-gate #define	VISINFO_KSTAT(opcode)	{					\
3790Sstevel@tonic-gate 	extern void __dtrace_probe___visinfo_##opcode(uint64_t *);	\
3800Sstevel@tonic-gate 	uint64_t *stataddr = &visinfo.opcode.value.ui64;		\
3810Sstevel@tonic-gate 	__dtrace_probe___visinfo_##opcode(stataddr);       		\
3820Sstevel@tonic-gate 	atomic_add_64(&visinfo.opcode.value.ui64, 1);			\
3830Sstevel@tonic-gate }
3840Sstevel@tonic-gate 
3850Sstevel@tonic-gate 
3860Sstevel@tonic-gate /* PUBLIC FUNCTIONS */
3870Sstevel@tonic-gate 
3880Sstevel@tonic-gate #ifdef	__STDC__
3890Sstevel@tonic-gate 
3900Sstevel@tonic-gate /*
3910Sstevel@tonic-gate  * fpu_vis_sim simulates FPU VIS Partial load store instructions; reads and
3920Sstevel@tonic-gate  * writes FPU data registers directly or works with the PCB image if fpu_exists
3930Sstevel@tonic-gate  * is 0.
3940Sstevel@tonic-gate  */
3950Sstevel@tonic-gate extern enum ftt_type fpu_vis_sim(fp_simd_type *pfpsd, fp_inst_type *pinst,
3960Sstevel@tonic-gate 	struct regs *pregs, fsr_type *pfsr, uint64_t gsr, uint32_t inst);
3970Sstevel@tonic-gate /*
3980Sstevel@tonic-gate  * fpu_simulator simulates FPU instructions only; reads and writes FPU data
3990Sstevel@tonic-gate  * registers directly.
4000Sstevel@tonic-gate  */
4010Sstevel@tonic-gate extern enum ftt_type fpu_simulator(fp_simd_type *pfpsd, fp_inst_type *pinst,
4020Sstevel@tonic-gate 	fsr_type *pfsr, uint64_t gsr, uint32_t inst);
4030Sstevel@tonic-gate /*
4040Sstevel@tonic-gate  * fp_emulator simulates FPU and CPU-FPU instructions; reads and writes FPU
4050Sstevel@tonic-gate  * data registers from image in pfpu.
4060Sstevel@tonic-gate  */
4070Sstevel@tonic-gate extern enum ftt_type fp_emulator(fp_simd_type *pfpsd, fp_inst_type *pinst,
4080Sstevel@tonic-gate 	struct regs *rp, void *prw, kfpu_t *pfpu);
4090Sstevel@tonic-gate /*
4100Sstevel@tonic-gate  * fp_traps handles passing exception conditions to the kernel.
4110Sstevel@tonic-gate  * It is called after fp_simulator or fp_emulator fail (return a non-zero ftt).
4120Sstevel@tonic-gate  */
4130Sstevel@tonic-gate extern void fp_traps(fp_simd_type *pfpsd, enum ftt_type ftt, struct regs *rp);
4140Sstevel@tonic-gate 
4150Sstevel@tonic-gate /*
4160Sstevel@tonic-gate  * fp_kstat_update tracks fpu exception conditions.
4170Sstevel@tonic-gate  * It is called after a hardware trap returns a non-zero ftt.
4180Sstevel@tonic-gate  */
4190Sstevel@tonic-gate extern void fp_kstat_update(enum ftt_type ftt);
4200Sstevel@tonic-gate 
4210Sstevel@tonic-gate /*
4220Sstevel@tonic-gate  * fp_precise handles floating point unimplemented and unfinished traps,
4230Sstevel@tonic-gate  * for sparc V9 hardware. These traps are normally passed along to the
4240Sstevel@tonic-gate  * fpu_simulator, to see if it can run the unimplemented instruction or
4250Sstevel@tonic-gate  * finish the unfinished instruction. Needless to say, this takes time.
4260Sstevel@tonic-gate  */
4270Sstevel@tonic-gate extern void fp_precise(struct regs *rp);
4280Sstevel@tonic-gate 
4290Sstevel@tonic-gate /*
4300Sstevel@tonic-gate  * fpu_trap handles V9 floating point ieee and other floating point traps.
4310Sstevel@tonic-gate  * It is called after fp_simulator or fp_emulator fail (return a non-zero ftt),
4320Sstevel@tonic-gate  * and from the _fp_ieee_exception trap handler.
4330Sstevel@tonic-gate  */
4340Sstevel@tonic-gate extern void fpu_trap(struct regs *rp, caddr_t addr, uint32_t type,
4350Sstevel@tonic-gate 			uint32_t code);
4360Sstevel@tonic-gate 
4370Sstevel@tonic-gate #else	/* ! __STDC__ */
4380Sstevel@tonic-gate 
4390Sstevel@tonic-gate /*
4400Sstevel@tonic-gate  * fpu_simulator simulates FPU instructions only; reads and writes FPU data
4410Sstevel@tonic-gate  * registers directly.
4420Sstevel@tonic-gate  */
4430Sstevel@tonic-gate extern enum ftt_type fpu_simulator(
4440Sstevel@tonic-gate 	fp_simd_type	*pfpsd,	 /* Pointer to FPU simulator data */
4450Sstevel@tonic-gate 	fp_inst_type	*pinst,	 /* Pointer to FPU instruction to simulate. */
4460Sstevel@tonic-gate 	fsr_type	*pfsr,	 /* Pointer to image of FSR to read & write. */
4470Sstevel@tonic-gate 	int		instr);	 /* Instruction to emulate. */
4480Sstevel@tonic-gate 
4490Sstevel@tonic-gate /*
4500Sstevel@tonic-gate  * fp_emulator simulates FPU and CPU-FPU instructions; reads and writes FPU
4510Sstevel@tonic-gate  * data registers from image in pfpu.
4520Sstevel@tonic-gate  */
4530Sstevel@tonic-gate extern enum ftt_type fp_emulator(
4540Sstevel@tonic-gate 	fp_simd_type	*pfpsd,	   /* Pointer to FPU simulator data */
4550Sstevel@tonic-gate 	fp_inst_type	*pinst,    /* Pointer to FPU instruction to simulate. */
4560Sstevel@tonic-gate 	struct regs	*pregs,    /* Pointer to PCB image of registers. */
4570Sstevel@tonic-gate 	struct rwindow	*pwindow,  /* Pointer to locals and ins. */
4580Sstevel@tonic-gate 	struct fpu	*pfpu);	   /* Pointer to FPU register block. */
4590Sstevel@tonic-gate 
4600Sstevel@tonic-gate /*
4610Sstevel@tonic-gate  * fp_traps handles passing exception conditions to the kernel.
4620Sstevel@tonic-gate  * It is called after fp_simulator or fp_emulator fail (return a non-zero ftt).
4630Sstevel@tonic-gate  */
4640Sstevel@tonic-gate extern void fp_traps(
4650Sstevel@tonic-gate 	fp_simd_type	*pfpsd,	 /* Pointer to FPU simulator data */
4660Sstevel@tonic-gate 	enum ftt_type	ftt,	 /* Type of trap. */
4670Sstevel@tonic-gate 	struct regs	*rp);	 /* Pointer to PCB image of registers. */
4680Sstevel@tonic-gate 
4690Sstevel@tonic-gate /*
4700Sstevel@tonic-gate  * fp_kstat_update tracks fpu exception conditions.
4710Sstevel@tonic-gate  * It is called after a hardware trap returns a non-zero ftt.
4720Sstevel@tonic-gate  */
4730Sstevel@tonic-gate extern void fp_kstat_update(enum ftt_type ftt);	/* Type of trap. */
4740Sstevel@tonic-gate 
4750Sstevel@tonic-gate /*
4760Sstevel@tonic-gate  * fp_precise handles floating point unimplemented and unfinished traps,
4770Sstevel@tonic-gate  * for sparc V9 hardware. These traps are normally passed along to the
4780Sstevel@tonic-gate  * fpu_simulator, to see if it can run the unimplemented instruction or
4790Sstevel@tonic-gate  * finish the unfinished instruction. Needless to say, this takes time.
4800Sstevel@tonic-gate  */
4810Sstevel@tonic-gate extern void fp_precise(
4820Sstevel@tonic-gate 	struct regs *rp);	/* Pointer to PCB image of registers. */
4830Sstevel@tonic-gate 
4840Sstevel@tonic-gate /*
4850Sstevel@tonic-gate  * fpu_trap handles V9 floating point ieee and other floating point traps.
4860Sstevel@tonic-gate  * It is called after fp_simulator or fp_emulator fail (return a non-zero ftt),
4870Sstevel@tonic-gate  * and from the _fp_ieee_exception trap handler.
4880Sstevel@tonic-gate  */
4890Sstevel@tonic-gate extern void fpu_trap(
4900Sstevel@tonic-gate 	struct regs *rp,	/* Pointer to PCB image of registers. */
4910Sstevel@tonic-gate 	caddr_t addr,		/* Address of trapping instruction. */
4920Sstevel@tonic-gate 	uint32_t type,		/* Type of trapping exception. */
4930Sstevel@tonic-gate 	uint32_t code);		/* Trap code -> si_code. */
4940Sstevel@tonic-gate 
4950Sstevel@tonic-gate #endif	/* __STDC__ */
4960Sstevel@tonic-gate #endif /* _ASM */
4970Sstevel@tonic-gate 
4980Sstevel@tonic-gate #ifdef	__cplusplus
4990Sstevel@tonic-gate }
5000Sstevel@tonic-gate #endif
5010Sstevel@tonic-gate 
5020Sstevel@tonic-gate #endif	/* _SYS_FPU_FPU_SIMULATOR_H */
503