summaryrefslogtreecommitdiffstats
path: root/sys/amd64
diff options
context:
space:
mode:
authorwollman <wollman@FreeBSD.org>1996-03-28 20:35:03 +0000
committerwollman <wollman@FreeBSD.org>1996-03-28 20:35:03 +0000
commita607edf55969f0b165d31f35bb7bfe09fef26f04 (patch)
tree6100e75c70461c0dcae2fcb93104d6e41f4a627d /sys/amd64
parentcb41a0ae0ec578308c3ad467b32ae82c78c46762 (diff)
downloadFreeBSD-src-a607edf55969f0b165d31f35bb7bfe09fef26f04.zip
FreeBSD-src-a607edf55969f0b165d31f35bb7bfe09fef26f04.tar.gz
Teach the disassembler about the 0f,3x family of instructions
(RDMSR, RDTSC, WRMSR, and RDPMC).
Diffstat (limited to 'sys/amd64')
-rw-r--r--sys/amd64/amd64/db_disasm.c124
1 files changed, 72 insertions, 52 deletions
diff --git a/sys/amd64/amd64/db_disasm.c b/sys/amd64/amd64/db_disasm.c
index cf60221..ab7ae80 100644
--- a/sys/amd64/amd64/db_disasm.c
+++ b/sys/amd64/amd64/db_disasm.c
@@ -23,7 +23,7 @@
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*
- * $Id: db_disasm.c,v 1.12 1995/12/07 12:45:29 davidg Exp $
+ * $Id: db_disasm.c,v 1.13 1996/01/15 22:40:17 phk Exp $
*/
/*
@@ -91,7 +91,7 @@
#define XA 34 /* for 'fstcw %ax' */
struct inst {
- char * i_name; /* name */
+ const char * i_name; /* name */
short i_has_modrm; /* has regmodrm byte */
short i_size; /* operand size */
int i_mode; /* addressing modes */
@@ -103,14 +103,14 @@ struct inst {
#define op3(x,y,z) ((x)|((y)<<8)|((z)<<16))
struct finst {
- char * f_name; /* name for memory instruction */
+ const char * f_name; /* name for memory instruction */
int f_size; /* size for memory instruction */
int f_rrmode; /* mode for rr instruction */
char * f_rrname; /* name for rr instruction
(or pointer to table) */
};
-static char * db_Grp6[] = {
+static const char * const db_Grp6[] = {
"sldt",
"str",
"lldt",
@@ -121,7 +121,7 @@ static char * db_Grp6[] = {
""
};
-static char * db_Grp7[] = {
+static const char * const db_Grp7[] = {
"sgdt",
"sidt",
"lgdt",
@@ -132,7 +132,7 @@ static char * db_Grp7[] = {
"invlpg"
};
-static char * db_Grp8[] = {
+static const char * const db_Grp8[] = {
"",
"",
"",
@@ -143,7 +143,7 @@ static char * db_Grp8[] = {
"btc"
};
-static struct inst db_inst_0f0x[] = {
+static const struct inst db_inst_0f0x[] = {
/*00*/ { "", TRUE, NONE, op1(Ew), (char *)db_Grp6 },
/*01*/ { "", TRUE, NONE, op1(Ew), (char *)db_Grp7 },
/*02*/ { "lar", TRUE, LONG, op2(E,R), 0 },
@@ -163,7 +163,7 @@ static struct inst db_inst_0f0x[] = {
/*0f*/ { "", FALSE, NONE, 0, 0 },
};
-static struct inst db_inst_0f2x[] = {
+static const struct inst db_inst_0f2x[] = {
/*20*/ { "mov", TRUE, LONG, op2(CR,E), 0 }, /* use E for reg */
/*21*/ { "mov", TRUE, LONG, op2(DR,E), 0 }, /* since mod == 11 */
/*22*/ { "mov", TRUE, LONG, op2(E,CR), 0 },
@@ -183,7 +183,27 @@ static struct inst db_inst_0f2x[] = {
/*2f*/ { "", FALSE, NONE, 0, 0 },
};
-static struct inst db_inst_0f8x[] = {
+static const struct inst db_inst_0f3x[] = {
+/*30*/ { "wrmsr", FALSE, NONE, 0, 0 },
+/*31*/ { "rdtsc", FALSE, NONE, 0, 0 },
+/*32*/ { "rdmsr", FALSE, NONE, 0, 0 },
+/*33*/ { "rdpmc", FALSE, NONE, 0, 0 },
+/*34*/ { "", FALSE, NONE, 0, 0 },
+/*35*/ { "", FALSE, NONE, 0, 0 },
+/*36*/ { "", FALSE, NONE, 0, 0 },
+/*37*/ { "", FALSE, NONE, 0, 0 },
+
+/*38*/ { "", FALSE, NONE, 0, 0 },
+/*39*/ { "", FALSE, NONE, 0, 0 },
+/*3a*/ { "", FALSE, NONE, 0, 0 },
+/*3b*/ { "", FALSE, NONE, 0, 0 },
+/*3c*/ { "", FALSE, NONE, 0, 0 },
+/*3d*/ { "", FALSE, NONE, 0, 0 },
+/*3e*/ { "", FALSE, NONE, 0, 0 },
+/*3f*/ { "", FALSE, NONE, 0, 0 },
+};
+
+static const struct inst db_inst_0f8x[] = {
/*80*/ { "jo", FALSE, NONE, op1(Dl), 0 },
/*81*/ { "jno", FALSE, NONE, op1(Dl), 0 },
/*82*/ { "jb", FALSE, NONE, op1(Dl), 0 },
@@ -203,7 +223,7 @@ static struct inst db_inst_0f8x[] = {
/*8f*/ { "jnle", FALSE, NONE, op1(Dl), 0 },
};
-static struct inst db_inst_0f9x[] = {
+static const struct inst db_inst_0f9x[] = {
/*90*/ { "seto", TRUE, NONE, op1(Eb), 0 },
/*91*/ { "setno", TRUE, NONE, op1(Eb), 0 },
/*92*/ { "setb", TRUE, NONE, op1(Eb), 0 },
@@ -223,7 +243,7 @@ static struct inst db_inst_0f9x[] = {
/*9f*/ { "setnle",TRUE, NONE, op1(Eb), 0 },
};
-static struct inst db_inst_0fax[] = {
+static const struct inst db_inst_0fax[] = {
/*a0*/ { "push", FALSE, NONE, op1(Si), 0 },
/*a1*/ { "pop", FALSE, NONE, op1(Si), 0 },
/*a2*/ { "", FALSE, NONE, 0, 0 },
@@ -243,7 +263,7 @@ static struct inst db_inst_0fax[] = {
/*a7*/ { "imul", TRUE, LONG, op2(E,R), 0 },
};
-static struct inst db_inst_0fbx[] = {
+static const struct inst db_inst_0fbx[] = {
/*b0*/ { "", FALSE, NONE, 0, 0 },
/*b1*/ { "", FALSE, NONE, 0, 0 },
/*b2*/ { "lss", TRUE, LONG, op2(E, R), 0 },
@@ -263,7 +283,7 @@ static struct inst db_inst_0fbx[] = {
/*bf*/ { "movsw", TRUE, LONG, op2(E, R), 0 },
};
-static struct inst db_inst_0fcx[] = {
+static const struct inst db_inst_0fcx[] = {
/*c0*/ { "xadd", TRUE, BYTE, op2(R, E), 0 },
/*c1*/ { "xadd", TRUE, LONG, op2(R, E), 0 },
/*c2*/ { "", FALSE, NONE, 0, 0 },
@@ -282,7 +302,7 @@ static struct inst db_inst_0fcx[] = {
/*cf*/ { "bswap", FALSE, LONG, op1(Ri), 0 },
};
-static struct inst db_inst_0fdx[] = {
+static const struct inst db_inst_0fdx[] = {
/*c0*/ { "cmpxchg",TRUE, BYTE, op2(R, E), 0 },
/*c1*/ { "cmpxchg",TRUE, LONG, op2(R, E), 0 },
/*c2*/ { "", FALSE, NONE, 0, 0 },
@@ -301,11 +321,11 @@ static struct inst db_inst_0fdx[] = {
/*cf*/ { "", FALSE, NONE, 0, 0 },
};
-static struct inst *db_inst_0f[] = {
+static const struct inst * const db_inst_0f[] = {
db_inst_0f0x,
0,
db_inst_0f2x,
- 0,
+ db_inst_0f3x,
0,
0,
0,
@@ -320,43 +340,43 @@ static struct inst *db_inst_0f[] = {
0
};
-static char * db_Esc92[] = {
+static const char * const db_Esc92[] = {
"fnop", "", "", "", "", "", "", ""
};
-static char * db_Esc93[] = {
+static const char * const db_Esc93[] = {
"", "", "", "", "", "", "", ""
};
-static char * db_Esc94[] = {
+static const char * const db_Esc94[] = {
"fchs", "fabs", "", "", "ftst", "fxam", "", ""
};
-static char * db_Esc95[] = {
+static const char *const db_Esc95[] = {
"fld1", "fldl2t","fldl2e","fldpi","fldlg2","fldln2","fldz",""
};
-static char * db_Esc96[] = {
+static const char *const db_Esc96[] = {
"f2xm1","fyl2x","fptan","fpatan","fxtract","fprem1","fdecstp",
"fincstp"
};
-static char * db_Esc97[] = {
+static const char * const db_Esc97[] = {
"fprem","fyl2xp1","fsqrt","fsincos","frndint","fscale","fsin","fcos"
};
-static char * db_Esca4[] = {
+static const char *const db_Esca4[] = {
"", "fucompp","", "", "", "", "", ""
};
-static char * db_Escb4[] = {
+static const char *const db_Escb4[] = {
"", "", "fnclex","fninit","", "", "", ""
};
-static char * db_Esce3[] = {
+static const char * const db_Esce3[] = {
"", "fcompp","", "", "", "", "", ""
};
-static char * db_Escf4[] = {
+static const char *const db_Escf4[] = {
"fnstsw","", "", "", "", "", "", ""
};
-static struct finst db_Esc8[] = {
+static const struct finst db_Esc8[] = {
/*0*/ { "fadd", SNGL, op2(STI,ST), 0 },
/*1*/ { "fmul", SNGL, op2(STI,ST), 0 },
/*2*/ { "fcom", SNGL, op2(STI,ST), 0 },
@@ -367,7 +387,7 @@ static struct finst db_Esc8[] = {
/*7*/ { "fdivr", SNGL, op2(STI,ST), 0 },
};
-static struct finst db_Esc9[] = {
+static const struct finst db_Esc9[] = {
/*0*/ { "fld", SNGL, op1(STI), 0 },
/*1*/ { "", NONE, op1(STI), "fxch" },
/*2*/ { "fst", SNGL, op1(X), (char *)db_Esc92 },
@@ -378,7 +398,7 @@ static struct finst db_Esc9[] = {
/*7*/ { "fnstcw", NONE, op1(X), (char *)db_Esc97 },
};
-static struct finst db_Esca[] = {
+static const struct finst db_Esca[] = {
/*0*/ { "fiadd", WORD, 0, 0 },
/*1*/ { "fimul", WORD, 0, 0 },
/*2*/ { "ficom", WORD, 0, 0 },
@@ -389,7 +409,7 @@ static struct finst db_Esca[] = {
/*7*/ { "fidivr", WORD, 0, 0 }
};
-static struct finst db_Escb[] = {
+static const struct finst db_Escb[] = {
/*0*/ { "fild", WORD, 0, 0 },
/*1*/ { "", NONE, 0, 0 },
/*2*/ { "fist", WORD, 0, 0 },
@@ -400,7 +420,7 @@ static struct finst db_Escb[] = {
/*7*/ { "fstp", EXTR, 0, 0 },
};
-static struct finst db_Escc[] = {
+static const struct finst db_Escc[] = {
/*0*/ { "fadd", DBLR, op2(ST,STI), 0 },
/*1*/ { "fmul", DBLR, op2(ST,STI), 0 },
/*2*/ { "fcom", DBLR, op2(ST,STI), 0 },
@@ -411,7 +431,7 @@ static struct finst db_Escc[] = {
/*7*/ { "fdivr", DBLR, op2(ST,STI), "fdiv" },
};
-static struct finst db_Escd[] = {
+static const struct finst db_Escd[] = {
/*0*/ { "fld", DBLR, op1(STI), "ffree" },
/*1*/ { "", NONE, 0, 0 },
/*2*/ { "fst", DBLR, op1(STI), 0 },
@@ -422,7 +442,7 @@ static struct finst db_Escd[] = {
/*7*/ { "fnstsw", NONE, 0, 0 },
};
-static struct finst db_Esce[] = {
+static const struct finst db_Esce[] = {
/*0*/ { "fiadd", LONG, op2(ST,STI), "faddp" },
/*1*/ { "fimul", LONG, op2(ST,STI), "fmulp" },
/*2*/ { "ficom", LONG, 0, 0 },
@@ -433,7 +453,7 @@ static struct finst db_Esce[] = {
/*7*/ { "fidivr", LONG, op2(ST,STI), "fdivp" },
};
-static struct finst db_Escf[] = {
+static const struct finst db_Escf[] = {
/*0*/ { "fild", LONG, 0, 0 },
/*1*/ { "", LONG, 0, 0 },
/*2*/ { "fist", LONG, 0, 0 },
@@ -444,12 +464,12 @@ static struct finst db_Escf[] = {
/*7*/ { "fstp", QUAD, 0, 0 },
};
-static struct finst *db_Esc_inst[] = {
+static const struct finst *const db_Esc_inst[] = {
db_Esc8, db_Esc9, db_Esca, db_Escb,
db_Escc, db_Escd, db_Esce, db_Escf
};
-static char * db_Grp1[] = {
+static const char * const db_Grp1[] = {
"add",
"or",
"adc",
@@ -460,7 +480,7 @@ static char * db_Grp1[] = {
"cmp"
};
-static char * db_Grp2[] = {
+static const char * const db_Grp2[] = {
"rol",
"ror",
"rcl",
@@ -471,7 +491,7 @@ static char * db_Grp2[] = {
"sar"
};
-static struct inst db_Grp3[] = {
+static const struct inst db_Grp3[] = {
{ "test", TRUE, NONE, op2(I,E), 0 },
{ "test", TRUE, NONE, op2(I,E), 0 },
{ "not", TRUE, NONE, op1(E), 0 },
@@ -482,7 +502,7 @@ static struct inst db_Grp3[] = {
{ "idiv", TRUE, NONE, op2(E,A), 0 },
};
-static struct inst db_Grp4[] = {
+static const struct inst db_Grp4[] = {
{ "inc", TRUE, BYTE, op1(E), 0 },
{ "dec", TRUE, BYTE, op1(E), 0 },
{ "", TRUE, NONE, 0, 0 },
@@ -493,7 +513,7 @@ static struct inst db_Grp4[] = {
{ "", TRUE, NONE, 0, 0 }
};
-static struct inst db_Grp5[] = {
+static const struct inst db_Grp5[] = {
{ "inc", TRUE, LONG, op1(E), 0 },
{ "dec", TRUE, LONG, op1(E), 0 },
{ "call", TRUE, NONE, op1(Eind),0 },
@@ -504,7 +524,7 @@ static struct inst db_Grp5[] = {
{ "", TRUE, NONE, 0, 0 }
};
-static struct inst db_inst_table[256] = {
+static const struct inst db_inst_table[256] = {
/*00*/ { "add", TRUE, BYTE, op2(R, E), 0 },
/*01*/ { "add", TRUE, LONG, op2(R, E), 0 },
/*02*/ { "add", TRUE, BYTE, op2(E, R), 0 },
@@ -795,7 +815,7 @@ static struct inst db_inst_table[256] = {
/*ff*/ { "", TRUE, NONE, 0, (char *)db_Grp5 },
};
-static struct inst db_bad_inst =
+static const struct inst db_bad_inst =
{ "???", FALSE, NONE, 0, 0 }
;
@@ -810,12 +830,12 @@ static struct inst db_bad_inst =
struct i_addr {
int is_reg; /* if reg, reg number is in 'disp' */
int disp;
- char * base;
- char * index;
+ const char * base;
+ const char * index;
int ss;
};
-static char * db_index_reg_16[8] = {
+static const char * const db_index_reg_16[8] = {
"%bx,%si",
"%bx,%di",
"%bp,%si",
@@ -826,20 +846,20 @@ static char * db_index_reg_16[8] = {
"%bx"
};
-static char * db_reg[3][8] = {
+static const char * const db_reg[3][8] = {
"%al", "%cl", "%dl", "%bl", "%ah", "%ch", "%dh", "%bh",
"%ax", "%cx", "%dx", "%bx", "%sp", "%bp", "%si", "%di",
"%eax", "%ecx", "%edx", "%ebx", "%esp", "%ebp", "%esi", "%edi"
};
-static char * db_seg_reg[8] = {
+static const char *const db_seg_reg[8] = {
"%es", "%cs", "%ss", "%ds", "%fs", "%gs", "", ""
};
/*
* lengths for size attributes
*/
-static int db_lengths[] = {
+static const int db_lengths[] = {
1, /* BYTE */
2, /* WORD */
4, /* LONG */
@@ -989,10 +1009,10 @@ db_disasm_esc(loc, inst, short_addr, size, seg)
char * seg;
{
int regmodrm;
- struct finst *fp;
+ const struct finst *fp;
int mod;
struct i_addr address;
- char * name;
+ const char * name;
get_value_inc(regmodrm, loc, 1, FALSE);
fp = &db_Esc_inst[inst - 0xd8][f_reg(regmodrm)];
@@ -1075,8 +1095,8 @@ db_disasm(loc, altfmt)
int size;
int short_addr;
char * seg;
- struct inst * ip;
- char * i_name;
+ const struct inst * ip;
+ const char * i_name;
int i_size;
int i_mode;
int regmodrm = 0;
OpenPOWER on IntegriCloud