xref: /illumos-gate/usr/src/uts/intel/sys/fasttrap_isa.h (revision 88f8b78a88cbdc6d8c1af5c3e54bc49d25095c98)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_FASTTRAP_ISA_H
28 #define	_FASTTRAP_ISA_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <sys/types.h>
33 
34 #ifdef	__cplusplus
35 extern "C" {
36 #endif
37 
38 #define	FASTTRAP_MAX_INSTR_SIZE		15
39 
40 #define	FASTTRAP_INSTR			0xcc
41 
42 #define	FASTTRAP_SUNWDTRACE_SIZE	64
43 
44 typedef	uint8_t		fasttrap_instr_t;
45 
46 typedef struct fasttrap_machtp {
47 	uint8_t		ftmt_instr[FASTTRAP_MAX_INSTR_SIZE]; /* orig. instr. */
48 	uint8_t		ftmt_size;	/* instruction size */
49 #ifdef __amd64
50 	uint8_t		ftmt_ripmode;	/* %rip-relative handling mode */
51 	uint8_t		ftmt_modrm;	/* saved modrm byte */
52 #endif
53 	uint8_t		ftmt_type;	/* emulation type */
54 	uint8_t		ftmt_code;	/* branch condition */
55 	uint8_t		ftmt_base;	/* branch base */
56 	uint8_t		ftmt_index;	/* branch index */
57 	uint8_t		ftmt_scale;	/* branch scale */
58 	uintptr_t	ftmt_dest;	/* destination of control flow */
59 } fasttrap_machtp_t;
60 
61 #define	ftt_instr	ftt_mtp.ftmt_instr
62 #ifdef __amd64
63 #define	ftt_ripmode	ftt_mtp.ftmt_ripmode
64 #define	ftt_modrm	ftt_mtp.ftmt_modrm
65 #endif
66 #define	ftt_size	ftt_mtp.ftmt_size
67 #define	ftt_type	ftt_mtp.ftmt_type
68 #define	ftt_code	ftt_mtp.ftmt_code
69 #define	ftt_base	ftt_mtp.ftmt_base
70 #define	ftt_index	ftt_mtp.ftmt_index
71 #define	ftt_scale	ftt_mtp.ftmt_scale
72 #define	ftt_dest	ftt_mtp.ftmt_dest
73 
74 #define	FASTTRAP_T_COMMON	0x00	/* common case -- no emulation */
75 #define	FASTTRAP_T_JCC		0x01	/* near and far conditional jumps */
76 #define	FASTTRAP_T_LOOP		0x02	/* loop instructions */
77 #define	FASTTRAP_T_JCXZ		0x03	/* jump if %ecx/%rcx is zero */
78 #define	FASTTRAP_T_JMP		0x04	/* relative jump */
79 #define	FASTTRAP_T_CALL		0x05	/* near call (and link) */
80 #define	FASTTRAP_T_RET		0x06	/* ret */
81 #define	FASTTRAP_T_RET16	0x07	/* ret <imm16> */
82 
83 /*
84  * For performance rather than correctness.
85  */
86 #define	FASTTRAP_T_PUSHL_EBP	0x10	/* pushl %ebp (for function entry) */
87 
88 #define	FASTTRAP_RIP_1		0x1
89 #define	FASTTRAP_RIP_2		0x2
90 #define	FASTTRAP_RIP_X		0x4
91 
92 #define	FASTTRAP_AFRAMES		3
93 #define	FASTTRAP_RETURN_AFRAMES		4
94 #define	FASTTRAP_ENTRY_AFRAMES		3
95 #define	FASTTRAP_OFFSET_AFRAMES		3
96 
97 #ifdef	__cplusplus
98 }
99 #endif
100 
101 #endif	/* _FASTTRAP_ISA_H */
102