11545Seschrock /*
21545Seschrock  * CDDL HEADER START
31545Seschrock  *
41545Seschrock  * The contents of this file are subject to the terms of the
51545Seschrock  * Common Development and Distribution License (the "License").
61545Seschrock  * You may not use this file except in compliance with the License.
71545Seschrock  *
81545Seschrock  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
91545Seschrock  * or http://www.opensolaris.org/os/licensing.
101545Seschrock  * See the License for the specific language governing permissions
111545Seschrock  * and limitations under the License.
121545Seschrock  *
131545Seschrock  * When distributing Covered Code, include this CDDL HEADER in each
141545Seschrock  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
151545Seschrock  * If applicable, add the following below this CDDL HEADER, with the
161545Seschrock  * fields enclosed by brackets "[]" replaced with your own identifying
171545Seschrock  * information: Portions Copyright [yyyy] [name of copyright owner]
181545Seschrock  *
191545Seschrock  * CDDL HEADER END
201545Seschrock  */
211545Seschrock 
221545Seschrock /*
23*3892Sdmick  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
241545Seschrock  * Use is subject to license terms.
251545Seschrock  */
261545Seschrock 
271545Seschrock #ifndef	_LIBDISASM_H
281545Seschrock #define	_LIBDISASM_H
291545Seschrock 
301545Seschrock #pragma ident	"%Z%%M%	%I%	%E% SMI"
311545Seschrock 
321545Seschrock #include <sys/types.h>
331545Seschrock 
341545Seschrock #ifdef	__cplusplus
351545Seschrock extern "C" {
361545Seschrock #endif
371545Seschrock 
381545Seschrock typedef struct dis_handle dis_handle_t;
391545Seschrock 
401545Seschrock #define	DIS_DEFAULT		0x0
411545Seschrock 
421545Seschrock /* SPARC disassembler flags */
431545Seschrock #define	DIS_SPARC_V8		0x01
441545Seschrock #define	DIS_SPARC_V9		0x02
451545Seschrock #define	DIS_SPARC_V9_SGI	0x04
461545Seschrock 
471545Seschrock /* x86 diassembler flags (mutually exclusive) */
481545Seschrock #define	DIS_X86_SIZE16		0x08
491545Seschrock #define	DIS_X86_SIZE32		0x10
501545Seschrock #define	DIS_X86_SIZE64		0x20
511545Seschrock 
521545Seschrock /* generic disassembler flags */
531545Seschrock #define	DIS_OCTAL		0x40
54*3892Sdmick #define	DIS_NOIMMSYM		0x80
551545Seschrock 
561545Seschrock typedef int (*dis_lookup_f)(void *, uint64_t, char *, size_t, uint64_t *,
571545Seschrock     size_t *);
581545Seschrock typedef int (*dis_read_f)(void *, uint64_t, void *, size_t);
591545Seschrock 
601545Seschrock extern dis_handle_t *dis_handle_create(int, void *, dis_lookup_f, dis_read_f);
611545Seschrock extern void dis_handle_destroy(dis_handle_t *);
621545Seschrock 
631545Seschrock extern int dis_disassemble(dis_handle_t *, uint64_t, char *, size_t);
641545Seschrock extern uint64_t dis_previnstr(dis_handle_t *, uint64_t, int n);
651545Seschrock extern void dis_set_data(dis_handle_t *, void *);
66*3892Sdmick extern void dis_flags_set(dis_handle_t *, int f);
67*3892Sdmick extern void dis_flags_clear(dis_handle_t *, int f);
681545Seschrock extern int dis_max_instrlen(dis_handle_t *);
691545Seschrock 
701545Seschrock /* libdisasm errors */
711545Seschrock #define	E_DIS_NOMEM		1	/* Out of memory */
721545Seschrock #define	E_DIS_INVALFLAG		2	/* Invalid flag for this architecture */
731545Seschrock 
741545Seschrock extern int dis_errno(void);
751545Seschrock extern const char *dis_strerror(int);
761545Seschrock 
771545Seschrock #ifdef	__cplusplus
781545Seschrock }
791545Seschrock #endif
801545Seschrock 
811545Seschrock #endif	/* _LIBDISASM_H */
82