Add the remaining kgdb pieces from sun3/hp300, with some mac68k-specific
adjustments to initialization.
This commit is contained in:
parent
4015691473
commit
22b90adcc2
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: zs.c,v 1.19 1998/01/12 19:22:18 thorpej Exp $ */
|
||||
/* $NetBSD: zs.c,v 1.20 1998/05/05 06:48:51 scottr Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996 Bill Studenmund
|
||||
@ -65,15 +65,15 @@
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/syslog.h>
|
||||
|
||||
#include <dev/cons.h>
|
||||
|
||||
#include <dev/ic/z8530reg.h>
|
||||
#include <machine/z8530var.h>
|
||||
|
||||
#include <machine/autoconf.h>
|
||||
#include <machine/cpu.h>
|
||||
#include <machine/viareg.h>
|
||||
|
||||
#include <dev/cons.h>
|
||||
#include <dev/ic/z8530reg.h>
|
||||
#include <machine/z8530var.h>
|
||||
#include <mac68k/dev/zs_cons.h>
|
||||
|
||||
/* Are these in a header file anywhere? */
|
||||
/* Booter flags interface */
|
||||
#define ZSMAC_RAW 0x01
|
||||
@ -140,9 +140,7 @@ dev_t mac68k_zsdev;
|
||||
/* Mac stuff */
|
||||
volatile unsigned char *sccA = 0;
|
||||
|
||||
static struct zschan *zs_get_chan_addr __P((int zsc_unit, int channel));
|
||||
void zs_init __P((void));
|
||||
int zs_cn_check_speed __P((int bps));
|
||||
int zs_cn_check_speed __P((int bps));
|
||||
|
||||
/*
|
||||
* Even though zsparam will set up the clock multiples, etc., we
|
||||
@ -170,7 +168,7 @@ static u_char zs_init_reg[16] = {
|
||||
ZSWR15_BREAK_IE | ZSWR15_DCD_IE,
|
||||
};
|
||||
|
||||
static struct zschan *
|
||||
struct zschan *
|
||||
zs_get_chan_addr(zsc_unit, channel)
|
||||
int zsc_unit, channel;
|
||||
{
|
||||
@ -183,7 +181,7 @@ zs_get_chan_addr(zsc_unit, channel)
|
||||
if (addr == NULL)
|
||||
return NULL;
|
||||
if (channel == 0) {
|
||||
zc = (struct zschan *)(addr +2);
|
||||
zc = (struct zschan *)(addr + 2);
|
||||
/* handle the fact the ports are intertwined. */
|
||||
} else {
|
||||
zc = (struct zschan *)(addr);
|
||||
@ -465,8 +463,8 @@ int
|
||||
zshard(arg)
|
||||
void *arg;
|
||||
{
|
||||
register struct zsc_softc *zsc;
|
||||
register int unit, rval;
|
||||
struct zsc_softc *zsc;
|
||||
int unit, rval;
|
||||
|
||||
rval = 0;
|
||||
for (unit = 0; unit < zsc_cd.cd_ndevs; unit++) {
|
||||
@ -495,8 +493,8 @@ int
|
||||
zssoft(arg)
|
||||
void *arg;
|
||||
{
|
||||
register struct zsc_softc *zsc;
|
||||
register int unit;
|
||||
struct zsc_softc *zsc;
|
||||
int unit;
|
||||
|
||||
/* This is not the only ISR on this IPL. */
|
||||
if (zssoftpending == 0)
|
||||
@ -815,7 +813,7 @@ zs_write_reg(cs, reg, val)
|
||||
u_char zs_read_csr(cs)
|
||||
struct zs_chanstate *cs;
|
||||
{
|
||||
register u_char val;
|
||||
u_char val;
|
||||
|
||||
val = *cs->cs_reg_csr;
|
||||
ZS_DELAY();
|
||||
@ -836,7 +834,7 @@ void zs_write_csr(cs, val)
|
||||
u_char zs_read_data(cs)
|
||||
struct zs_chanstate *cs;
|
||||
{
|
||||
register u_char val;
|
||||
u_char val;
|
||||
|
||||
val = *cs->cs_reg_data;
|
||||
ZS_DELAY();
|
||||
@ -862,8 +860,6 @@ void zs_write_data(cs, val)
|
||||
#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 *));
|
||||
static void zscnsetup __P((void));
|
||||
extern int zsopen __P(( dev_t dev, int flags, int mode, struct proc *p));
|
||||
|
||||
@ -1003,11 +999,12 @@ zscninit(struct consdev * cp)
|
||||
/*
|
||||
* Polled input char.
|
||||
*/
|
||||
static int
|
||||
zs_getc(zc)
|
||||
register volatile struct zschan *zc;
|
||||
int
|
||||
zs_getc(arg)
|
||||
void *arg;
|
||||
{
|
||||
register int s, c, rr0;
|
||||
volatile struct zschan *zc = arg;
|
||||
int s, c, rr0;
|
||||
|
||||
s = splhigh();
|
||||
/* Wait for a character to arrive. */
|
||||
@ -1030,13 +1027,14 @@ zs_getc(zc)
|
||||
/*
|
||||
* Polled output char.
|
||||
*/
|
||||
static void
|
||||
zs_putc(zc, c)
|
||||
register volatile struct zschan *zc;
|
||||
void
|
||||
zs_putc(arg, c)
|
||||
void *arg;
|
||||
int c;
|
||||
{
|
||||
register int s, rr0;
|
||||
register long wait = 0;
|
||||
volatile struct zschan *zc = arg;
|
||||
int s, rr0;
|
||||
long wait = 0;
|
||||
|
||||
s = splhigh();
|
||||
/* Wait for transmitter to become ready. */
|
||||
@ -1060,8 +1058,8 @@ int
|
||||
zscngetc(dev)
|
||||
dev_t dev;
|
||||
{
|
||||
register volatile struct zschan *zc = zs_conschan;
|
||||
register int c;
|
||||
struct zschan *zc = zs_conschan;
|
||||
int c;
|
||||
|
||||
c = zs_getc(zc);
|
||||
return (c);
|
||||
@ -1075,7 +1073,7 @@ zscnputc(dev, c)
|
||||
dev_t dev;
|
||||
int c;
|
||||
{
|
||||
register volatile struct zschan *zc = zs_conschan;
|
||||
struct zschan *zc = zs_conschan;
|
||||
|
||||
zs_putc(zc, c);
|
||||
}
|
||||
@ -1091,7 +1089,7 @@ zs_abort(cs)
|
||||
{
|
||||
volatile struct zschan *zc = zs_conschan;
|
||||
int rr0;
|
||||
register long wait = 0;
|
||||
long wait = 0;
|
||||
|
||||
if (zs_cons_canabort == 0)
|
||||
return;
|
||||
|
14
sys/arch/mac68k/dev/zs_cons.h
Normal file
14
sys/arch/mac68k/dev/zs_cons.h
Normal file
@ -0,0 +1,14 @@
|
||||
/* $NetBSD: zs_cons.h,v 1.1 1998/05/05 06:48:52 scottr Exp $ */
|
||||
|
||||
extern int zsinited;
|
||||
extern void *zs_conschan;
|
||||
|
||||
void zs_init __P((void));
|
||||
int zs_getc __P((void *arg));
|
||||
void zs_putc __P((void *arg, int c));
|
||||
|
||||
struct zschan *zs_get_chan_addr __P((int zsc_unit, int channel));
|
||||
|
||||
#ifdef KGDB
|
||||
void zs_kgdb_init __P((void));
|
||||
#endif
|
303
sys/arch/mac68k/dev/zs_kgdb.c
Normal file
303
sys/arch/mac68k/dev/zs_kgdb.c
Normal file
@ -0,0 +1,303 @@
|
||||
/* $NetBSD: zs_kgdb.c,v 1.1 1998/05/05 06:48:52 scottr 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/ic/z8530reg.h>
|
||||
#include <machine/z8530var.h>
|
||||
#include <mac68k/dev/zs_cons.h>
|
||||
|
||||
/*
|
||||
* Macs supposely provide a 3.672 MHz clock to the SCC. Unfortunately,
|
||||
* empirical evidence suggests that it's really a 3.6864 MHz clock.
|
||||
* Oh, what to do, what to do?!
|
||||
*/
|
||||
#define PCLK (9600 * 384) /* PCLK pin input clock rate */
|
||||
#define ZSHARD_PRI 4 /* Wired on the CPU board... */
|
||||
|
||||
#define ZS_DELAY() delay(2)
|
||||
|
||||
/* 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;
|
||||
u_char zc_xxx1; /* part of the other channel lives here! */
|
||||
u_char zc_xxx2; /* Yea Apple! */
|
||||
volatile u_char zc_data; /* data */
|
||||
u_char zc_xxx3;
|
||||
u_char zc_xxx4;
|
||||
u_char zc_xxx5;
|
||||
};
|
||||
|
||||
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) */
|
||||
0x18 + ZSHARD_PRI, /* 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,
|
||||
14, /*12: BAUDLO (default=9600) */
|
||||
0, /*13: BAUDHI (default=9600) */
|
||||
ZSWR14_BAUD_FROM_PCLK | ZSWR14_BAUD_ENA,
|
||||
ZSWR15_BREAK_IE | ZSWR15_DCD_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);
|
||||
}
|
||||
|
||||
/*
|
||||
* 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 channel;
|
||||
|
||||
/* printf("zs_kgdb_init: kgdb_dev=0x%x\n", kgdb_dev); */
|
||||
if (major(kgdb_dev) != zs_major)
|
||||
return;
|
||||
|
||||
/* Note: (ttya,ttyb) on zsc1, and (ttyc,ttyd) on zsc0 */
|
||||
channel = kgdb_dev & 1;
|
||||
printf("zs_kgdb_init: attaching tty0%c at %d baud\n",
|
||||
'0' + (kgdb_dev & 3), kgdb_rate);
|
||||
|
||||
if (!zsinited)
|
||||
zs_init();
|
||||
|
||||
/* Setup temporary chanstate. */
|
||||
bzero((caddr_t)&cs, sizeof(cs));
|
||||
zc = zs_get_chan_addr(0, channel);
|
||||
if (zc == NULL) {
|
||||
printf("zs_kgdb_init: zs not mapped.\n");
|
||||
kgdb_dev = -1;
|
||||
return;
|
||||
}
|
||||
|
||||
cs.cs_channel = channel;
|
||||
cs.cs_brg_clk = PCLK / 16;
|
||||
cs.cs_reg_csr = &zc->zc_csr;
|
||||
cs.cs_reg_data = &zc->zc_data;
|
||||
|
||||
/* Now set parameters. (interrupts disabled) */
|
||||
zs_setparam(&cs, 0, kgdb_rate);
|
||||
|
||||
/* Store the getc/putc functions and arg. */
|
||||
kgdb_attach(zs_getc, zs_putc, (void *)zc);
|
||||
}
|
||||
|
||||
/*
|
||||
* This is a "hook" called by zstty_attach to allow the tty
|
||||
* to be "taken over" for exclusive use by kgdb.
|
||||
* Return non-zero if this is the kgdb port.
|
||||
*
|
||||
* Set the speed to kgdb_rate, CS8, etc.
|
||||
*/
|
||||
int
|
||||
zs_check_kgdb(cs, dev)
|
||||
struct zs_chanstate *cs;
|
||||
int dev;
|
||||
{
|
||||
|
||||
if (dev != kgdb_dev)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Yes, this is port in use by kgdb.
|
||||
*/
|
||||
cs->cs_private = NULL;
|
||||
cs->cs_ops = &zsops_kgdb;
|
||||
|
||||
/* Now set parameters. (interrupts enabled) */
|
||||
zs_setparam(cs, 1, kgdb_rate);
|
||||
|
||||
return (1);
|
||||
}
|
||||
|
||||
/*
|
||||
* KGDB framing character received: enter kernel debugger. This probably
|
||||
* should time out after a few seconds to avoid hanging on spurious input.
|
||||
*/
|
||||
static void
|
||||
zskgdb(cs)
|
||||
struct zs_chanstate *cs;
|
||||
{
|
||||
int unit = minor(kgdb_dev);
|
||||
|
||||
printf("zstty%d: kgdb interrupt\n", unit);
|
||||
/* This will trap into the debugger. */
|
||||
kgdb_connect(1);
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************
|
||||
* Interface to the lower layer (zscc)
|
||||
****************************************************************/
|
||||
|
||||
static void zs_kgdb_rxint __P((struct zs_chanstate *));
|
||||
static void zs_kgdb_txint __P((struct zs_chanstate *));
|
||||
static void zs_kgdb_stint __P((struct zs_chanstate *));
|
||||
static void zs_kgdb_softint __P((struct zs_chanstate *));
|
||||
|
||||
int kgdb_input_lost;
|
||||
|
||||
static void
|
||||
zs_kgdb_rxint(cs)
|
||||
struct zs_chanstate *cs;
|
||||
{
|
||||
register u_char c, rr1;
|
||||
|
||||
/*
|
||||
* First read the status, because reading the received char
|
||||
* destroys the status of this char.
|
||||
*/
|
||||
rr1 = zs_read_reg(cs, 1);
|
||||
c = zs_read_data(cs);
|
||||
|
||||
if (rr1 & (ZSRR1_FE | ZSRR1_DO | ZSRR1_PE)) {
|
||||
/* Clear the receive error. */
|
||||
zs_write_csr(cs, ZSWR0_RESET_ERRORS);
|
||||
}
|
||||
|
||||
if (c == KGDB_START) {
|
||||
zskgdb(cs);
|
||||
} else {
|
||||
kgdb_input_lost++;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
zs_kgdb_txint(cs)
|
||||
register struct zs_chanstate *cs;
|
||||
{
|
||||
register int rr0;
|
||||
|
||||
rr0 = zs_read_csr(cs);
|
||||
zs_write_csr(cs, ZSWR0_RESET_TXINT);
|
||||
}
|
||||
|
||||
static void
|
||||
zs_kgdb_stint(cs)
|
||||
register struct zs_chanstate *cs;
|
||||
{
|
||||
register int rr0;
|
||||
|
||||
rr0 = zs_read_csr(cs);
|
||||
zs_write_csr(cs, ZSWR0_RESET_STATUS);
|
||||
|
||||
/*
|
||||
* Check here for console break, so that we can abort
|
||||
* even when interrupts are locking up the machine.
|
||||
*/
|
||||
if (rr0 & ZSRR0_BREAK) {
|
||||
zskgdb(cs);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
zs_kgdb_softint(cs)
|
||||
struct zs_chanstate *cs;
|
||||
{
|
||||
printf("zs_kgdb_softint?\n");
|
||||
}
|
||||
|
||||
struct zsops zsops_kgdb = {
|
||||
zs_kgdb_rxint, /* receive char available */
|
||||
zs_kgdb_stint, /* external/status */
|
||||
zs_kgdb_txint, /* xmit buffer empty */
|
||||
zs_kgdb_softint, /* process software interrupt */
|
||||
};
|
122
sys/arch/mac68k/mac68k/kgdb_machdep.c
Normal file
122
sys/arch/mac68k/mac68k/kgdb_machdep.c
Normal file
@ -0,0 +1,122 @@
|
||||
/* $NetBSD: kgdb_machdep.c,v 1.1 1998/05/05 06:48:52 scottr Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1990, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This software was developed by the Computer Systems Engineering group
|
||||
* at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
|
||||
* contributed to Berkeley.
|
||||
*
|
||||
* 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, Lawrence Berkeley Laboratories.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @(#)kgdb_stub.c 8.4 (Berkeley) 1/12/94
|
||||
*/
|
||||
|
||||
/*
|
||||
* Machine-dependent part of the KGDB remote "stub"
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/kgdb.h>
|
||||
|
||||
#include <vm/vm.h>
|
||||
|
||||
#include <machine/db_machdep.h>
|
||||
#include <machine/pmap.h>
|
||||
#include <machine/pte.h>
|
||||
|
||||
#define INVOKE_KGDB() __asm __volatile("trap #15")
|
||||
|
||||
/*
|
||||
* Determine if the memory at va..(va+len) is valid.
|
||||
*/
|
||||
int
|
||||
kgdb_acc(va, ulen)
|
||||
vm_offset_t va;
|
||||
size_t ulen;
|
||||
{
|
||||
int len, pgoff;
|
||||
pt_entry_t *pte;
|
||||
|
||||
len = (int)ulen;
|
||||
pgoff = va & PGOFSET;
|
||||
va -= pgoff;
|
||||
len += pgoff;
|
||||
|
||||
while (len > 0) {
|
||||
pte = kvtopte(va);
|
||||
if ((*pte & PG_V) == 0)
|
||||
return (0);
|
||||
va += NBPG;
|
||||
len -= NBPG;
|
||||
}
|
||||
|
||||
return (1);
|
||||
}
|
||||
|
||||
/*
|
||||
* 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...");
|
||||
|
||||
INVOKE_KGDB();
|
||||
|
||||
if (verbose)
|
||||
printf("connected.\n");
|
||||
|
||||
kgdb_debug_panic = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Decide what to do on panic.
|
||||
*/
|
||||
void
|
||||
kgdb_panic()
|
||||
{
|
||||
if (kgdb_dev >= 0 && kgdb_debug_panic) {
|
||||
printf("entering kgdb\n");
|
||||
INVOKE_KGDB();
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: machdep.c,v 1.194 1998/05/01 03:53:47 scottr Exp $ */
|
||||
/* $NetBSD: machdep.c,v 1.195 1998/05/05 06:48:52 scottr Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988 University of Utah.
|
||||
@ -102,6 +102,9 @@
|
||||
#include <sys/mount.h>
|
||||
#include <sys/extent.h>
|
||||
#include <sys/syscallargs.h>
|
||||
#ifdef KGDB
|
||||
#include <sys/kgdb.h>
|
||||
#endif
|
||||
#ifdef SYSVMSG
|
||||
#include <sys/msg.h>
|
||||
#endif
|
||||
@ -324,6 +327,10 @@ consinit(void)
|
||||
|
||||
if (!init) {
|
||||
cninit();
|
||||
init = 1;
|
||||
} else {
|
||||
mac68k_calibrate_delay();
|
||||
|
||||
#if NZSC > 0 && defined(KGDB)
|
||||
zs_kgdb_init();
|
||||
#endif
|
||||
@ -333,9 +340,20 @@ consinit(void)
|
||||
*/
|
||||
ddb_init();
|
||||
#endif
|
||||
init = 1;
|
||||
} else
|
||||
mac68k_calibrate_delay();
|
||||
|
||||
if (boothowto & RB_KDB) {
|
||||
#ifdef KGDB
|
||||
/* XXX - Ask on console for kgdb_dev? */
|
||||
/* Note: this will just return if kgdb_dev==NODEV */
|
||||
kgdb_connect(1);
|
||||
#else /* KGDB */
|
||||
#ifdef DDB
|
||||
/* Enter DDB. We don't have a monitor PROM. */
|
||||
Debugger();
|
||||
#endif /* DDB */
|
||||
#endif /* KGDB */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#define CURRENTBOOTERVER 111
|
||||
@ -2354,7 +2372,7 @@ setmachdep()
|
||||
}
|
||||
|
||||
/*
|
||||
* Set `internal' framebuffer location and length, if we know
|
||||
* Set on-board video RAM location and length, if we know
|
||||
* what they are.
|
||||
*/
|
||||
for (i = 0; intvid_info[i].machineid; i++) {
|
||||
|
Loading…
Reference in New Issue
Block a user