Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch add support for kgdb over zs
details: https://anonhg.NetBSD.org/src/rev/b49f348fd93c
branches: trunk
changeset: 520251:b49f348fd93c
user: dbj <dbj%NetBSD.org@localhost>
date: Sun Jan 06 00:35:10 2002 +0000
description:
add support for kgdb over zs
diffstat:
sys/arch/macppc/conf/files.macppc | 3 +-
sys/arch/macppc/dev/z8530tty.c | 4 +-
sys/arch/macppc/dev/zs.c | 37 +--
sys/arch/macppc/dev/zs_kgdb.c | 303 ++++++++++++++++++++++++++++++++
sys/arch/macppc/include/z8530var.h | 15 +-
sys/arch/macppc/macppc/locore.S | 3 +-
sys/arch/macppc/macppc/machdep.c | 71 +++++--
sys/arch/powerpc/conf/files.powerpc | 4 +-
sys/arch/powerpc/include/db_machdep.h | 9 +-
sys/arch/powerpc/include/mpc6xx/bat.h | 9 +-
sys/arch/powerpc/powerpc/db_interface.c | 39 +++-
sys/arch/powerpc/powerpc/kgdb_machdep.c | 45 ++++-
sys/arch/powerpc/powerpc/trap_subr.S | 12 +-
13 files changed, 486 insertions(+), 68 deletions(-)
diffs (truncated from 989 to 300 lines):
diff -r f29613e4f8ca -r b49f348fd93c sys/arch/macppc/conf/files.macppc
--- a/sys/arch/macppc/conf/files.macppc Sat Jan 05 22:57:38 2002 +0000
+++ b/sys/arch/macppc/conf/files.macppc Sun Jan 06 00:35:10 2002 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.macppc,v 1.46 2001/08/26 02:47:37 matt Exp $
+# $NetBSD: files.macppc,v 1.47 2002/01/06 00:35:10 dbj Exp $
#
# macppc-specific configuration info
@@ -147,6 +147,7 @@
attach zsc at obio
file arch/macppc/dev/zs.c zsc needs-flag
file dev/ic/z8530sc.c zsc
+file arch/macppc/dev/zs_kgdb.c zsc & kgdb
device zstty: tty
attach zstty at zsc
diff -r f29613e4f8ca -r b49f348fd93c sys/arch/macppc/dev/z8530tty.c
--- a/sys/arch/macppc/dev/z8530tty.c Sat Jan 05 22:57:38 2002 +0000
+++ b/sys/arch/macppc/dev/z8530tty.c Sun Jan 06 00:35:10 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: z8530tty.c,v 1.10 2001/06/20 02:01:56 briggs Exp $ */
+/* $NetBSD: z8530tty.c,v 1.11 2002/01/06 00:35:11 dbj Exp $ */
/*-
* Copyright (c) 1993, 1994, 1995, 1996, 1997, 1998, 1999
@@ -281,7 +281,7 @@
DELAY(20000);
cn_tab->cn_dev = dev;
} else
-#ifdef KGDB_needs_support_in_zs_c
+#ifdef KGDB
if (zs_check_kgdb(cs, dev)) {
/*
* Allow kgdb to "take over" this port. Returns true
diff -r f29613e4f8ca -r b49f348fd93c sys/arch/macppc/dev/zs.c
--- a/sys/arch/macppc/dev/zs.c Sat Jan 05 22:57:38 2002 +0000
+++ b/sys/arch/macppc/dev/zs.c Sun Jan 06 00:35:10 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: zs.c,v 1.18 2001/07/22 11:29:47 wiz Exp $ */
+/* $NetBSD: zs.c,v 1.19 2002/01/06 00:35:11 dbj Exp $ */
/*
* Copyright (c) 1996, 1998 Bill Studenmund
@@ -54,6 +54,7 @@
*/
#include "opt_ddb.h"
+#include "opt_kgdb.h"
#include <sys/param.h>
#include <sys/systm.h>
@@ -66,6 +67,9 @@
#include <sys/time.h>
#include <sys/kernel.h>
#include <sys/syslog.h>
+#ifdef KGDB
+#include <sys/kgdb.h>
+#endif
#include <dev/cons.h>
#include <dev/ofw/openfirm.h>
@@ -81,8 +85,6 @@
#define ZSMAC_RAW 0x01
#define ZSMAC_LOCALTALK 0x02
-#define PCLK (9600 * 384)
-
#include "zsc.h" /* get the # of zs chips defined */
/*
@@ -98,13 +100,6 @@
*/
#define ZSABORT_DELAY 3000000
-/* The layout of this is hardware-dependent (padding, order). */
-struct zschan {
- volatile u_char zc_csr; /* ctrl,status, and indirect access */
- u_char zc_xxx0[15];
- volatile u_char zc_data; /* data */
- u_char zc_xxx1[15];
-};
struct zsdevice {
/* Yes, they are backwards. */
struct zschan zs_chan_b;
@@ -907,10 +902,6 @@
#define zscnpollc nullcnpollc
cons_decl(zs);
-static void zs_putc __P((register volatile struct zschan *, int));
-static int zs_getc __P((register volatile struct zschan *));
-extern int zsopen __P(( dev_t dev, int flags, int mode, struct proc *p));
-
static int stdin, stdout;
/*
@@ -935,9 +926,10 @@
* Polled input char.
*/
int
-zs_getc(zc)
- register volatile struct zschan *zc;
+zs_getc(v)
+ void *v;
{
+ register volatile struct zschan *zc = v;
register int s, c, rr0;
s = splhigh();
@@ -962,10 +954,11 @@
* Polled output char.
*/
void
-zs_putc(zc, c)
- register volatile struct zschan *zc;
+zs_putc(v, c)
+ void *v;
int c;
{
+ register volatile struct zschan *zc = v;
register int s, rr0;
register long wait = 0;
@@ -995,7 +988,7 @@
register int c;
if (zc) {
- c = zs_getc(zc);
+ c = zs_getc((void *)zc);
} else {
char ch = 0;
OF_read(stdin, &ch, 1);
@@ -1015,7 +1008,7 @@
register volatile struct zschan *zc = zs_conschan;
if (zc) {
- zs_putc(zc, c);
+ zs_putc((void *)zc, c);
} else {
char ch = c;
OF_write(stdout, &ch, 1);
@@ -1047,7 +1040,9 @@
/* If we time out, turn off the abort ability! */
}
-#ifdef DDB
+#if defined(KGDB)
+ kgdb_connect(1);
+#elif defined(DDB)
Debugger();
#endif
}
diff -r f29613e4f8ca -r b49f348fd93c sys/arch/macppc/dev/zs_kgdb.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/macppc/dev/zs_kgdb.c Sun Jan 06 00:35:10 2002 +0000
@@ -0,0 +1,303 @@
+/* $NetBSD: zs_kgdb.c,v 1.1 2002/01/06 00:36:38 dbj Exp $ */
+
+/*-
+ * Copyright (c) 1996 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Gordon W. Ross.
+ *
+ * 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 NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+ */
+
+/*
+ * Hooks for kgdb when attached via the z8530 driver
+ *
+ * To use this, build a kernel with: option KGDB, and
+ * boot that kernel with "-d". (The kernel will call
+ * zs_kgdb_init, kgdb_connect.) When the console prints
+ * "kgdb waiting..." you run "gdb -k kernel" and do:
+ * (gdb) set remotebaud 19200
+ * (gdb) target remote /dev/ttyb
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/proc.h>
+#include <sys/device.h>
+#include <sys/conf.h>
+#include <sys/ioctl.h>
+#include <sys/kernel.h>
+#include <sys/syslog.h>
+#include <sys/kgdb.h>
+
+#include <dev/ofw/openfirm.h>
+#include <dev/ic/z8530reg.h>
+#include <machine/z8530var.h>
+
+static void zs_setparam __P((struct zs_chanstate *, int, int));
+static void zskgdb __P((struct zs_chanstate *));
+
+struct zsops zsops_kgdb;
+
+static u_char zs_kgdb_regs[16] = {
+ 0, /* 0: CMD (reset, etc.) */
+ 0, /* 1: ~(ZSWR1_RIE | ZSWR1_TIE | ZSWR1_SIE) */
+ 0, /* IVECT */
+ ZSWR3_RX_8 | ZSWR3_RX_ENABLE,
+ ZSWR4_CLK_X16 | ZSWR4_ONESB | ZSWR4_EVENP,
+ ZSWR5_TX_8 | ZSWR5_TX_ENABLE,
+ 0, /* 6: TXSYNC/SYNCLO */
+ 0, /* 7: RXSYNC/SYNCHI */
+ 0, /* 8: alias for data port */
+ ZSWR9_MASTER_IE,
+ 0, /*10: Misc. TX/RX control bits */
+ ZSWR11_TXCLK_BAUD | ZSWR11_RXCLK_BAUD,
+ ((PCLK/32)/38400)-2, /*12: BAUDLO (default=38400) */
+ 0, /*13: BAUDHI (default=38400) */
+ ZSWR14_BAUD_ENA,
+ ZSWR15_BREAK_IE,
+};
+
+/*
+ * This replaces "zs_reset()" in the sparc driver.
+ */
+static void
+zs_setparam(cs, iena, rate)
+ struct zs_chanstate *cs;
+ int iena;
+ int rate;
+{
+ int s, tconst;
+
+ bcopy(zs_kgdb_regs, cs->cs_preg, 16);
+
+ if (iena) {
+ cs->cs_preg[1] = ZSWR1_RIE | ZSWR1_SIE;
+ }
+
+ /* Initialize the speed, etc. */
+ tconst = BPS_TO_TCONST(cs->cs_brg_clk, rate);
+ cs->cs_preg[5] |= ZSWR5_DTR | ZSWR5_RTS;
+ cs->cs_preg[12] = tconst;
+ cs->cs_preg[13] = tconst >> 8;
+
+ s = splhigh();
+ zs_loadchannelregs(cs);
+ splx(s);
+}
+
+#ifndef KGDB_DEVNAME
+#define KGDB_DEVNAME "scca"
+#endif
+char *zs_kgdb_devname = KGDB_DEVNAME;
+/*
+ * Set up for kgdb; called at boot time before configuration.
+ * KGDB interrupts will be enabled later when zs0 is configured.
+ * Called after cninit(), so printf() etc. works.
+ */
+void
+zs_kgdb_init()
+{
+ struct zs_chanstate cs;
+ volatile struct zschan *zc;
+ int escc, escc_ch, obio, zs_offset;
+ int channel = 0;
+ u_int32_t reg[5];
+ char name[16];
+
+ if ((escc_ch = OF_finddevice(zs_kgdb_devname)) == -1)
+ return;
+
+ memset(name, 0, sizeof(name));
+ if (OF_getprop(escc_ch, "device_type", name, sizeof(name)) == -1)
+ return;
+
+ if (strcmp(name, "serial") != 0)
+ return;
+
Home |
Main Index |
Thread Index |
Old Index