1179237Sjb/*
2179237Sjb * CDDL HEADER START
3179237Sjb *
4179237Sjb * The contents of this file are subject to the terms of the
5179237Sjb * Common Development and Distribution License (the "License").
6179237Sjb * You may not use this file except in compliance with the License.
7179237Sjb *
8179237Sjb * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9179237Sjb * or http://www.opensolaris.org/os/licensing.
10179237Sjb * See the License for the specific language governing permissions
11179237Sjb * and limitations under the License.
12179237Sjb *
13179237Sjb * When distributing Covered Code, include this CDDL HEADER in each
14179237Sjb * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15179237Sjb * If applicable, add the following below this CDDL HEADER, with the
16179237Sjb * fields enclosed by brackets "[]" replaced with your own identifying
17179237Sjb * information: Portions Copyright [yyyy] [name of copyright owner]
18179237Sjb *
19179237Sjb * CDDL HEADER END
20179237Sjb */
21179237Sjb/*
22253772Savg * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23179237Sjb * Use is subject to license terms.
24179237Sjb */
25179237Sjb
26179237Sjb/*	Copyright (c) 1988 AT&T	*/
27179237Sjb/*	  All Rights Reserved  	*/
28179237Sjb
29253772Savg/*
30253772Savg * $FreeBSD$
31253772Savg */
32179237Sjb
33179237Sjb#ifndef _DIS_TABLES_H
34179237Sjb#define	_DIS_TABLES_H
35179237Sjb
36179237Sjb/*
37179237Sjb * Constants and prototypes for the IA32 disassembler backend.  See dis_tables.c
38179237Sjb * for usage information and documentation.
39179237Sjb */
40179237Sjb
41179237Sjb#ifdef __cplusplus
42179237Sjbextern "C" {
43179237Sjb#endif
44179237Sjb
45179237Sjb#include <sys/types.h>
46179237Sjb#include <sys/param.h>
47179237Sjb
48179237Sjb/*
49179237Sjb * values for cpu mode
50179237Sjb */
51179237Sjb#define	SIZE16	1
52179237Sjb#define	SIZE32	2
53179237Sjb#define	SIZE64	3
54179237Sjb
55179237Sjb#define	OPLEN	256
56179237Sjb#define	PFIXLEN	  8
57253772Savg#define	NCPS	20	/* number of chars per symbol	*/
58179237Sjb
59179237Sjb/*
60179237Sjb * data structures that must be provided to dtrace_dis86()
61179237Sjb */
62179237Sjbtypedef struct d86opnd {
63179237Sjb	char		d86_opnd[OPLEN];	/* symbolic rep of operand */
64179237Sjb	char		d86_prefix[PFIXLEN];	/* any prefix string or "" */
65179237Sjb	uint_t		d86_mode;		/* mode for immediate */
66179237Sjb	uint_t		d86_value_size;		/* size in bytes of d86_value */
67179237Sjb	uint64_t	d86_value;		/* immediate value of opnd */
68179237Sjb} d86opnd_t;
69179237Sjb
70179237Sjbtypedef struct dis86 {
71179237Sjb	uint_t		d86_mode;
72179237Sjb	uint_t		d86_error;
73179237Sjb	uint_t		d86_len;		/* instruction length */
74179237Sjb	int		d86_rmindex;		/* index of modrm byte or -1 */
75179237Sjb	uint_t		d86_memsize;		/* size of memory referenced */
76179237Sjb	char		d86_bytes[16];		/* bytes of instruction */
77253772Savg	char		d86_mnem[OPLEN];
78179237Sjb	uint_t		d86_numopnds;
79179237Sjb	uint_t		d86_rex_prefix;		/* value of REX prefix if !0 */
80179237Sjb	char		*d86_seg_prefix;	/* segment prefix, if any */
81179237Sjb	uint_t		d86_opnd_size;
82179237Sjb	uint_t		d86_addr_size;
83179237Sjb	uint_t		d86_got_modrm;
84253772Savg	struct d86opnd	d86_opnd[4];		/* up to 4 operands */
85179237Sjb	int		(*d86_check_func)(void *);
86179237Sjb	int		(*d86_get_byte)(void *);
87179237Sjb#ifdef DIS_TEXT
88179237Sjb	int		(*d86_sym_lookup)(void *, uint64_t, char *, size_t);
89179237Sjb	int		(*d86_sprintf_func)(char *, size_t, const char *, ...);
90179237Sjb	int		d86_flags;
91179237Sjb	uint_t		d86_imm_bytes;
92179237Sjb#endif
93179237Sjb	void		*d86_data;
94179237Sjb} dis86_t;
95179237Sjb
96179237Sjbextern int dtrace_disx86(dis86_t *x, uint_t cpu_mode);
97179237Sjb
98253772Savg#define	DIS_F_OCTAL	0x1	/* Print all numbers in octal */
99253772Savg#define	DIS_F_NOIMMSYM	0x2	/* Don't print symbols for immediates (.o) */
100179237Sjb
101179237Sjb#ifdef DIS_TEXT
102253772Savgextern void dtrace_disx86_str(dis86_t *x, uint_t cpu_mode, uint64_t pc,
103179237Sjb    char *buf, size_t len);
104179237Sjb#endif
105179237Sjb
106179237Sjb#ifdef __cplusplus
107179237Sjb}
108179237Sjb#endif
109179237Sjb
110179237Sjb#endif /* _DIS_TABLES_H */
111