Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/arc/arc Moved from /cvsroot/syssrc/sys/arch/pica/pi...



details:   https://anonhg.NetBSD.org/src/rev/cfb1cb0fcbd5
branches:  trunk
changeset: 481110:cfb1cb0fcbd5
user:      soda <soda%NetBSD.org@localhost>
date:      Sun Jan 23 20:09:14 2000 +0000

description:
Moved from /cvsroot/syssrc/sys/arch/pica/pica/minidebug.c,v

diffstat:

 sys/arch/arc/arc/minidebug.c |  1111 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 1111 insertions(+), 0 deletions(-)

diffs (truncated from 1115 to 300 lines):

diff -r bdb97db4e8c8 -r cfb1cb0fcbd5 sys/arch/arc/arc/minidebug.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/arc/arc/minidebug.c      Sun Jan 23 20:09:14 2000 +0000
@@ -0,0 +1,1111 @@
+/*     $NetBSD: minidebug.c,v 1.6 2000/01/23 20:09:15 soda Exp $       */
+
+/*-
+ * Copyright (c) 1991, 1993
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Ralph Campbell.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions 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.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *     from: @(#)kadb.c        8.1 (Berkeley) 6/10/93
+ */
+
+/*
+ * Define machine dependent primitives for mdb.
+ */
+
+#include <sys/types.h>
+#include <machine/pte.h>
+#include <vm/vm_prot.h>
+#undef SP
+#include <machine/machConst.h>
+#include <machine/reg.h>
+#include <machine/pcb.h>
+#include <machine/trap.h>
+#include <machine/mips_opcode.h>
+
+#ifndef TRUE
+#define TRUE 1
+#define FALSE 0
+#endif
+
+void pica_dump_tlb(int, int);
+
+static char *op_name[64] = {
+/* 0 */        "spec", "bcond","j",    "jal",  "beq",  "bne",  "blez", "bgtz",
+/* 8 */        "addi", "addiu","slti", "sltiu","andi", "ori",  "xori", "lui",
+/*16 */        "cop0", "cop1", "cop2", "cop3", "beql", "bnel", "blezl","bgtzl",
+/*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",
+/*48 */        "ll",   "lwc1", "lwc2", "lwc3", "lld",  "ldc1", "ldc2", "ld",
+/*56 */        "sc",   "swc1", "swc2", "swc3", "scd",  "sdc1", "sdc2", "sd"
+};
+
+static char *spec_name[64] = {
+/* 0 */        "sll",  "spec01","srl", "sra",  "sllv", "spec05","srlv","srav",
+/* 8 */        "jr",   "jalr", "spec12","spec13","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",
+/*40 */        "spec50","spec51","slt","sltu", "dadd","daddu","dsub","dsubu",
+/*48 */        "tge","tgeu","tlt","tltu","teq","spec65","tne","spec67",
+/*56 */        "dsll","spec71","dsrl","dsra","dsll32","spec75","dsrl32","dsra32"
+};
+
+static char *bcond_name[32] = {
+/* 0 */        "bltz", "bgez", "bltzl", "bgezl", "?", "?", "?", "?",
+/* 8 */        "tgei", "tgeiu", "tlti", "tltiu", "teqi", "?", "tnei", "?",
+/*16 */        "bltzal", "bgezal", "bltzall", "bgezall", "?", "?", "?", "?",
+/*24 */        "?", "?", "?", "?", "?", "?", "?", "?",
+};
+
+static char *cop1_name[64] = {
+/* 0 */        "fadd", "fsub", "fmpy", "fdiv", "fsqrt","fabs", "fmov", "fneg",
+/* 8 */        "fop08","fop09","fop0a","fop0b","fop0c","fop0d","fop0e","fop0f",
+/*16 */        "fop10","fop11","fop12","fop13","fop14","fop15","fop16","fop17",
+/*24 */        "fop18","fop19","fop1a","fop1b","fop1c","fop1d","fop1e","fop1f",
+/*32 */        "fcvts","fcvtd","fcvte","fop23","fcvtw","fop25","fop26","fop27",
+/*40 */        "fop28","fop29","fop2a","fop2b","fop2c","fop2d","fop2e","fop2f",
+/*48 */        "fcmp.f","fcmp.un","fcmp.eq","fcmp.ueq","fcmp.olt","fcmp.ult",
+       "fcmp.ole","fcmp.ule",
+/*56 */        "fcmp.sf","fcmp.ngle","fcmp.seq","fcmp.ngl","fcmp.lt","fcmp.nge",
+       "fcmp.le","fcmp.ngt"
+};
+
+static char *fmt_name[16] = {
+       "s",    "d",    "e",    "fmt3",
+       "w",    "fmt5", "fmt6", "fmt7",
+       "fmt8", "fmt9", "fmta", "fmtb",
+       "fmtc", "fmtd", "fmte", "fmtf"
+};
+
+static char *reg_name[32] = {
+       "zero", "at",   "v0",   "v1",   "a0",   "a1",   "a2",   "a3",
+       "t0",   "t1",   "t2",   "t3",   "t4",   "t5",   "t6",   "t7",
+       "s0",   "s1",   "s2",   "s3",   "s4",   "s5",   "s6",   "s7",
+       "t8",   "t9",   "k0",   "k1",   "gp",   "sp",   "s8",   "ra"
+};
+
+static char *c0_opname[64] = {
+       "c0op00","tlbr",  "tlbwi", "c0op03","c0op04","c0op05","tlbwr", "c0op07",
+       "tlbp",  "c0op11","c0op12","c0op13","c0op14","c0op15","c0op16","c0op17",
+       "rfe",   "c0op21","c0op22","c0op23","c0op24","c0op25","c0op26","c0op27",
+       "eret","c0op31","c0op32","c0op33","c0op34","c0op35","c0op36","c0op37",
+       "c0op40","c0op41","c0op42","c0op43","c0op44","c0op45","c0op46","c0op47",
+       "c0op50","c0op51","c0op52","c0op53","c0op54","c0op55","c0op56","c0op57",
+       "c0op60","c0op61","c0op62","c0op63","c0op64","c0op65","c0op66","c0op67",
+       "c0op70","c0op71","c0op72","c0op73","c0op74","c0op75","c0op77","c0op77",
+};
+
+static char *c0_reg[32] = {
+       "index","random","tlblo0","tlblo1","context","tlbmask","wired","c0r7",
+       "badvaddr","count","tlbhi","c0r11","sr","cause","epc",  "prid",
+       "config","lladr","watchlo","watchhi","xcontext","c0r21","c0r22","c0r23",
+       "c0r24","c0r25","ecc","cacheerr","taglo","taghi","errepc","c0r31"
+};
+
+extern char *trap_type[];
+
+struct pcb mdbpcb;
+int mdbmkfault;
+
+#define MAXBRK 10
+struct brk {
+       int     inst;
+       int     addr;
+} brk_tab[MAXBRK];
+
+/*
+ * Mini debugger for kernel.
+ */
+int gethex(u_int *val, u_int dotval)
+{
+       u_int c;
+
+       *val = 0;
+       while((c = cngetc()) != '\e' && c != '\n') {
+               if(c >= '0' && c <= '9') {
+                       *val = (*val << 4) + c - '0';
+                       cnputc(c);
+               }
+               else if(c >= 'a' && c <= 'f') {
+                       *val = (*val << 4) + c - 'a' + 10;
+                       cnputc(c);
+               }
+               else if(c == '\b') {
+                       *val = *val >> 4;
+                       printf("\b \b");
+               }
+               else if(c == ',') {
+                       cnputc(c);
+                       return(c);
+               }
+               else if(c == '.') {
+                       *val = dotval;;
+                       cnputc(c);
+               }
+       }
+       return(c);
+}
+
+void dump(u_int *addr, u_int size)
+{
+       int     cnt;
+
+       cnt = 0;
+
+       size = (size + 3) / 4;
+       while(size--) {
+               if((cnt++ & 3) == 0)
+                       printf("\n%08x: ",(int)addr);
+               printf("%08x ",*addr++);
+       }
+}
+
+void print_regs()
+{
+       printf("\n");
+       printf("T0-7 %08x %08x %08x %08x %08x %08x %08x %08x\n",
+               mdbpcb.pcb_regs[T0],mdbpcb.pcb_regs[T1],
+               mdbpcb.pcb_regs[T2],mdbpcb.pcb_regs[T3],
+               mdbpcb.pcb_regs[T4],mdbpcb.pcb_regs[T5],
+               mdbpcb.pcb_regs[T6],mdbpcb.pcb_regs[T7]);
+       printf("T8-9 %08x %08x     A0-4 %08x %08x %08x %08x\n",
+               mdbpcb.pcb_regs[T8],mdbpcb.pcb_regs[T9],
+               mdbpcb.pcb_regs[A0],mdbpcb.pcb_regs[A1],
+               mdbpcb.pcb_regs[A2],mdbpcb.pcb_regs[A3]);
+       printf("S0-7 %08x %08x %08x %08x %08x %08x %08x %08x\n",
+               mdbpcb.pcb_regs[S0],mdbpcb.pcb_regs[S1],
+               mdbpcb.pcb_regs[S2],mdbpcb.pcb_regs[S3],
+               mdbpcb.pcb_regs[S4],mdbpcb.pcb_regs[S5],
+               mdbpcb.pcb_regs[S6],mdbpcb.pcb_regs[S7]);
+       printf("  S8 %08x     V0-1 %08x %08x       GP %08x       SP %08x\n",
+               mdbpcb.pcb_regs[S8],mdbpcb.pcb_regs[V0],
+               mdbpcb.pcb_regs[V1],mdbpcb.pcb_regs[GP],
+               mdbpcb.pcb_regs[SP]);
+       printf("  AT %08x       PC %08x       RA %08x       SR %08x",
+               mdbpcb.pcb_regs[AST],mdbpcb.pcb_regs[PC],
+               mdbpcb.pcb_regs[RA],mdbpcb.pcb_regs[SR]);
+}
+
+set_break(va)
+{
+       int i;
+
+       va = va & ~3;
+       for(i = 0; i < MAXBRK; i++) {
+               if(brk_tab[i].addr == 0) {
+                       brk_tab[i].addr = va;
+                       brk_tab[i].inst = *(u_int *)va;
+                       return;
+               }
+       }
+       printf(" Break table full!!");
+}
+
+del_break(va)
+{
+       int i;
+
+       va = va & ~3;
+       for(i = 0; i < MAXBRK; i++) {
+               if(brk_tab[i].addr == va) {
+                       brk_tab[i].addr = 0;
+                       return;
+               }
+       }
+       printf(" Break to remove not found!!");
+}
+
+break_insert()
+{
+       int i;
+
+       for(i = 0; i < MAXBRK; i++) {
+               if(brk_tab[i].addr != 0) {
+                       brk_tab[i].inst = *(u_int *)brk_tab[i].addr;
+                       *(u_int *)brk_tab[i].addr = MIPS_BREAK_BRKPT;
+                       MachFlushDCache(brk_tab[i].addr,4);
+                       MachFlushICache(brk_tab[i].addr,4);
+               }
+       }
+}
+
+break_restore()
+{
+       int i;
+
+       for(i = 0; i < MAXBRK; i++) {
+               if(brk_tab[i].addr != 0) {
+                       *(u_int *)brk_tab[i].addr = brk_tab[i].inst;
+                       MachFlushDCache(brk_tab[i].addr,4);
+                       MachFlushICache(brk_tab[i].addr,4);
+               }
+       }
+}
+
+break_find(va)
+{
+       int i;
+
+       for(i = 0; i < MAXBRK; i++) {
+               if(brk_tab[i].addr == va) {
+                       return(i);
+               }
+       }
+       return(-1);
+}
+
+prt_break()
+{
+       int i;
+
+       for(i = 0; i < MAXBRK; i++) {
+               if(brk_tab[i].addr != 0) {
+                       printf("\n    %08x\t", brk_tab[i].addr);
+                       mdbprintins(brk_tab[i].inst, brk_tab[i].addr);
+               }



Home | Main Index | Thread Index | Old Index