xref: /titanic_52/usr/src/common/dis/i386/dis_tables.h (revision 03831d35f7499c87d51205817c93e9a8d42c4bae)
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 (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 /*	Copyright (c) 1988 AT&T	*/
27 /*	  All Rights Reserved  	*/
28 
29 
30 #ifndef _DIS_TABLES_H
31 #define	_DIS_TABLES_H
32 
33 #pragma ident	"%Z%%M%	%I%	%E% SMI"
34 
35 /*
36  * Constants and prototypes for the IA32 disassembler backend.  See dis_tables.c
37  * for usage information and documentation.
38  */
39 
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43 
44 #include <sys/types.h>
45 #include <sys/param.h>
46 
47 /*
48  * values for cpu mode
49  */
50 #define	SIZE16	1
51 #define	SIZE32	2
52 #define	SIZE64	3
53 
54 #define	OPLEN	256
55 #define	PFIXLEN	  8
56 #define	NCPS	12	/* number of chars per symbol	*/
57 
58 /*
59  * data structures that must be provided to dtrace_dis86()
60  */
61 typedef struct d86opnd {
62 	char		d86_opnd[OPLEN];	/* symbolic rep of operand */
63 	char		d86_prefix[PFIXLEN];	/* any prefix string or "" */
64 	uint_t		d86_mode;		/* mode for immediate */
65 	uint_t		d86_value_size;		/* size in bytes of d86_value */
66 	uint64_t	d86_value;		/* immediate value of opnd */
67 } d86opnd_t;
68 
69 typedef struct dis86 {
70 	uint_t		d86_mode;
71 	uint_t		d86_error;
72 	uint_t		d86_len;		/* instruction length */
73 	int		d86_rmindex;		/* index of modrm byte or -1 */
74 	uint_t		d86_memsize;		/* size of memory referenced */
75 	char		d86_bytes[16];		/* bytes of instruction */
76 	char		d86_mneu[OPLEN];
77 	uint_t		d86_numopnds;
78 	uint_t		d86_rex_prefix;		/* value of REX prefix if !0 */
79 	char		*d86_seg_prefix;	/* segment prefix, if any */
80 	uint_t		d86_opnd_size;
81 	uint_t		d86_addr_size;
82 	uint_t		d86_got_modrm;
83 	struct d86opnd	d86_opnd[3];		/* up to 3 operands */
84 	int		(*d86_check_func)(void *);
85 	int		(*d86_get_byte)(void *);
86 #ifdef DIS_TEXT
87 	int		(*d86_sym_lookup)(void *, uint64_t, char *, size_t);
88 	int		(*d86_sprintf_func)(char *, size_t, const char *, ...);
89 	int		d86_flags;
90 	uint_t		d86_imm_bytes;
91 #endif
92 	void		*d86_data;
93 } dis86_t;
94 
95 extern int dtrace_disx86(dis86_t *x, uint_t cpu_mode);
96 
97 #define	DIS_OP_OCTAL	0x1	/* Print all numbers in octal */
98 
99 #ifdef DIS_TEXT
100 extern void dtrace_disx86_str(dis86_t *x, uint_t cpu_mode, uintptr_t pc,
101     char *buf, size_t len);
102 #endif
103 
104 #ifdef __cplusplus
105 }
106 #endif
107 
108 #endif /* _DIS_TABLES_H */
109