Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/mips Add a lot of missing mipsNNr2 instruction + ca...



details:   https://anonhg.NetBSD.org/src/rev/cc24f4b0c0c3
branches:  trunk
changeset: 338685:cc24f4b0c0c3
user:      matt <matt%NetBSD.org@localhost>
date:      Thu Jun 04 02:26:49 2015 +0000

description:
Add a lot of missing mipsNNr2 instruction + cavium specific instructions.

diffstat:

 sys/arch/mips/include/mips_opcode.h |   53 +++++++-
 sys/arch/mips/mips/db_disasm.c      |  247 ++++++++++++++++++++++++++++++++++-
 2 files changed, 284 insertions(+), 16 deletions(-)

diffs (truncated from 445 to 300 lines):

diff -r cd699430abe6 -r cc24f4b0c0c3 sys/arch/mips/include/mips_opcode.h
--- a/sys/arch/mips/include/mips_opcode.h       Thu Jun 04 01:58:30 2015 +0000
+++ b/sys/arch/mips/include/mips_opcode.h       Thu Jun 04 02:26:49 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mips_opcode.h,v 1.19 2015/06/01 22:55:13 matt Exp $    */
+/*     $NetBSD: mips_opcode.h,v 1.20 2015/06/04 02:26:49 matt Exp $    */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -179,7 +179,10 @@
 #define OP_PREF                063
 #define OP_LLD         064             /* MIPS-II, for r4000 port */
 #define OP_LDC1                065
+#define OP_LDC2                066
 #define OP_LD          067             /* MIPS-II, for r4000 port */
+#define OP_CVM_BBIT0   OP_LWC2
+#define OP_CVM_BBIT032 OP_LDC2
 
 #define OP_SC          070
 #define OP_SWC0                OP_SC   /* backwards source compatibility */
@@ -188,7 +191,10 @@
 #define OP_RSVD073     073
 #define OP_SCD         074             /* MIPS-II, for r4000 port */
 #define OP_SDC1                075
+#define OP_SDC2                076
 #define OP_SD          077             /* MIPS-II, for r4000 port */
+#define OP_CVM_BBIT1   OP_SWC2
+#define OP_CVM_BBIT132 OP_SDC2
 
 /*
  * Values for the 'func' field when 'op' == OP_SPECIAL.
@@ -206,6 +212,16 @@
 #define OP_BREAK       015
 #define OP_SYNC                017             /* MIPS-II, for r4000 port */
 
+#define SYNC_CVM_IODBDMA       0x02
+#define SYNC_WMB       0x04
+#define SYNC_CVM_W     SYNC_WMB
+#define SYNC_CVM_WS    0x05
+#define SYNC_CVM_S     0x06
+#define SYNC_MB                0x10
+#define SYNC_ACQUIRE   0x11
+#define SYNC_RELEASE   0x12
+#define SYNC_RMB       0x13
+
 #define OP_MFHI                020
 #define OP_MTHI                021
 #define OP_MFLO                022
@@ -256,22 +272,52 @@
 /*
  * Values for the 'func' field when 'op' == OP_SPECIAL2.
  */
-#define OP_MAD         000             /* QED */
-#define OP_MADU                001             /* QED */
+#define OP_MADD                000             /* QED */
+#define OP_MADDU       001             /* QED */
 #define OP_MUL         002             /* QED */
+#define        OP_CVM_DMUL     003             /* OCTEON */
 #define OP_MSUB                004             /* MIPS32/64 */
 #define OP_MSUBU       005             /* MIPS32/64 */
+#define        OP_CVM_SAA      030             /* OCTEON */
+#define        OP_CVM_SAAD     031             /* OCTEON */
 #define OP_CLZ         040             /* MIPS32/64 */
 #define OP_CLO         041             /* MIPS32/64 */
 #define OP_DCLZ                044             /* MIPS32/64 */
 #define OP_DCLO                045             /* MIPS32/64 */
+#define        OP_CVM_BADDU    050             /* OCTEON */
+#define        OP_CVM_SEQ      052             /* OCTEON */
+#define        OP_CVM_SNE      053             /* OCTEON */
+#define        OP_CVM_SEQI     056             /* OCTEON */
+#define        OP_CVM_SNEI     057             /* OCTEON */
+#define        OP_CVM_POP      054             /* OCTEON */
+#define        OP_CVM_DPOP     055             /* OCTEON */
+#define        OP_CVM_CINS     062             /* OCTEON */
+#define        OP_CVM_CINS32   063             /* OCTEON */
+#define        OP_CVM_EXTS     072             /* OCTEON */
+#define        OP_CVM_EXTS32   073             /* OCTEON */
+#define        OP_SDBBP        077             /* MIPS32/MIPS64 */
 
 /*
  * Values for the 'func' field when 'op' == OP_SPECIAL3.
  */
