xref: /titanic_41/usr/src/common/dis/i386/dis_tables.h (revision 70025d765b044c6d8594bb965a2247a61e991a99)
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 /*	Copyright (c) 1988 AT&T	*/
28 /*	  All Rights Reserved  	*/
29 
30 
31 #ifndef _DIS_TABLES_H
32 #define	_DIS_TABLES_H
33 
34 #pragma ident	"%Z%%M%	%I%	%E% SMI"
35 
36 /*
37  * Constants and prototypes for the IA32 disassembler backend.  See dis_tables.c
38  * for usage information and documentation.
39  */
40 
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
45 #include <sys/types.h>
46 #include <sys/param.h>
47 
48 /*
49  * values for cpu mode
50  */
51 #define	SIZE16	1
52 #define	SIZE32	2
53 #define	SIZE64	3
54 
55 #define	OPLEN	256
56 #define	PFIXLEN	  8
57 #define	NCPS	12	/* number of chars per symbol	*/
58 
59 /*
60  * data structures that must be provided to dtrace_dis86()
61  */
62 typedef struct d86opnd {
63 	char		d86_opnd[OPLEN];	/* symbolic rep of operand */
64 	char		d86_prefix[PFIXLEN];	/* any prefix string or "" */
65 	uint_t		d86_mode;		/* mode for immediate */
66 	uint_t		d86_value_size;		/* size in bytes of d86_value */
67 	uint64_t	d86_value;		/* immediate value of opnd */
68 } d86opnd_t;
69 
70 typedef struct dis86 {
71 	uint_t		d86_mode;
72 	uint_t		d86_error;
73 	uint_t		d86_len;		/* instruction length */
74 	int		d86_rmindex;		/* index of modrm byte or -1 */
75 	uint_t		d86_memsize;		/* size of memory referenced */
76 	char		d86_bytes[16];		/* bytes of instruction */
77 	char		d86_mneu[OPLEN];
78 	uint_t		d86_numopnds;
79 	uint_t		d86_rex_prefix;		/* value of REX prefix if !0 */
80 	char		*d86_seg_prefix;	/* segment prefix, if any */
81 	uint_t		d86_opnd_size;
82 	uint_t		d86_addr_size;
83 	uint_t		d86_got_modrm;
84 	struct d86opnd	d86_opnd[3];		/* up to 3 operands */
85 	int		(*d86_check_func)();
86 	int		(*d86_get_byte)(void *);
87 #ifdef DIS_TEXT
88 	int		(*d86_sym_lookup)(uint64_t, char *, size_t);
89 	int		(*d86_sprintf_func)(char *, size_t, const char *, ...);
90 	int		d86_flags;
91 	uint_t		d86_imm_bytes;
92 #endif
93 	void		*d86_data;
94 } dis86_t;
95 
96 extern int dtrace_disx86(dis86_t *x, uint_t cpu_mode);
97 
98 #define	DIS_OP_OCTAL	0x1	/* Print all numbers in octal */
99 
100 #ifdef DIS_TEXT
101 extern void dtrace_disx86_str(dis86_t *x, uint_t cpu_mode, uintptr_t pc,
102     char *buf, size_t len);
103 #endif
104 
105 #ifdef __cplusplus
106 }
107 #endif
108 
109 #endif /* _DIS_TABLES_H */
110