17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
227c478bd9Sstevel@tonic-gate /*
237c478bd9Sstevel@tonic-gate  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate #ifndef	_SYS_FPU_FPU_SIMULATOR_H
287c478bd9Sstevel@tonic-gate #define	_SYS_FPU_FPU_SIMULATOR_H
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
317c478bd9Sstevel@tonic-gate /* SunOS-4.0 1.10	*/
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate /*
347c478bd9Sstevel@tonic-gate  * sparc floating-point simulator definitions.
357c478bd9Sstevel@tonic-gate  */
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate #ifndef	_ASM
387c478bd9Sstevel@tonic-gate #include <sys/types.h>
397c478bd9Sstevel@tonic-gate #include <sys/ieeefp.h>
407c478bd9Sstevel@tonic-gate #include <vm/seg.h>
417c478bd9Sstevel@tonic-gate #include <sys/kstat.h>
427c478bd9Sstevel@tonic-gate #endif /* _ASM */
437c478bd9Sstevel@tonic-gate 
447c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
457c478bd9Sstevel@tonic-gate extern "C" {
467c478bd9Sstevel@tonic-gate #endif
477c478bd9Sstevel@tonic-gate 
487c478bd9Sstevel@tonic-gate /*
497c478bd9Sstevel@tonic-gate  * Constants to decode/extract "fitos" instruction fields
507c478bd9Sstevel@tonic-gate  */
517c478bd9Sstevel@tonic-gate #define	FITOS_INSTR_MASK	0xc1f83fe0
527c478bd9Sstevel@tonic-gate #define	FITOS_INSTR		0x81a01880
537c478bd9Sstevel@tonic-gate #define	FITOS_RS2_SHIFT		0
547c478bd9Sstevel@tonic-gate #define	FITOS_RD_SHIFT		25
557c478bd9Sstevel@tonic-gate #define	FITOS_REG_MASK		0x1f
567c478bd9Sstevel@tonic-gate 
577c478bd9Sstevel@tonic-gate #ifndef _ASM
587c478bd9Sstevel@tonic-gate /*	PUBLIC TYPES	*/
597c478bd9Sstevel@tonic-gate 
607c478bd9Sstevel@tonic-gate enum fcc_type {			/* relationships */
617c478bd9Sstevel@tonic-gate 	fcc_equal	= 0,
627c478bd9Sstevel@tonic-gate 	fcc_less	= 1,
637c478bd9Sstevel@tonic-gate 	fcc_greater	= 2,
647c478bd9Sstevel@tonic-gate 	fcc_unordered	= 3
657c478bd9Sstevel@tonic-gate };
667c478bd9Sstevel@tonic-gate 
677c478bd9Sstevel@tonic-gate enum cc_type {			/* icc/fcc number */
687c478bd9Sstevel@tonic-gate 	fcc_0	= 0,
697c478bd9Sstevel@tonic-gate 	fcc_1	= 1,
707c478bd9Sstevel@tonic-gate 	fcc_2	= 2,
717c478bd9Sstevel@tonic-gate 	fcc_3	= 3,
727c478bd9Sstevel@tonic-gate 	icc	= 4,
737c478bd9Sstevel@tonic-gate 	xcc	= 6
747c478bd9Sstevel@tonic-gate };
757c478bd9Sstevel@tonic-gate 
767c478bd9Sstevel@tonic-gate /* FSR types. */
777c478bd9Sstevel@tonic-gate 
787c478bd9Sstevel@tonic-gate enum ftt_type {			/* types of traps */
797c478bd9Sstevel@tonic-gate 	ftt_none	= 0,
807c478bd9Sstevel@tonic-gate 	ftt_ieee	= 1,
817c478bd9Sstevel@tonic-gate 	ftt_unfinished	= 2,
827c478bd9Sstevel@tonic-gate 	ftt_unimplemented = 3,
837c478bd9Sstevel@tonic-gate 	ftt_sequence	= 4,
847c478bd9Sstevel@tonic-gate 	ftt_alignment	= 5,	/* defined by software convention only */
857c478bd9Sstevel@tonic-gate 	ftt_fault	= 6,	/* defined by software convention only */
867c478bd9Sstevel@tonic-gate 	ftt_7		= 7
877c478bd9Sstevel@tonic-gate };
887c478bd9Sstevel@tonic-gate 
897c478bd9Sstevel@tonic-gate typedef	struct {		/* sparc V9 FSR. */
907c478bd9Sstevel@tonic-gate 	unsigned int			: 26;
917c478bd9Sstevel@tonic-gate 	unsigned int		fcc3	: 2;	/* fp condition code 3 */
927c478bd9Sstevel@tonic-gate 	unsigned int		fcc2	: 2;	/* fp condition code 2 */
937c478bd9Sstevel@tonic-gate 	unsigned int		fcc1	: 2;	/* fp condition code 1 */
947c478bd9Sstevel@tonic-gate 						/* enum fp_direction_type */
957c478bd9Sstevel@tonic-gate 	unsigned int		rnd	: 2;	/* rounding direction */
967c478bd9Sstevel@tonic-gate 	unsigned int		rnp	: 2;	/* for v7 compatibility only */
977c478bd9Sstevel@tonic-gate 	unsigned int		tem	: 5;	/* trap enable mask */
987c478bd9Sstevel@tonic-gate 	unsigned int		 ns	: 1;	/* non-standard */
997c478bd9Sstevel@tonic-gate 	unsigned int			: 5;
1007c478bd9Sstevel@tonic-gate 						/* enum ftt_type */
1017c478bd9Sstevel@tonic-gate 	unsigned int 		ftt	: 3;	/* FPU trap type */
1027c478bd9Sstevel@tonic-gate 	unsigned int		qne	: 1;	/* FPQ not empty */
1037c478bd9Sstevel@tonic-gate 	unsigned int		 pr	: 1;	/* partial result */
1047c478bd9Sstevel@tonic-gate 						/* enum fcc_type */
1057c478bd9Sstevel@tonic-gate 	unsigned int 		fcc	: 2;	/* fp condition code 0 */
1067c478bd9Sstevel@tonic-gate 	unsigned int		aexc	: 5;	/* accumulated exceptions */
1077c478bd9Sstevel@tonic-gate 	unsigned int		cexc	: 5;	/* current exception */
1087c478bd9Sstevel@tonic-gate } fsr_types;
1097c478bd9Sstevel@tonic-gate 
1107c478bd9Sstevel@tonic-gate /*
1117c478bd9Sstevel@tonic-gate  * The C compiler and the C spec do not support bitfields in a long long,
1127c478bd9Sstevel@tonic-gate  * as per fsr_types above, so don't hold your breath waiting for this
1137c478bd9Sstevel@tonic-gate  * workaround cruft to disappear.
1147c478bd9Sstevel@tonic-gate  */
1157c478bd9Sstevel@tonic-gate 
1167c478bd9Sstevel@tonic-gate typedef union {
1177c478bd9Sstevel@tonic-gate 	fsr_types	fsr;
1187c478bd9Sstevel@tonic-gate 	uint64_t	ll;
1197c478bd9Sstevel@tonic-gate } fsr_type;
1207c478bd9Sstevel@tonic-gate 
1217c478bd9Sstevel@tonic-gate #define	fcc3	fsr.fcc3
1227c478bd9Sstevel@tonic-gate #define	fcc2	fsr.fcc2
1237c478bd9Sstevel@tonic-gate #define	fcc1	fsr.fcc1
1247c478bd9Sstevel@tonic-gate #define	fcc0	fsr.fcc
1257c478bd9Sstevel@tonic-gate #define	rnd	fsr.rnd
1267c478bd9Sstevel@tonic-gate #define	rnp	fsr.rnp
1277c478bd9Sstevel@tonic-gate #define	tem	fsr.tem
1287c478bd9Sstevel@tonic-gate #define	aexc	fsr.aexc
1297c478bd9Sstevel@tonic-gate #define	cexc	fsr.cexc
1307c478bd9Sstevel@tonic-gate 
1317c478bd9Sstevel@tonic-gate typedef			/* FPU register viewed as single components. */
1327c478bd9Sstevel@tonic-gate 	struct {
1337c478bd9Sstevel@tonic-gate 	uint32_t sign :		1;
1347c478bd9Sstevel@tonic-gate 	uint32_t exponent :	8;
1357c478bd9Sstevel@tonic-gate 	uint32_t significand : 23;
1367c478bd9Sstevel@tonic-gate } single_type;
1377c478bd9Sstevel@tonic-gate 
1387c478bd9Sstevel@tonic-gate typedef			/* FPU register viewed as double components. */
1397c478bd9Sstevel@tonic-gate 	struct {
1407c478bd9Sstevel@tonic-gate 	uint32_t sign :		1;
1417c478bd9Sstevel@tonic-gate 	uint32_t exponent :    11;
1427c478bd9Sstevel@tonic-gate 	uint32_t significand : 20;
1437c478bd9Sstevel@tonic-gate } double_type;
1447c478bd9Sstevel@tonic-gate 
1457c478bd9Sstevel@tonic-gate typedef			/* FPU register viewed as extended components. */
1467c478bd9Sstevel@tonic-gate 	struct {
1477c478bd9Sstevel@tonic-gate 	uint32_t sign :		 1;
1487c478bd9Sstevel@tonic-gate 	uint32_t exponent :	15;
1497c478bd9Sstevel@tonic-gate 	uint32_t significand :	16;
1507c478bd9Sstevel@tonic-gate } extended_type;
1517c478bd9Sstevel@tonic-gate 
1527c478bd9Sstevel@tonic-gate typedef			/* FPU register with multiple data views. */
1537c478bd9Sstevel@tonic-gate 	union {
1547c478bd9Sstevel@tonic-gate 	int32_t		int32_reg;
1557c478bd9Sstevel@tonic-gate 	int64_t		int64_reg;
1567c478bd9Sstevel@tonic-gate 	uint32_t	uint32_reg;
1577c478bd9Sstevel@tonic-gate 	uint64_t	uint64_reg;
1587c478bd9Sstevel@tonic-gate 	float		float_reg;
1597c478bd9Sstevel@tonic-gate 	single_type	single_reg;
1607c478bd9Sstevel@tonic-gate 	double_type	double_reg;
1617c478bd9Sstevel@tonic-gate 	extended_type	extended_reg;
1627c478bd9Sstevel@tonic-gate } freg_type;
1637c478bd9Sstevel@tonic-gate 
1647c478bd9Sstevel@tonic-gate enum fp_op_type {		/* Type specifiers in FPU instructions. */
1657c478bd9Sstevel@tonic-gate 	fp_op_int32	= 0,	/* Not in hardware, but convenient to define. */
1667c478bd9Sstevel@tonic-gate 	fp_op_single	= 1,
1677c478bd9Sstevel@tonic-gate 	fp_op_double	= 2,
1687c478bd9Sstevel@tonic-gate 	fp_op_extended	= 3,
1697c478bd9Sstevel@tonic-gate 	fp_op_int64	= 4
1707c478bd9Sstevel@tonic-gate };
1717c478bd9Sstevel@tonic-gate 
1727c478bd9Sstevel@tonic-gate enum fp_opcode {	/* FPU op codes, minus precision and leading 0. */
1737c478bd9Sstevel@tonic-gate 	fmovs		= 0x0,
1747c478bd9Sstevel@tonic-gate 	fnegs		= 0x1,
1757c478bd9Sstevel@tonic-gate 	fabss		= 0x2,
1767c478bd9Sstevel@tonic-gate 	fp_op_3 = 3, fp_op_4 = 4, fp_op_5 = 5, fp_op_6 = 6, fp_op_7 = 7,
1777c478bd9Sstevel@tonic-gate 	fp_op_8		= 0x8,
1787c478bd9Sstevel@tonic-gate 	fp_op_9		= 0x9,
1797c478bd9Sstevel@tonic-gate 	fsqrt		= 0xa,
1807c478bd9Sstevel@tonic-gate 	fp_op_b = 0xb, fp_op_c = 0xc, fp_op_d = 0xd,
1817c478bd9Sstevel@tonic-gate 	fp_op_e = 0xe, fp_op_f = 0xf,
1827c478bd9Sstevel@tonic-gate 	fadd		= 0x10,
1837c478bd9Sstevel@tonic-gate 	fsub		= 0x11,
1847c478bd9Sstevel@tonic-gate 	fmul		= 0x12,
1857c478bd9Sstevel@tonic-gate 	fdiv		= 0x13,
1867c478bd9Sstevel@tonic-gate 	fcmp		= 0x14,
1877c478bd9Sstevel@tonic-gate 	fcmpe		= 0x15,
1887c478bd9Sstevel@tonic-gate 	fp_op_16 = 0x16, fp_op_17 = 0x17,
1897c478bd9Sstevel@tonic-gate 	fp_op_18	= 0x18,
1907c478bd9Sstevel@tonic-gate 	fp_op_19	= 0x19,
1917c478bd9Sstevel@tonic-gate 	fsmuld		= 0x1a,
1927c478bd9Sstevel@tonic-gate 	fdmulx		= 0x1b,
1937c478bd9Sstevel@tonic-gate 	ftoll		= 0x20,
1947c478bd9Sstevel@tonic-gate 	flltos		= 0x21,
1957c478bd9Sstevel@tonic-gate 	flltod		= 0x22,
1967c478bd9Sstevel@tonic-gate 	flltox		= 0x23,
1977c478bd9Sstevel@tonic-gate 	fp_op_24 = 0x24, fp_op_25 = 0x25, fp_op_26 = 0x26, fp_op_27 = 0x27,
1987c478bd9Sstevel@tonic-gate 	fp_op_28 = 0x28, fp_op_29 = 0x29, fp_op_2a = 0x2a, fp_op_2b = 0x2b,
1997c478bd9Sstevel@tonic-gate 	fp_op_2c = 0x2c, fp_op_2d = 0x2d, fp_op_2e = 0x2e, fp_op_2f = 0x2f,
2007c478bd9Sstevel@tonic-gate 	fp_op_30	= 0x30,
2017c478bd9Sstevel@tonic-gate 	fitos		= 0x31,
2027c478bd9Sstevel@tonic-gate 	fitod		= 0x32,
2037c478bd9Sstevel@tonic-gate 	fitox		= 0x33,
2047c478bd9Sstevel@tonic-gate 	ftoi		= 0x34,
2057c478bd9Sstevel@tonic-gate 	fp_op_35 = 0x35, fp_op_36 = 0x36, fp_op_37 = 0x37,
2067c478bd9Sstevel@tonic-gate 	ft_op_38	= 0x38,
2077c478bd9Sstevel@tonic-gate 	fp_op_39 = 0x39, fp_op_3a = 0x3a, fp_op_3b = 0x3b,
2087c478bd9Sstevel@tonic-gate 	fp_op_3c	= 0x3c,
2097c478bd9Sstevel@tonic-gate 	fp_op_3d = 0x3d, fp_op_3e = 0x3e, fp_op_3f = 0x3f
2107c478bd9Sstevel@tonic-gate };
2117c478bd9Sstevel@tonic-gate 
2127c478bd9Sstevel@tonic-gate typedef			/* FPU instruction. */
2137c478bd9Sstevel@tonic-gate 	struct {
2147c478bd9Sstevel@tonic-gate 	uint32_t		hibits	: 2;	/* Top two bits. */
2157c478bd9Sstevel@tonic-gate 	uint32_t		rd	: 5;	/* Destination. */
2167c478bd9Sstevel@tonic-gate 	uint32_t		op3	: 6;	/* Main op code. */
2177c478bd9Sstevel@tonic-gate 	uint32_t		rs1	: 5;	/* First operand. */
2187c478bd9Sstevel@tonic-gate 	uint32_t		ibit	: 1;	/* I format bit. */
2197c478bd9Sstevel@tonic-gate 	uint32_t /* enum fp_opcode */  opcode : 6; /* Floating-point op code. */
2207c478bd9Sstevel@tonic-gate 	uint32_t /* enum fp_op_type */ prec   : 2; /* Precision. */
2217c478bd9Sstevel@tonic-gate 	uint32_t		rs2	: 5;	/* Second operand. */
2227c478bd9Sstevel@tonic-gate } fp_inst_type;
2237c478bd9Sstevel@tonic-gate 
2247c478bd9Sstevel@tonic-gate typedef			/* Integer condition code. */
2257c478bd9Sstevel@tonic-gate 	struct {
2267c478bd9Sstevel@tonic-gate 	uint32_t			: 28;	/* the unused part */
2277c478bd9Sstevel@tonic-gate 	uint32_t		n	: 1;	/* Negative bit. */
2287c478bd9Sstevel@tonic-gate 	uint32_t		z	: 1;	/* Zero bit. */
2297c478bd9Sstevel@tonic-gate 	uint32_t		v	: 1;	/* Overflow bit. */
2307c478bd9Sstevel@tonic-gate 	uint32_t		c	: 1;	/* Carry bit. */
2317c478bd9Sstevel@tonic-gate } ccr_type;
2327c478bd9Sstevel@tonic-gate 
2337c478bd9Sstevel@tonic-gate typedef			/* FPU data used by simulator. */
2347c478bd9Sstevel@tonic-gate 	struct {
2357c478bd9Sstevel@tonic-gate 	uint_t			fp_fsrtem;
2367c478bd9Sstevel@tonic-gate 	enum fp_direction_type	fp_direction;
2377c478bd9Sstevel@tonic-gate 	enum fp_precision_type	fp_precision;
2387c478bd9Sstevel@tonic-gate 	uint_t			fp_current_exceptions;
2397c478bd9Sstevel@tonic-gate 	kfpu_t			*fp_current_pfregs;
2407c478bd9Sstevel@tonic-gate 	void			(*fp_current_read_freg) ();
2417c478bd9Sstevel@tonic-gate 	void			(*fp_current_write_freg) ();
2427c478bd9Sstevel@tonic-gate 	void			(*fp_current_read_dreg) ();
2437c478bd9Sstevel@tonic-gate 	void			(*fp_current_write_dreg) ();
244*5892374fSdf 	uint64_t		(*fp_current_read_gsr) (kfpu_t *);
245*5892374fSdf 	void			(*fp_current_write_gsr) (uint64_t, kfpu_t *);
2467c478bd9Sstevel@tonic-gate 	int			fp_trapcode;
2477c478bd9Sstevel@tonic-gate 	char			*fp_trapaddr;
2487c478bd9Sstevel@tonic-gate 	struct	regs		*fp_traprp;
2497c478bd9Sstevel@tonic-gate 	enum	seg_rw		fp_traprw;
2507c478bd9Sstevel@tonic-gate } fp_simd_type;
2517c478bd9Sstevel@tonic-gate 
2527c478bd9Sstevel@tonic-gate /*
2537c478bd9Sstevel@tonic-gate  * FPU related kstat structures
2547c478bd9Sstevel@tonic-gate  */
2557c478bd9Sstevel@tonic-gate struct fpustat_kstat  {
2567c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_ieee_traps;
2577c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_unfinished_traps;
2587c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_unimplemented_traps;
2597c478bd9Sstevel@tonic-gate };
2607c478bd9Sstevel@tonic-gate 
2617c478bd9Sstevel@tonic-gate struct fpuinfo_kstat {
2627c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fmovs;
2637c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fmovd;
2647c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fmovq;
2657c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fnegs;
2667c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fnegd;
2677c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fnegq;
2687c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fabss;
2697c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fabsd;
2707c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fabsq;
2717c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fsqrts;
2727c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fsqrtd;
2737c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fsqrtq;
2747c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fadds;
2757c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_faddd;
2767c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_faddq;
2777c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fsubs;
2787c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fsubd;
2797c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fsubq;
2807c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fmuls;
2817c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fmuld;
2827c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fmulq;
2837c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fdivs;
2847c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fdivd;
2857c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fdivq;
2867c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fcmps;
2877c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fcmpd;
2887c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fcmpq;
2897c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fcmpes;
2907c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fcmped;
2917c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fcmpeq;
2927c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fsmuld;
2937c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fdmulx;
2947c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fstox;
2957c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fdtox;
2967c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fqtox;
2977c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fxtos;
2987c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fxtod;
2997c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fxtoq;
3007c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fitos;
3017c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fitod;
3027c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fitoq;
3037c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fstoi;
3047c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fdtoi;
3057c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fqtoi;
3067c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fmovcc;
3077c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fmovr;
3087c478bd9Sstevel@tonic-gate };
3097c478bd9Sstevel@tonic-gate 
3107c478bd9Sstevel@tonic-gate struct visinfo_kstat {
3117c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_edge8;
3127c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_edge8n;
3137c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_edge8l;
3147c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_edge8ln;
3157c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_edge16;
3167c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_edge16n;
3177c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_edge16l;
3187c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_edge16ln;
3197c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_edge32;
3207c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_edge32n;
3217c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_edge32l;
3227c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_edge32ln;
3237c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_array8;
3247c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_array16;
3257c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_array32;
3267c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_bmask;
3277c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_fcmple16;
3287c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_fcmpne16;
3297c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_fcmpgt16;
3307c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_fcmpeq16;
3317c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_fcmple32;
3327c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_fcmpne32;
3337c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_fcmpgt32;
3347c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_fcmpeq32;
3357c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_fmul8x16;
3367c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_fmul8x16au;
3377c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_fmul8x16al;
3387c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_fmul8sux16;
3397c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_fmul8ulx16;
3407c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_fmuld8sux16;
3417c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_fmuld8ulx16;
3427c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_fpack16;
3437c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_fpack32;
3447c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_fpackfix;
3457c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_fexpand;
3467c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_fpmerge;
3477c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_pdist;
3487c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_bshuffle;
3497c478bd9Sstevel@tonic-gate };
3507c478bd9Sstevel@tonic-gate 
3517c478bd9Sstevel@tonic-gate #define	VISINFO_KSTAT(opcode)	{					\
3527c478bd9Sstevel@tonic-gate 	extern void __dtrace_probe___visinfo_##opcode(uint64_t *);	\
3537c478bd9Sstevel@tonic-gate 	uint64_t *stataddr = &visinfo.opcode.value.ui64;		\
3547c478bd9Sstevel@tonic-gate 	__dtrace_probe___visinfo_##opcode(stataddr);       		\
3557c478bd9Sstevel@tonic-gate 	atomic_add_64(&visinfo.opcode.value.ui64, 1);			\
3567c478bd9Sstevel@tonic-gate }
3577c478bd9Sstevel@tonic-gate 
3587c478bd9Sstevel@tonic-gate 
3597c478bd9Sstevel@tonic-gate /* PUBLIC FUNCTIONS */
3607c478bd9Sstevel@tonic-gate 
3617c478bd9Sstevel@tonic-gate #ifdef	__STDC__
3627c478bd9Sstevel@tonic-gate 
3637c478bd9Sstevel@tonic-gate /*
3647c478bd9Sstevel@tonic-gate  * fpu_vis_sim simulates FPU VIS Partial load store instructions; reads and
3657c478bd9Sstevel@tonic-gate  * writes FPU data registers directly or works with the PCB image if fpu_exists
3667c478bd9Sstevel@tonic-gate  * is 0.
3677c478bd9Sstevel@tonic-gate  */
3687c478bd9Sstevel@tonic-gate extern enum ftt_type fpu_vis_sim(fp_simd_type *pfpsd, fp_inst_type *pinst,
3697c478bd9Sstevel@tonic-gate 	struct regs *pregs, fsr_type *pfsr, uint64_t gsr, uint32_t inst);
3707c478bd9Sstevel@tonic-gate /*
3717c478bd9Sstevel@tonic-gate  * fpu_simulator simulates FPU instructions only; reads and writes FPU data
3727c478bd9Sstevel@tonic-gate  * registers directly.
3737c478bd9Sstevel@tonic-gate  */
3747c478bd9Sstevel@tonic-gate extern enum ftt_type fpu_simulator(fp_simd_type *pfpsd, fp_inst_type *pinst,
3757c478bd9Sstevel@tonic-gate 	fsr_type *pfsr, uint64_t gsr, uint32_t inst);
3767c478bd9Sstevel@tonic-gate /*
3777c478bd9Sstevel@tonic-gate  * fp_emulator simulates FPU and CPU-FPU instructions; reads and writes FPU
3787c478bd9Sstevel@tonic-gate  * data registers from image in pfpu.
3797c478bd9Sstevel@tonic-gate  */
3807c478bd9Sstevel@tonic-gate extern enum ftt_type fp_emulator(fp_simd_type *pfpsd, fp_inst_type *pinst,
3817c478bd9Sstevel@tonic-gate 	struct regs *rp, void *prw, kfpu_t *pfpu);
3827c478bd9Sstevel@tonic-gate /*
3837c478bd9Sstevel@tonic-gate  * fp_traps handles passing exception conditions to the kernel.
3847c478bd9Sstevel@tonic-gate  * It is called after fp_simulator or fp_emulator fail (return a non-zero ftt).
3857c478bd9Sstevel@tonic-gate  */
3867c478bd9Sstevel@tonic-gate extern void fp_traps(fp_simd_type *pfpsd, enum ftt_type ftt, struct regs *rp);
3877c478bd9Sstevel@tonic-gate 
3887c478bd9Sstevel@tonic-gate /*
3897c478bd9Sstevel@tonic-gate  * fp_kstat_update tracks fpu exception conditions.
3907c478bd9Sstevel@tonic-gate  * It is called after a hardware trap returns a non-zero ftt.
3917c478bd9Sstevel@tonic-gate  */
3927c478bd9Sstevel@tonic-gate extern void fp_kstat_update(enum ftt_type ftt);
3937c478bd9Sstevel@tonic-gate 
3947c478bd9Sstevel@tonic-gate /*
3957c478bd9Sstevel@tonic-gate  * fp_precise handles floating point unimplemented and unfinished traps,
3967c478bd9Sstevel@tonic-gate  * for sparc V9 hardware. These traps are normally passed along to the
3977c478bd9Sstevel@tonic-gate  * fpu_simulator, to see if it can run the unimplemented instruction or
3987c478bd9Sstevel@tonic-gate  * finish the unfinished instruction. Needless to say, this takes time.
3997c478bd9Sstevel@tonic-gate  */
4007c478bd9Sstevel@tonic-gate extern void fp_precise(struct regs *rp);
4017c478bd9Sstevel@tonic-gate 
4027c478bd9Sstevel@tonic-gate /*
4037c478bd9Sstevel@tonic-gate  * fpu_trap handles V9 floating point ieee and other floating point traps.
4047c478bd9Sstevel@tonic-gate  * It is called after fp_simulator or fp_emulator fail (return a non-zero ftt),
4057c478bd9Sstevel@tonic-gate  * and from the _fp_ieee_exception trap handler.
4067c478bd9Sstevel@tonic-gate  */
4077c478bd9Sstevel@tonic-gate extern void fpu_trap(struct regs *rp, caddr_t addr, uint32_t type,
4087c478bd9Sstevel@tonic-gate 			uint32_t code);
4097c478bd9Sstevel@tonic-gate 
4107c478bd9Sstevel@tonic-gate #else	/* ! __STDC__ */
4117c478bd9Sstevel@tonic-gate 
4127c478bd9Sstevel@tonic-gate /*
4137c478bd9Sstevel@tonic-gate  * fpu_simulator simulates FPU instructions only; reads and writes FPU data
4147c478bd9Sstevel@tonic-gate  * registers directly.
4157c478bd9Sstevel@tonic-gate  */
4167c478bd9Sstevel@tonic-gate extern enum ftt_type fpu_simulator(
4177c478bd9Sstevel@tonic-gate 	fp_simd_type	*pfpsd,	 /* Pointer to FPU simulator data */
4187c478bd9Sstevel@tonic-gate 	fp_inst_type	*pinst,	 /* Pointer to FPU instruction to simulate. */
4197c478bd9Sstevel@tonic-gate 	fsr_type	*pfsr,	 /* Pointer to image of FSR to read & write. */
4207c478bd9Sstevel@tonic-gate 	int		instr);	 /* Instruction to emulate. */
4217c478bd9Sstevel@tonic-gate 
4227c478bd9Sstevel@tonic-gate /*
4237c478bd9Sstevel@tonic-gate  * fp_emulator simulates FPU and CPU-FPU instructions; reads and writes FPU
4247c478bd9Sstevel@tonic-gate  * data registers from image in pfpu.
4257c478bd9Sstevel@tonic-gate  */
4267c478bd9Sstevel@tonic-gate extern enum ftt_type fp_emulator(
4277c478bd9Sstevel@tonic-gate 	fp_simd_type	*pfpsd,	   /* Pointer to FPU simulator data */
4287c478bd9Sstevel@tonic-gate 	fp_inst_type	*pinst,    /* Pointer to FPU instruction to simulate. */
4297c478bd9Sstevel@tonic-gate 	struct regs	*pregs,    /* Pointer to PCB image of registers. */
4307c478bd9Sstevel@tonic-gate 	struct rwindow	*pwindow,  /* Pointer to locals and ins. */
4317c478bd9Sstevel@tonic-gate 	struct fpu	*pfpu);	   /* Pointer to FPU register block. */
4327c478bd9Sstevel@tonic-gate 
4337c478bd9Sstevel@tonic-gate /*
4347c478bd9Sstevel@tonic-gate  * fp_traps handles passing exception conditions to the kernel.
4357c478bd9Sstevel@tonic-gate  * It is called after fp_simulator or fp_emulator fail (return a non-zero ftt).
4367c478bd9Sstevel@tonic-gate  */
4377c478bd9Sstevel@tonic-gate extern void fp_traps(
4387c478bd9Sstevel@tonic-gate 	fp_simd_type	*pfpsd,	 /* Pointer to FPU simulator data */
4397c478bd9Sstevel@tonic-gate 	enum ftt_type	ftt,	 /* Type of trap. */
4407c478bd9Sstevel@tonic-gate 	struct regs	*rp);	 /* Pointer to PCB image of registers. */
4417c478bd9Sstevel@tonic-gate 
4427c478bd9Sstevel@tonic-gate /*
4437c478bd9Sstevel@tonic-gate  * fp_kstat_update tracks fpu exception conditions.
4447c478bd9Sstevel@tonic-gate  * It is called after a hardware trap returns a non-zero ftt.
4457c478bd9Sstevel@tonic-gate  */
4467c478bd9Sstevel@tonic-gate extern void fp_kstat_update(enum ftt_type ftt);	/* Type of trap. */
4477c478bd9Sstevel@tonic-gate 
4487c478bd9Sstevel@tonic-gate /*
4497c478bd9Sstevel@tonic-gate  * fp_precise handles floating point unimplemented and unfinished traps,
4507c478bd9Sstevel@tonic-gate  * for sparc V9 hardware. These traps are normally passed along to the
4517c478bd9Sstevel@tonic-gate  * fpu_simulator, to see if it can run the unimplemented instruction or
4527c478bd9Sstevel@tonic-gate  * finish the unfinished instruction. Needless to say, this takes time.
4537c478bd9Sstevel@tonic-gate  */
4547c478bd9Sstevel@tonic-gate extern void fp_precise(
4557c478bd9Sstevel@tonic-gate 	struct regs *rp);	/* Pointer to PCB image of registers. */
4567c478bd9Sstevel@tonic-gate 
4577c478bd9Sstevel@tonic-gate /*
4587c478bd9Sstevel@tonic-gate  * fpu_trap handles V9 floating point ieee and other floating point traps.
4597c478bd9Sstevel@tonic-gate  * It is called after fp_simulator or fp_emulator fail (return a non-zero ftt),
4607c478bd9Sstevel@tonic-gate  * and from the _fp_ieee_exception trap handler.
4617c478bd9Sstevel@tonic-gate  */
4627c478bd9Sstevel@tonic-gate extern void fpu_trap(
4637c478bd9Sstevel@tonic-gate 	struct regs *rp,	/* Pointer to PCB image of registers. */
4647c478bd9Sstevel@tonic-gate 	caddr_t addr,		/* Address of trapping instruction. */
4657c478bd9Sstevel@tonic-gate 	uint32_t type,		/* Type of trapping exception. */
4667c478bd9Sstevel@tonic-gate 	uint32_t code);		/* Trap code -> si_code. */
4677c478bd9Sstevel@tonic-gate 
4687c478bd9Sstevel@tonic-gate #endif	/* __STDC__ */
4697c478bd9Sstevel@tonic-gate #endif /* _ASM */
4707c478bd9Sstevel@tonic-gate 
4717c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
4727c478bd9Sstevel@tonic-gate }
4737c478bd9Sstevel@tonic-gate #endif
4747c478bd9Sstevel@tonic-gate 
4757c478bd9Sstevel@tonic-gate #endif	/* _SYS_FPU_FPU_SIMULATOR_H */
476