+#define OP_EXT         000             /* MIPS32/64 r2 */
+#define OP_DEXTM       001             /* MIPS32/64 r2 */
+#define OP_DEXTU       002             /* MIPS32/64 r2 */
+#define OP_DEXT                003             /* MIPS32/64 r2 */
+#define OP_INS         004             /* MIPS32/64 r2 */
+#define OP_DINSM       005             /* MIPS32/64 r2 */
+#define OP_DINSU       006             /* MIPS32/64 r2 */
+#define OP_DINS                007             /* MIPS32/64 r2 */
 #define        OP_LX           012             /* DSP */
+#define OP_BSHFL       040             /* MIPS32/64 r2 */
+#define OP_DBSHFL      044             /* MIPS32/64 r2 */
 #define OP_RDHWR       073             /* MIPS32/64 r2 */
 
+#define OP_BSHFL_SBH   2               /* swap bytes within halfwords */
+#define OP_BSHFL_SHD   4               /* swap halfworks within double */
+#define OP_BSHFL_SEB   16              /* sign extend byte */
+#define OP_BSHFL_SEH   24              /* sign extend halfword */
+
 #define        OP_LX_LWX       0               /* lwx */
 #define        OP_LX_LHX       4               /* lhx */
 #define        OP_LX_LBUX      6               /* lbux */
@@ -309,6 +355,7 @@
 #define OP_CT          006
 #define OP_MTH         007
 #define OP_BCx         010
+#define OP_MFM         013             /* MIPS32/64 r2 */
 #define OP_BCy         014
 
 /*
diff -r cd699430abe6 -r cc24f4b0c0c3 sys/arch/mips/mips/db_disasm.c
--- a/sys/arch/mips/mips/db_disasm.c    Thu Jun 04 01:58:30 2015 +0000
+++ b/sys/arch/mips/mips/db_disasm.c    Thu Jun 04 02:26:49 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: db_disasm.c,v 1.24 2011/08/18 21:04:23 matt Exp $      */
+/*     $NetBSD: db_disasm.c,v 1.25 2015/06/04 02:26:49 matt Exp $      */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: db_disasm.c,v 1.24 2011/08/18 21:04:23 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_disasm.c,v 1.25 2015/06/04 02:26:49 matt Exp $");
 
 #include <sys/param.h>
 #include <sys/cpu.h>
@@ -58,13 +58,18 @@
 /*24 */ "daddi","daddiu","ldl", "ldr", "op34", "op35", "op36", "op37",
 /*32 */ "lb",  "lh",   "lwl",  "lw",   "lbu",  "lhu",  "lwr",  "lwu",
 /*40 */ "sb",  "sh",   "swl",  "sw",   "sdl",  "sdr",  "swr",  "cache",
+#ifdef __OCTEON__
+/*48 */ "ll",  "lwc1", "bbit0", "lwc3", "lld", "ldc1", "bbit032", "ld",
+/*56 */ "sc",  "swc1", "bbit1", "swc3", "scd", "sdc1", "bbit132", "sd"
+#else
 /*48 */ "ll",  "lwc1", "lwc2", "lwc3", "lld",  "ldc1", "ldc2", "ld",
 /*56 */ "sc",  "swc1", "swc2", "swc3", "scd",  "sdc1", "sdc2", "sd"
+#endif
 };
 
 static const char * const spec_name[64] = {
-/* 0 */ "sll", "spec01","srl", "sra",  "sllv", "spec05","srlv","srav",
-/* 8 */ "jr",  "jalr", "spec12","spec13","syscall","break","spec16","sync",
+/* 0 */ "sll", "movc1","srl", "sra",   "sllv", "spec05","srlv","srav",
+/* 8 */ "jr",  "jalr", "movz","movn","syscall","break","spec16","sync",
 /*16 */ "mfhi", "mthi", "mflo", "mtlo", "dsllv","spec25","dsrlv","dsrav",
 /*24 */ "mult", "multu","div", "divu", "dmult","dmultu","ddiv","ddivu",
 /*32 */ "add", "addu", "sub",  "subu", "and",  "or",   "xor",  "nor",
@@ -73,8 +78,49 @@
 /*56 */ "dsll","spec71","dsrl","dsra","dsll32","spec75","dsrl32","dsra32"
 };
 
