1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate #ifndef	_SYS_FPU_FPU_SIMULATOR_H
28*7c478bd9Sstevel@tonic-gate #define	_SYS_FPU_FPU_SIMULATOR_H
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*7c478bd9Sstevel@tonic-gate /* SunOS-4.0 1.10	*/
32*7c478bd9Sstevel@tonic-gate 
33*7c478bd9Sstevel@tonic-gate /*
34*7c478bd9Sstevel@tonic-gate  * sparc floating-point simulator definitions.
35*7c478bd9Sstevel@tonic-gate  */
36*7c478bd9Sstevel@tonic-gate 
37*7c478bd9Sstevel@tonic-gate #ifndef	_ASM
38*7c478bd9Sstevel@tonic-gate #include <sys/types.h>
39*7c478bd9Sstevel@tonic-gate #include <sys/ieeefp.h>
40*7c478bd9Sstevel@tonic-gate #include <vm/seg.h>
41*7c478bd9Sstevel@tonic-gate #include <sys/kstat.h>
42*7c478bd9Sstevel@tonic-gate #endif /* _ASM */
43*7c478bd9Sstevel@tonic-gate 
44*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
45*7c478bd9Sstevel@tonic-gate extern "C" {
46*7c478bd9Sstevel@tonic-gate #endif
47*7c478bd9Sstevel@tonic-gate 
48*7c478bd9Sstevel@tonic-gate /*
49*7c478bd9Sstevel@tonic-gate  * Constants to decode/extract "fitos" instruction fields
50*7c478bd9Sstevel@tonic-gate  */
51*7c478bd9Sstevel@tonic-gate #define	FITOS_INSTR_MASK	0xc1f83fe0
52*7c478bd9Sstevel@tonic-gate #define	FITOS_INSTR		0x81a01880
53*7c478bd9Sstevel@tonic-gate #define	FITOS_RS2_SHIFT		0
54*7c478bd9Sstevel@tonic-gate #define	FITOS_RD_SHIFT		25
55*7c478bd9Sstevel@tonic-gate #define	FITOS_REG_MASK		0x1f
56*7c478bd9Sstevel@tonic-gate 
57*7c478bd9Sstevel@tonic-gate #ifndef _ASM
58*7c478bd9Sstevel@tonic-gate /*	PUBLIC TYPES	*/
59*7c478bd9Sstevel@tonic-gate 
60*7c478bd9Sstevel@tonic-gate enum fcc_type {			/* relationships */
61*7c478bd9Sstevel@tonic-gate 	fcc_equal	= 0,
62*7c478bd9Sstevel@tonic-gate 	fcc_less	= 1,
63*7c478bd9Sstevel@tonic-gate 	fcc_greater	= 2,
64*7c478bd9Sstevel@tonic-gate 	fcc_unordered	= 3
65*7c478bd9Sstevel@tonic-gate };
66*7c478bd9Sstevel@tonic-gate 
67*7c478bd9Sstevel@tonic-gate enum cc_type {			/* icc/fcc number */
68*7c478bd9Sstevel@tonic-gate 	fcc_0	= 0,
69*7c478bd9Sstevel@tonic-gate 	fcc_1	= 1,
70*7c478bd9Sstevel@tonic-gate 	fcc_2	= 2,
71*7c478bd9Sstevel@tonic-gate 	fcc_3	= 3,
72*7c478bd9Sstevel@tonic-gate 	icc	= 4,
73*7c478bd9Sstevel@tonic-gate 	xcc	= 6
74*7c478bd9Sstevel@tonic-gate };
75*7c478bd9Sstevel@tonic-gate 
76*7c478bd9Sstevel@tonic-gate /* FSR types. */
77*7c478bd9Sstevel@tonic-gate 
78*7c478bd9Sstevel@tonic-gate enum ftt_type {			/* types of traps */
79*7c478bd9Sstevel@tonic-gate 	ftt_none	= 0,
80*7c478bd9Sstevel@tonic-gate 	ftt_ieee	= 1,
81*7c478bd9Sstevel@tonic-gate 	ftt_unfinished	= 2,
82*7c478bd9Sstevel@tonic-gate 	ftt_unimplemented = 3,
83*7c478bd9Sstevel@tonic-gate 	ftt_sequence	= 4,
84*7c478bd9Sstevel@tonic-gate 	ftt_alignment	= 5,	/* defined by software convention only */
85*7c478bd9Sstevel@tonic-gate 	ftt_fault	= 6,	/* defined by software convention only */
86*7c478bd9Sstevel@tonic-gate 	ftt_7		= 7
87*7c478bd9Sstevel@tonic-gate };
88*7c478bd9Sstevel@tonic-gate 
89*7c478bd9Sstevel@tonic-gate typedef	struct {		/* sparc V9 FSR. */
90*7c478bd9Sstevel@tonic-gate 	unsigned int			: 26;
91*7c478bd9Sstevel@tonic-gate 	unsigned int		fcc3	: 2;	/* fp condition code 3 */
92*7c478bd9Sstevel@tonic-gate 	unsigned int		fcc2	: 2;	/* fp condition code 2 */
93*7c478bd9Sstevel@tonic-gate 	unsigned int		fcc1	: 2;	/* fp condition code 1 */
94*7c478bd9Sstevel@tonic-gate 						/* enum fp_direction_type */
95*7c478bd9Sstevel@tonic-gate 	unsigned int		rnd	: 2;	/* rounding direction */
96*7c478bd9Sstevel@tonic-gate 	unsigned int		rnp	: 2;	/* for v7 compatibility only */
97*7c478bd9Sstevel@tonic-gate 	unsigned int		tem	: 5;	/* trap enable mask */
98*7c478bd9Sstevel@tonic-gate 	unsigned int		 ns	: 1;	/* non-standard */
99*7c478bd9Sstevel@tonic-gate 	unsigned int			: 5;
100*7c478bd9Sstevel@tonic-gate 						/* enum ftt_type */
101*7c478bd9Sstevel@tonic-gate 	unsigned int 		ftt	: 3;	/* FPU trap type */
102*7c478bd9Sstevel@tonic-gate 	unsigned int		qne	: 1;	/* FPQ not empty */
103*7c478bd9Sstevel@tonic-gate 	unsigned int		 pr	: 1;	/* partial result */
104*7c478bd9Sstevel@tonic-gate 						/* enum fcc_type */
105*7c478bd9Sstevel@tonic-gate 	unsigned int 		fcc	: 2;	/* fp condition code 0 */
106*7c478bd9Sstevel@tonic-gate 	unsigned int		aexc	: 5;	/* accumulated exceptions */
107*7c478bd9Sstevel@tonic-gate 	unsigned int		cexc	: 5;	/* current exception */
108*7c478bd9Sstevel@tonic-gate } fsr_types;
109*7c478bd9Sstevel@tonic-gate 
110*7c478bd9Sstevel@tonic-gate /*
111*7c478bd9Sstevel@tonic-gate  * The C compiler and the C spec do not support bitfields in a long long,
112*7c478bd9Sstevel@tonic-gate  * as per fsr_types above, so don't hold your breath waiting for this
113*7c478bd9Sstevel@tonic-gate  * workaround cruft to disappear.
114*7c478bd9Sstevel@tonic-gate  */
115*7c478bd9Sstevel@tonic-gate 
116*7c478bd9Sstevel@tonic-gate typedef union {
117*7c478bd9Sstevel@tonic-gate 	fsr_types	fsr;
118*7c478bd9Sstevel@tonic-gate 	uint64_t	ll;
119*7c478bd9Sstevel@tonic-gate } fsr_type;
120*7c478bd9Sstevel@tonic-gate 
121*7c478bd9Sstevel@tonic-gate #define	fcc3	fsr.fcc3
122*7c478bd9Sstevel@tonic-gate #define	fcc2	fsr.fcc2
123*7c478bd9Sstevel@tonic-gate #define	fcc1	fsr.fcc1
124*7c478bd9Sstevel@tonic-gate #define	fcc0	fsr.fcc
125*7c478bd9Sstevel@tonic-gate #define	rnd	fsr.rnd
126*7c478bd9Sstevel@tonic-gate #define	rnp	fsr.rnp
127*7c478bd9Sstevel@tonic-gate #define	tem	fsr.tem
128*7c478bd9Sstevel@tonic-gate #define	aexc	fsr.aexc
129*7c478bd9Sstevel@tonic-gate #define	cexc	fsr.cexc
130*7c478bd9Sstevel@tonic-gate 
131*7c478bd9Sstevel@tonic-gate typedef			/* FPU register viewed as single components. */
132*7c478bd9Sstevel@tonic-gate 	struct {
133*7c478bd9Sstevel@tonic-gate 	uint32_t sign :		1;
134*7c478bd9Sstevel@tonic-gate 	uint32_t exponent :	8;
135*7c478bd9Sstevel@tonic-gate 	uint32_t significand : 23;
136*7c478bd9Sstevel@tonic-gate } single_type;
137*7c478bd9Sstevel@tonic-gate 
138*7c478bd9Sstevel@tonic-gate typedef			/* FPU register viewed as double components. */
139*7c478bd9Sstevel@tonic-gate 	struct {
140*7c478bd9Sstevel@tonic-gate 	uint32_t sign :		1;
141*7c478bd9Sstevel@tonic-gate 	uint32_t exponent :    11;
142*7c478bd9Sstevel@tonic-gate 	uint32_t significand : 20;
143*7c478bd9Sstevel@tonic-gate } double_type;
144*7c478bd9Sstevel@tonic-gate 
145*7c478bd9Sstevel@tonic-gate typedef			/* FPU register viewed as extended components. */
146*7c478bd9Sstevel@tonic-gate 	struct {
147*7c478bd9Sstevel@tonic-gate 	uint32_t sign :		 1;
148*7c478bd9Sstevel@tonic-gate 	uint32_t exponent :	15;
149*7c478bd9Sstevel@tonic-gate 	uint32_t significand :	16;
150*7c478bd9Sstevel@tonic-gate } extended_type;
151*7c478bd9Sstevel@tonic-gate 
152*7c478bd9Sstevel@tonic-gate typedef			/* FPU register with multiple data views. */
153*7c478bd9Sstevel@tonic-gate 	union {
154*7c478bd9Sstevel@tonic-gate 	int32_t		int32_reg;
155*7c478bd9Sstevel@tonic-gate 	int64_t		int64_reg;
156*7c478bd9Sstevel@tonic-gate 	uint32_t	uint32_reg;
157*7c478bd9Sstevel@tonic-gate 	uint64_t	uint64_reg;
158*7c478bd9Sstevel@tonic-gate 	float		float_reg;
159*7c478bd9Sstevel@tonic-gate 	single_type	single_reg;
160*7c478bd9Sstevel@tonic-gate 	double_type	double_reg;
161*7c478bd9Sstevel@tonic-gate 	extended_type	extended_reg;
162*7c478bd9Sstevel@tonic-gate } freg_type;
163*7c478bd9Sstevel@tonic-gate 
164*7c478bd9Sstevel@tonic-gate enum fp_op_type {		/* Type specifiers in FPU instructions. */
165*7c478bd9Sstevel@tonic-gate 	fp_op_int32	= 0,	/* Not in hardware, but convenient to define. */
166*7c478bd9Sstevel@tonic-gate 	fp_op_single	= 1,
167*7c478bd9Sstevel@tonic-gate 	fp_op_double	= 2,
168*7c478bd9Sstevel@tonic-gate 	fp_op_extended	= 3,
169*7c478bd9Sstevel@tonic-gate 	fp_op_int64	= 4
170*7c478bd9Sstevel@tonic-gate };
171*7c478bd9Sstevel@tonic-gate 
172*7c478bd9Sstevel@tonic-gate enum fp_opcode {	/* FPU op codes, minus precision and leading 0. */
173*7c478bd9Sstevel@tonic-gate 	fmovs		= 0x0,
174*7c478bd9Sstevel@tonic-gate 	fnegs		= 0x1,
175*7c478bd9Sstevel@tonic-gate 	fabss		= 0x2,
176*7c478bd9Sstevel@tonic-gate 	fp_op_3 = 3, fp_op_4 = 4, fp_op_5 = 5, fp_op_6 = 6, fp_op_7 = 7,
177*7c478bd9Sstevel@tonic-gate 	fp_op_8		= 0x8,
178*7c478bd9Sstevel@tonic-gate 	fp_op_9		= 0x9,
179*7c478bd9Sstevel@tonic-gate 	fsqrt		= 0xa,
180*7c478bd9Sstevel@tonic-gate 	fp_op_b = 0xb, fp_op_c = 0xc, fp_op_d = 0xd,
181*7c478bd9Sstevel@tonic-gate 	fp_op_e = 0xe, fp_op_f = 0xf,
182*7c478bd9Sstevel@tonic-gate 	fadd		= 0x10,
183*7c478bd9Sstevel@tonic-gate 	fsub		= 0x11,
184*7c478bd9Sstevel@tonic-gate 	fmul		= 0x12,
185*7c478bd9Sstevel@tonic-gate 	fdiv		= 0x13,
186*7c478bd9Sstevel@tonic-gate 	fcmp		= 0x14,
187*7c478bd9Sstevel@tonic-gate 	fcmpe		= 0x15,
188*7c478bd9Sstevel@tonic-gate 	fp_op_16 = 0x16, fp_op_17 = 0x17,
189*7c478bd9Sstevel@tonic-gate 	fp_op_18	= 0x18,
190*7c478bd9Sstevel@tonic-gate 	fp_op_19	= 0x19,
191*7c478bd9Sstevel@tonic-gate 	fsmuld		= 0x1a,
192*7c478bd9Sstevel@tonic-gate 	fdmulx		= 0x1b,
193*7c478bd9Sstevel@tonic-gate 	ftoll		= 0x20,
194*7c478bd9Sstevel@tonic-gate 	flltos		= 0x21,
195*7c478bd9Sstevel@tonic-gate 	flltod		= 0x22,
196*7c478bd9Sstevel@tonic-gate 	flltox		= 0x23,
197*7c478bd9Sstevel@tonic-gate 	fp_op_24 = 0x24, fp_op_25 = 0x25, fp_op_26 = 0x26, fp_op_27 = 0x27,
198*7c478bd9Sstevel@tonic-gate 	fp_op_28 = 0x28, fp_op_29 = 0x29, fp_op_2a = 0x2a, fp_op_2b = 0x2b,
199*7c478bd9Sstevel@tonic-gate 	fp_op_2c = 0x2c, fp_op_2d = 0x2d, fp_op_2e = 0x2e, fp_op_2f = 0x2f,
200*7c478bd9Sstevel@tonic-gate 	fp_op_30	= 0x30,
201*7c478bd9Sstevel@tonic-gate 	fitos		= 0x31,
202*7c478bd9Sstevel@tonic-gate 	fitod		= 0x32,
203*7c478bd9Sstevel@tonic-gate 	fitox		= 0x33,
204*7c478bd9Sstevel@tonic-gate 	ftoi		= 0x34,
205*7c478bd9Sstevel@tonic-gate 	fp_op_35 = 0x35, fp_op_36 = 0x36, fp_op_37 = 0x37,
206*7c478bd9Sstevel@tonic-gate 	ft_op_38	= 0x38,
207*7c478bd9Sstevel@tonic-gate 	fp_op_39 = 0x39, fp_op_3a = 0x3a, fp_op_3b = 0x3b,
208*7c478bd9Sstevel@tonic-gate 	fp_op_3c	= 0x3c,
209*7c478bd9Sstevel@tonic-gate 	fp_op_3d = 0x3d, fp_op_3e = 0x3e, fp_op_3f = 0x3f
210*7c478bd9Sstevel@tonic-gate };
211*7c478bd9Sstevel@tonic-gate 
212*7c478bd9Sstevel@tonic-gate typedef			/* FPU instruction. */
213*7c478bd9Sstevel@tonic-gate 	struct {
214*7c478bd9Sstevel@tonic-gate 	uint32_t		hibits	: 2;	/* Top two bits. */
215*7c478bd9Sstevel@tonic-gate 	uint32_t		rd	: 5;	/* Destination. */
216*7c478bd9Sstevel@tonic-gate 	uint32_t		op3	: 6;	/* Main op code. */
217*7c478bd9Sstevel@tonic-gate 	uint32_t		rs1	: 5;	/* First operand. */
218*7c478bd9Sstevel@tonic-gate 	uint32_t		ibit	: 1;	/* I format bit. */
219*7c478bd9Sstevel@tonic-gate 	uint32_t /* enum fp_opcode */  opcode : 6; /* Floating-point op code. */
220*7c478bd9Sstevel@tonic-gate 	uint32_t /* enum fp_op_type */ prec   : 2; /* Precision. */
221*7c478bd9Sstevel@tonic-gate 	uint32_t		rs2	: 5;	/* Second operand. */
222*7c478bd9Sstevel@tonic-gate } fp_inst_type;
223*7c478bd9Sstevel@tonic-gate 
224*7c478bd9Sstevel@tonic-gate typedef			/* Integer condition code. */
225*7c478bd9Sstevel@tonic-gate 	struct {
226*7c478bd9Sstevel@tonic-gate 	uint32_t			: 28;	/* the unused part */
227*7c478bd9Sstevel@tonic-gate 	uint32_t		n	: 1;	/* Negative bit. */
228*7c478bd9Sstevel@tonic-gate 	uint32_t		z	: 1;	/* Zero bit. */
229*7c478bd9Sstevel@tonic-gate 	uint32_t		v	: 1;	/* Overflow bit. */
230*7c478bd9Sstevel@tonic-gate 	uint32_t		c	: 1;	/* Carry bit. */
231*7c478bd9Sstevel@tonic-gate } ccr_type;
232*7c478bd9Sstevel@tonic-gate 
233*7c478bd9Sstevel@tonic-gate typedef			/* FPU data used by simulator. */
234*7c478bd9Sstevel@tonic-gate 	struct {
235*7c478bd9Sstevel@tonic-gate 	uint_t			fp_fsrtem;
236*7c478bd9Sstevel@tonic-gate 	enum fp_direction_type	fp_direction;
237*7c478bd9Sstevel@tonic-gate 	enum fp_precision_type	fp_precision;
238*7c478bd9Sstevel@tonic-gate 	uint_t			fp_current_exceptions;
239*7c478bd9Sstevel@tonic-gate 	kfpu_t			*fp_current_pfregs;
240*7c478bd9Sstevel@tonic-gate 	void			(*fp_current_read_freg) ();
241*7c478bd9Sstevel@tonic-gate 	void			(*fp_current_write_freg) ();
242*7c478bd9Sstevel@tonic-gate 	void			(*fp_current_read_dreg) ();
243*7c478bd9Sstevel@tonic-gate 	void			(*fp_current_write_dreg) ();
244*7c478bd9Sstevel@tonic-gate 	uint64_t		(*get_gsr) (kfpu_t *);
245*7c478bd9Sstevel@tonic-gate 	uint_t			(*get_ccr) ();
246*7c478bd9Sstevel@tonic-gate 	uint_t			(*get_pstate) ();
247*7c478bd9Sstevel@tonic-gate 	void			(*set_gsr) (uint64_t, kfpu_t *);
248*7c478bd9Sstevel@tonic-gate 	void			(*set_ccr) (uint_t);
249*7c478bd9Sstevel@tonic-gate 	int			fp_trapcode;
250*7c478bd9Sstevel@tonic-gate 	char			*fp_trapaddr;
251*7c478bd9Sstevel@tonic-gate 	struct	regs		*fp_traprp;
252*7c478bd9Sstevel@tonic-gate 	enum	seg_rw		fp_traprw;
253*7c478bd9Sstevel@tonic-gate } fp_simd_type;
254*7c478bd9Sstevel@tonic-gate 
255*7c478bd9Sstevel@tonic-gate /*
256*7c478bd9Sstevel@tonic-gate  * FPU related kstat structures
257*7c478bd9Sstevel@tonic-gate  */
258*7c478bd9Sstevel@tonic-gate struct fpustat_kstat  {
259*7c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_ieee_traps;
260*7c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_unfinished_traps;
261*7c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_unimplemented_traps;
262*7c478bd9Sstevel@tonic-gate };
263*7c478bd9Sstevel@tonic-gate 
264*7c478bd9Sstevel@tonic-gate struct fpuinfo_kstat {
265*7c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fmovs;
266*7c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fmovd;
267*7c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fmovq;
268*7c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fnegs;
269*7c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fnegd;
270*7c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fnegq;
271*7c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fabss;
272*7c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fabsd;
273*7c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fabsq;
274*7c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fsqrts;
275*7c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fsqrtd;
276*7c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fsqrtq;
277*7c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fadds;
278*7c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_faddd;
279*7c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_faddq;
280*7c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fsubs;
281*7c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fsubd;
282*7c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fsubq;
283*7c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fmuls;
284*7c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fmuld;
285*7c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fmulq;
286*7c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fdivs;
287*7c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fdivd;
288*7c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fdivq;
289*7c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fcmps;
290*7c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fcmpd;
291*7c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fcmpq;
292*7c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fcmpes;
293*7c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fcmped;
294*7c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fcmpeq;
295*7c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fsmuld;
296*7c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fdmulx;
297*7c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fstox;
298*7c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fdtox;
299*7c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fqtox;
300*7c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fxtos;
301*7c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fxtod;
302*7c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fxtoq;
303*7c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fitos;
304*7c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fitod;
305*7c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fitoq;
306*7c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fstoi;
307*7c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fdtoi;
308*7c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fqtoi;
309*7c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fmovcc;
310*7c478bd9Sstevel@tonic-gate 	struct kstat_named		fpu_sim_fmovr;
311*7c478bd9Sstevel@tonic-gate };
312*7c478bd9Sstevel@tonic-gate 
313*7c478bd9Sstevel@tonic-gate struct visinfo_kstat {
314*7c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_edge8;
315*7c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_edge8n;
316*7c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_edge8l;
317*7c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_edge8ln;
318*7c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_edge16;
319*7c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_edge16n;
320*7c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_edge16l;
321*7c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_edge16ln;
322*7c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_edge32;
323*7c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_edge32n;
324*7c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_edge32l;
325*7c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_edge32ln;
326*7c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_array8;
327*7c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_array16;
328*7c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_array32;
329*7c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_bmask;
330*7c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_fcmple16;
331*7c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_fcmpne16;
332*7c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_fcmpgt16;
333*7c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_fcmpeq16;
334*7c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_fcmple32;
335*7c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_fcmpne32;
336*7c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_fcmpgt32;
337*7c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_fcmpeq32;
338*7c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_fmul8x16;
339*7c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_fmul8x16au;
340*7c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_fmul8x16al;
341*7c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_fmul8sux16;
342*7c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_fmul8ulx16;
343*7c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_fmuld8sux16;
344*7c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_fmuld8ulx16;
345*7c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_fpack16;
346*7c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_fpack32;
347*7c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_fpackfix;
348*7c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_fexpand;
349*7c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_fpmerge;
350*7c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_pdist;
351*7c478bd9Sstevel@tonic-gate 	struct kstat_named		vis_bshuffle;
352*7c478bd9Sstevel@tonic-gate };
353*7c478bd9Sstevel@tonic-gate 
354*7c478bd9Sstevel@tonic-gate #define	VISINFO_KSTAT(opcode)	{					\
355*7c478bd9Sstevel@tonic-gate 	extern void __dtrace_probe___visinfo_##opcode(uint64_t *);	\
356*7c478bd9Sstevel@tonic-gate 	uint64_t *stataddr = &visinfo.opcode.value.ui64;		\
357*7c478bd9Sstevel@tonic-gate 	__dtrace_probe___visinfo_##opcode(stataddr);       		\
358*7c478bd9Sstevel@tonic-gate 	atomic_add_64(&visinfo.opcode.value.ui64, 1);			\
359*7c478bd9Sstevel@tonic-gate }
360*7c478bd9Sstevel@tonic-gate 
361*7c478bd9Sstevel@tonic-gate 
362*7c478bd9Sstevel@tonic-gate /* PUBLIC FUNCTIONS */
363*7c478bd9Sstevel@tonic-gate 
364*7c478bd9Sstevel@tonic-gate #ifdef	__STDC__
365*7c478bd9Sstevel@tonic-gate 
366*7c478bd9Sstevel@tonic-gate /*
367*7c478bd9Sstevel@tonic-gate  * fpu_vis_sim simulates FPU VIS Partial load store instructions; reads and
368*7c478bd9Sstevel@tonic-gate  * writes FPU data registers directly or works with the PCB image if fpu_exists
369*7c478bd9Sstevel@tonic-gate  * is 0.
370*7c478bd9Sstevel@tonic-gate  */
371*7c478bd9Sstevel@tonic-gate extern enum ftt_type fpu_vis_sim(fp_simd_type *pfpsd, fp_inst_type *pinst,
372*7c478bd9Sstevel@tonic-gate 	struct regs *pregs, fsr_type *pfsr, uint64_t gsr, uint32_t inst);
373*7c478bd9Sstevel@tonic-gate /*
374*7c478bd9Sstevel@tonic-gate  * fpu_simulator simulates FPU instructions only; reads and writes FPU data
375*7c478bd9Sstevel@tonic-gate  * registers directly.
376*7c478bd9Sstevel@tonic-gate  */
377*7c478bd9Sstevel@tonic-gate extern enum ftt_type fpu_simulator(fp_simd_type *pfpsd, fp_inst_type *pinst,
378*7c478bd9Sstevel@tonic-gate 	fsr_type *pfsr, uint64_t gsr, uint32_t inst);
379*7c478bd9Sstevel@tonic-gate /*
380*7c478bd9Sstevel@tonic-gate  * fp_emulator simulates FPU and CPU-FPU instructions; reads and writes FPU
381*7c478bd9Sstevel@tonic-gate  * data registers from image in pfpu.
382*7c478bd9Sstevel@tonic-gate  */
383*7c478bd9Sstevel@tonic-gate extern enum ftt_type fp_emulator(fp_simd_type *pfpsd, fp_inst_type *pinst,
384*7c478bd9Sstevel@tonic-gate 	struct regs *rp, void *prw, kfpu_t *pfpu);
385*7c478bd9Sstevel@tonic-gate /*
386*7c478bd9Sstevel@tonic-gate  * fp_traps handles passing exception conditions to the kernel.
387*7c478bd9Sstevel@tonic-gate  * It is called after fp_simulator or fp_emulator fail (return a non-zero ftt).
388*7c478bd9Sstevel@tonic-gate  */
389*7c478bd9Sstevel@tonic-gate extern void fp_traps(fp_simd_type *pfpsd, enum ftt_type ftt, struct regs *rp);
390*7c478bd9Sstevel@tonic-gate 
391*7c478bd9Sstevel@tonic-gate /*
392*7c478bd9Sstevel@tonic-gate  * fp_kstat_update tracks fpu exception conditions.
393*7c478bd9Sstevel@tonic-gate  * It is called after a hardware trap returns a non-zero ftt.
394*7c478bd9Sstevel@tonic-gate  */
395*7c478bd9Sstevel@tonic-gate extern void fp_kstat_update(enum ftt_type ftt);
396*7c478bd9Sstevel@tonic-gate 
397*7c478bd9Sstevel@tonic-gate /*
398*7c478bd9Sstevel@tonic-gate  * fp_precise handles floating point unimplemented and unfinished traps,
399*7c478bd9Sstevel@tonic-gate  * for sparc V9 hardware. These traps are normally passed along to the
400*7c478bd9Sstevel@tonic-gate  * fpu_simulator, to see if it can run the unimplemented instruction or
401*7c478bd9Sstevel@tonic-gate  * finish the unfinished instruction. Needless to say, this takes time.
402*7c478bd9Sstevel@tonic-gate  */
403*7c478bd9Sstevel@tonic-gate extern void fp_precise(struct regs *rp);
404*7c478bd9Sstevel@tonic-gate 
405*7c478bd9Sstevel@tonic-gate /*
406*7c478bd9Sstevel@tonic-gate  * fpu_trap handles V9 floating point ieee and other floating point traps.
407*7c478bd9Sstevel@tonic-gate  * It is called after fp_simulator or fp_emulator fail (return a non-zero ftt),
408*7c478bd9Sstevel@tonic-gate  * and from the _fp_ieee_exception trap handler.
409*7c478bd9Sstevel@tonic-gate  */
410*7c478bd9Sstevel@tonic-gate extern void fpu_trap(struct regs *rp, caddr_t addr, uint32_t type,
411*7c478bd9Sstevel@tonic-gate 			uint32_t code);
412*7c478bd9Sstevel@tonic-gate 
413*7c478bd9Sstevel@tonic-gate #else	/* ! __STDC__ */
414*7c478bd9Sstevel@tonic-gate 
415*7c478bd9Sstevel@tonic-gate /*
416*7c478bd9Sstevel@tonic-gate  * fpu_simulator simulates FPU instructions only; reads and writes FPU data
417*7c478bd9Sstevel@tonic-gate  * registers directly.
418*7c478bd9Sstevel@tonic-gate  */
419*7c478bd9Sstevel@tonic-gate extern enum ftt_type fpu_simulator(
420*7c478bd9Sstevel@tonic-gate 	fp_simd_type	*pfpsd,	 /* Pointer to FPU simulator data */
421*7c478bd9Sstevel@tonic-gate 	fp_inst_type	*pinst,	 /* Pointer to FPU instruction to simulate. */
422*7c478bd9Sstevel@tonic-gate 	fsr_type	*pfsr,	 /* Pointer to image of FSR to read & write. */
423*7c478bd9Sstevel@tonic-gate 	int		instr);	 /* Instruction to emulate. */
424*7c478bd9Sstevel@tonic-gate 
425*7c478bd9Sstevel@tonic-gate /*
426*7c478bd9Sstevel@tonic-gate  * fp_emulator simulates FPU and CPU-FPU instructions; reads and writes FPU
427*7c478bd9Sstevel@tonic-gate  * data registers from image in pfpu.
428*7c478bd9Sstevel@tonic-gate  */
429*7c478bd9Sstevel@tonic-gate extern enum ftt_type fp_emulator(
430*7c478bd9Sstevel@tonic-gate 	fp_simd_type	*pfpsd,	   /* Pointer to FPU simulator data */
431*7c478bd9Sstevel@tonic-gate 	fp_inst_type	*pinst,    /* Pointer to FPU instruction to simulate. */
432*7c478bd9Sstevel@tonic-gate 	struct regs	*pregs,    /* Pointer to PCB image of registers. */
433*7c478bd9Sstevel@tonic-gate 	struct rwindow	*pwindow,  /* Pointer to locals and ins. */
434*7c478bd9Sstevel@tonic-gate 	struct fpu	*pfpu);	   /* Pointer to FPU register block. */
435*7c478bd9Sstevel@tonic-gate 
436*7c478bd9Sstevel@tonic-gate /*
437*7c478bd9Sstevel@tonic-gate  * fp_traps handles passing exception conditions to the kernel.
438*7c478bd9Sstevel@tonic-gate  * It is called after fp_simulator or fp_emulator fail (return a non-zero ftt).
439*7c478bd9Sstevel@tonic-gate  */
440*7c478bd9Sstevel@tonic-gate extern void fp_traps(
441*7c478bd9Sstevel@tonic-gate 	fp_simd_type	*pfpsd,	 /* Pointer to FPU simulator data */
442*7c478bd9Sstevel@tonic-gate 	enum ftt_type	ftt,	 /* Type of trap. */
443*7c478bd9Sstevel@tonic-gate 	struct regs	*rp);	 /* Pointer to PCB image of registers. */
444*7c478bd9Sstevel@tonic-gate 
445*7c478bd9Sstevel@tonic-gate /*
446*7c478bd9Sstevel@tonic-gate  * fp_kstat_update tracks fpu exception conditions.
447*7c478bd9Sstevel@tonic-gate  * It is called after a hardware trap returns a non-zero ftt.
448*7c478bd9Sstevel@tonic-gate  */
449*7c478bd9Sstevel@tonic-gate extern void fp_kstat_update(enum ftt_type ftt);	/* Type of trap. */
450*7c478bd9Sstevel@tonic-gate 
451*7c478bd9Sstevel@tonic-gate /*
452*7c478bd9Sstevel@tonic-gate  * fp_precise handles floating point unimplemented and unfinished traps,
453*7c478bd9Sstevel@tonic-gate  * for sparc V9 hardware. These traps are normally passed along to the
454*7c478bd9Sstevel@tonic-gate  * fpu_simulator, to see if it can run the unimplemented instruction or
455*7c478bd9Sstevel@tonic-gate  * finish the unfinished instruction. Needless to say, this takes time.
456*7c478bd9Sstevel@tonic-gate  */
457*7c478bd9Sstevel@tonic-gate extern void fp_precise(
458*7c478bd9Sstevel@tonic-gate 	struct regs *rp);	/* Pointer to PCB image of registers. */
459*7c478bd9Sstevel@tonic-gate 
460*7c478bd9Sstevel@tonic-gate /*
461*7c478bd9Sstevel@tonic-gate  * fpu_trap handles V9 floating point ieee and other floating point traps.
462*7c478bd9Sstevel@tonic-gate  * It is called after fp_simulator or fp_emulator fail (return a non-zero ftt),
463*7c478bd9Sstevel@tonic-gate  * and from the _fp_ieee_exception trap handler.
464*7c478bd9Sstevel@tonic-gate  */
465*7c478bd9Sstevel@tonic-gate extern void fpu_trap(
466*7c478bd9Sstevel@tonic-gate 	struct regs *rp,	/* Pointer to PCB image of registers. */
467*7c478bd9Sstevel@tonic-gate 	caddr_t addr,		/* Address of trapping instruction. */
468*7c478bd9Sstevel@tonic-gate 	uint32_t type,		/* Type of trapping exception. */
469*7c478bd9Sstevel@tonic-gate 	uint32_t code);		/* Trap code -> si_code. */
470*7c478bd9Sstevel@tonic-gate 
471*7c478bd9Sstevel@tonic-gate #endif	/* __STDC__ */
472*7c478bd9Sstevel@tonic-gate #endif /* _ASM */
473*7c478bd9Sstevel@tonic-gate 
474*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
475*7c478bd9Sstevel@tonic-gate }
476*7c478bd9Sstevel@tonic-gate #endif
477*7c478bd9Sstevel@tonic-gate 
478*7c478bd9Sstevel@tonic-gate #endif	/* _SYS_FPU_FPU_SIMULATOR_H */
479