xref: /titanic_51/usr/src/uts/intel/sys/fasttrap_isa.h (revision 2b6e762c557496a41438c0b105d604f60c593682)
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
59acbbeafSnn35248  * Common Development and Distribution License (the "License").
69acbbeafSnn35248  * 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 /*
229acbbeafSnn35248  * Copyright 2006 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	_FASTTRAP_ISA_H
277c478bd9Sstevel@tonic-gate #define	_FASTTRAP_ISA_H
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate #include <sys/types.h>
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
347c478bd9Sstevel@tonic-gate extern "C" {
357c478bd9Sstevel@tonic-gate #endif
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate #define	FASTTRAP_MAX_INSTR_SIZE		15
387c478bd9Sstevel@tonic-gate 
397c478bd9Sstevel@tonic-gate #define	FASTTRAP_INSTR			0xcc
407c478bd9Sstevel@tonic-gate 
417c478bd9Sstevel@tonic-gate #define	FASTTRAP_SUNWDTRACE_SIZE	64
427c478bd9Sstevel@tonic-gate 
437c478bd9Sstevel@tonic-gate typedef	uint8_t		fasttrap_instr_t;
447c478bd9Sstevel@tonic-gate 
457c478bd9Sstevel@tonic-gate typedef struct fasttrap_machtp {
467c478bd9Sstevel@tonic-gate 	uint8_t		ftmt_instr[FASTTRAP_MAX_INSTR_SIZE]; /* orig. instr. */
477c478bd9Sstevel@tonic-gate 	uint8_t		ftmt_size;	/* instruction size */
487c478bd9Sstevel@tonic-gate #ifdef __amd64
497c478bd9Sstevel@tonic-gate 	uint8_t		ftmt_ripmode;	/* %rip-relative handling mode */
507c478bd9Sstevel@tonic-gate 	uint8_t		ftmt_modrm;	/* saved modrm byte */
517c478bd9Sstevel@tonic-gate #endif
527c478bd9Sstevel@tonic-gate 	uint8_t		ftmt_type;	/* emulation type */
537c478bd9Sstevel@tonic-gate 	uint8_t		ftmt_code;	/* branch condition */
547c478bd9Sstevel@tonic-gate 	uint8_t		ftmt_base;	/* branch base */
557c478bd9Sstevel@tonic-gate 	uint8_t		ftmt_index;	/* branch index */
567c478bd9Sstevel@tonic-gate 	uint8_t		ftmt_scale;	/* branch scale */
579acbbeafSnn35248 	uint8_t		ftmt_segment;	/* segment for memory accesses */
587c478bd9Sstevel@tonic-gate 	uintptr_t	ftmt_dest;	/* destination of control flow */
597c478bd9Sstevel@tonic-gate } fasttrap_machtp_t;
607c478bd9Sstevel@tonic-gate 
617c478bd9Sstevel@tonic-gate #define	ftt_instr	ftt_mtp.ftmt_instr
627c478bd9Sstevel@tonic-gate #ifdef __amd64
637c478bd9Sstevel@tonic-gate #define	ftt_ripmode	ftt_mtp.ftmt_ripmode
647c478bd9Sstevel@tonic-gate #define	ftt_modrm	ftt_mtp.ftmt_modrm
657c478bd9Sstevel@tonic-gate #endif
667c478bd9Sstevel@tonic-gate #define	ftt_size	ftt_mtp.ftmt_size
677c478bd9Sstevel@tonic-gate #define	ftt_type	ftt_mtp.ftmt_type
687c478bd9Sstevel@tonic-gate #define	ftt_code	ftt_mtp.ftmt_code
697c478bd9Sstevel@tonic-gate #define	ftt_base	ftt_mtp.ftmt_base
707c478bd9Sstevel@tonic-gate #define	ftt_index	ftt_mtp.ftmt_index
717c478bd9Sstevel@tonic-gate #define	ftt_scale	ftt_mtp.ftmt_scale
729acbbeafSnn35248 #define	ftt_segment	ftt_mtp.ftmt_segment
737c478bd9Sstevel@tonic-gate #define	ftt_dest	ftt_mtp.ftmt_dest
747c478bd9Sstevel@tonic-gate 
757c478bd9Sstevel@tonic-gate #define	FASTTRAP_T_COMMON	0x00	/* common case -- no emulation */
767c478bd9Sstevel@tonic-gate #define	FASTTRAP_T_JCC		0x01	/* near and far conditional jumps */
777c478bd9Sstevel@tonic-gate #define	FASTTRAP_T_LOOP		0x02	/* loop instructions */
787c478bd9Sstevel@tonic-gate #define	FASTTRAP_T_JCXZ		0x03	/* jump if %ecx/%rcx is zero */
797c478bd9Sstevel@tonic-gate #define	FASTTRAP_T_JMP		0x04	/* relative jump */
807c478bd9Sstevel@tonic-gate #define	FASTTRAP_T_CALL		0x05	/* near call (and link) */
817c478bd9Sstevel@tonic-gate #define	FASTTRAP_T_RET		0x06	/* ret */
827c478bd9Sstevel@tonic-gate #define	FASTTRAP_T_RET16	0x07	/* ret <imm16> */
837c478bd9Sstevel@tonic-gate 
847c478bd9Sstevel@tonic-gate /*
857c478bd9Sstevel@tonic-gate  * For performance rather than correctness.
867c478bd9Sstevel@tonic-gate  */
877c478bd9Sstevel@tonic-gate #define	FASTTRAP_T_PUSHL_EBP	0x10	/* pushl %ebp (for function entry) */
88*2b6e762cSahl #define	FASTTRAP_T_NOP		0x11	/* nop */
897c478bd9Sstevel@tonic-gate 
907c478bd9Sstevel@tonic-gate #define	FASTTRAP_RIP_1		0x1
917c478bd9Sstevel@tonic-gate #define	FASTTRAP_RIP_2		0x2
927c478bd9Sstevel@tonic-gate #define	FASTTRAP_RIP_X		0x4
937c478bd9Sstevel@tonic-gate 
949acbbeafSnn35248 /*
959acbbeafSnn35248  * Segment values.
969acbbeafSnn35248  */
979acbbeafSnn35248 #define	FASTTRAP_SEG_NONE		0
989acbbeafSnn35248 #define	FASTTRAP_SEG_CS			1
999acbbeafSnn35248 #define	FASTTRAP_SEG_DS			2
1009acbbeafSnn35248 #define	FASTTRAP_SEG_ES			3
1019acbbeafSnn35248 #define	FASTTRAP_SEG_FS			4
1029acbbeafSnn35248 #define	FASTTRAP_SEG_GS			5
1039acbbeafSnn35248 #define	FASTTRAP_SEG_SS			6
1049acbbeafSnn35248 
1057c478bd9Sstevel@tonic-gate #define	FASTTRAP_AFRAMES		3
1067c478bd9Sstevel@tonic-gate #define	FASTTRAP_RETURN_AFRAMES		4
1077c478bd9Sstevel@tonic-gate #define	FASTTRAP_ENTRY_AFRAMES		3
1087c478bd9Sstevel@tonic-gate #define	FASTTRAP_OFFSET_AFRAMES		3
1097c478bd9Sstevel@tonic-gate 
1107c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1117c478bd9Sstevel@tonic-gate }
1127c478bd9Sstevel@tonic-gate #endif
1137c478bd9Sstevel@tonic-gate 
1147c478bd9Sstevel@tonic-gate #endif	/* _FASTTRAP_ISA_H */
115