PERFORCE change 49876 for review
Marcel Moolenaar
marcel at FreeBSD.org
Mon Mar 29 00:07:21 PST 2004
http://perforce.freebsd.org/chv.cgi?CH=49876
Change 49876 by marcel at marcel_nfs on 2004/03/29 00:06:41
Add support to sio for being a debug port. This probably breaks
alpha.
Affected files ...
.. //depot/projects/gdb/sys/dev/sio/sio.c#5 edit
Differences ...
==== //depot/projects/gdb/sys/dev/sio/sio.c#5 (text+ko) ====
@@ -39,7 +39,8 @@
#include "opt_comconsole.h"
#include "opt_compat.h"
-#include "opt_ddb.h"
+#include "opt_gdb.h"
+#include "opt_kdb.h"
#include "opt_sio.h"
/*
@@ -74,9 +75,6 @@
#include <sys/timepps.h>
#include <sys/uio.h>
#include <sys/cons.h>
-#if DDB > 0
-#include <ddb/ddb.h>
-#endif
#include <isa/isavar.h>
@@ -343,8 +341,6 @@
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;
@@ -353,6 +349,10 @@
= 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. */
@@ -1172,7 +1172,7 @@
}
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
@@ -1424,7 +1424,7 @@
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
@@ -1800,13 +1800,13 @@
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_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.
@@ -1821,9 +1821,9 @@
* 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
@@ -2758,9 +2758,6 @@
#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;
@@ -2775,10 +2772,6 @@
siocnputc, NULL);
#endif
-#if DDB > 0
-static struct consdev gdbconsdev;
-#endif
-
static void
siocntxwait(iobase)
Port_t iobase;
@@ -2979,40 +2972,12 @@
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
@@ -3077,53 +3042,6 @@
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
@@ -3134,13 +3052,17 @@
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);
@@ -3162,12 +3084,16 @@
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);
@@ -3188,12 +3114,16 @@
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;
@@ -3210,56 +3140,56 @@
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
More information about the p4-projects
mailing list