17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * 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.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
21dc0093f4Seschrock 
227c478bd9Sstevel@tonic-gate /*
23dc0093f4Seschrock  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * 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.
277c478bd9Sstevel@tonic-gate  */
287c478bd9Sstevel@tonic-gate 
29dc0093f4Seschrock #ifndef	_LIBDISASM_IMPL_H
30dc0093f4Seschrock #define	_LIBDISASM_IMPL_H
317c478bd9Sstevel@tonic-gate 
32*f7184619SJoshua M. Clulow #include <stdarg.h>
33*f7184619SJoshua M. Clulow #include <sys/sysmacros.h>
347c478bd9Sstevel@tonic-gate 
35dc0093f4Seschrock #ifdef	__cplusplus
367c478bd9Sstevel@tonic-gate extern "C" {
377c478bd9Sstevel@tonic-gate #endif
387c478bd9Sstevel@tonic-gate 
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);
627c478bd9Sstevel@tonic-gate 
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, ...);
677c478bd9Sstevel@tonic-gate 
68dc0093f4Seschrock #ifdef	__cplusplus
697c478bd9Sstevel@tonic-gate }
707c478bd9Sstevel@tonic-gate #endif
717c478bd9Sstevel@tonic-gate 
72dc0093f4Seschrock #endif	/* _LIBDISASM_IMPL_H */
73