xref: /titanic_50/usr/src/lib/libdisasm/common/libdisasm_impl.h (revision f7184619589931c4b827180c213074c470f08a8f)
1dc0093f4Seschrock /*
2dc0093f4Seschrock  * CDDL HEADER START
3dc0093f4Seschrock  *
4dc0093f4Seschrock  * The contents of this file are subject to the terms of the
5dc0093f4Seschrock  * Common Development and Distribution License (the "License").
6dc0093f4Seschrock  * You may not use this file except in compliance with the License.
7dc0093f4Seschrock  *
8dc0093f4Seschrock  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9dc0093f4Seschrock  * or http://www.opensolaris.org/os/licensing.
10dc0093f4Seschrock  * See the License for the specific language governing permissions
11dc0093f4Seschrock  * and limitations under the License.
12dc0093f4Seschrock  *
13dc0093f4Seschrock  * When distributing Covered Code, include this CDDL HEADER in each
14dc0093f4Seschrock  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15dc0093f4Seschrock  * If applicable, add the following below this CDDL HEADER, with the
16dc0093f4Seschrock  * fields enclosed by brackets "[]" replaced with your own identifying
17dc0093f4Seschrock  * information: Portions Copyright [yyyy] [name of copyright owner]
18dc0093f4Seschrock  *
19dc0093f4Seschrock  * CDDL HEADER END
20dc0093f4Seschrock  */
21dc0093f4Seschrock 
22dc0093f4Seschrock /*
23dc0093f4Seschrock  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
24dc0093f4Seschrock  * Use is subject to license terms.
25*f7184619SJoshua M. Clulow  * Copyright 2012 Joshua M. Clulow <josh@sysmgr.org>
26*f7184619SJoshua M. Clulow  * Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
27dc0093f4Seschrock  */
28dc0093f4Seschrock 
29dc0093f4Seschrock #ifndef	_LIBDISASM_IMPL_H
30dc0093f4Seschrock #define	_LIBDISASM_IMPL_H
31dc0093f4Seschrock 
32*f7184619SJoshua M. Clulow #include <stdarg.h>
33*f7184619SJoshua M. Clulow #include <sys/sysmacros.h>
34dc0093f4Seschrock 
35dc0093f4Seschrock #ifdef	__cplusplus
36dc0093f4Seschrock extern "C" {
37dc0093f4Seschrock #endif
38dc0093f4Seschrock 
39*f7184619SJoshua M. Clulow typedef struct dis_arch {
40*f7184619SJoshua M. Clulow 	int (*da_supports_flags)(int);
41*f7184619SJoshua M. Clulow 	int (*da_handle_attach)(dis_handle_t *);
42*f7184619SJoshua M. Clulow 	void (*da_handle_detach)(dis_handle_t *);
43*f7184619SJoshua M. Clulow 	int (*da_disassemble)(dis_handle_t *, uint64_t, char *, size_t);
44*f7184619SJoshua M. Clulow 	uint64_t (*da_previnstr)(dis_handle_t *, uint64_t, int n);
45*f7184619SJoshua M. Clulow 	int (*da_min_instrlen)(dis_handle_t *);
46*f7184619SJoshua M. Clulow 	int (*da_max_instrlen)(dis_handle_t *);
47*f7184619SJoshua M. Clulow 	int (*da_instrlen)(dis_handle_t *, uint64_t);
48*f7184619SJoshua M. Clulow } dis_arch_t;
49*f7184619SJoshua M. Clulow 
50*f7184619SJoshua M. Clulow struct dis_handle {
51*f7184619SJoshua M. Clulow 	void		*dh_data;
52*f7184619SJoshua M. Clulow 	int		dh_flags;
53*f7184619SJoshua M. Clulow 	dis_lookup_f	dh_lookup;
54*f7184619SJoshua M. Clulow 	dis_read_f	dh_read;
55*f7184619SJoshua M. Clulow 	uint64_t	dh_addr;
56*f7184619SJoshua M. Clulow 
57*f7184619SJoshua M. Clulow 	dis_arch_t	*dh_arch;
58*f7184619SJoshua M. Clulow 	void		*dh_arch_private;
59*f7184619SJoshua M. Clulow };
60*f7184619SJoshua M. Clulow 
61dc0093f4Seschrock extern int dis_seterrno(int);
62dc0093f4Seschrock 
63dc0093f4Seschrock extern void *dis_zalloc(size_t);
64dc0093f4Seschrock extern void dis_free(void *, size_t);
65*f7184619SJoshua M. Clulow extern int dis_vsnprintf(char *restrict, size_t, const char *restrict, va_list);
66*f7184619SJoshua M. Clulow extern int dis_snprintf(char *restrict, size_t, const char *restrict, ...);
67dc0093f4Seschrock 
68dc0093f4Seschrock #ifdef	__cplusplus
69dc0093f4Seschrock }
70dc0093f4Seschrock #endif
71dc0093f4Seschrock 
72dc0093f4Seschrock #endif	/* _LIBDISASM_IMPL_H */
73