xref: /onnv-gate/usr/src/lib/libdisasm/common/libdisasm.h (revision 5198:a4512bf4070e)
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 /*
233892Sdmick  * 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
46*5198Sjmcp #define	DIS_SPARC_V9_OPL	0x08
471545Seschrock 
481545Seschrock /* x86 diassembler flags (mutually exclusive) */
491545Seschrock #define	DIS_X86_SIZE16		0x08
501545Seschrock #define	DIS_X86_SIZE32		0x10
511545Seschrock #define	DIS_X86_SIZE64		0x20
521545Seschrock 
531545Seschrock /* generic disassembler flags */
541545Seschrock #define	DIS_OCTAL		0x40
553892Sdmick #define	DIS_NOIMMSYM		0x80
561545Seschrock 
571545Seschrock typedef int (*dis_lookup_f)(void *, uint64_t, char *, size_t, uint64_t *,
581545Seschrock     size_t *);
591545Seschrock typedef int (*dis_read_f)(void *, uint64_t, void *, size_t);
601545Seschrock 
611545Seschrock extern dis_handle_t *dis_handle_create(int, void *, dis_lookup_f, dis_read_f);
621545Seschrock extern void dis_handle_destroy(dis_handle_t *);
631545Seschrock 
641545Seschrock extern int dis_disassemble(dis_handle_t *, uint64_t, char *, size_t);
651545Seschrock extern uint64_t dis_previnstr(dis_handle_t *, uint64_t, int n);
661545Seschrock extern void dis_set_data(dis_handle_t *, void *);
673892Sdmick extern void dis_flags_set(dis_handle_t *, int f);
683892Sdmick extern void dis_flags_clear(dis_handle_t *, int f);
691545Seschrock extern int dis_max_instrlen(dis_handle_t *);
701545Seschrock 
711545Seschrock /* libdisasm errors */
721545Seschrock #define	E_DIS_NOMEM		1	/* Out of memory */
731545Seschrock #define	E_DIS_INVALFLAG		2	/* Invalid flag for this architecture */
741545Seschrock 
751545Seschrock extern int dis_errno(void);
761545Seschrock extern const char *dis_strerror(int);
771545Seschrock 
781545Seschrock #ifdef	__cplusplus
791545Seschrock }
801545Seschrock #endif
811545Seschrock 
821545Seschrock #endif	/* _LIBDISASM_H */
83