-static const char * const spec2_name[4] = {            /* QED RM4650, R5000, etc. */
-/* 0 */ "mad", "madu", "mul", "spec3"
+static const char * const spec2_name[64] = {   /* QED RM4650, R5000, etc. */
+       [OP_MADD] = "madd",
+       [OP_MADDU] = "maddu",
+       [OP_MUL] = "mul",
+#ifdef __OCTEON__
+       [OP_CVM_DMUL] = "baddu",
+#endif
+       [OP_MSUB] = "msub",
+       [OP_MSUBU] = "msubu",
+       [OP_CLZ] = "clz",
+       [OP_CLO] = "clo",
+       [OP_DCLZ] = "dclz",
+       [OP_DCLO] = "dclo",
+#ifdef __OCTEON__
+       [OP_CVM_BADDU] = "baddu",
+       [OP_CVM_POP] = "pop",
+       [OP_CVM_DPOP] = "dpop",
+       [OP_CVM_CINS] = "cins",
+       [OP_CVM_CINS32] = "cins32",
+       [OP_CVM_EXTS] = "exts",
+       [OP_CVM_EXTS32] = "exts32",
+       [OP_CVM_SEQ] = "seq",
+       [OP_CVM_SEQI] = "seqi",
+       [OP_CVM_SNE] = "sne",
+       [OP_CVM_SNEI] = "snei",
+       [OP_CVM_SAA] = "saa",
+       [OP_CVM_SAAD] = "saad",
+#endif
+       [OP_SDBBP] = "sdbbp",
+};
+
+static const char * const spec3_name[64] = {
+       [OP_EXT] = "ext",
+       [OP_DEXTM] = "dextm",
+       [OP_DEXTU] = "dextu",
+       [OP_DEXT] = "dext",
+       [OP_INS] = "ins",
+       [OP_DINSM] = "dinsm",
+       [OP_DINSU] = "dinsu",
+       [OP_DINS] = "dins",
+       [OP_BSHFL] = "bshfl",
+       [OP_DBSHFL] = "dbshfl",
+       [OP_RDHWR] = "rdhwr",
 };
 
 static const char * const regimm_name[32] = {
@@ -191,7 +237,8 @@
        i.word = insn;
 
        switch (i.JType.op) {
-       case OP_SPECIAL:
+       case OP_SPECIAL: {
+               const char *name = spec_name[i.RType.func];
                if (i.word == 0) {
                        db_printf("nop");
                        break;
@@ -206,7 +253,15 @@
                            reg_name[i.RType.rs]);
                        break;
                }
-               db_printf("%s", spec_name[i.RType.func]);
+               if ((i.RType.func == OP_SRL || i.RType.func == OP_SRLV)
+                   && i.RType.rs == 1) {
+                       name = (i.RType.func == OP_SRL) ? "rotr" : "rotrv";
+               } else if ((i.RType.func == OP_DSRL || i.RType.func == OP_DSRLV)
+                   && i.RType.shamt == 1) {
+                       name = (i.RType.func == OP_DSRL) ? "drotr" : "drotrv";
+               }
+               
+               db_printf("%s", name);
                switch (i.RType.func) {
                case OP_SLL:
                case OP_SRL:
@@ -266,7 +321,10 @@
 
 
                case OP_SYSCALL:
+                       break;
                case OP_SYNC:
+                       if (i.RType.shamt != 0)
+                               db_printf("\t%d", i.RType.shamt);
                        break;
 
                case OP_BREAK:
@@ -280,20 +338,150 @@
                            reg_name[i.RType.rt]);
                }
                break;
+       }
 
        case OP_SPECIAL2:
-               if (i.RType.func == OP_MUL)
+               if (spec_name[i.RType.func] == NULL) {
+                       db_printf("spec2#%03o\t%s,%s",
+                               i.RType.func,
+                               reg_name[i.RType.rs],
+                               reg_name[i.RType.rt]);
+                       break;
+               }
+               if (i.RType.func == OP_MUL
+#ifdef __OCTEON__
+                   || i.RType.func == OP_CVM_DMUL
+                   || i.RType.func == OP_CVM_SEQ
+                   || i.RType.func == OP_CVM_SNE
+#endif
+                   || false) {
                        db_printf("%s\t%s,%s,%s",
-                               spec2_name[i.RType.func & 0x3],
+                               spec2_name[i.RType.func],
                                reg_name[i.RType.rd],
                                reg_name[i.RType.rs],
                                reg_name[i.RType.rt]);
-               else
+                       break;
+               }
+#ifdef __OCTEON__
+               if (i.RType.func == OP_CVM_CINS
+                   || i.RType.func == OP_CVM_CINS32
+                   || i.RType.func == OP_CVM_EXTS
+                   || i.RType.func == OP_CVM_EXTS32) {
+                       db_printf("%s\t%s,%s,%d,%d",
+                               spec2_name[i.RType.func],
+                               reg_name[i.RType.rt],
+                               reg_name[i.RType.rs],
+                               i.RType.shamt,
+                               i.RType.rd);
+                       break;
+               }
+               if (i.RType.func == OP_CVM_SEQI
+                   || i.RType.func == OP_CVM_SNEI) {
+                       db_printf("%s\t%s,%s,%d",
+                               spec2_name[i.RType.func],
+                               reg_name[i.RType.rs],
+                               reg_name[i.RType.rt],
+                               (short)i.IType.imm >> 6);
+                       break;
+               }
+               if (i.RType.func == OP_CVM_SAA
+                   || i.RType.func == OP_CVM_SAAD) {
+                       db_printf("%s\t%s,(%s)",
+                               spec2_name[i.RType.func],
+                               reg_name[i.RType.rt],
+                               reg_name[i.RType.rs]);
+                       break;



Home | Main Index | Thread Index | Old Index