xref: /onnv-gate/usr/src/uts/intel/sys/fasttrap_isa.h (revision 2769:b2e3d55c6e12)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
52712Snn35248  * Common Development and Distribution License (the "License").
62712Snn35248  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
222712Snn35248  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #ifndef	_FASTTRAP_ISA_H
270Sstevel@tonic-gate #define	_FASTTRAP_ISA_H
280Sstevel@tonic-gate 
290Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
300Sstevel@tonic-gate 
310Sstevel@tonic-gate #include <sys/types.h>
320Sstevel@tonic-gate 
330Sstevel@tonic-gate #ifdef	__cplusplus
340Sstevel@tonic-gate extern "C" {
350Sstevel@tonic-gate #endif
360Sstevel@tonic-gate 
370Sstevel@tonic-gate #define	FASTTRAP_MAX_INSTR_SIZE		15
380Sstevel@tonic-gate 
390Sstevel@tonic-gate #define	FASTTRAP_INSTR			0xcc
400Sstevel@tonic-gate 
410Sstevel@tonic-gate #define	FASTTRAP_SUNWDTRACE_SIZE	64
420Sstevel@tonic-gate 
430Sstevel@tonic-gate typedef	uint8_t		fasttrap_instr_t;
440Sstevel@tonic-gate 
450Sstevel@tonic-gate typedef struct fasttrap_machtp {
460Sstevel@tonic-gate 	uint8_t		ftmt_instr[FASTTRAP_MAX_INSTR_SIZE]; /* orig. instr. */
470Sstevel@tonic-gate 	uint8_t		ftmt_size;	/* instruction size */
480Sstevel@tonic-gate #ifdef __amd64
490Sstevel@tonic-gate 	uint8_t		ftmt_ripmode;	/* %rip-relative handling mode */
500Sstevel@tonic-gate 	uint8_t		ftmt_modrm;	/* saved modrm byte */
510Sstevel@tonic-gate #endif
520Sstevel@tonic-gate 	uint8_t		ftmt_type;	/* emulation type */
530Sstevel@tonic-gate 	uint8_t		ftmt_code;	/* branch condition */
540Sstevel@tonic-gate 	uint8_t		ftmt_base;	/* branch base */
550Sstevel@tonic-gate 	uint8_t		ftmt_index;	/* branch index */
560Sstevel@tonic-gate 	uint8_t		ftmt_scale;	/* branch scale */
572712Snn35248 	uint8_t		ftmt_segment;	/* segment for memory accesses */
580Sstevel@tonic-gate 	uintptr_t	ftmt_dest;	/* destination of control flow */
590Sstevel@tonic-gate } fasttrap_machtp_t;
600Sstevel@tonic-gate 
610Sstevel@tonic-gate #define	ftt_instr	ftt_mtp.ftmt_instr
620Sstevel@tonic-gate #ifdef __amd64
630Sstevel@tonic-gate #define	ftt_ripmode	ftt_mtp.ftmt_ripmode
640Sstevel@tonic-gate #define	ftt_modrm	ftt_mtp.ftmt_modrm
650Sstevel@tonic-gate #endif
660Sstevel@tonic-gate #define	ftt_size	ftt_mtp.ftmt_size
670Sstevel@tonic-gate #define	ftt_type	ftt_mtp.ftmt_type
680Sstevel@tonic-gate #define	ftt_code	ftt_mtp.ftmt_code
690Sstevel@tonic-gate #define	ftt_base	ftt_mtp.ftmt_base
700Sstevel@tonic-gate #define	ftt_index	ftt_mtp.ftmt_index
710Sstevel@tonic-gate #define	ftt_scale	ftt_mtp.ftmt_scale
722712Snn35248 #define	ftt_segment	ftt_mtp.ftmt_segment
730Sstevel@tonic-gate #define	ftt_dest	ftt_mtp.ftmt_dest
740Sstevel@tonic-gate 
750Sstevel@tonic-gate #define	FASTTRAP_T_COMMON	0x00	/* common case -- no emulation */
760Sstevel@tonic-gate #define	FASTTRAP_T_JCC		0x01	/* near and far conditional jumps */
770Sstevel@tonic-gate #define	FASTTRAP_T_LOOP		0x02	/* loop instructions */
780Sstevel@tonic-gate #define	FASTTRAP_T_JCXZ		0x03	/* jump if %ecx/%rcx is zero */
790Sstevel@tonic-gate #define	FASTTRAP_T_JMP		0x04	/* relative jump */
800Sstevel@tonic-gate #define	FASTTRAP_T_CALL		0x05	/* near call (and link) */
810Sstevel@tonic-gate #define	FASTTRAP_T_RET		0x06	/* ret */
820Sstevel@tonic-gate #define	FASTTRAP_T_RET16	0x07	/* ret <imm16> */
830Sstevel@tonic-gate 
840Sstevel@tonic-gate /*
850Sstevel@tonic-gate  * For performance rather than correctness.
860Sstevel@tonic-gate  */
870Sstevel@tonic-gate #define	FASTTRAP_T_PUSHL_EBP	0x10	/* pushl %ebp (for function entry) */
88*2769Sahl #define	FASTTRAP_T_NOP		0x11	/* nop */
890Sstevel@tonic-gate 
900Sstevel@tonic-gate #define	FASTTRAP_RIP_1		0x1
910Sstevel@tonic-gate #define	FASTTRAP_RIP_2		0x2
920Sstevel@tonic-gate #define	FASTTRAP_RIP_X		0x4
930Sstevel@tonic-gate 
942712Snn35248 /*
952712Snn35248  * Segment values.
962712Snn35248  */
972712Snn35248 #define	FASTTRAP_SEG_NONE		0
982712Snn35248 #define	FASTTRAP_SEG_CS			1
992712Snn35248 #define	FASTTRAP_SEG_DS			2
1002712Snn35248 #define	FASTTRAP_SEG_ES			3
1012712Snn35248 #define	FASTTRAP_SEG_FS			4
1022712Snn35248 #define	FASTTRAP_SEG_GS			5
1032712Snn35248 #define	FASTTRAP_SEG_SS			6
1042712Snn35248 
1050Sstevel@tonic-gate #define	FASTTRAP_AFRAMES		3
1060Sstevel@tonic-gate #define	FASTTRAP_RETURN_AFRAMES		4
1070Sstevel@tonic-gate #define	FASTTRAP_ENTRY_AFRAMES		3
1080Sstevel@tonic-gate #define	FASTTRAP_OFFSET_AFRAMES		3
1090Sstevel@tonic-gate 
1100Sstevel@tonic-gate #ifdef	__cplusplus
1110Sstevel@tonic-gate }
1120Sstevel@tonic-gate #endif
1130Sstevel@tonic-gate 
1140Sstevel@tonic-gate #endif	/* _FASTTRAP_ISA_H */
115