* ========== Copyright Header Begin ==========================================
* Hypervisor Software File: dis.c
* Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
* - Do no alter or remove copyright notices
* - Redistribution and use of this software in source and binary forms, with
* or without modification, are permitted provided that the following
* - Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistribution in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of Sun Microsystems, Inc. or the names of contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
* This software is provided "AS IS," without a warranty of any kind.
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
* INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
* MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
* ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
* DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN
* OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR
* FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
* DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
* SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
* You acknowledge that this software is not designed, licensed or
* intended for use in the design, construction, operation or maintenance of
* ========== Copyright Header End ============================================
* Copyright 2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
#pragma ident "@(#)dis.c 1.2 03/11/10 SMI"
#define RD(inst) (((inst) >> 25) & 0x1f)
#define RS1(inst) (((inst) >> 14) & 0x1f)
#define RS2(inst) (((inst) ) & 0x1f)
#define OP(inst) (((inst) >> 30) & 0x3)
#define OP2(inst) (((inst) >> 22) & 0x7)
#define OP3(inst) (((inst) >> 19) & 0x3f)
#define IMM22(inst) (((inst) << 10) >> 10)
#define IMM(inst) (((inst) >> 13) & 1)
#define SIMM13(inst) (int64_t)(((((int32_t)(inst) << 19)) >> 19))
#define X(inst) (((inst) >> 12) & 1)
#define SHIFT32(inst) ((inst) & 0x1f)
#define SHIFT64(inst) ((inst) & 0x3f)
#define CMASK(inst) (((inst) >> 4) & 0x7)
#define MMASK(inst) ((inst) & 0xf)
#define A(inst) (((inst) >> 29) & 1)
#define CC(inst) (((inst) >> 20) & 3)
#define TCC(inst) (((inst) >> 10) & 3)
#define DISP19(inst) (int64_t)(((((int32_t)(inst) << 13)) >> 11))
#define DISP22(inst) (int64_t)(((((int32_t)(inst) << 10)) >> 8))
#define COND(inst) (((inst) >> 25) & 0xf)
#define PT(inst) (((inst) >> 19) & 1)
#define FCN(inst) (((inst) >> 25) & 0x1f)
#define IMMASI(inst) (((inst) >> 5) & 0xff)
#define SWTRAP(inst) ((inst) & 0x3f)
#define HT(inst) (((inst) >> 7) & 0x1)
(void)printf("%p:\tIllegal instruction %08x\n", (void *)pc, inst);\
"%g0", "%g1", "%g2", "%g3", "%g4", "%g5", "%g6", "%g7",
"%o0", "%o1", "%o2", "%o3", "%o4", "%o5", "%o6", "%i7",
"%l0", "%l1", "%l2", "%l3", "%l4", "%l5", "%l6", "%l7",
"%i0", "%i1", "%i2", "%i3", "%i4", "%i5", "%i6", "%i7"
static int dis_format2(uint32_t *, uint32_t);
static int dis_class2(uint32_t *, uint32_t);
static int dis_class3(uint32_t *, uint32_t);
static int dis_bpcc(uint32_t *, uint32_t);
static int dis_bpr(uint32_t *, uint32_t);
static int dis_tcc(uint32_t *, uint32_t);
static int dis_fbfcc(uint32_t *, uint32_t);
static int dis_fbpfcc(uint32_t *, uint32_t);
static int dis_bicc(uint32_t *, uint32_t);
static int dis_rdasr(uint32_t *, uint32_t);
static int dis_rdpr(uint32_t *, uint32_t);
static int dis_wrasr(uint32_t *, uint32_t);
static int dis_wrpr(uint32_t *, uint32_t);
return dis_format2(pc
, inst
);
int64_t label
= (inst
<< 2) + (int64_t) pc
;
(void)printf("%p:\tcall\t0x%lx\n", (void *)pc
, label
);
return dis_class2(pc
, inst
);
return dis_class3(pc
, inst
);
dis_format2(uint32_t *pc
, uint32_t inst
)
(void)printf("%p:\tilltrap\n", (void *)pc
);
return dis_bpcc(pc
, inst
);
return dis_bicc(pc
, inst
);
return dis_bpr(pc
, inst
);
if ((RD(inst
) == 0) && (IMM22(inst
) == 0)) {
(void)printf("%p:\tnop\n", (void *)pc
);
(void)printf("%p:\tsethi\t0x%x, %s\n", (void *)pc
,
IMM22(inst
) << 10, sregs
[RD(inst
)]);
return dis_fbpfcc(pc
, inst
);
return dis_fbfcc(pc
, inst
);
dis_class2(uint32_t *pc
, uint32_t inst
)
"add", "and", "or", "xor",
"sub", "andn", "orn", "xnor",
"addc", "mulx", "umul", "smul",
"subc", "udivx", "udiv", "sdiv",
"addcc", "andcc", "orcc", "xorcc",
"subcc", "andncc", "orncc", "xnorcc",
"addccc", "-", "umulcc", "smulcc",
"subccc", "-", "udivcc", "sdivcc",
"taddcc", "tsubcc", "taddcctv", "tsubcctv",
"mulscc", "sll", "srl", "sra",
"rdy", "-", "rdpr", "flushw",
"movcc", "sdivx", "popc", "movr",
"wry", "saved", "wrpr", "-",
"fpop1", "fpop2", "impldep1", "impldep2",
"jmpl", "return", "tcc", "flush",
"save", "restore", "done", "-"
case 0x22: /* TADDccTV */
case 0x23: /* TSUBccTV */
(void)printf("%p:\t%s\t%s, ", (void *)pc
,
opc
[op3
], sregs
[RS1(inst
)]);
(void)printf("%ld, ", SIMM13(inst
));
(void)printf("%s, ", sregs
[RS2(inst
)]);
(void)printf("%s\n", sregs
[RD(inst
)]);
return (op3
== 0x38) ? DELAY
: OK
;
if ((RD(inst
) == 0) && (RS1(inst
) == 0)
&& (IMM(inst
) == 0) && (SIMM13(inst
) == 0)) {
(void)printf("%p:\t%s\n", (void *)pc
, opc
[op3
]);
(void)printf("%p:\t%s\t%s + ", (void *)pc
, opc
[op3
], sregs
[RS1(inst
)]);
(void)printf("%ld\n", SIMM13(inst
));
(void)printf("%s\n", sregs
[RS2(inst
)]);
case 0x25: /* SLL/SLLX */
case 0x26: /* SRL/SRLX */
case 0x27: /* SRA/SRAX */
(void)printf("%p:\t%s%s\t%s, ", (void *)pc
,
opc
[op3
], X(inst
) ? "x" : "", sregs
[RS1(inst
)]);
X(inst
) ? SHIFT64(inst
) : SHIFT32(inst
));
(void)printf("%s, ", sregs
[RS2(inst
)]);
(void)printf("%s\n", sregs
[RD(inst
)]);
return dis_rdasr(pc
, inst
);
return dis_rdpr(pc
, inst
);
return dis_wrasr(pc
, inst
);
case 0x31: /* SAVED/RESTORED */
(void)printf("%p:\tsaved\n", (void *)pc
);
(void)printf("%p:\trestored\n", (void *)pc
);
return dis_wrpr(pc
, inst
);
return dis_tcc(pc
, inst
);
case 0x3e: /* DONE/RETRY */
(void)printf("%p:\tdone\n", (void *)pc
);
(void)printf("%p:\tretry\n", (void *)pc
);
(void)printf("XXXX %p:\timpldep1\n", (void *)pc
);
case 0x37: /* IMPLDEP2 */
(void)printf("XXXX %p:\timpldep2\n", (void *)pc
);
(void)printf("XXXX dis_class2 op3=%x\n", op3
);
static int dis_rdpr(uint32_t *pc
, uint32_t inst
)
"%tpc", "%tnpc", "%tstate", "%tt",
"%tick", "%tba", "%pstate", "%tl",
"%pil", "%cwp", "%cansave", "%canrestore",
"%cleanwin", "%otherwin", "%wstate", "%fq",
if ((SIMM13(inst
)) || (RS1(inst
) >= 16 && RS1(inst
) <=30)) {
(void)printf("%p:\trdpr\t%s,%s\n", (void *)pc
, prs
[RS1(inst
)], sregs
[RD(inst
)]);
static int dis_wrpr(uint32_t *pc
, uint32_t inst
)
"%tpc", "%tnpc", "%tstate", "%tt",
"%tick", "%tba", "%pstate", "%tl",
"%pil", "%cwp", "%cansave", "%canrestore",
"%cleanwin", "%otherwin", "%wstate", "%fq",
(void)printf("%p:\twrpr\t%s,%s, ", (void *)pc
, prs
[RD(inst
)], sregs
[RS1(inst
)]);
(void)printf("%ld, ", SIMM13(inst
));
(void)printf("%s, ", sregs
[RS2(inst
)]);
(void)printf("%s\n", sregs
[RD(inst
)]);
static int dis_wrasr(uint32_t *pc
, uint32_t inst
)
"wry", "-", "wrccr", "wrasi",
"wrtick", "-", "wrfprs", "-",
if ((RD(inst
) == 0xf) && (RS1(inst
) != 0) && (IMM(inst
) == 0)) {
(void)printf("%p:\t%s\t%s,", (void *)pc
, asrs
[RD(inst
)], sregs
[RS1(inst
)]);
(void)printf("%ld, ", SIMM13(inst
));
(void)printf("%s, ", sregs
[RS2(inst
)]);
(void)printf("%p:\twr\t%s, ", (void *)pc
, sregs
[RS1(inst
)]);
(void)printf("%ld, ", SIMM13(inst
));
(void)printf("%s, ", sregs
[RS2(inst
)]);
(void)printf("%%asr%d\n", RD(inst
));
(void)printf("XXXX wrasr %d\n", RD(inst
));
static int dis_rdasr(uint32_t *pc
, uint32_t inst
)
"rdy", "-", "rdccr", "rdasi",
"rdtick", "rdpc", "rdfprs", "-",
(void)printf("%p:\t%s\t%s\n", (void *)pc
, asrs
[RS1(inst
)],
case 0xf: /* MEMBAR / STBAR */
(void)printf("%p\tmembar\t", (void *)pc
);
(void)printf("#Lookaside ");
(void)printf("#MemIssue ");
(void)printf("#LoadLoad ");
(void)printf("#StoreLoad ");
(void)printf("#LoadStore ");
(void)printf("#StoreStore");
(void)printf("%p:\tstbar\n", (void *)pc
);
(void)printf("%p:\trd\t%%asr%d, %s\n", (void *)pc
, RS1(inst
), sregs
[RD(inst
)]);
dis_class3(uint32_t *pc
, uint32_t inst
)
"lduw", "ldub", "lduh", "ldd",
"stw", "stb", "sth", "std",
"ldsw", "ldsb", "ldsh", "ldx",
"-", "ldstub", "stx", "swap",
"lduwa", "lduba", "lduha", "ldda",
"stwa", "stba", "stha", "stda",
"ldswa", "ldsba", "ldsha", "ldxa",
"-", "ldstuba", "stxa", "swapa",
"ldf", "ldfsr", "ldqf", "lddf"
"stf", "stfsr", "stqf", "stdf",
"-", "prefetch", "-", "-",
"ldfa", "-", "ldqfa", "lddfa",
"stfa", "-", "stqfa", "stdfa",
"casa", "prefetcha", "casxa", "-"
(void)printf("%p:\t%s\t[%s + ", (void *)pc
, opc
[op3
], sregs
[RS1(inst
)]);
(void)printf("%ld], ", SIMM13(inst
));
(void)printf("%s], ", sregs
[RS2(inst
)]);
(void)printf("%s\n", sregs
[RD(inst
)]);
(void)printf("%p:\t%s\t%s, ", (void *)pc
, opc
[op3
], sregs
[RD(inst
)]);
(void)printf("[%s + ", sregs
[RS1(inst
)]);
(void)printf("%ld]\n", SIMM13(inst
));
(void)printf("%s]\n", sregs
[RS2(inst
)]);
(void)printf("%p:\t%s\t[%s + ", (void *)pc
, opc
[op3
], sregs
[RS1(inst
)]);
(void)printf("%ld] %%asi, ", SIMM13(inst
));
(void)printf("%s] 0x%x, ", sregs
[RS2(inst
)], IMMASI(inst
));
(void)printf("%s\n", sregs
[RD(inst
)]);
(void)printf("%p:\t%s\t%s, ", (void *)pc
, opc
[op3
], sregs
[RD(inst
)]);
(void)printf("[%s + ", sregs
[RS1(inst
)]);
(void)printf("%ld] %%asi\n", SIMM13(inst
));
(void)printf("%s] 0x%x\n", sregs
[RS2(inst
)], IMMASI(inst
));
case 0x2d: /* PREFETCH */
if ((RD(inst
) >=5) && (RD(inst
) <= 15)) {
(void)printf("%p:\t%s\t[%s + ", (void *)pc
, opc
[op3
], sregs
[RS1(inst
)]);
(void)printf("%ld], ", SIMM13(inst
));
(void)printf("%s], ", sregs
[RS2(inst
)]);
(void)printf("%d\n", RD(inst
));
case 0x3d: /* PREFETCHA */
if ((RD(inst
) >=5) && (RD(inst
) <= 15)) {
(void)printf("%p:\t%s\t[%s + ", (void *)pc
, opc
[op3
], sregs
[RS1(inst
)]);
(void)printf("%ld] %%asi, ", SIMM13(inst
));
(void)printf("%s] 0x%x, ", sregs
[RS2(inst
)], IMMASI(inst
));
(void)printf("%d\n", RD(inst
));
(void)printf("XXXX %p:\tLDF XXX op3=%x\n", (void *)pc
, OP3(inst
));
(void)printf("XXXX %p:\tSTF XXX op3=%x\n", (void *)pc
, OP3(inst
));
(void)printf("XXXX dis_class3 op3=%x\n", OP3(inst
));
static int dis_bpcc(uint32_t *pc
, uint32_t inst
)
"bpn", "bpe", "bple", "bpl",
"bpleu", "bpcs", "bpneg", "bpvs"
"bpa", "bpne", "bpg", "bpge",
"bpgu", "bpcc", "bppos", "bpvc"
if ((CC(inst
) != 0) && (CC(inst
) != 2)) {
(void)printf("%p:\t%s%s%s\t%s,0x%lx\n", (void *)pc
,
PT(inst
) ? ",pt" : ",pn",
CC(inst
) ? "%xcc" : "%icc",
DISP19(inst
) + (int64_t)pc
);
static int dis_bpr(uint32_t *pc
, uint32_t inst
)
(void)printf("%p:\tXXXX dis_bpr 0x%x\n", (void *)pc
, inst
);
static int dis_bicc(uint32_t *pc
, uint32_t inst
)
"bleu", "bcs", "bneg", "bvs"
"ba", "bne", "bg", "bge",
"bgu", "bcc", "bpos", "bvc"
(void)printf("%p:\t%s%s\t0x%lx\n", (void *)pc
,
DISP22(inst
) + (int64_t)pc
);
static int dis_tcc(uint32_t *pc
, uint32_t inst
)
"tleu", "tcs", "tneg", "tvs",
"ta", "tne", "tg", "tge",
"tgu", "tcc", "tpos", "tvc"
(void)printf("%p:\t%s%s\t%s, ", (void *)pc
, HT(inst
) ? "h" : "", tcc
[COND(inst
)],
TCC(inst
) ? "%xcc" : "%icc");
(void)printf("0x%x\n", SWTRAP(inst
));
(void)printf("%s\n", sregs
[RS2(inst
)]);
static int dis_fbfcc(uint32_t *pc
, uint32_t inst
)
(void)printf("%p:\tXXXX dis_fbfcc 0x%x\n", (void *)pc
, inst
);
static int dis_fbpfcc(uint32_t *pc
, uint32_t inst
)
(void)printf("%p:\tXXXX dis_fbpfcc 0x%x\n", (void *)pc
, inst
);