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. 25f7184619SJoshua M. Clulow * Copyright 2012 Joshua M. Clulow <josh@sysmgr.org> 26*0472e113SJosef 'Jeff' Sipek * Copyright 2015 Josef 'Jeff' Sipek <jeffpc@josefsipek.net> 27dc0093f4Seschrock */ 28dc0093f4Seschrock 29dc0093f4Seschrock #ifndef _LIBDISASM_H 30dc0093f4Seschrock #define _LIBDISASM_H 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 */ 43f7184619SJoshua M. Clulow #define DIS_SPARC_V8 0x001 44f7184619SJoshua M. Clulow #define DIS_SPARC_V9 0x002 45f7184619SJoshua M. Clulow #define DIS_SPARC_V9_SGI 0x004 46f7184619SJoshua M. Clulow #define DIS_SPARC_V9_OPL 0x008 47dc0093f4Seschrock 48f7184619SJoshua M. Clulow /* x86 diassembler flags */ 49f7184619SJoshua M. Clulow #define DIS_X86_SIZE16 0x100 50f7184619SJoshua M. Clulow #define DIS_X86_SIZE32 0x010 51f7184619SJoshua M. Clulow #define DIS_X86_SIZE64 0x020 52dc0093f4Seschrock 53*0472e113SJosef 'Jeff' Sipek /* s390 disassembler flags */ 54*0472e113SJosef 'Jeff' Sipek #define DIS_S370 0x200 55*0472e113SJosef 'Jeff' Sipek #define DIS_S390_31 0x400 56*0472e113SJosef 'Jeff' Sipek #define DIS_S390_64 0x800 57*0472e113SJosef 'Jeff' Sipek 58dc0093f4Seschrock /* generic disassembler flags */ 59f7184619SJoshua M. Clulow #define DIS_OCTAL 0x040 60f7184619SJoshua M. Clulow #define DIS_NOIMMSYM 0x080 61f7184619SJoshua M. Clulow 62f7184619SJoshua M. Clulow #define DIS_ARCH_MASK (DIS_SPARC_V8 | \ 63f7184619SJoshua M. Clulow DIS_SPARC_V9 | DIS_SPARC_V9_SGI | DIS_SPARC_V9_OPL | \ 64*0472e113SJosef 'Jeff' Sipek DIS_X86_SIZE16 | DIS_X86_SIZE32 | DIS_X86_SIZE64 | \ 65*0472e113SJosef 'Jeff' Sipek DIS_S370 | DIS_S390_31 | DIS_S390_64) 66dc0093f4Seschrock 67dc0093f4Seschrock typedef int (*dis_lookup_f)(void *, uint64_t, char *, size_t, uint64_t *, 68dc0093f4Seschrock size_t *); 69dc0093f4Seschrock typedef int (*dis_read_f)(void *, uint64_t, void *, size_t); 70dc0093f4Seschrock 71dc0093f4Seschrock extern dis_handle_t *dis_handle_create(int, void *, dis_lookup_f, dis_read_f); 72dc0093f4Seschrock extern void dis_handle_destroy(dis_handle_t *); 73dc0093f4Seschrock 74dc0093f4Seschrock extern int dis_disassemble(dis_handle_t *, uint64_t, char *, size_t); 75dc0093f4Seschrock extern uint64_t dis_previnstr(dis_handle_t *, uint64_t, int n); 76dc0093f4Seschrock extern void dis_set_data(dis_handle_t *, void *); 77e0070315Sdmick extern void dis_flags_set(dis_handle_t *, int f); 78e0070315Sdmick extern void dis_flags_clear(dis_handle_t *, int f); 79dc0093f4Seschrock extern int dis_max_instrlen(dis_handle_t *); 80f7184619SJoshua M. Clulow extern int dis_min_instrlen(dis_handle_t *); 81702941cdSRichard Lowe extern int dis_instrlen(dis_handle_t *, uint64_t); 82dc0093f4Seschrock 83dc0093f4Seschrock /* libdisasm errors */ 84dc0093f4Seschrock #define E_DIS_NOMEM 1 /* Out of memory */ 85dc0093f4Seschrock #define E_DIS_INVALFLAG 2 /* Invalid flag for this architecture */ 86f7184619SJoshua M. Clulow #define E_DIS_UNSUPARCH 3 /* Unsupported architecture */ 87dc0093f4Seschrock 88dc0093f4Seschrock extern int dis_errno(void); 89dc0093f4Seschrock extern const char *dis_strerror(int); 90dc0093f4Seschrock 91dc0093f4Seschrock #ifdef __cplusplus 92dc0093f4Seschrock } 93dc0093f4Seschrock #endif 94dc0093f4Seschrock 95dc0093f4Seschrock #endif /* _LIBDISASM_H */ 96