1*1545Seschrock /*
2*1545Seschrock  * CDDL HEADER START
3*1545Seschrock  *
4*1545Seschrock  * The contents of this file are subject to the terms of the
5*1545Seschrock  * Common Development and Distribution License (the "License").
6*1545Seschrock  * You may not use this file except in compliance with the License.
7*1545Seschrock  *
8*1545Seschrock  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*1545Seschrock  * or http://www.opensolaris.org/os/licensing.
10*1545Seschrock  * See the License for the specific language governing permissions
11*1545Seschrock  * and limitations under the License.
12*1545Seschrock  *
13*1545Seschrock  * When distributing Covered Code, include this CDDL HEADER in each
14*1545Seschrock  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*1545Seschrock  * If applicable, add the following below this CDDL HEADER, with the
16*1545Seschrock  * fields enclosed by brackets "[]" replaced with your own identifying
17*1545Seschrock  * information: Portions Copyright [yyyy] [name of copyright owner]
18*1545Seschrock  *
19*1545Seschrock  * CDDL HEADER END
20*1545Seschrock  */
21*1545Seschrock 
22*1545Seschrock /*
23*1545Seschrock  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
24*1545Seschrock  * Use is subject to license terms.
25*1545Seschrock  */
26*1545Seschrock 
27*1545Seschrock #ifndef	_LIBDISASM_H
28*1545Seschrock #define	_LIBDISASM_H
29*1545Seschrock 
30*1545Seschrock #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*1545Seschrock 
32*1545Seschrock #include <sys/types.h>
33*1545Seschrock 
34*1545Seschrock #ifdef	__cplusplus
35*1545Seschrock extern "C" {
36*1545Seschrock #endif
37*1545Seschrock 
38*1545Seschrock typedef struct dis_handle dis_handle_t;
39*1545Seschrock 
40*1545Seschrock #define	DIS_DEFAULT		0x0
41*1545Seschrock 
42*1545Seschrock /* SPARC disassembler flags */
43*1545Seschrock #define	DIS_SPARC_V8		0x01
44*1545Seschrock #define	DIS_SPARC_V9		0x02
45*1545Seschrock #define	DIS_SPARC_V9_SGI	0x04
46*1545Seschrock 
47*1545Seschrock /* x86 diassembler flags (mutually exclusive) */
48*1545Seschrock #define	DIS_X86_SIZE16		0x08
49*1545Seschrock #define	DIS_X86_SIZE32		0x10
50*1545Seschrock #define	DIS_X86_SIZE64		0x20
51*1545Seschrock 
52*1545Seschrock /* generic disassembler flags */
53*1545Seschrock #define	DIS_OCTAL		0x40
54*1545Seschrock 
55*1545Seschrock typedef int (*dis_lookup_f)(void *, uint64_t, char *, size_t, uint64_t *,
56*1545Seschrock     size_t *);
57*1545Seschrock typedef int (*dis_read_f)(void *, uint64_t, void *, size_t);
58*1545Seschrock 
59*1545Seschrock extern dis_handle_t *dis_handle_create(int, void *, dis_lookup_f, dis_read_f);
60*1545Seschrock extern void dis_handle_destroy(dis_handle_t *);
61*1545Seschrock 
62*1545Seschrock extern int dis_disassemble(dis_handle_t *, uint64_t, char *, size_t);
63*1545Seschrock extern uint64_t dis_previnstr(dis_handle_t *, uint64_t, int n);
64*1545Seschrock extern void dis_set_data(dis_handle_t *, void *);
65*1545Seschrock extern int dis_max_instrlen(dis_handle_t *);
66*1545Seschrock 
67*1545Seschrock /* libdisasm errors */
68*1545Seschrock #define	E_DIS_NOMEM		1	/* Out of memory */
69*1545Seschrock #define	E_DIS_INVALFLAG		2	/* Invalid flag for this architecture */
70*1545Seschrock 
71*1545Seschrock extern int dis_errno(void);
72*1545Seschrock extern const char *dis_strerror(int);
73*1545Seschrock 
74*1545Seschrock #ifdef	__cplusplus
75*1545Seschrock }
76*1545Seschrock #endif
77*1545Seschrock 
78*1545Seschrock #endif	/* _LIBDISASM_H */
79