10339a1c2SMark Johnston /* 20339a1c2SMark Johnston * CDDL HEADER START 30339a1c2SMark Johnston * 40339a1c2SMark Johnston * The contents of this file are subject to the terms of the 50339a1c2SMark Johnston * Common Development and Distribution License (the "License"). 60339a1c2SMark Johnston * You may not use this file except in compliance with the License. 70339a1c2SMark Johnston * 80339a1c2SMark Johnston * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90339a1c2SMark Johnston * or http://www.opensolaris.org/os/licensing. 100339a1c2SMark Johnston * See the License for the specific language governing permissions 110339a1c2SMark Johnston * and limitations under the License. 120339a1c2SMark Johnston * 130339a1c2SMark Johnston * When distributing Covered Code, include this CDDL HEADER in each 140339a1c2SMark Johnston * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150339a1c2SMark Johnston * If applicable, add the following below this CDDL HEADER, with the 160339a1c2SMark Johnston * fields enclosed by brackets "[]" replaced with your own identifying 170339a1c2SMark Johnston * information: Portions Copyright [yyyy] [name of copyright owner] 180339a1c2SMark Johnston * 190339a1c2SMark Johnston * CDDL HEADER END 200339a1c2SMark Johnston */ 210339a1c2SMark Johnston /* 220339a1c2SMark Johnston * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 230339a1c2SMark Johnston * Use is subject to license terms. 240339a1c2SMark Johnston */ 250339a1c2SMark Johnston 260339a1c2SMark Johnston /* Copyright (c) 1988 AT&T */ 270339a1c2SMark Johnston /* All Rights Reserved */ 280339a1c2SMark Johnston 290339a1c2SMark Johnston /* 300339a1c2SMark Johnston */ 310339a1c2SMark Johnston 320339a1c2SMark Johnston #ifndef _DIS_TABLES_H 330339a1c2SMark Johnston #define _DIS_TABLES_H 340339a1c2SMark Johnston 350339a1c2SMark Johnston /* 360339a1c2SMark Johnston * Constants and prototypes for the IA32 disassembler backend. See dis_tables.c 370339a1c2SMark Johnston * for usage information and documentation. 380339a1c2SMark Johnston */ 390339a1c2SMark Johnston 400339a1c2SMark Johnston #ifdef __cplusplus 410339a1c2SMark Johnston extern "C" { 420339a1c2SMark Johnston #endif 430339a1c2SMark Johnston 440339a1c2SMark Johnston #include <sys/types.h> 450339a1c2SMark Johnston #include <sys/param.h> 460339a1c2SMark Johnston 470339a1c2SMark Johnston /* 480339a1c2SMark Johnston * values for cpu mode 490339a1c2SMark Johnston */ 500339a1c2SMark Johnston #define SIZE16 1 510339a1c2SMark Johnston #define SIZE32 2 520339a1c2SMark Johnston #define SIZE64 3 530339a1c2SMark Johnston 540339a1c2SMark Johnston #define OPLEN 256 550339a1c2SMark Johnston #define PFIXLEN 8 560339a1c2SMark Johnston #define NCPS 20 /* number of chars per symbol */ 570339a1c2SMark Johnston 580339a1c2SMark Johnston /* 590339a1c2SMark Johnston * data structures that must be provided to dtrace_dis86() 600339a1c2SMark Johnston */ 610339a1c2SMark Johnston typedef struct d86opnd { 620339a1c2SMark Johnston char d86_opnd[OPLEN]; /* symbolic rep of operand */ 630339a1c2SMark Johnston char d86_prefix[PFIXLEN]; /* any prefix string or "" */ 640339a1c2SMark Johnston uint_t d86_mode; /* mode for immediate */ 650339a1c2SMark Johnston uint_t d86_value_size; /* size in bytes of d86_value */ 660339a1c2SMark Johnston uint64_t d86_value; /* immediate value of opnd */ 670339a1c2SMark Johnston } d86opnd_t; 680339a1c2SMark Johnston 690339a1c2SMark Johnston typedef struct dis86 { 700339a1c2SMark Johnston uint_t d86_mode; 710339a1c2SMark Johnston uint_t d86_error; 720339a1c2SMark Johnston uint_t d86_len; /* instruction length */ 730339a1c2SMark Johnston int d86_rmindex; /* index of modrm byte or -1 */ 740339a1c2SMark Johnston uint_t d86_memsize; /* size of memory referenced */ 750339a1c2SMark Johnston char d86_bytes[16]; /* bytes of instruction */ 760339a1c2SMark Johnston char d86_mnem[OPLEN]; 770339a1c2SMark Johnston uint_t d86_numopnds; 780339a1c2SMark Johnston uint_t d86_rex_prefix; /* value of REX prefix if !0 */ 790339a1c2SMark Johnston char *d86_seg_prefix; /* segment prefix, if any */ 800339a1c2SMark Johnston uint_t d86_opnd_size; 810339a1c2SMark Johnston uint_t d86_addr_size; 820339a1c2SMark Johnston uint_t d86_got_modrm; 83*b3b5bfebSMark Johnston uint_t d86_vsib; /* Has a VSIB */ 840339a1c2SMark Johnston struct d86opnd d86_opnd[4]; /* up to 4 operands */ 850339a1c2SMark Johnston int (*d86_check_func)(void *); 860339a1c2SMark Johnston int (*d86_get_byte)(void *); 870339a1c2SMark Johnston #ifdef DIS_TEXT 880339a1c2SMark Johnston int (*d86_sym_lookup)(void *, uint64_t, char *, size_t); 890339a1c2SMark Johnston int (*d86_sprintf_func)(char *, size_t, const char *, ...); 900339a1c2SMark Johnston int d86_flags; 910339a1c2SMark Johnston uint_t d86_imm_bytes; 920339a1c2SMark Johnston #endif 930339a1c2SMark Johnston void *d86_data; 940339a1c2SMark Johnston } dis86_t; 950339a1c2SMark Johnston 960339a1c2SMark Johnston extern int dtrace_disx86(dis86_t *x, uint_t cpu_mode); 970339a1c2SMark Johnston 980339a1c2SMark Johnston #define DIS_F_OCTAL 0x1 /* Print all numbers in octal */ 990339a1c2SMark Johnston #define DIS_F_NOIMMSYM 0x2 /* Don't print symbols for immediates (.o) */ 1000339a1c2SMark Johnston 1010339a1c2SMark Johnston #ifdef DIS_TEXT 1020339a1c2SMark Johnston extern void dtrace_disx86_str(dis86_t *x, uint_t cpu_mode, uint64_t pc, 1030339a1c2SMark Johnston char *buf, size_t len); 1040339a1c2SMark Johnston #endif 1050339a1c2SMark Johnston 1060339a1c2SMark Johnston #ifdef __cplusplus 1070339a1c2SMark Johnston } 1080339a1c2SMark Johnston #endif 1090339a1c2SMark Johnston 1100339a1c2SMark Johnston #endif /* _DIS_TABLES_H */ 111