xref: /titanic_51/usr/src/uts/sparc/sys/simulate.h (revision 4e8a0fa6fce12b5763c5ec0a8fdc66de5f4d8214)
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 /*
23*4e8a0fa6Swsm  * 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_SIMULATE_H
287c478bd9Sstevel@tonic-gate #define	_SYS_SIMULATE_H
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
317c478bd9Sstevel@tonic-gate 
327c478bd9Sstevel@tonic-gate #ifdef __cplusplus
337c478bd9Sstevel@tonic-gate extern "C" {
347c478bd9Sstevel@tonic-gate #endif
357c478bd9Sstevel@tonic-gate 
367c478bd9Sstevel@tonic-gate /* SPARC instruction simulator return codes.  */
377c478bd9Sstevel@tonic-gate 
387c478bd9Sstevel@tonic-gate #define	SIMU_SUCCESS	1	/* simulation worked */
397c478bd9Sstevel@tonic-gate #define	SIMU_ILLEGAL	2	/* tried to simulate an illegal instuction */
407c478bd9Sstevel@tonic-gate #define	SIMU_FAULT	3	/* simulation generated an illegal access */
417c478bd9Sstevel@tonic-gate #define	SIMU_DZERO	4	/* simulation generated divide by zero */
427c478bd9Sstevel@tonic-gate #define	SIMU_UNALIGN	5	/* simulation generated an unaligned access */
437c478bd9Sstevel@tonic-gate #define	SIMU_RETRY	6	/* fixed up instruction, now retry it */
447c478bd9Sstevel@tonic-gate 
457c478bd9Sstevel@tonic-gate 
467c478bd9Sstevel@tonic-gate /*
477c478bd9Sstevel@tonic-gate  * Opcode types.
487c478bd9Sstevel@tonic-gate  */
497c478bd9Sstevel@tonic-gate #define	OP_V8_BRANCH	0
507c478bd9Sstevel@tonic-gate #define	OP_V8_CALL	1
517c478bd9Sstevel@tonic-gate #define	OP_V8_ARITH	2	/* includes control xfer (e.g. JMPL) */
527c478bd9Sstevel@tonic-gate #define	OP_V8_LDSTR	3
537c478bd9Sstevel@tonic-gate 
547c478bd9Sstevel@tonic-gate /*
557c478bd9Sstevel@tonic-gate  * Relevant instruction opcodes.
567c478bd9Sstevel@tonic-gate  */
577c478bd9Sstevel@tonic-gate 
587c478bd9Sstevel@tonic-gate /* OP_V8_LDSTR  */
597c478bd9Sstevel@tonic-gate #define	IOP_V8_LD	0x00
607c478bd9Sstevel@tonic-gate #define	IOP_V8_LDA	0x10
617c478bd9Sstevel@tonic-gate #define	IOP_V8_LDUBA	0x11
627c478bd9Sstevel@tonic-gate #define	IOP_V8_LDUHA	0x12
637c478bd9Sstevel@tonic-gate #define	IOP_V8_LDDA	0x13
647c478bd9Sstevel@tonic-gate #define	IOP_V8_STA	0x14
657c478bd9Sstevel@tonic-gate #define	IOP_V8_STBA	0x15
667c478bd9Sstevel@tonic-gate #define	IOP_V8_STHA	0x16
677c478bd9Sstevel@tonic-gate #define	IOP_V8_STDA	0x17
687c478bd9Sstevel@tonic-gate #define	IOP_V8_LDSBA	0x19
697c478bd9Sstevel@tonic-gate #define	IOP_V8_LDSHA	0x1a
707c478bd9Sstevel@tonic-gate #define	IOP_V8_LDSTUBA	0x1d
717c478bd9Sstevel@tonic-gate #define	IOP_V8_SWAPA	0x1f
727c478bd9Sstevel@tonic-gate #define	IOP_V8_LDFSR	0x21
737c478bd9Sstevel@tonic-gate #define	IOP_V8_LDQF	0x22
747c478bd9Sstevel@tonic-gate #define	IOP_V8_STFSR	0x25
757c478bd9Sstevel@tonic-gate #define	IOP_V8_STQF	0x26
767c478bd9Sstevel@tonic-gate #define	IOP_V8_LDQFA	0x32
777c478bd9Sstevel@tonic-gate #define	IOP_V8_LDDFA	0x33
787c478bd9Sstevel@tonic-gate #define	IOP_V8_STQFA	0x36
797c478bd9Sstevel@tonic-gate #define	IOP_V8_STDFA	0x37
807c478bd9Sstevel@tonic-gate 
817c478bd9Sstevel@tonic-gate /* OP_V8_ARITH */
827c478bd9Sstevel@tonic-gate #define	IOP_V8_ADD	0x00
837c478bd9Sstevel@tonic-gate #define	IOP_V8_AND	0x01
847c478bd9Sstevel@tonic-gate #define	IOP_V8_OR	0x02
857c478bd9Sstevel@tonic-gate #define	IOP_V8_XOR	0x03
867c478bd9Sstevel@tonic-gate #define	IOP_V8_SUB	0x04
877c478bd9Sstevel@tonic-gate #define	IOP_V8_ANDN	0x05
887c478bd9Sstevel@tonic-gate #define	IOP_V8_ORN	0x06
897c478bd9Sstevel@tonic-gate #define	IOP_V8_XNOR	0x07
907c478bd9Sstevel@tonic-gate #define	IOP_V8_ADDC	0x08
917c478bd9Sstevel@tonic-gate #define	IOP_V8_UMUL	0x0a
927c478bd9Sstevel@tonic-gate #define	IOP_V8_SMUL	0x0b
937c478bd9Sstevel@tonic-gate #define	IOP_V8_SUBC	0x0c
947c478bd9Sstevel@tonic-gate #define	IOP_V8_UDIV	0x0e
957c478bd9Sstevel@tonic-gate #define	IOP_V8_SDIV	0x0f
967c478bd9Sstevel@tonic-gate #define	IOP_V8_ADDcc	0x10
977c478bd9Sstevel@tonic-gate #define	IOP_V8_ANDcc	0x11
987c478bd9Sstevel@tonic-gate #define	IOP_V8_ORcc	0x12
997c478bd9Sstevel@tonic-gate #define	IOP_V8_XORcc	0x13
1007c478bd9Sstevel@tonic-gate #define	IOP_V8_SUBcc	0x14
1017c478bd9Sstevel@tonic-gate #define	IOP_V8_ANDNcc	0x15
1027c478bd9Sstevel@tonic-gate #define	IOP_V8_ORNcc	0x16
1037c478bd9Sstevel@tonic-gate #define	IOP_V8_XNORcc	0x17
1047c478bd9Sstevel@tonic-gate #define	IOP_V8_ADDCcc	0x18
1057c478bd9Sstevel@tonic-gate #define	IOP_V8_UMULcc	0x1a
1067c478bd9Sstevel@tonic-gate #define	IOP_V8_SMULcc	0x1b
1077c478bd9Sstevel@tonic-gate #define	IOP_V8_SUBCcc	0x1c
1087c478bd9Sstevel@tonic-gate #define	IOP_V8_UDIVcc	0x1e
1097c478bd9Sstevel@tonic-gate #define	IOP_V8_SDIVcc	0x1f
1107c478bd9Sstevel@tonic-gate #define	IOP_V8_TADDcc	0x20
1117c478bd9Sstevel@tonic-gate #define	IOP_V8_TSUBcc	0x21
1127c478bd9Sstevel@tonic-gate #define	IOP_V8_TADDccTV	0x22
1137c478bd9Sstevel@tonic-gate #define	IOP_V8_TSUBccTV	0x23
1147c478bd9Sstevel@tonic-gate #define	IOP_V8_MULScc	0x24
1157c478bd9Sstevel@tonic-gate #define	IOP_V8_SLL	0x25
1167c478bd9Sstevel@tonic-gate #define	IOP_V8_SRL	0x26
1177c478bd9Sstevel@tonic-gate #define	IOP_V8_SRA	0x27
1187c478bd9Sstevel@tonic-gate #define	IOP_V8_RDASR	0x28
1197c478bd9Sstevel@tonic-gate #define	IOP_V8_POPC	0x2e
1207c478bd9Sstevel@tonic-gate #define	IOP_V8_WRASR	0x30
1217c478bd9Sstevel@tonic-gate #define	IOP_V8_FCMP	0x35
1227c478bd9Sstevel@tonic-gate #define	IOP_V8_JMPL	0x38
1237c478bd9Sstevel@tonic-gate #define	IOP_V8_RETT	0x39
1247c478bd9Sstevel@tonic-gate #define	IOP_V8_TCC	0x3a
1257c478bd9Sstevel@tonic-gate #define	IOP_V8_FLUSH	0x3b
1267c478bd9Sstevel@tonic-gate #define	IOP_V8_SAVE	0x3c
1277c478bd9Sstevel@tonic-gate #define	IOP_V8_RESTORE	0x3d
1287c478bd9Sstevel@tonic-gate 
1297c478bd9Sstevel@tonic-gate /*
1307c478bd9Sstevel@tonic-gate  * Check for a load/store to alternate space. All other ld/st
1317c478bd9Sstevel@tonic-gate  * instructions should have bits 12-5 clear, if the i-bit is 0.
1327c478bd9Sstevel@tonic-gate  */
1337c478bd9Sstevel@tonic-gate #define	IS_LDST_ALT(x) \
1347c478bd9Sstevel@tonic-gate 	(((x) == IOP_V8_LDA || (x) == IOP_V8_LDDA || \
1357c478bd9Sstevel@tonic-gate 	    (x) == IOP_V8_LDSBA || (x) == IOP_V8_LDSHA || \
1367c478bd9Sstevel@tonic-gate 	    (x) == IOP_V8_LDSTUBA || (x) == IOP_V8_LDUBA || \
1377c478bd9Sstevel@tonic-gate 	    (x) == IOP_V8_LDUHA || (x) == IOP_V8_STA || \
1387c478bd9Sstevel@tonic-gate 	    (x) == IOP_V8_STBA || (x) == IOP_V8_STDA || \
1397c478bd9Sstevel@tonic-gate 	    (x) == IOP_V8_STHA || (x) == IOP_V8_SWAPA) ? 1 : 0)
1407c478bd9Sstevel@tonic-gate 
1417c478bd9Sstevel@tonic-gate 
1427c478bd9Sstevel@tonic-gate #ifndef _ASM
1437c478bd9Sstevel@tonic-gate 
1447c478bd9Sstevel@tonic-gate #include <vm/seg_enum.h>
1457c478bd9Sstevel@tonic-gate 
1467c478bd9Sstevel@tonic-gate extern int32_t fetch_user_instr(caddr_t);
1477c478bd9Sstevel@tonic-gate extern int simulate_unimp(struct regs *, caddr_t *);
148*4e8a0fa6Swsm extern int simulate_lddstd(struct regs *, caddr_t *);
1497c478bd9Sstevel@tonic-gate extern int do_unaligned(struct regs *, caddr_t *);
1507c478bd9Sstevel@tonic-gate extern int calc_memaddr(struct regs *, caddr_t *);
1517c478bd9Sstevel@tonic-gate extern int is_atomic(struct regs *);
1527c478bd9Sstevel@tonic-gate extern int instr_size(struct regs *, caddr_t *, enum seg_rw);
1537c478bd9Sstevel@tonic-gate extern int getreg(struct regs *, uint_t, uint64_t *, caddr_t *);
1547c478bd9Sstevel@tonic-gate extern int putreg(uint64_t *, struct regs *, uint_t, caddr_t *);
1557c478bd9Sstevel@tonic-gate extern int extended_asi_size(int asi);
1567c478bd9Sstevel@tonic-gate 
1577c478bd9Sstevel@tonic-gate #endif /* _ASM */
1587c478bd9Sstevel@tonic-gate 
1597c478bd9Sstevel@tonic-gate #ifdef __cplusplus
1607c478bd9Sstevel@tonic-gate }
1617c478bd9Sstevel@tonic-gate #endif
1627c478bd9Sstevel@tonic-gate 
1637c478bd9Sstevel@tonic-gate #endif /* _SYS_SIMULATE_H */
164