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 /* 23e0070315Sdmick * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 24dc0093f4Seschrock * Use is subject to license terms. 25dc0093f4Seschrock */ 26dc0093f4Seschrock 27dc0093f4Seschrock #ifndef _LIBDISASM_H 28dc0093f4Seschrock #define _LIBDISASM_H 29dc0093f4Seschrock 30dc0093f4Seschrock #pragma ident "%Z%%M% %I% %E% SMI" 31dc0093f4Seschrock 32dc0093f4Seschrock #include <sys/types.h> 33dc0093f4Seschrock 34dc0093f4Seschrock #ifdef __cplusplus 35dc0093f4Seschrock extern "C" { 36dc0093f4Seschrock #endif 37dc0093f4Seschrock 38dc0093f4Seschrock typedef struct dis_handle dis_handle_t; 39dc0093f4Seschrock 40dc0093f4Seschrock #define DIS_DEFAULT 0x0 41dc0093f4Seschrock 42dc0093f4Seschrock /* SPARC disassembler flags */ 43dc0093f4Seschrock #define DIS_SPARC_V8 0x01 44dc0093f4Seschrock #define DIS_SPARC_V9 0x02 45dc0093f4Seschrock #define DIS_SPARC_V9_SGI 0x04 46*a2bb96e7Sjmcp #define DIS_SPARC_V9_OPL 0x08 47dc0093f4Seschrock 48dc0093f4Seschrock /* x86 diassembler flags (mutually exclusive) */ 49dc0093f4Seschrock #define DIS_X86_SIZE16 0x08 50dc0093f4Seschrock #define DIS_X86_SIZE32 0x10 51dc0093f4Seschrock #define DIS_X86_SIZE64 0x20 52dc0093f4Seschrock 53dc0093f4Seschrock /* generic disassembler flags */ 54dc0093f4Seschrock #define DIS_OCTAL 0x40 55e0070315Sdmick #define DIS_NOIMMSYM 0x80 56dc0093f4Seschrock 57dc0093f4Seschrock typedef int (*dis_lookup_f)(void *, uint64_t, char *, size_t, uint64_t *, 58dc0093f4Seschrock size_t *); 59dc0093f4Seschrock typedef int (*dis_read_f)(void *, uint64_t, void *, size_t); 60dc0093f4Seschrock 61dc0093f4Seschrock extern dis_handle_t *dis_handle_create(int, void *, dis_lookup_f, dis_read_f); 62dc0093f4Seschrock extern void dis_handle_destroy(dis_handle_t *); 63dc0093f4Seschrock 64dc0093f4Seschrock extern int dis_disassemble(dis_handle_t *, uint64_t, char *, size_t); 65dc0093f4Seschrock extern uint64_t dis_previnstr(dis_handle_t *, uint64_t, int n); 66dc0093f4Seschrock extern void dis_set_data(dis_handle_t *, void *); 67e0070315Sdmick extern void dis_flags_set(dis_handle_t *, int f); 68e0070315Sdmick extern void dis_flags_clear(dis_handle_t *, int f); 69dc0093f4Seschrock extern int dis_max_instrlen(dis_handle_t *); 70dc0093f4Seschrock 71dc0093f4Seschrock /* libdisasm errors */ 72dc0093f4Seschrock #define E_DIS_NOMEM 1 /* Out of memory */ 73dc0093f4Seschrock #define E_DIS_INVALFLAG 2 /* Invalid flag for this architecture */ 74dc0093f4Seschrock 75dc0093f4Seschrock extern int dis_errno(void); 76dc0093f4Seschrock extern const char *dis_strerror(int); 77dc0093f4Seschrock 78dc0093f4Seschrock #ifdef __cplusplus 79dc0093f4Seschrock } 80dc0093f4Seschrock #endif 81dc0093f4Seschrock 82dc0093f4Seschrock #endif /* _LIBDISASM_H */ 83