1*f7184619SJoshua M. Clulow /* 2*f7184619SJoshua M. Clulow * CDDL HEADER START 3*f7184619SJoshua M. Clulow * 4*f7184619SJoshua M. Clulow * The contents of this file are subject to the terms of the 5*f7184619SJoshua M. Clulow * Common Development and Distribution License (the "License"). 6*f7184619SJoshua M. Clulow * You may not use this file except in compliance with the License. 7*f7184619SJoshua M. Clulow * 8*f7184619SJoshua M. Clulow * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*f7184619SJoshua M. Clulow * or http://www.opensolaris.org/os/licensing. 10*f7184619SJoshua M. Clulow * See the License for the specific language governing permissions 11*f7184619SJoshua M. Clulow * and limitations under the License. 12*f7184619SJoshua M. Clulow * 13*f7184619SJoshua M. Clulow * When distributing Covered Code, include this CDDL HEADER in each 14*f7184619SJoshua M. Clulow * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*f7184619SJoshua M. Clulow * If applicable, add the following below this CDDL HEADER, with the 16*f7184619SJoshua M. Clulow * fields enclosed by brackets "[]" replaced with your own identifying 17*f7184619SJoshua M. Clulow * information: Portions Copyright [yyyy] [name of copyright owner] 18*f7184619SJoshua M. Clulow * 19*f7184619SJoshua M. Clulow * CDDL HEADER END 20*f7184619SJoshua M. Clulow */ 21*f7184619SJoshua M. Clulow 22*f7184619SJoshua M. Clulow /* 23*f7184619SJoshua M. Clulow * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 24*f7184619SJoshua M. Clulow * Use is subject to license terms. 25*f7184619SJoshua M. Clulow */ 26*f7184619SJoshua M. Clulow 27*f7184619SJoshua M. Clulow /* 28*f7184619SJoshua M. Clulow * Copyright 2007 Jason King. All rights reserved. 29*f7184619SJoshua M. Clulow * Use is subject to license terms. 30*f7184619SJoshua M. Clulow */ 31*f7184619SJoshua M. Clulow 32*f7184619SJoshua M. Clulow #ifndef _DIS_SPARC_FMT_H 33*f7184619SJoshua M. Clulow #define _DIS_SPARC_FMT_H 34*f7184619SJoshua M. Clulow 35*f7184619SJoshua M. Clulow #ifdef __cplusplus 36*f7184619SJoshua M. Clulow extern "C" { 37*f7184619SJoshua M. Clulow #endif 38*f7184619SJoshua M. Clulow 39*f7184619SJoshua M. Clulow #include <sys/types.h> 40*f7184619SJoshua M. Clulow #include "libdisasm.h" 41*f7184619SJoshua M. Clulow #include "dis_sparc.h" 42*f7184619SJoshua M. Clulow 43*f7184619SJoshua M. Clulow /* which set of registers are used with an instruction */ 44*f7184619SJoshua M. Clulow #define REG_INT 0x00 /* regular integer registers */ 45*f7184619SJoshua M. Clulow #define REG_FP 0x01 /* single-precision fp registers */ 46*f7184619SJoshua M. Clulow #define REG_FPD 0x02 /* double-precision fp registers */ 47*f7184619SJoshua M. Clulow #define REG_FPQ 0x03 /* quad-precision fp registers */ 48*f7184619SJoshua M. Clulow #define REG_CP 0x04 /* coprocessor registers (v8) */ 49*f7184619SJoshua M. Clulow #define REG_ICC 0x05 /* %icc / % xcc */ 50*f7184619SJoshua M. Clulow #define REG_FCC 0x06 /* %fccn */ 51*f7184619SJoshua M. Clulow #define REG_FSR 0x07 /* %fsr */ 52*f7184619SJoshua M. Clulow #define REG_CSR 0x08 /* %csr */ 53*f7184619SJoshua M. Clulow #define REG_CQ 0x09 /* %cq */ 54*f7184619SJoshua M. Clulow #define REG_NONE 0x0a /* no registers */ 55*f7184619SJoshua M. Clulow 56*f7184619SJoshua M. Clulow /* the size fo the displacement for branches */ 57*f7184619SJoshua M. Clulow #define DISP22 0x00 58*f7184619SJoshua M. Clulow #define DISP19 0x01 59*f7184619SJoshua M. Clulow #define DISP16 0x02 60*f7184619SJoshua M. Clulow #define CONST22 0x03 61*f7184619SJoshua M. Clulow 62*f7184619SJoshua M. Clulow /* get/set the register set name for the rd field of an instruction */ 63*f7184619SJoshua M. Clulow #define FLG_RD(x) (x) 64*f7184619SJoshua M. Clulow #define FLG_RD_VAL(x) (x & 0xfL) 65*f7184619SJoshua M. Clulow 66*f7184619SJoshua M. Clulow #define FLG_STORE (0x1L << 24) /* the instruction is not a load */ 67*f7184619SJoshua M. Clulow #define FLG_ASI (0x2L << 24) /* the load/store includes an asi value */ 68*f7184619SJoshua M. Clulow 69*f7184619SJoshua M. Clulow 70*f7184619SJoshua M. Clulow /* flags for ALU instructions */ 71*f7184619SJoshua M. Clulow 72*f7184619SJoshua M. Clulow /* set/get register set name for 1st argument position */ 73*f7184619SJoshua M. Clulow #define FLG_P1(x) (x << 8) 74*f7184619SJoshua M. Clulow #define FLG_P1_VAL(x) ((x >> 8) & 0xfL) 75*f7184619SJoshua M. Clulow 76*f7184619SJoshua M. Clulow /* get/set reg set for 2nd argument position */ 77*f7184619SJoshua M. Clulow #define FLG_P2(x) (x << 4) 78*f7184619SJoshua M. Clulow #define FLG_P2_VAL(x) ((x >> 4) & 0xfL) 79*f7184619SJoshua M. Clulow 80*f7184619SJoshua M. Clulow /* get/set for 3rd argument position */ 81*f7184619SJoshua M. Clulow #define FLG_P3(x) (x) 82*f7184619SJoshua M. Clulow #define FLG_P3_VAL(x) (x & 0xfL) 83*f7184619SJoshua M. Clulow 84*f7184619SJoshua M. Clulow /* set if the arguments do not contain immediate values */ 85*f7184619SJoshua M. Clulow #define FLG_NOIMM (0x01L << 24) 86*f7184619SJoshua M. Clulow 87*f7184619SJoshua M. Clulow 88*f7184619SJoshua M. Clulow 89*f7184619SJoshua M. Clulow /* flags for branch instructions */ 90*f7184619SJoshua M. Clulow 91*f7184619SJoshua M. Clulow /* has branch prediction */ 92*f7184619SJoshua M. Clulow #define FLG_PRED (0x01L << 24) 93*f7184619SJoshua M. Clulow 94*f7184619SJoshua M. Clulow /* get/set condition code register set -- usually REG_NONE */ 95*f7184619SJoshua M. Clulow #define FLG_RS1(x) (x) 96*f7184619SJoshua M. Clulow #define FLG_RS1_VAL(x) (x & 0xfL) 97*f7184619SJoshua M. Clulow 98*f7184619SJoshua M. Clulow /* get/set displacement size */ 99*f7184619SJoshua M. Clulow #define FLG_DISP(x) (x << 4L) 100*f7184619SJoshua M. Clulow #define FLG_DISP_VAL(x) ((x >> 4L) & 0x0fL) 101*f7184619SJoshua M. Clulow 102*f7184619SJoshua M. Clulow 103*f7184619SJoshua M. Clulow int fmt_call(dis_handle_t *, uint32_t, const inst_t *, int); 104*f7184619SJoshua M. Clulow int fmt_ls(dis_handle_t *, uint32_t, const inst_t *, int); 105*f7184619SJoshua M. Clulow int fmt_alu(dis_handle_t *, uint32_t, const inst_t *, int); 106*f7184619SJoshua M. Clulow int fmt_branch(dis_handle_t *, uint32_t, const inst_t *, int); 107*f7184619SJoshua M. Clulow int fmt_sethi(dis_handle_t *, uint32_t, const inst_t *, int); 108*f7184619SJoshua M. Clulow int fmt_fpop1(dis_handle_t *, uint32_t, const inst_t *, int); 109*f7184619SJoshua M. Clulow int fmt_fpop2(dis_handle_t *, uint32_t, const inst_t *, int); 110*f7184619SJoshua M. Clulow int fmt_vis(dis_handle_t *, uint32_t, const inst_t *, int); 111*f7184619SJoshua M. Clulow int fmt_trap(dis_handle_t *, uint32_t, const inst_t *, int); 112*f7184619SJoshua M. Clulow int fmt_regwin(dis_handle_t *, uint32_t, const inst_t *, int); 113*f7184619SJoshua M. Clulow int fmt_trap_ret(dis_handle_t *, uint32_t, const inst_t *, int); 114*f7184619SJoshua M. Clulow int fmt_movcc(dis_handle_t *, uint32_t, const inst_t *, int); 115*f7184619SJoshua M. Clulow int fmt_movr(dis_handle_t *, uint32_t, const inst_t *, int); 116*f7184619SJoshua M. Clulow int fmt_fused(dis_handle_t *, uint32_t, const inst_t *, int); 117*f7184619SJoshua M. Clulow 118*f7184619SJoshua M. Clulow #ifdef __cplusplus 119*f7184619SJoshua M. Clulow } 120*f7184619SJoshua M. Clulow #endif 121*f7184619SJoshua M. Clulow 122*f7184619SJoshua M. Clulow #endif /* _DIS_SPARC_FMT_H */ 123