xref: /titanic_51/usr/src/uts/sparc/sys/simulate.h (revision 023e71de9e5670cebc23dd51162833661d3d2d3b)
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
5*023e71deSHaik Aftandilian  * Common Development and Distribution License (the "License").
6*023e71deSHaik Aftandilian  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22*023e71deSHaik Aftandilian  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #ifndef	_SYS_SIMULATE_H
277c478bd9Sstevel@tonic-gate #define	_SYS_SIMULATE_H
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #ifdef __cplusplus
307c478bd9Sstevel@tonic-gate extern "C" {
317c478bd9Sstevel@tonic-gate #endif
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate /* SPARC instruction simulator return codes.  */
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate #define	SIMU_SUCCESS	1	/* simulation worked */
367c478bd9Sstevel@tonic-gate #define	SIMU_ILLEGAL	2	/* tried to simulate an illegal instuction */
377c478bd9Sstevel@tonic-gate #define	SIMU_FAULT	3	/* simulation generated an illegal access */
387c478bd9Sstevel@tonic-gate #define	SIMU_DZERO	4	/* simulation generated divide by zero */
397c478bd9Sstevel@tonic-gate #define	SIMU_UNALIGN	5	/* simulation generated an unaligned access */
407c478bd9Sstevel@tonic-gate #define	SIMU_RETRY	6	/* fixed up instruction, now retry it */
417c478bd9Sstevel@tonic-gate 
427c478bd9Sstevel@tonic-gate 
437c478bd9Sstevel@tonic-gate /*
447c478bd9Sstevel@tonic-gate  * Opcode types.
457c478bd9Sstevel@tonic-gate  */
467c478bd9Sstevel@tonic-gate #define	OP_V8_BRANCH	0
477c478bd9Sstevel@tonic-gate #define	OP_V8_CALL	1
487c478bd9Sstevel@tonic-gate #define	OP_V8_ARITH	2	/* includes control xfer (e.g. JMPL) */
497c478bd9Sstevel@tonic-gate #define	OP_V8_LDSTR	3
507c478bd9Sstevel@tonic-gate 
517c478bd9Sstevel@tonic-gate /*
527c478bd9Sstevel@tonic-gate  * Relevant instruction opcodes.
537c478bd9Sstevel@tonic-gate  */
547c478bd9Sstevel@tonic-gate 
557c478bd9Sstevel@tonic-gate /* OP_V8_LDSTR  */
567c478bd9Sstevel@tonic-gate #define	IOP_V8_LD	0x00
577c478bd9Sstevel@tonic-gate #define	IOP_V8_LDA	0x10
587c478bd9Sstevel@tonic-gate #define	IOP_V8_LDUBA	0x11
597c478bd9Sstevel@tonic-gate #define	IOP_V8_LDUHA	0x12
607c478bd9Sstevel@tonic-gate #define	IOP_V8_LDDA	0x13
617c478bd9Sstevel@tonic-gate #define	IOP_V8_STA	0x14
627c478bd9Sstevel@tonic-gate #define	IOP_V8_STBA	0x15
637c478bd9Sstevel@tonic-gate #define	IOP_V8_STHA	0x16
647c478bd9Sstevel@tonic-gate #define	IOP_V8_STDA	0x17
657c478bd9Sstevel@tonic-gate #define	IOP_V8_LDSBA	0x19
667c478bd9Sstevel@tonic-gate #define	IOP_V8_LDSHA	0x1a
677c478bd9Sstevel@tonic-gate #define	IOP_V8_LDSTUBA	0x1d
687c478bd9Sstevel@tonic-gate #define	IOP_V8_SWAPA	0x1f
697c478bd9Sstevel@tonic-gate #define	IOP_V8_LDFSR	0x21
707c478bd9Sstevel@tonic-gate #define	IOP_V8_LDQF	0x22
717c478bd9Sstevel@tonic-gate #define	IOP_V8_STFSR	0x25
727c478bd9Sstevel@tonic-gate #define	IOP_V8_STQF	0x26
737c478bd9Sstevel@tonic-gate #define	IOP_V8_LDQFA	0x32
747c478bd9Sstevel@tonic-gate #define	IOP_V8_LDDFA	0x33
757c478bd9Sstevel@tonic-gate #define	IOP_V8_STQFA	0x36
767c478bd9Sstevel@tonic-gate #define	IOP_V8_STDFA	0x37
777c478bd9Sstevel@tonic-gate 
787c478bd9Sstevel@tonic-gate /* OP_V8_ARITH */
797c478bd9Sstevel@tonic-gate #define	IOP_V8_ADD	0x00
807c478bd9Sstevel@tonic-gate #define	IOP_V8_AND	0x01
817c478bd9Sstevel@tonic-gate #define	IOP_V8_OR	0x02
827c478bd9Sstevel@tonic-gate #define	IOP_V8_XOR	0x03
837c478bd9Sstevel@tonic-gate #define	IOP_V8_SUB	0x04
847c478bd9Sstevel@tonic-gate #define	IOP_V8_ANDN	0x05
857c478bd9Sstevel@tonic-gate #define	IOP_V8_ORN	0x06
867c478bd9Sstevel@tonic-gate #define	IOP_V8_XNOR	0x07
877c478bd9Sstevel@tonic-gate #define	IOP_V8_ADDC	0x08
887c478bd9Sstevel@tonic-gate #define	IOP_V8_UMUL	0x0a
897c478bd9Sstevel@tonic-gate #define	IOP_V8_SMUL	0x0b
907c478bd9Sstevel@tonic-gate #define	IOP_V8_SUBC	0x0c
917c478bd9Sstevel@tonic-gate #define	IOP_V8_UDIV	0x0e
927c478bd9Sstevel@tonic-gate #define	IOP_V8_SDIV	0x0f
937c478bd9Sstevel@tonic-gate #define	IOP_V8_ADDcc	0x10
947c478bd9Sstevel@tonic-gate #define	IOP_V8_ANDcc	0x11
957c478bd9Sstevel@tonic-gate #define	IOP_V8_ORcc	0x12
967c478bd9Sstevel@tonic-gate #define	IOP_V8_XORcc	0x13
977c478bd9Sstevel@tonic-gate #define	IOP_V8_SUBcc	0x14
987c478bd9Sstevel@tonic-gate #define	IOP_V8_ANDNcc	0x15
997c478bd9Sstevel@tonic-gate #define	IOP_V8_ORNcc	0x16
1007c478bd9Sstevel@tonic-gate #define	IOP_V8_XNORcc	0x17
1017c478bd9Sstevel@tonic-gate #define	IOP_V8_ADDCcc	0x18
1027c478bd9Sstevel@tonic-gate #define	IOP_V8_UMULcc	0x1a
1037c478bd9Sstevel@tonic-gate #define	IOP_V8_SMULcc	0x1b
1047c478bd9Sstevel@tonic-gate #define	IOP_V8_SUBCcc	0x1c
1057c478bd9Sstevel@tonic-gate #define	IOP_V8_UDIVcc	0x1e
1067c478bd9Sstevel@tonic-gate #define	IOP_V8_SDIVcc	0x1f
1077c478bd9Sstevel@tonic-gate #define	IOP_V8_TADDcc	0x20
1087c478bd9Sstevel@tonic-gate #define	IOP_V8_TSUBcc	0x21
1097c478bd9Sstevel@tonic-gate #define	IOP_V8_TADDccTV	0x22
1107c478bd9Sstevel@tonic-gate #define	IOP_V8_TSUBccTV	0x23
1117c478bd9Sstevel@tonic-gate #define	IOP_V8_MULScc	0x24
1127c478bd9Sstevel@tonic-gate #define	IOP_V8_SLL	0x25
1137c478bd9Sstevel@tonic-gate #define	IOP_V8_SRL	0x26
1147c478bd9Sstevel@tonic-gate #define	IOP_V8_SRA	0x27
1157c478bd9Sstevel@tonic-gate #define	IOP_V8_RDASR	0x28
1167c478bd9Sstevel@tonic-gate #define	IOP_V8_POPC	0x2e
1177c478bd9Sstevel@tonic-gate #define	IOP_V8_WRASR	0x30
1187c478bd9Sstevel@tonic-gate #define	IOP_V8_FCMP	0x35
1197c478bd9Sstevel@tonic-gate #define	IOP_V8_JMPL	0x38
1207c478bd9Sstevel@tonic-gate #define	IOP_V8_RETT	0x39
1217c478bd9Sstevel@tonic-gate #define	IOP_V8_TCC	0x3a
1227c478bd9Sstevel@tonic-gate #define	IOP_V8_FLUSH	0x3b
1237c478bd9Sstevel@tonic-gate #define	IOP_V8_SAVE	0x3c
1247c478bd9Sstevel@tonic-gate #define	IOP_V8_RESTORE	0x3d
1257c478bd9Sstevel@tonic-gate 
1267c478bd9Sstevel@tonic-gate /*
1277c478bd9Sstevel@tonic-gate  * Check for a load/store to alternate space. All other ld/st
1287c478bd9Sstevel@tonic-gate  * instructions should have bits 12-5 clear, if the i-bit is 0.
1297c478bd9Sstevel@tonic-gate  */
1307c478bd9Sstevel@tonic-gate #define	IS_LDST_ALT(x) \
1317c478bd9Sstevel@tonic-gate 	(((x) == IOP_V8_LDA || (x) == IOP_V8_LDDA || \
1327c478bd9Sstevel@tonic-gate 	    (x) == IOP_V8_LDSBA || (x) == IOP_V8_LDSHA || \
1337c478bd9Sstevel@tonic-gate 	    (x) == IOP_V8_LDSTUBA || (x) == IOP_V8_LDUBA || \
1347c478bd9Sstevel@tonic-gate 	    (x) == IOP_V8_LDUHA || (x) == IOP_V8_STA || \
1357c478bd9Sstevel@tonic-gate 	    (x) == IOP_V8_STBA || (x) == IOP_V8_STDA || \
1367c478bd9Sstevel@tonic-gate 	    (x) == IOP_V8_STHA || (x) == IOP_V8_SWAPA) ? 1 : 0)
1377c478bd9Sstevel@tonic-gate 
1387c478bd9Sstevel@tonic-gate 
1397c478bd9Sstevel@tonic-gate #ifndef _ASM
1407c478bd9Sstevel@tonic-gate 
1417c478bd9Sstevel@tonic-gate #include <vm/seg_enum.h>
1427c478bd9Sstevel@tonic-gate 
1437c478bd9Sstevel@tonic-gate extern int32_t fetch_user_instr(caddr_t);
1447c478bd9Sstevel@tonic-gate extern int simulate_unimp(struct regs *, caddr_t *);
1454e8a0fa6Swsm extern int simulate_lddstd(struct regs *, caddr_t *);
146*023e71deSHaik Aftandilian extern int simulate_rdtick(struct regs *);
1477c478bd9Sstevel@tonic-gate extern int do_unaligned(struct regs *, caddr_t *);
1487c478bd9Sstevel@tonic-gate extern int calc_memaddr(struct regs *, caddr_t *);
1497c478bd9Sstevel@tonic-gate extern int is_atomic(struct regs *);
1507c478bd9Sstevel@tonic-gate extern int instr_size(struct regs *, caddr_t *, enum seg_rw);
1517c478bd9Sstevel@tonic-gate extern int getreg(struct regs *, uint_t, uint64_t *, caddr_t *);
1527c478bd9Sstevel@tonic-gate extern int putreg(uint64_t *, struct regs *, uint_t, caddr_t *);
1537c478bd9Sstevel@tonic-gate extern int extended_asi_size(int asi);
1547c478bd9Sstevel@tonic-gate 
1557c478bd9Sstevel@tonic-gate #endif /* _ASM */
1567c478bd9Sstevel@tonic-gate 
1577c478bd9Sstevel@tonic-gate #ifdef __cplusplus
1587c478bd9Sstevel@tonic-gate }
1597c478bd9Sstevel@tonic-gate #endif
1607c478bd9Sstevel@tonic-gate 
1617c478bd9Sstevel@tonic-gate #endif /* _SYS_SIMULATE_H */
162