Module Name: src
Committed By: mrg
Date: Mon Aug 17 03:14:09 UTC 2020
Modified Files:
src/sys/arch/mips/include: mips_opcode.h
src/sys/arch/mips/mips: db_disasm.c
Log Message:
add a "special3 offset" type of decode to ddb disasm so we see the
offsets properly decoded. add mips r6 "cache" insn.
avoid signed/unsigned compare and ufetch_32() for upcoming crash(8).
To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/mips/include/mips_opcode.h
cvs rdiff -u -r1.32 -r1.33 src/sys/arch/mips/mips/db_disasm.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/mips/include/mips_opcode.h
diff -u src/sys/arch/mips/include/mips_opcode.h:1.23 src/sys/arch/mips/include/mips_opcode.h:1.24
--- src/sys/arch/mips/include/mips_opcode.h:1.23 Sat Aug 15 04:27:28 2020
+++ src/sys/arch/mips/include/mips_opcode.h Mon Aug 17 03:14:08 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: mips_opcode.h,v 1.23 2020/08/15 04:27:28 simonb Exp $ */
+/* $NetBSD: mips_opcode.h,v 1.24 2020/08/17 03:14:08 mrg Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -79,6 +79,16 @@ typedef union {
unsigned : 1; /* always '1' */
unsigned op: 6; /* always '0x11' */
} FRType;
+
+ struct {
+ unsigned func: 6;
+ unsigned zero: 1; /* always '0' */
+ unsigned offset: 9;
+ unsigned rt: 5;
+ unsigned rs: 5;
+ unsigned op: 6;
+ } S3OType; /* has "special3 offset" type */
+
#endif
#if BYTE_ORDER == BIG_ENDIAN
struct {
@@ -111,6 +121,16 @@ typedef union {
unsigned fd: 5;
unsigned func: 6;
} FRType;
+
+ struct {
+ unsigned op: 6;
+ unsigned rs: 5;
+ unsigned rt: 5;
+ unsigned offset: 9;
+ unsigned zero: 1; /* always '0' */
+ unsigned func: 6;
+ } S3OType; /* has "special3 offset" type */
+
#endif
} InstFmt;
@@ -323,6 +343,7 @@ typedef union {
#define OP_SWRE 042 /* EVA */
#define OP_PREFE 043 /* EVA */
#define OP_DBSHFL 044 /* MIPS32/64 r2 */
+#define OP_CACHE_R6 045 /* MIPS32/64 r6 */
#define OP_LBUE 050 /* EVA */
#define OP_LHUE 051 /* EVA */
#define OP_LBE 054 /* EVA */
Index: src/sys/arch/mips/mips/db_disasm.c
diff -u src/sys/arch/mips/mips/db_disasm.c:1.32 src/sys/arch/mips/mips/db_disasm.c:1.33
--- src/sys/arch/mips/mips/db_disasm.c:1.32 Sat Apr 6 03:06:26 2019
+++ src/sys/arch/mips/mips/db_disasm.c Mon Aug 17 03:14:08 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: db_disasm.c,v 1.32 2019/04/06 03:06:26 thorpej Exp $ */
+/* $NetBSD: db_disasm.c,v 1.33 2020/08/17 03:14:08 mrg Exp $ */
/*-
* Copyright (c) 1991, 1993
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: db_disasm.c,v 1.32 2019/04/06 03:06:26 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_disasm.c,v 1.33 2020/08/17 03:14:08 mrg Exp $");
#include <sys/param.h>
#include <sys/cpu.h>
@@ -47,6 +47,7 @@ __KERNEL_RCSID(0, "$NetBSD: db_disasm.c,
#include <machine/db_machdep.h>
+#include <ddb/db_user.h>
#include <ddb/db_interface.h>
#include <ddb/db_output.h>
#include <ddb/db_extern.h>
@@ -131,6 +132,7 @@ static const char * const spec3_name[64]
[OP_SWRE] = "swre",
[OP_PREFE] = "prefe",
[OP_DBSHFL] = "dbshfl",
+ [OP_CACHE_R6] = "cache",
[OP_LBUE] = "lbue",
[OP_LHUE] = "lhue",
[OP_LBE] = "lbe",
@@ -225,11 +227,15 @@ db_disasm(db_addr_t loc, bool altfmt)
* Take some care with addresses to not UTLB here as it
* loses the current debugging context. KSEG2 not checked.
*/
- if (loc < MIPS_KSEG0_START) {
+ if (loc < (db_addr_t)MIPS_KSEG0_START) {
+#ifdef _KERNEL
if (ufetch_32((void *)loc, &instr) != 0) {
db_printf("invalid address.\n");
return loc;
}
+#else
+ return loc;
+#endif
} else {
instr = *(uint32_t *)loc;
}
@@ -507,10 +513,37 @@ db_disasm_insn(int insn, db_addr_t loc,
}
break;
}
- db_printf("%s\t%s,%s",
- spec3_name[i.RType.func],
- reg_name[i.RType.rs],
- reg_name[i.RType.rt]);
+ switch (i.RType.func) {
+ case OP_LWLE:
+ case OP_LWRE:
+ case OP_CACHEE:
+ case OP_SBE:
+ case OP_SHE:
+ case OP_SCE:
+ case OP_SWE:
+ case OP_SWLE:
+ case OP_SWRE:
+ case OP_PREFE:
+ case OP_CACHE_R6:
+ case OP_LBUE:
+ case OP_LHUE:
+ case OP_LBE:
+ case OP_LHE:
+ case OP_LLE:
+ case OP_LWE:
+ db_printf("%s\t%s,%d(%s)",
+ spec3_name[i.RType.func],
+ reg_name[i.RType.rs],
+ i.S3OType.offset > 255 ?
+ -i.S3OType.offset : i.S3OType.offset,
+ reg_name[i.RType.rt]);
+ break;
+ default:
+ db_printf("%s\t%s,%s",
+ spec3_name[i.RType.func],
+ reg_name[i.RType.rs],
+ reg_name[i.RType.rt]);
+ }
break;
case OP_REGIMM: