summaryrefslogtreecommitdiffstats
path: root/sys/dev
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>2004-07-10 22:29:41 +0000
committermarcel <marcel@FreeBSD.org>2004-07-10 22:29:41 +0000
commit6660e9e4c036ddedee1dea43979df8f99db432a7 (patch)
tree569c7748c22c6a063892c171ce8c938b786c180d /sys/dev
parentd86985b3e61f5ae382d55784f7eb9dddd70555fc (diff)
downloadFreeBSD-src-6660e9e4c036ddedee1dea43979df8f99db432a7.zip
FreeBSD-src-6660e9e4c036ddedee1dea43979df8f99db432a7.tar.gz
Update for the KDB framework. Sanitize the alpha console code now that
it's in the way even more. Basicly: remove all alpha specific console support from gfb(4), sio(4) and syscons(4). Rewrite the alpha console initialization to be identical to all other platforms. In a nutshell: call cninit(). The platform specific code now only sets or clears RB_SERIAL and thus automaticly causes the right console to be selected. sio.c: o Replace the remote GDB hacks and use the GDB debug port interface instead. o Make debugging code conditional upon KDB instead of DDB. o Call kdb_alt_break() instead of db_alt_break(). o Call kdb_enter() instead of breakpoint(). o Remove the ugly compatibility of using the console as the debug port.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/gfb/gfb_pci.c34
-rw-r--r--sys/dev/sio/sio.c285
-rw-r--r--sys/dev/syscons/syscons.c76
3 files changed, 81 insertions, 314 deletions
diff --git a/sys/dev/gfb/gfb_pci.c b/sys/dev/gfb/gfb_pci.c
index 3e22978..ba57878 100644
--- a/sys/dev/gfb/gfb_pci.c
+++ b/sys/dev/gfb/gfb_pci.c
@@ -32,9 +32,6 @@ __FBSDID("$FreeBSD$");
#include "opt_fb.h"
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
@@ -66,23 +63,10 @@ __FBSDID("$FreeBSD$");
#include <dev/fb/gfb.h>
#include <dev/gfb/gfb_pci.h>
-#ifdef __alpha__
-
-#include <machine/rpb.h>
-#include <machine/cpu.h>
-
-#endif /* __alpha__ */
-
#if 0
static devclass_t gfb_devclass;
#endif
-#ifdef __alpha__
-
-extern void sccnattach(void);
-
-#endif /* __alpha__ */
-
extern struct gfb_font bold8x16;
extern struct gfb_softc *gfb_device_softcs[2][16];
@@ -93,9 +77,6 @@ pcigfb_attach(device_t dev)
gfb_softc_t sc;
video_adapter_t *adp;
int unit, flags, error, rid, va_index;
-#ifdef __alpha__
- struct ctb *ctb;
-#endif /* __alpha__ */
s = splimp();
error = 0;
@@ -136,7 +117,7 @@ pcigfb_attach(device_t dev)
adp->va_mem_base = (vm_offset_t)rman_get_virtual(sc->res);
adp->va_mem_size = rman_get_end(sc->res) -
rman_get_start(sc->res);
- adp->va_io_base = 0;
+ adp->va_io_base = (vm_offset_t)sc->res; /* XXX */
adp->va_io_size = 0;
adp->va_crtc_addr = 0;
gfb_device_softcs[sc->model][unit] = sc;
@@ -191,19 +172,6 @@ pcigfb_attach(device_t dev)
gfb_device_softcs[sc->model][unit] = sc;
}
- /*
- This is a back-door for PCI devices--since FreeBSD no longer supports
- PCI configuration-space accesses during the *configure() phase for
- video adapters, we cannot identify a PCI device as the console during
- the first call to sccnattach(). There must be a second chance for PCI
- adapters to be recognized as the console, and this is it...
- */
-#ifdef __alpha__
- ctb = (struct ctb *)(((caddr_t)hwrpb) + hwrpb->rpb_ctb_off);
- if (ctb->ctb_term_type == 3) /* Display adapter */
- sccnattach();
-#endif /* __alpha__ */
-
device_printf(dev, "Board type %s\n", sc->gfbc->name);
device_printf(dev, "%d x %d, %dbpp, %s RAMDAC\n",
sc->adp->va_info.vi_width, sc->adp->va_info.vi_height,
diff --git a/sys/dev/sio/sio.c b/sys/dev/sio/sio.c
index fe219b1..078fb0d 100644
--- a/sys/dev/sio/sio.c
+++ b/sys/dev/sio/sio.c
@@ -35,7 +35,8 @@ __FBSDID("$FreeBSD$");
#include "opt_comconsole.h"
#include "opt_compat.h"
-#include "opt_ddb.h"
+#include "opt_gdb.h"
+#include "opt_kdb.h"
#include "opt_sio.h"
/*
@@ -53,6 +54,7 @@ __FBSDID("$FreeBSD$");
#include <sys/conf.h>
#include <sys/fcntl.h>
#include <sys/interrupt.h>
+#include <sys/kdb.h>
#include <sys/kernel.h>
#include <sys/limits.h>
#include <sys/lock.h>
@@ -71,9 +73,6 @@ __FBSDID("$FreeBSD$");
#include <sys/timepps.h>
#include <sys/uio.h>
#include <sys/cons.h>
-#if DDB > 0
-#include <ddb/ddb.h>
-#endif
#include <isa/isavar.h>
@@ -352,8 +351,6 @@ SYSCTL_UINT(_machdep, OID_AUTO, gdbspeed, CTLFLAG_RW,
static u_int com_events; /* input chars + weighted output completions */
static Port_t siocniobase;
static int siocnunit = -1;
-static Port_t siogdbiobase;
-static int siogdbunit = -1;
static void *sio_slow_ih;
static void *sio_fast_ih;
static int sio_timeout;
@@ -362,6 +359,10 @@ static struct callout_handle sio_timeout_handle
= CALLOUT_HANDLE_INITIALIZER(&sio_timeout_handle);
static int sio_numunits;
+#ifdef GDB
+static Port_t siogdbiobase = 0;
+#endif
+
#ifdef COM_ESP
/* XXX configure this properly. */
/* XXX quite broken for new-bus. */
@@ -1178,7 +1179,7 @@ determined_type: ;
}
if (ret)
device_printf(dev, "could not activate interrupt\n");
-#if defined(DDB) && (defined(BREAK_TO_DEBUGGER) || \
+#if defined(KDB) && (defined(BREAK_TO_DEBUGGER) || \
defined(ALT_BREAK_TO_DEBUGGER))
/*
* Enable interrupts for early break-to-debugger support
@@ -1454,7 +1455,7 @@ comhardclose(com)
sio_setreg(com, com_cfcr, com->cfcr_image &= ~CFCR_SBREAK);
tp = com->tp;
-#if defined(DDB) && (defined(BREAK_TO_DEBUGGER) || \
+#if defined(KDB) && (defined(BREAK_TO_DEBUGGER) || \
defined(ALT_BREAK_TO_DEBUGGER))
/*
* Leave interrupts enabled and don't clear DTR if this is the
@@ -1834,13 +1835,13 @@ siointr1(com)
recv_data = 0;
else
recv_data = inb(com->data_port);
-#ifdef DDB
+#ifdef KDB
#ifdef ALT_BREAK_TO_DEBUGGER
if (com->unit == comconsole &&
- db_alt_break(recv_data, &com->alt_brk_state) != 0)
- breakpoint();
+ kdb_alt_break(recv_data, &com->alt_brk_state) != 0)
+ kdb_enter("Break sequence on console");
#endif /* ALT_BREAK_TO_DEBUGGER */
-#endif /* DDB */
+#endif /* KDB */
if (line_status & (LSR_BI | LSR_FE | LSR_PE)) {
/*
* Don't store BI if IGNBRK or FE/PE if IGNPAR.
@@ -1855,9 +1856,9 @@ siointr1(com)
* Note: BI together with FE/PE means just BI.
*/
if (line_status & LSR_BI) {
-#if defined(DDB) && defined(BREAK_TO_DEBUGGER)
+#if defined(KDB) && defined(BREAK_TO_DEBUGGER)
if (com->unit == comconsole) {
- breakpoint();
+ kdb_enter("Line break on console");
goto cont;
}
#endif
@@ -2752,35 +2753,20 @@ siocnset(struct consdev *cd, int unit)
sprintf(cd->cn_name, "ttyd%d", unit);
}
-#ifndef __alpha__
static speed_t siocngetspeed(Port_t, u_long rclk);
-#endif
static void siocnclose(struct siocnstate *sp, Port_t iobase);
static void siocnopen(struct siocnstate *sp, Port_t iobase, int speed);
static void siocntxwait(Port_t iobase);
-#ifdef __alpha__
-int siocnattach(int port, int speed);
-int siogdbattach(int port, int speed);
-int siogdbgetc(void);
-void siogdbputc(int c);
-#else
static cn_probe_t siocnprobe;
static cn_init_t siocninit;
static cn_term_t siocnterm;
-#endif
static cn_checkc_t siocncheckc;
static cn_getc_t siocngetc;
static cn_putc_t siocnputc;
-#ifndef __alpha__
CONS_DRIVER(sio, siocnprobe, siocninit, siocnterm, siocngetc, siocncheckc,
siocnputc, NULL);
-#endif
-
-#if DDB > 0
-static struct consdev gdbconsdev;
-#endif
static void
siocntxwait(iobase)
@@ -2799,8 +2785,6 @@ siocntxwait(iobase)
;
}
-#ifndef __alpha__
-
/*
* Read the serial port specified and try to figure out what speed
* it's currently running at. We're assuming the serial port has
@@ -2836,8 +2820,6 @@ siocngetspeed(iobase, rclk)
return (rclk / (16UL * divisor));
}
-#endif
-
static void
siocnopen(sp, iobase, speed)
struct siocnstate *sp;
@@ -2905,8 +2887,6 @@ siocnclose(sp, iobase)
outb(iobase + com_ier, sp->ier);
}
-#ifndef __alpha__
-
static void
siocnprobe(cp)
struct consdev *cp;
@@ -2982,40 +2962,12 @@ siocnprobe(cp)
siocniobase = iobase;
siocnunit = unit;
}
- if (COM_DEBUGGER(flags)) {
- printf("sio%d: gdb debugging port\n", unit);
+#ifdef GDB
+ if (COM_DEBUGGER(flags))
siogdbiobase = iobase;
- siogdbunit = unit;
-#if DDB > 0
- siocnset(&gdbconsdev, unit);
- gdb_arg = &gdbconsdev;
- gdb_getc = siocngetc;
- gdb_putc = siocnputc;
#endif
- }
}
}
-#ifdef __i386__
-#if DDB > 0
- /*
- * XXX Ugly Compatability.
- * If no gdb port has been specified, set it to be the console
- * as some configuration files don't specify the gdb port.
- */
- if (gdb_arg == NULL && (boothowto & RB_GDB)) {
- printf("Warning: no GDB port specified. Defaulting to sio%d.\n",
- siocnunit);
- printf("Set flag 0x80 on desired GDB port in your\n");
- printf("configuration file (currently sio only).\n");
- siogdbiobase = siocniobase;
- siogdbunit = siocnunit;
- siocnset(&gdbconsdev, siocnunit);
- gdb_arg = &gdbconsdev;
- gdb_getc = siocngetc;
- gdb_putc = siocnputc;
- }
-#endif
-#endif
}
static void
@@ -3032,103 +2984,6 @@ siocnterm(cp)
comconsole = -1;
}
-#endif
-
-#ifdef __alpha__
-
-CONS_DRIVER(sio, NULL, NULL, NULL, siocngetc, siocncheckc, siocnputc, NULL);
-
-int
-siocnattach(port, speed)
- int port;
- int speed;
-{
- int s;
- u_char cfcr;
- u_int divisor;
- struct siocnstate sp;
- int unit = 0; /* XXX random value! */
-
- siocniobase = port;
- siocnunit = unit;
- comdefaultrate = speed;
- sio_consdev.cn_pri = CN_NORMAL;
- siocnset(&sio_consdev, unit);
-
- s = spltty();
-
- /*
- * Initialize the divisor latch. We can't rely on
- * siocnopen() to do this the first time, since it
- * avoids writing to the latch if the latch appears
- * to have the correct value. Also, if we didn't
- * just read the speed from the hardware, then we
- * need to set the speed in hardware so that
- * switching it later is null.
- */
- cfcr = inb(siocniobase + com_cfcr);
- outb(siocniobase + com_cfcr, CFCR_DLAB | cfcr);
- divisor = siodivisor(comdefaultrclk, comdefaultrate);
- outb(siocniobase + com_dlbl, divisor & 0xff);
- outb(siocniobase + com_dlbh, divisor >> 8);
- outb(siocniobase + com_cfcr, cfcr);
-
- siocnopen(&sp, siocniobase, comdefaultrate);
- splx(s);
-
- cnadd(&sio_consdev);
- return (0);
-}
-
-int
-siogdbattach(port, speed)
- int port;
- int speed;
-{
- int s;
- u_char cfcr;
- u_int divisor;
- struct siocnstate sp;
- int unit = 1; /* XXX random value! */
-
- siogdbiobase = port;
- gdbdefaultrate = speed;
-
- printf("sio%d: gdb debugging port\n", unit);
- siogdbunit = unit;
-#if DDB > 0
- siocnset(&gdbconsdev, unit);
- gdb_arg = &gdbconsdev;
- gdb_getc = siocngetc;
- gdb_putc = siocnputc;
-#endif
-
- s = spltty();
-
- /*
- * Initialize the divisor latch. We can't rely on
- * siocnopen() to do this the first time, since it
- * avoids writing to the latch if the latch appears
- * to have the correct value. Also, if we didn't
- * just read the speed from the hardware, then we
- * need to set the speed in hardware so that
- * switching it later is null.
- */
- cfcr = inb(siogdbiobase + com_cfcr);
- outb(siogdbiobase + com_cfcr, CFCR_DLAB | cfcr);
- divisor = siodivisor(comdefaultrclk, gdbdefaultrate);
- outb(siogdbiobase + com_dlbl, divisor & 0xff);
- outb(siogdbiobase + com_dlbh, divisor >> 8);
- outb(siogdbiobase + com_cfcr, cfcr);
-
- siocnopen(&sp, siogdbiobase, gdbdefaultrate);
- splx(s);
-
- return (0);
-}
-
-#endif
-
static int
siocncheckc(struct consdev *cd)
{
@@ -3137,13 +2992,17 @@ siocncheckc(struct consdev *cd)
int s;
struct siocnstate sp;
speed_t speed;
-
- if (cd->cn_unit == siocnunit) {
+
+ if (cd != NULL && cd->cn_unit == siocnunit) {
iobase = siocniobase;
speed = comdefaultrate;
} else {
+#ifdef GDB
iobase = siogdbiobase;
speed = gdbdefaultrate;
+#else
+ return (-1);
+#endif
}
s = spltty();
siocnopen(&sp, iobase, speed);
@@ -3165,12 +3024,16 @@ siocngetc(struct consdev *cd)
struct siocnstate sp;
speed_t speed;
- if (cd->cn_unit == siocnunit) {
+ if (cd != NULL && cd->cn_unit == siocnunit) {
iobase = siocniobase;
speed = comdefaultrate;
} else {
+#ifdef GDB
iobase = siogdbiobase;
speed = gdbdefaultrate;
+#else
+ return (-1);
+#endif
}
s = spltty();
siocnopen(&sp, iobase, speed);
@@ -3191,12 +3054,16 @@ siocnputc(struct consdev *cd, int c)
Port_t iobase;
speed_t speed;
- if (cd->cn_unit == siocnunit) {
+ if (cd != NULL && cd->cn_unit == siocnunit) {
iobase = siocniobase;
speed = comdefaultrate;
} else {
+#ifdef GDB
iobase = siogdbiobase;
speed = gdbdefaultrate;
+#else
+ return;
+#endif
}
s = spltty();
need_unlock = 0;
@@ -3213,56 +3080,56 @@ siocnputc(struct consdev *cd, int c)
splx(s);
}
-#ifdef __alpha__
-int
-siogdbgetc()
+/*
+ * Remote gdb(1) support.
+ */
+
+#if defined(GDB)
+
+#include <gdb/gdb.h>
+
+static gdb_probe_f siogdbprobe;
+static gdb_init_f siogdbinit;
+static gdb_term_f siogdbterm;
+static gdb_getc_f siogdbgetc;
+static gdb_checkc_f siogdbcheckc;
+static gdb_putc_f siogdbputc;
+
+GDB_DBGPORT(sio, siogdbprobe, siogdbinit, siogdbterm, siogdbcheckc,
+ siogdbgetc, siogdbputc);
+
+static int
+siogdbprobe(void)
{
- int c;
- Port_t iobase;
- speed_t speed;
- int s;
- struct siocnstate sp;
+ return ((siogdbiobase != 0) ? 0 : -1);
+}
- if (siogdbunit == siocnunit) {
- iobase = siocniobase;
- speed = comdefaultrate;
- } else {
- iobase = siogdbiobase;
- speed = gdbdefaultrate;
- }
+static void
+siogdbinit(void)
+{
+}
- s = spltty();
- siocnopen(&sp, iobase, speed);
- while (!(inb(iobase + com_lsr) & LSR_RXRDY))
- ;
- c = inb(iobase + com_data);
- siocnclose(&sp, iobase);
- splx(s);
- return (c);
+static void
+siogdbterm(void)
+{
}
-void
-siogdbputc(c)
- int c;
+static void
+siogdbputc(int c)
{
- Port_t iobase;
- speed_t speed;
- int s;
- struct siocnstate sp;
+ siocnputc(NULL, c);
+}
- if (siogdbunit == siocnunit) {
- iobase = siocniobase;
- speed = comdefaultrate;
- } else {
- iobase = siogdbiobase;
- speed = gdbdefaultrate;
- }
+static int
+siogdbcheckc(void)
+{
+ return (siocncheckc(NULL));
+}
- s = spltty();
- siocnopen(&sp, iobase, speed);
- siocntxwait(siogdbiobase);
- outb(siogdbiobase + com_data, c);
- siocnclose(&sp, siogdbiobase);
- splx(s);
+static int
+siogdbgetc(void)
+{
+ return (siocngetc(NULL));
}
+
#endif
diff --git a/sys/dev/syscons/syscons.c b/sys/dev/syscons/syscons.c
index 6c1a549..2620ea7 100644
--- a/sys/dev/syscons/syscons.c
+++ b/sys/dev/syscons/syscons.c
@@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$");
#include <sys/conf.h>
#include <sys/cons.h>
#include <sys/consio.h>
+#include <sys/kdb.h>
#include <sys/eventhandler.h>
#include <sys/fbio.h>
#include <sys/kbio.h>
@@ -154,9 +155,7 @@ static int scparam(struct tty *tp, struct termios *t);
static void scstart(struct tty *tp);
static void scinit(int unit, int flags);
static scr_stat *sc_get_stat(struct cdev *devptr);
-#if !__alpha__
static void scterm(int unit, int flags);
-#endif
static void scshutdown(void *arg, int howto);
static u_int scgetc(sc_softc_t *sc, u_int flags);
#define SCGETC_CN 1
@@ -205,10 +204,6 @@ static cn_putc_t sccnputc;
static cn_dbctl_t sccndbctl;
static cn_term_t sccnterm;
-#if __alpha__
-void sccnattach(void);
-#endif
-
CONS_DRIVER(sc, sccnprobe, sccninit, sccnterm, sccngetc, sccncheckc, sccnputc,
sccndbctl);
@@ -1377,7 +1372,6 @@ scstart(struct tty *tp)
static void
sccnprobe(struct consdev *cp)
{
-#if !__alpha__
int unit;
int flags;
@@ -1395,22 +1389,11 @@ sccnprobe(struct consdev *cp)
/* initialize required fields */
sprintf(cp->cn_name, "consolectl");
-#endif /* !__alpha__ */
-
-#if __alpha__
- /*
- * alpha use sccnattach() rather than cnprobe()/cninit()/cnterm()
- * interface to install the console. Always return CN_DEAD from
- * here.
- */
- cp->cn_pri = CN_DEAD;
-#endif /* __alpha__ */
}
static void
sccninit(struct consdev *cp)
{
-#if !__alpha__
int unit;
int flags;
@@ -1419,11 +1402,6 @@ sccninit(struct consdev *cp)
sc_console_unit = unit;
sc_console = sc_get_stat(sc_get_softc(unit, SC_KERNEL_CONSOLE)->dev[0]);
sc_consptr = cp;
-#endif /* !__alpha__ */
-
-#if __alpha__
- /* SHOULDN'T REACH HERE */
-#endif /* __alpha__ */
}
static void
@@ -1434,54 +1412,16 @@ sccnterm(struct consdev *cp)
if (sc_console_unit < 0)
return; /* shouldn't happen */
-#if !__alpha__
#if 0 /* XXX */
sc_clear_screen(sc_console);
sccnupdate(sc_console);
#endif
+
scterm(sc_console_unit, SC_KERNEL_CONSOLE);
sc_console_unit = -1;
sc_console = NULL;
-#endif /* !__alpha__ */
-
-#if __alpha__
- /* do nothing XXX */
-#endif /* __alpha__ */
-}
-
-#ifdef __alpha__
-
-void
-sccnattach(void)
-{
- static struct consdev consdev;
- int unit;
- int flags;
-
- bcopy(&sc_consdev, &consdev, sizeof(sc_consdev));
- consdev.cn_pri = sc_get_cons_priority(&unit, &flags);
-
- /* a video card is always required */
- if (!scvidprobe(unit, flags, TRUE))
- consdev.cn_pri = CN_DEAD;
-
- /* alpha doesn't allow the console being without a keyboard... Why? */
- if (!sckbdprobe(unit, flags, TRUE))
- consdev.cn_pri = CN_DEAD;
-
- if (consdev.cn_pri == CN_DEAD)
- return;
-
- scinit(unit, flags | SC_KERNEL_CONSOLE);
- sc_console_unit = unit;
- sc_consptr = &consdev;
- sc_console = sc_get_stat(sc_get_softc(unit, SC_KERNEL_CONSOLE)->dev[0]);
- sprintf(consdev.cn_name, "ttyv%r", 0);
- cnadd(&consdev);
}
-#endif /* __alpha__ */
-
static void
sccnputc(struct consdev *cd, int c)
{
@@ -2846,7 +2786,6 @@ scinit(int unit, int flags)
sc->flags |= SC_INIT_DONE;
}
-#if !__alpha__
static void
scterm(int unit, int flags)
{
@@ -2902,7 +2841,6 @@ scterm(int unit, int flags)
sc->keyboard = -1;
sc->adapter = -1;
}
-#endif /* !__alpha__ */
static void
scshutdown(void *arg, int howto)
@@ -3342,15 +3280,9 @@ next_code:
break;
case DBG:
-#ifndef SC_DISABLE_DDBKEY
-#ifdef DDB
- Debugger("manual escape to debugger");
-#else
- printf("No debugger in kernel\n");
+#ifndef SC_DISABLE_KDBKEY
+ kdb_enter("manual escape to debugger");
#endif
-#else /* SC_DISABLE_DDBKEY */
- /* do nothing */
-#endif /* SC_DISABLE_DDBKEY */
break;
case PNC:
OpenPOWER on IntegriCloud