Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/powerpc Build for kgdb as well as for ddb (mutually...
details: https://anonhg.NetBSD.org/src/rev/db3fea68d703
branches: trunk
changeset: 511486:db3fea68d703
user: briggs <briggs%NetBSD.org@localhost>
date: Wed Jun 20 02:40:14 2001 +0000
description:
Build for kgdb as well as for ddb (mutually exclusive).
diffstat:
sys/arch/powerpc/conf/files.powerpc | 7 +-
sys/arch/powerpc/include/db_machdep.h | 24 +++-
sys/arch/powerpc/powerpc/kgdb_machdep.c | 231 ++++++++++++++++++++++++++++++++
3 files changed, 258 insertions(+), 4 deletions(-)
diffs (truncated from 302 to 300 lines):
diff -r 0e8bcf20245f -r db3fea68d703 sys/arch/powerpc/conf/files.powerpc
--- a/sys/arch/powerpc/conf/files.powerpc Wed Jun 20 02:34:26 2001 +0000
+++ b/sys/arch/powerpc/conf/files.powerpc Wed Jun 20 02:40:14 2001 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.powerpc,v 1.21 2001/06/17 19:32:17 tsubai Exp $
+# $NetBSD: files.powerpc,v 1.22 2001/06/20 02:40:14 briggs Exp $
defopt opt_altivec.h ALTIVEC K_ALTIVEC
defopt OPENPIC
defopt opt_ppcarch.h PPC_MPC6XX PPC_MPC8XX PPC_IBM4XX
@@ -10,6 +10,7 @@
file arch/powerpc/powerpc/fuswintr.c
file arch/powerpc/powerpc/in_cksum.c
file arch/powerpc/powerpc/ipkdb_glue.c ipkdb
+file arch/powerpc/powerpc/kgdb_machdep.c kgdb
file arch/powerpc/powerpc/mem.c
file arch/powerpc/powerpc/openpic.c openpic
file arch/powerpc/powerpc/powerpc_machdep.c
@@ -21,8 +22,8 @@
file arch/powerpc/powerpc/suswintr.c
file arch/powerpc/powerpc/sys_machdep.c
file arch/powerpc/powerpc/vm_machdep.c
-file arch/powerpc/powerpc/setjmp.S ddb
-file arch/powerpc/powerpc/db_memrw.c ddb
+file arch/powerpc/powerpc/setjmp.S ddb | kgdb
+file arch/powerpc/powerpc/db_memrw.c ddb | kgdb
file arch/powerpc/powerpc/db_disasm.c ddb
file arch/powerpc/powerpc/db_interface.c ddb
file arch/powerpc/powerpc/db_trace.c ddb
diff -r 0e8bcf20245f -r db3fea68d703 sys/arch/powerpc/include/db_machdep.h
--- a/sys/arch/powerpc/include/db_machdep.h Wed Jun 20 02:34:26 2001 +0000
+++ b/sys/arch/powerpc/include/db_machdep.h Wed Jun 20 02:40:14 2001 +0000
@@ -1,5 +1,5 @@
/* $OpenBSD: db_machdep.h,v 1.2 1997/03/21 00:48:48 niklas Exp $ */
-/* $NetBSD: db_machdep.h,v 1.9 2001/06/13 06:01:48 simonb Exp $ */
+/* $NetBSD: db_machdep.h,v 1.10 2001/06/20 02:40:14 briggs Exp $ */
/*
* Mach Operating System
@@ -101,6 +101,28 @@
#define inst_load(ins) 0
#define inst_store(ins) 0
+/*
+ * GDB's register array is:
+ * 32 4-byte GPRs
+ * 32 8-byte FPRs
+ * 7 4-byte UISA special-purpose registers
+ * 16 4-byte segment registers
+ * 32 4-byte standard OEA special-purpose registers,
+ * and up to 64 4-byte non-standard OES special-purpose registers.
+ * GDB keeps some extra space, so the total size of the register array
+ * they use is 880 bytes (gdb-5.0).
+ */
+typedef long kgdb_reg_t;
+#define KGDB_NUMREGS 220 /* Treat all registers as 4-byte */
+#define KGDB_BUFLEN 512
+#define KGDB_PPC_PC_REG 96 /* first UISA SP register */
+#define KGDB_PPC_MSR_REG 97
+#define KGDB_PPC_CR_REG 98
+#define KGDB_PPC_LR_REG 99
+#define KGDB_PPC_CTR_REG 100
+#define KGDB_PPC_XER_REG 101
+#define KGDB_PPC_MQ_REG 102
+
#ifdef _KERNEL
void kdb_kintr __P((void *));
diff -r 0e8bcf20245f -r db3fea68d703 sys/arch/powerpc/powerpc/kgdb_machdep.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/powerpc/powerpc/kgdb_machdep.c Wed Jun 20 02:40:14 2001 +0000
@@ -0,0 +1,231 @@
+/* $NetBSD: kgdb_machdep.c,v 1.1 2001/06/20 02:40:14 briggs Exp $ */
+
+/*
+ * Copyright 2001 Wasabi Systems, Inc.
+ * All rights reserved.
+ *
+ * Written by Allen Briggs for Wasabi Systems, Inc.
+ *
+ * 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 for the NetBSD Project by
+ * Wasabi Systems, Inc.
+ * 4. The name of Wasabi Systems, Inc. may not be used to endorse
+ * or promote products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``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 WASABI SYSTEMS, INC
+ * 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.
+ */
+
+#include "opt_ddb.h"
+
+#if defined(DDB)
+#error "Can't build DDB and KGDB together."
+#endif
+
+/*
+ * Machine-dependent functions for remote KGDB.
+ */
+
+#include <sys/param.h>
+#include <sys/kgdb.h>
+#include <sys/systm.h>
+
+#include <uvm/uvm_extern.h>
+
+#include <machine/reg.h>
+#include <machine/trap.h>
+#include <machine/pmap.h>
+
+/*
+ * Determine if the memory at va..(va+len) is valid.
+ */
+int
+kgdb_acc(vaddr_t va, size_t len)
+{
+ vaddr_t last_va;
+ paddr_t pa;
+ boolean_t v;
+
+ last_va = va + len;
+ va &= ~PGOFSET;
+ last_va &= ~PGOFSET;
+
+ do {
+ /*
+ * I think this should be able to handle
+ * non-pmap_kernel() va's, too.
+ */
+ if (!pmap_extract(pmap_kernel(), va, &pa))
+ return 0;
+ va += PAGE_SIZE;
+ } while (va <= last_va);
+
+ return (1);
+}
+
+/*
+ * Translate a trap number into a unix compatible signal value.
+ * (gdb only understands unix signal numbers). Some of these are bogus
+ * and should be reviewed.
+ */
+int
+kgdb_signal(type)
+ int type;
+{
+ switch (type) {
+#ifdef PPC_IBM4XX
+ case EXC_PIT: /* 40x - Programmable interval timer */
+ case EXC_FIT: /* 40x - Fixed interval timer */
+ return SIGALRM
+
+ case EXC_CII: /* 40x - Critical input interrupt */
+ case EXC_WDOG: /* 40x - Watchdog timer */
+ case EXC_DEBUG: /* 40x - Debug trap */
+ return SIGTRAP;
+
+ case EXC_DTMISS: /* 40x - Instruction TLB miss */
+ case EXC_ITMISS: /* 40x - Data TLB miss */
+ return SIGSEGV;
+#endif
+
+#ifdef PPC_MPC6XX
+ case EXC_PERF: /* 604/750/7400 - Performance monitoring */
+ case EXC_BPT: /* 604/750/7400 - Instruction breakpoint */
+ case EXC_SMI: /* 604/750/7400 - System management interrupt */
+ case EXC_THRM: /* 750/7400 - Thermal management interrupt */
+ return SIGTRAP;
+
+ case EXC_IMISS: /* 603 - Instruction translation miss */
+ case EXC_DLMISS: /* 603 - Data load translation miss */
+ case EXC_DSMISS: /* 603 - Data store translation miss */
+ return SIGSEGV;
+
+ case EXC_RST: /* All but IBM 4xx - Reset */
+ return SIGURG;
+
+ case EXC_VEC: /* 7400 - Altivec unavailable */
+ case EXC_VECAST: /* 7400 - Altivec assist */
+ return SIGFPE;
+#endif
+
+ case EXC_DECR: /* Decrementer interrupt */
+ return SIGALRM;
+
+ case EXC_EXI: /* External interrupt */
+ return SIGINT;
+
+ case EXC_PGM: /* Program interrupt */
+ case EXC_ALI: /* Alignment */
+ return SIGILL;
+
+ case EXC_MCHK: /* Machine check */
+ case EXC_TRC: /* Trace */
+ return SIGTRAP;
+
+ case EXC_ISI: /* Instruction storage interrupt */
+ case EXC_DSI: /* Data storage interrupt */
+ return SIGSEGV;
+
+ case EXC_FPU: /* Floating point unavailable */
+ case EXC_FPA: /* Floating-point assist */
+ return SIGFPE;
+
+ case EXC_SC: /* System call */
+ return SIGURG;
+
+ case EXC_RSVD: /* Reserved */
+ case EXC_AST: /* Floating point unavailable */
+ default:
+ return SIGEMT;
+ }
+}
+
+/*
+ * Translate the values stored in the kernel regs struct to the format
+ * understood by gdb.
+ */
+void
+kgdb_getregs(regs, gdb_regs)
+ db_regs_t *regs;
+ kgdb_reg_t *gdb_regs;
+{
+ memcpy(gdb_regs, regs, 32 * sizeof(unsigned long));
+ gdb_regs[KGDB_PPC_PC_REG] = regs->iar;
+ gdb_regs[KGDB_PPC_MSR_REG] = regs->msr;
+ gdb_regs[KGDB_PPC_CR_REG] = regs->cr;
+ gdb_regs[KGDB_PPC_LR_REG] = regs->lr;
+ gdb_regs[KGDB_PPC_CTR_REG] = regs->ctr;
+ gdb_regs[KGDB_PPC_XER_REG] = regs->xer;
+}
+
+/*
+ * Reverse the above.
+ */
+void
+kgdb_setregs(regs, gdb_regs)
+ db_regs_t *regs;
+ kgdb_reg_t *gdb_regs;
+{
+ regs->xer = gdb_regs[KGDB_PPC_XER_REG];
+ regs->ctr = gdb_regs[KGDB_PPC_CTR_REG];
+ regs->lr = gdb_regs[KGDB_PPC_LR_REG];
+ regs->cr = gdb_regs[KGDB_PPC_CR_REG];
+ regs->msr = gdb_regs[KGDB_PPC_MSR_REG];
+ regs->iar = gdb_regs[KGDB_PPC_PC_REG];
+ memcpy(regs, gdb_regs, 32 * sizeof(unsigned long));
+}
+
+/*
+ * Trap into kgdb to wait for debugger to connect,
+ * noting on the console why nothing else is going on.
+ */
+void
+kgdb_connect(verbose)
+ int verbose;
+{
+
+ if (kgdb_dev < 0)
+ return;
+
+ if (verbose)
+ printf("kgdb waiting...");
+
+ __asm __volatile("tweq 1,1");
+
+ if (verbose)
+ printf("connected.\n");
+
+ kgdb_debug_panic = 1;
+}
+
+/*
+ * Decide what to do on panic.
+ * (This is called by panic, like Debugger())
+ */
+void
+kgdb_panic()
+{
+ if (kgdb_dev >= 0 && kgdb_debug_panic) {
+ printf("entering kgdb\n");
+ kgdb_connect(kgdb_active == 0);
Home |
Main Index |
Thread Index |
Old Index