xref: /titanic_51/usr/src/uts/sparc/sys/simulate.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
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 1991-1998,2003 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_SIMULATE_H
28*7c478bd9Sstevel@tonic-gate #define	_SYS_SIMULATE_H
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*7c478bd9Sstevel@tonic-gate 
32*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus
33*7c478bd9Sstevel@tonic-gate extern "C" {
34*7c478bd9Sstevel@tonic-gate #endif
35*7c478bd9Sstevel@tonic-gate 
36*7c478bd9Sstevel@tonic-gate /* SPARC instruction simulator return codes.  */
37*7c478bd9Sstevel@tonic-gate 
38*7c478bd9Sstevel@tonic-gate #define	SIMU_SUCCESS	1	/* simulation worked */
39*7c478bd9Sstevel@tonic-gate #define	SIMU_ILLEGAL	2	/* tried to simulate an illegal instuction */
40*7c478bd9Sstevel@tonic-gate #define	SIMU_FAULT	3	/* simulation generated an illegal access */
41*7c478bd9Sstevel@tonic-gate #define	SIMU_DZERO	4	/* simulation generated divide by zero */
42*7c478bd9Sstevel@tonic-gate #define	SIMU_UNALIGN	5	/* simulation generated an unaligned access */
43*7c478bd9Sstevel@tonic-gate #define	SIMU_RETRY	6	/* fixed up instruction, now retry it */
44*7c478bd9Sstevel@tonic-gate 
45*7c478bd9Sstevel@tonic-gate 
46*7c478bd9Sstevel@tonic-gate /*
47*7c478bd9Sstevel@tonic-gate  * Opcode types.
48*7c478bd9Sstevel@tonic-gate  */
49*7c478bd9Sstevel@tonic-gate #define	OP_V8_BRANCH	0
50*7c478bd9Sstevel@tonic-gate #define	OP_V8_CALL	1
51*7c478bd9Sstevel@tonic-gate #define	OP_V8_ARITH	2	/* includes control xfer (e.g. JMPL) */
52*7c478bd9Sstevel@tonic-gate #define	OP_V8_LDSTR	3
53*7c478bd9Sstevel@tonic-gate 
54*7c478bd9Sstevel@tonic-gate /*
55*7c478bd9Sstevel@tonic-gate  * Relevant instruction opcodes.
56*7c478bd9Sstevel@tonic-gate  */
57*7c478bd9Sstevel@tonic-gate 
58*7c478bd9Sstevel@tonic-gate /* OP_V8_LDSTR  */
59*7c478bd9Sstevel@tonic-gate #define	IOP_V8_LD	0x00
60*7c478bd9Sstevel@tonic-gate #define	IOP_V8_LDA	0x10
61*7c478bd9Sstevel@tonic-gate #define	IOP_V8_LDUBA	0x11
62*7c478bd9Sstevel@tonic-gate #define	IOP_V8_LDUHA	0x12
63*7c478bd9Sstevel@tonic-gate #define	IOP_V8_LDDA	0x13
64*7c478bd9Sstevel@tonic-gate #define	IOP_V8_STA	0x14
65*7c478bd9Sstevel@tonic-gate #define	IOP_V8_STBA	0x15
66*7c478bd9Sstevel@tonic-gate #define	IOP_V8_STHA	0x16
67*7c478bd9Sstevel@tonic-gate #define	IOP_V8_STDA	0x17
68*7c478bd9Sstevel@tonic-gate #define	IOP_V8_LDSBA	0x19
69*7c478bd9Sstevel@tonic-gate #define	IOP_V8_LDSHA	0x1a
70*7c478bd9Sstevel@tonic-gate #define	IOP_V8_LDSTUBA	0x1d
71*7c478bd9Sstevel@tonic-gate #define	IOP_V8_SWAPA	0x1f
72*7c478bd9Sstevel@tonic-gate #define	IOP_V8_LDFSR	0x21
73*7c478bd9Sstevel@tonic-gate #define	IOP_V8_LDQF	0x22
74*7c478bd9Sstevel@tonic-gate #define	IOP_V8_STFSR	0x25
75*7c478bd9Sstevel@tonic-gate #define	IOP_V8_STQF	0x26
76*7c478bd9Sstevel@tonic-gate #define	IOP_V8_LDQFA	0x32
77*7c478bd9Sstevel@tonic-gate #define	IOP_V8_LDDFA	0x33
78*7c478bd9Sstevel@tonic-gate #define	IOP_V8_STQFA	0x36
79*7c478bd9Sstevel@tonic-gate #define	IOP_V8_STDFA	0x37
80*7c478bd9Sstevel@tonic-gate 
81*7c478bd9Sstevel@tonic-gate /* OP_V8_ARITH */
82*7c478bd9Sstevel@tonic-gate #define	IOP_V8_ADD	0x00
83*7c478bd9Sstevel@tonic-gate #define	IOP_V8_AND	0x01
84*7c478bd9Sstevel@tonic-gate #define	IOP_V8_OR	0x02
85*7c478bd9Sstevel@tonic-gate #define	IOP_V8_XOR	0x03
86*7c478bd9Sstevel@tonic-gate #define	IOP_V8_SUB	0x04
87*7c478bd9Sstevel@tonic-gate #define	IOP_V8_ANDN	0x05
88*7c478bd9Sstevel@tonic-gate #define	IOP_V8_ORN	0x06
89*7c478bd9Sstevel@tonic-gate #define	IOP_V8_XNOR	0x07
90*7c478bd9Sstevel@tonic-gate #define	IOP_V8_ADDC	0x08
91*7c478bd9Sstevel@tonic-gate #define	IOP_V8_UMUL	0x0a
92*7c478bd9Sstevel@tonic-gate #define	IOP_V8_SMUL	0x0b
93*7c478bd9Sstevel@tonic-gate #define	IOP_V8_SUBC	0x0c
94*7c478bd9Sstevel@tonic-gate #define	IOP_V8_UDIV	0x0e
95*7c478bd9Sstevel@tonic-gate #define	IOP_V8_SDIV	0x0f
96*7c478bd9Sstevel@tonic-gate #define	IOP_V8_ADDcc	0x10
97*7c478bd9Sstevel@tonic-gate #define	IOP_V8_ANDcc	0x11
98*7c478bd9Sstevel@tonic-gate #define	IOP_V8_ORcc	0x12
99*7c478bd9Sstevel@tonic-gate #define	IOP_V8_XORcc	0x13
100*7c478bd9Sstevel@tonic-gate #define	IOP_V8_SUBcc	0x14
101*7c478bd9Sstevel@tonic-gate #define	IOP_V8_ANDNcc	0x15
102*7c478bd9Sstevel@tonic-gate #define	IOP_V8_ORNcc	0x16
103*7c478bd9Sstevel@tonic-gate #define	IOP_V8_XNORcc	0x17
104*7c478bd9Sstevel@tonic-gate #define	IOP_V8_ADDCcc	0x18
105*7c478bd9Sstevel@tonic-gate #define	IOP_V8_UMULcc	0x1a
106*7c478bd9Sstevel@tonic-gate #define	IOP_V8_SMULcc	0x1b
107*7c478bd9Sstevel@tonic-gate #define	IOP_V8_SUBCcc	0x1c
108*7c478bd9Sstevel@tonic-gate #define	IOP_V8_UDIVcc	0x1e
109*7c478bd9Sstevel@tonic-gate #define	IOP_V8_SDIVcc	0x1f
110*7c478bd9Sstevel@tonic-gate #define	IOP_V8_TADDcc	0x20
111*7c478bd9Sstevel@tonic-gate #define	IOP_V8_TSUBcc	0x21
112*7c478bd9Sstevel@tonic-gate #define	IOP_V8_TADDccTV	0x22
113*7c478bd9Sstevel@tonic-gate #define	IOP_V8_TSUBccTV	0x23
114*7c478bd9Sstevel@tonic-gate #define	IOP_V8_MULScc	0x24
115*7c478bd9Sstevel@tonic-gate #define	IOP_V8_SLL	0x25
116*7c478bd9Sstevel@tonic-gate #define	IOP_V8_SRL	0x26
117*7c478bd9Sstevel@tonic-gate #define	IOP_V8_SRA	0x27
118*7c478bd9Sstevel@tonic-gate #define	IOP_V8_RDASR	0x28
119*7c478bd9Sstevel@tonic-gate #define	IOP_V8_POPC	0x2e
120*7c478bd9Sstevel@tonic-gate #define	IOP_V8_WRASR	0x30
121*7c478bd9Sstevel@tonic-gate #define	IOP_V8_FCMP	0x35
122*7c478bd9Sstevel@tonic-gate #define	IOP_V8_JMPL	0x38
123*7c478bd9Sstevel@tonic-gate #define	IOP_V8_RETT	0x39
124*7c478bd9Sstevel@tonic-gate #define	IOP_V8_TCC	0x3a
125*7c478bd9Sstevel@tonic-gate #define	IOP_V8_FLUSH	0x3b
126*7c478bd9Sstevel@tonic-gate #define	IOP_V8_SAVE	0x3c
127*7c478bd9Sstevel@tonic-gate #define	IOP_V8_RESTORE	0x3d
128*7c478bd9Sstevel@tonic-gate 
129*7c478bd9Sstevel@tonic-gate /*
130*7c478bd9Sstevel@tonic-gate  * Check for a load/store to alternate space. All other ld/st
131*7c478bd9Sstevel@tonic-gate  * instructions should have bits 12-5 clear, if the i-bit is 0.
132*7c478bd9Sstevel@tonic-gate  */
133*7c478bd9Sstevel@tonic-gate #define	IS_LDST_ALT(x) \
134*7c478bd9Sstevel@tonic-gate 	(((x) == IOP_V8_LDA || (x) == IOP_V8_LDDA || \
135*7c478bd9Sstevel@tonic-gate 	    (x) == IOP_V8_LDSBA || (x) == IOP_V8_LDSHA || \
136*7c478bd9Sstevel@tonic-gate 	    (x) == IOP_V8_LDSTUBA || (x) == IOP_V8_LDUBA || \
137*7c478bd9Sstevel@tonic-gate 	    (x) == IOP_V8_LDUHA || (x) == IOP_V8_STA || \
138*7c478bd9Sstevel@tonic-gate 	    (x) == IOP_V8_STBA || (x) == IOP_V8_STDA || \
139*7c478bd9Sstevel@tonic-gate 	    (x) == IOP_V8_STHA || (x) == IOP_V8_SWAPA) ? 1 : 0)
140*7c478bd9Sstevel@tonic-gate 
141*7c478bd9Sstevel@tonic-gate 
142*7c478bd9Sstevel@tonic-gate #ifndef _ASM
143*7c478bd9Sstevel@tonic-gate 
144*7c478bd9Sstevel@tonic-gate #include <vm/seg_enum.h>
145*7c478bd9Sstevel@tonic-gate 
146*7c478bd9Sstevel@tonic-gate extern int32_t fetch_user_instr(caddr_t);
147*7c478bd9Sstevel@tonic-gate extern int simulate_unimp(struct regs *, caddr_t *);
148*7c478bd9Sstevel@tonic-gate extern int do_unaligned(struct regs *, caddr_t *);
149*7c478bd9Sstevel@tonic-gate extern int calc_memaddr(struct regs *, caddr_t *);
150*7c478bd9Sstevel@tonic-gate extern int is_atomic(struct regs *);
151*7c478bd9Sstevel@tonic-gate extern int instr_size(struct regs *, caddr_t *, enum seg_rw);
152*7c478bd9Sstevel@tonic-gate extern int getreg(struct regs *, uint_t, uint64_t *, caddr_t *);
153*7c478bd9Sstevel@tonic-gate extern int putreg(uint64_t *, struct regs *, uint_t, caddr_t *);
154*7c478bd9Sstevel@tonic-gate extern int extended_asi_size(int asi);
155*7c478bd9Sstevel@tonic-gate 
156*7c478bd9Sstevel@tonic-gate #endif /* _ASM */
157*7c478bd9Sstevel@tonic-gate 
158*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus
159*7c478bd9Sstevel@tonic-gate }
160*7c478bd9Sstevel@tonic-gate #endif
161*7c478bd9Sstevel@tonic-gate 
162*7c478bd9Sstevel@tonic-gate #endif /* _SYS_SIMULATE_H */
163