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