1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright (c) 1993 by Sun Microsystems, Inc. 24*7c478bd9Sstevel@tonic-gate */ 25*7c478bd9Sstevel@tonic-gate 26*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 27*7c478bd9Sstevel@tonic-gate 28*7c478bd9Sstevel@tonic-gate /* 29*7c478bd9Sstevel@tonic-gate * opcodes of the call instructions 30*7c478bd9Sstevel@tonic-gate */ 31*7c478bd9Sstevel@tonic-gate /* 32*7c478bd9Sstevel@tonic-gate * offset (in bytes) of the code from the entry address of a routine. 33*7c478bd9Sstevel@tonic-gate * (see asgnsamples for use and explanation.) 34*7c478bd9Sstevel@tonic-gate */ 35*7c478bd9Sstevel@tonic-gate #define OFFSET_OF_CODE 0 /* there is no mask on a SPARC */ 36*7c478bd9Sstevel@tonic-gate #define UNITS_TO_CODE (OFFSET_OF_CODE / sizeof(UNIT)) 37*7c478bd9Sstevel@tonic-gate /* 38*7c478bd9Sstevel@tonic-gate * address at which text begins N_TXTADDR is defined in a.out.h 39*7c478bd9Sstevel@tonic-gate */ 40*7c478bd9Sstevel@tonic-gate #ifdef _SYS_ELF_H 41*7c478bd9Sstevel@tonic-gate extern size_t textbegin; 42*7c478bd9Sstevel@tonic-gate #define TORIGIN (unsigned int) textbegin 43*7c478bd9Sstevel@tonic-gate #else 44*7c478bd9Sstevel@tonic-gate #define TORIGIN ((unsigned long) N_TXTADDR(xbuf)) 45*7c478bd9Sstevel@tonic-gate #endif 46*7c478bd9Sstevel@tonic-gate /* 47*7c478bd9Sstevel@tonic-gate * Macros for manipulating instruction fields. These use the 48*7c478bd9Sstevel@tonic-gate * structures defined below 49*7c478bd9Sstevel@tonic-gate */ 50*7c478bd9Sstevel@tonic-gate #define OP(x) (((union instruct *) (x))->f_1.op) 51*7c478bd9Sstevel@tonic-gate #define DISP30(x) (((union instruct *) (x))->f_1.disp30) 52*7c478bd9Sstevel@tonic-gate #define OP3(x) (((union instruct *) (x))->f_3c.op3) 53*7c478bd9Sstevel@tonic-gate #define RD(x) (((union instruct *) (x))->f_3c.rd) 54*7c478bd9Sstevel@tonic-gate #define IMMED(x) (((union instruct *) (x))->f_3c.i) 55*7c478bd9Sstevel@tonic-gate #define SIMM13(x) (((((union instruct *) (x))->f_3d.simm13) << 19) >> 19) 56*7c478bd9Sstevel@tonic-gate #define RS1(x) (((union instruct *) (x))->f_3c.rs1) 57*7c478bd9Sstevel@tonic-gate #define RS2(x) (((union instruct *) (x))->f_3c.rs2) 58*7c478bd9Sstevel@tonic-gate /* 59*7c478bd9Sstevel@tonic-gate * a few values for operand and register fields 60*7c478bd9Sstevel@tonic-gate */ 61*7c478bd9Sstevel@tonic-gate #define CALL 0x1 62*7c478bd9Sstevel@tonic-gate #define FMT3_0x10 0x2 63*7c478bd9Sstevel@tonic-gate #define JMPL 0x38 64*7c478bd9Sstevel@tonic-gate #define R_G0 0x0 65*7c478bd9Sstevel@tonic-gate #define R_O7 0xF 66*7c478bd9Sstevel@tonic-gate #define R_I7 0x1F 67*7c478bd9Sstevel@tonic-gate /* 68*7c478bd9Sstevel@tonic-gate * A macro for converting from instructp to the appropriate address in 69*7c478bd9Sstevel@tonic-gate * the program 70*7c478bd9Sstevel@tonic-gate */ 71*7c478bd9Sstevel@tonic-gate #define PC_VAL(x) ((x) - (unsigned long) textspace + TORIGIN) 72*7c478bd9Sstevel@tonic-gate /* 73*7c478bd9Sstevel@tonic-gate * structures for decoding instructions 74*7c478bd9Sstevel@tonic-gate */ 75*7c478bd9Sstevel@tonic-gate struct f_1 { 76*7c478bd9Sstevel@tonic-gate unsigned long op:2, 77*7c478bd9Sstevel@tonic-gate disp30:30; 78*7c478bd9Sstevel@tonic-gate }; 79*7c478bd9Sstevel@tonic-gate struct f_2a { 80*7c478bd9Sstevel@tonic-gate unsigned long op:2, 81*7c478bd9Sstevel@tonic-gate rd:5, 82*7c478bd9Sstevel@tonic-gate op2:3, 83*7c478bd9Sstevel@tonic-gate imm22:22; 84*7c478bd9Sstevel@tonic-gate }; 85*7c478bd9Sstevel@tonic-gate struct f_2b { 86*7c478bd9Sstevel@tonic-gate unsigned long op:2, 87*7c478bd9Sstevel@tonic-gate a:1, 88*7c478bd9Sstevel@tonic-gate cond:4, 89*7c478bd9Sstevel@tonic-gate op2:3, 90*7c478bd9Sstevel@tonic-gate disp22:22; 91*7c478bd9Sstevel@tonic-gate }; 92*7c478bd9Sstevel@tonic-gate struct f_3a { 93*7c478bd9Sstevel@tonic-gate unsigned long op:2, 94*7c478bd9Sstevel@tonic-gate ign1:1, 95*7c478bd9Sstevel@tonic-gate cond:4, 96*7c478bd9Sstevel@tonic-gate op3:6, 97*7c478bd9Sstevel@tonic-gate rs1:5, 98*7c478bd9Sstevel@tonic-gate i:1, 99*7c478bd9Sstevel@tonic-gate ign2:8, 100*7c478bd9Sstevel@tonic-gate rs2:5; 101*7c478bd9Sstevel@tonic-gate }; 102*7c478bd9Sstevel@tonic-gate struct f_3b { 103*7c478bd9Sstevel@tonic-gate unsigned long op:2, 104*7c478bd9Sstevel@tonic-gate ign1:1, 105*7c478bd9Sstevel@tonic-gate cond:4, 106*7c478bd9Sstevel@tonic-gate op3:6, 107*7c478bd9Sstevel@tonic-gate rs1:5, 108*7c478bd9Sstevel@tonic-gate i:1, 109*7c478bd9Sstevel@tonic-gate simm13:13; 110*7c478bd9Sstevel@tonic-gate }; 111*7c478bd9Sstevel@tonic-gate struct f_3c { 112*7c478bd9Sstevel@tonic-gate unsigned long op:2, 113*7c478bd9Sstevel@tonic-gate rd:5, 114*7c478bd9Sstevel@tonic-gate op3:6, 115*7c478bd9Sstevel@tonic-gate rs1:5, 116*7c478bd9Sstevel@tonic-gate i:1, 117*7c478bd9Sstevel@tonic-gate asi:8, 118*7c478bd9Sstevel@tonic-gate rs2:5; 119*7c478bd9Sstevel@tonic-gate }; 120*7c478bd9Sstevel@tonic-gate struct f_3d { 121*7c478bd9Sstevel@tonic-gate unsigned long op:2, 122*7c478bd9Sstevel@tonic-gate rd:5, 123*7c478bd9Sstevel@tonic-gate op3:6, 124*7c478bd9Sstevel@tonic-gate rs1:5, 125*7c478bd9Sstevel@tonic-gate i:1, 126*7c478bd9Sstevel@tonic-gate simm13:13; 127*7c478bd9Sstevel@tonic-gate }; 128*7c478bd9Sstevel@tonic-gate struct f_3e { 129*7c478bd9Sstevel@tonic-gate unsigned long op:2, 130*7c478bd9Sstevel@tonic-gate rd:5, 131*7c478bd9Sstevel@tonic-gate op3:6, 132*7c478bd9Sstevel@tonic-gate rs1:5, 133*7c478bd9Sstevel@tonic-gate opf:9, 134*7c478bd9Sstevel@tonic-gate rs2:5; 135*7c478bd9Sstevel@tonic-gate }; 136*7c478bd9Sstevel@tonic-gate 137*7c478bd9Sstevel@tonic-gate union instruct { 138*7c478bd9Sstevel@tonic-gate struct f_1 f_1; 139*7c478bd9Sstevel@tonic-gate struct f_2a f_2a; 140*7c478bd9Sstevel@tonic-gate struct f_2b f_2b; 141*7c478bd9Sstevel@tonic-gate struct f_3a f_3a; 142*7c478bd9Sstevel@tonic-gate struct f_3b f_3b; 143*7c478bd9Sstevel@tonic-gate struct f_3c f_3c; 144*7c478bd9Sstevel@tonic-gate struct f_3d f_3d; 145*7c478bd9Sstevel@tonic-gate struct f_3e f_3e; 146*7c478bd9Sstevel@tonic-gate }; 147*7c478bd9Sstevel@tonic-gate 148