Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/mips Tidy up NOP disassembly, handle "pause" as well.



details:   https://anonhg.NetBSD.org/src/rev/08fa54fe0251
branches:  trunk
changeset: 982220:08fa54fe0251
user:      simonb <simonb%NetBSD.org@localhost>
date:      Mon Apr 05 07:00:06 2021 +0000

description:
Tidy up NOP disassembly, handle "pause" as well.

diffstat:

 sys/arch/mips/include/mips_opcode.h |  11 +++++++++-
 sys/arch/mips/mips/db_disasm.c      |  39 +++++++++++++++++++++++++-----------
 2 files changed, 37 insertions(+), 13 deletions(-)

diffs (94 lines):

diff -r 5c349a4332ad -r 08fa54fe0251 sys/arch/mips/include/mips_opcode.h
--- a/sys/arch/mips/include/mips_opcode.h       Mon Apr 05 06:56:47 2021 +0000
+++ b/sys/arch/mips/include/mips_opcode.h       Mon Apr 05 07:00:06 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mips_opcode.h,v 1.24 2020/08/17 03:14:08 mrg Exp $     */
+/*     $NetBSD: mips_opcode.h,v 1.25 2021/04/05 07:00:06 simonb Exp $  */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -292,6 +292,15 @@
 #define        OP_DSRA32       077             /* MIPS-II, for r4000 port */
 
 /*
+ * Subvalues for SLL where the source and destination registers
+ * are both zero.
+ */
+#define        OP_SLL_NOP      0
+#define        OP_SLL_SSNOP    1
+#define        OP_SLL_EHB      3
+#define        OP_SLL_PAUSE    5
+
+/*
  * Values for the 'func' field when 'op' == OP_SPECIAL2.
  */
 #define        OP_MADD         000             /* QED */
diff -r 5c349a4332ad -r 08fa54fe0251 sys/arch/mips/mips/db_disasm.c
--- a/sys/arch/mips/mips/db_disasm.c    Mon Apr 05 06:56:47 2021 +0000
+++ b/sys/arch/mips/mips/db_disasm.c    Mon Apr 05 07:00:06 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: db_disasm.c,v 1.37 2021/04/05 06:38:01 simonb Exp $    */
+/*     $NetBSD: db_disasm.c,v 1.38 2021/04/05 07:00:06 simonb Exp $    */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: db_disasm.c,v 1.37 2021/04/05 06:38:01 simonb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_disasm.c,v 1.38 2021/04/05 07:00:06 simonb Exp $");
 
 #include <sys/param.h>
 #include <sys/cpu.h>
@@ -265,18 +265,32 @@
        switch (i.JType.op) {
        case OP_SPECIAL: {
                const char *name = spec_name[i.RType.func];
-               if (i.word == 0) {
-                       db_printf("nop");
+
+               /* Handle varations of NOPs */
+               if ((i.RType.func == OP_SLL) &&
+                   (i.RType.rs == 0) &&
+                   (i.RType.rt == 0) &&
+                   (i.RType.rd == 0)) {
+                       switch (i.RType.shamt) {
+                       case OP_SLL_NOP:
+                               db_printf("nop");
+                               break;
+                       case OP_SLL_SSNOP:
+                               db_printf("ssnop");
+                               break;
+                       case OP_SLL_EHB:
+                               db_printf("ehb");
+                               break;
+                       case OP_SLL_PAUSE:
+                               db_printf("pause");
+                               break;
+                       default:
+                               db_printf("nop *");     /* "undefined" NOP */
+                               break;
+                       }
                        break;
                }
-               if (i.word == (1 << 6)) {
-                       db_printf("ssnop");
-                       break;
-               }
-               if (i.word == (3 << 6)) {
-                       db_printf("ehb");
-                       break;
-               }
+
                /*
                 * The following are equivalents of a "move dst,src":
                 *      addu    dst,src,zero    (in 32-bit mode)
@@ -296,6 +310,7 @@
                            reg_name[i.RType.rs]);
                        break;
                }
+
                if ((i.RType.func == OP_SRL || i.RType.func == OP_SRLV)
                    && i.RType.rs == 1) {
                        name = (i.RType.func == OP_SRL) ? "rotr" : "rotrv";



Home | Main Index | Thread Index | Old Index