NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: port-evbarm/40307 (options KGDB doesn't work for some evbarm hosts)
On 5/11/21 20:27, skrll%NetBSD.org@localhost wrote:
Is the diff available somewhere else as the URL given is no longer valid.
Oops. I didn't realise that this was addressed to me for a PR I had
filed. Sorry about that.
The URL is still valid, but the web server in question is only available
over IPv6. That's probably the problem you are having.
I have attached the diff to this email so you will get file Nick, even
if it gets hung up by the mailing lists.
Cheers,
Lloyd
Index: arch/arm/ep93xx/epcom.c
===================================================================
RCS file: /vol/src/rsync-src/src/sys/arch/arm/ep93xx/epcom.c,v
retrieving revision 1.18
diff -u -r1.18 epcom.c
--- arch/arm/ep93xx/epcom.c 11 Jun 2008 22:37:21 -0000 1.18
+++ arch/arm/ep93xx/epcom.c 31 Dec 2008 03:49:12 -0000
@@ -145,9 +145,14 @@
bus_addr_t sc_hwbase;
int sc_ospeed;
tcflag_t sc_cflag;
- int sc_attached;
+
} epcomcn_sc;
+static int epcom_common_getc(struct epcom_cons_softc *, dev_t);
+static void epcom_common_putc(struct epcom_cons_softc *, int);
+static void epcominit(struct epcom_cons_softc *, bus_space_tag_t,
+ bus_addr_t, bus_space_handle_t, int, tcflag_t);
+
static struct cnm_state epcom_cnm_state;
extern struct cfdriver epcom_cd;
@@ -171,6 +176,18 @@
NULL, NULL, NODEV, CN_NORMAL
};
+#if defined(KGDB)
+#include <sys/kgdb.h>
+
+static int epcom_kgdb_getc (void *);
+static void epcom_kgdb_putc (void *, int);
+
+/* Reuse the console softc structure because
+ * we'll be reusing the console I/O code
+ */
+static struct epcom_cons_softc kgdb_sc;
+#endif
+
#ifndef DEFAULT_COMSPEED
#define DEFAULT_COMSPEED 115200
#endif
@@ -191,7 +208,6 @@
if (sc->sc_iot == epcomcn_sc.sc_iot
&& sc->sc_hwbase == epcomcn_sc.sc_hwbase) {
- epcomcn_sc.sc_attached = 1;
sc->sc_lcrlo = EPCOMSPEED2BRD(epcomcn_sc.sc_ospeed) & 0xff;
sc->sc_lcrmid = EPCOMSPEED2BRD(epcomcn_sc.sc_ospeed) >> 8;
@@ -235,6 +251,18 @@
aprint_normal("%s: console\n", sc->sc_dev.dv_xname);
}
+#ifdef KGDB
+ /*
+ * Allow kgdb to "take over" this port. If this is
+ * the kgdb device, it has exclusive use.
+ */
+ if (sc->sc_iot == kgdb_sc.sc_iot &&
+ sc->sc_hwbase == kgdb_sc.sc_hwbase) {
+ SET(sc->sc_hwflags, COM_HW_KGDB);
+ printf("%s: kgdb\n", sc->sc_dev.dv_xname);
+ }
+#endif
+
sc->sc_si = softint_establish(SOFTINT_SERIAL, epcomsoft, sc);
#if NRND > 0 && defined(RND_COM)
@@ -785,35 +813,11 @@
epcomcnattach(bus_space_tag_t iot, bus_addr_t iobase, bus_space_handle_t ioh,
int ospeed, tcflag_t cflag)
{
- u_int lcrlo, lcrmid, lcrhi, ctrl, pwrcnt;
- bus_space_handle_t syscon_ioh;
-
cn_tab = &epcomcons;
cn_init_magic(&epcom_cnm_state);
cn_set_magic("\047\001");
- epcomcn_sc.sc_iot = iot;
- epcomcn_sc.sc_ioh = ioh;
- epcomcn_sc.sc_hwbase = iobase;
- epcomcn_sc.sc_ospeed = ospeed;
- epcomcn_sc.sc_cflag = cflag;
-
- lcrhi = cflag2lcrhi(cflag);
- lcrlo = EPCOMSPEED2BRD(ospeed) & 0xff;
- lcrmid = EPCOMSPEED2BRD(ospeed) >> 8;
- ctrl = Ctrl_UARTE;
-
- bus_space_map(iot, EP93XX_APB_HWBASE + EP93XX_APB_SYSCON,
- EP93XX_APB_SYSCON_SIZE, 0, &syscon_ioh);
- pwrcnt = bus_space_read_4(iot, syscon_ioh, EP93XX_SYSCON_PwrCnt);
- pwrcnt &= ~(PwrCnt_UARTBAUD);
- bus_space_write_4(iot, syscon_ioh, EP93XX_SYSCON_PwrCnt, pwrcnt);
- bus_space_unmap(iot, syscon_ioh, EP93XX_APB_SYSCON_SIZE);
-
- bus_space_write_4(iot, ioh, EPCOM_LinCtrlLow, lcrlo);
- bus_space_write_4(iot, ioh, EPCOM_LinCtrlMid, lcrmid);
- bus_space_write_4(iot, ioh, EPCOM_LinCtrlHigh, lcrhi);
- bus_space_write_4(iot, ioh, EPCOM_Ctrl, ctrl);
+ epcominit (&epcomcn_sc, iot, iobase, ioh, ospeed, cflag);
return (0);
}
@@ -832,9 +836,15 @@
void
epcomcnputc(dev_t dev, int c)
{
+ epcom_common_putc (&epcomcn_sc, c);
+}
+
+static void
+epcom_common_putc(struct epcom_cons_softc *sc, int c)
+{
int s;
- bus_space_tag_t iot = epcomcn_sc.sc_iot;
- bus_space_handle_t ioh = epcomcn_sc.sc_ioh;
+ bus_space_tag_t iot = sc->sc_iot;
+ bus_space_handle_t ioh = sc->sc_ioh;
s = splserial();
@@ -856,10 +866,16 @@
int
epcomcngetc(dev_t dev)
{
+ return epcom_common_getc (&epcomcn_sc, dev);
+}
+
+static int
+epcom_common_getc(struct epcom_cons_softc *sc, dev_t dev)
+{
int c, sts;
int s;
- bus_space_tag_t iot = epcomcn_sc.sc_iot;
- bus_space_handle_t ioh = epcomcn_sc.sc_ioh;
+ bus_space_tag_t iot = sc->sc_iot;
+ bus_space_handle_t ioh = sc->sc_ioh;
s = splserial();
@@ -875,8 +891,8 @@
#endif
{
int cn_trapped = 0; /* unused */
-
- cn_check_magic(dev, c, epcom_cnm_state);
+ if (dev != NODEV)
+ cn_check_magic(dev, c, epcom_cnm_state);
}
c &= 0xff;
splx(s);
@@ -1138,3 +1154,78 @@
#endif
return (1);
}
+
+#ifdef KGDB
+int
+epcom_kgdb_attach(bus_space_tag_t iot, bus_addr_t iobase, int rate,
+ tcflag_t cflag)
+{
+ bus_space_handle_t ioh;
+
+ if (iot == epcomcn_sc.sc_iot && iobase == epcomcn_sc.sc_hwbase) {
+#if !defined(DDB)
+ return (EBUSY); /* cannot share with console */
+#else
+ /* XXX I have no intention of ever testing and code path
+ * implied by getting here
+ */
+ kgdb_sc = epcomcn_sc;
+#endif
+ } else {
+ bus_space_map (iot, iobase, EP93XX_APB_UART_SIZE, 0, &ioh);
+ epcominit(&kgdb_sc, iot, iobase, ioh, rate, cflag);
+ }
+
+ kgdb_attach(epcom_kgdb_getc, epcom_kgdb_putc, &kgdb_sc);
+ kgdb_dev = 123; /* unneeded, only to satisfy some tests */
+
+ return (0);
+}
+
+static int
+epcom_kgdb_getc (void *sc)
+{
+ return epcom_common_getc(sc, NODEV);
+}
+
+static void
+epcom_kgdb_putc (void *sc, int c)
+{
+ epcom_common_putc(sc, c);
+}
+#endif /* KGDB */
+
+/*
+ * Common code used for initialisation of the console or KGDB connection
+ */
+static void
+epcominit(struct epcom_cons_softc *sc, bus_space_tag_t iot,
+ bus_addr_t iobase, bus_space_handle_t ioh, int rate, tcflag_t cflag)
+{
+ u_int lcrlo, lcrmid, lcrhi, ctrl, pwrcnt;
+ bus_space_handle_t syscon_ioh;
+
+ sc->sc_iot = iot;
+ sc->sc_ioh = ioh;
+ sc->sc_hwbase = iobase;
+ sc->sc_ospeed = rate;
+ sc->sc_cflag = cflag;
+
+ lcrhi = cflag2lcrhi(cflag);
+ lcrlo = EPCOMSPEED2BRD(rate) & 0xff;
+ lcrmid = EPCOMSPEED2BRD(rate) >> 8;
+ ctrl = Ctrl_UARTE;
+
+ /* Make sure the UARTs are clocked at the system default rate */
+ bus_space_map(iot, EP93XX_APB_HWBASE + EP93XX_APB_SYSCON,
+ EP93XX_APB_SYSCON_SIZE, 0, &syscon_ioh);
+ pwrcnt = bus_space_read_4(iot, syscon_ioh, EP93XX_SYSCON_PwrCnt);
+ pwrcnt &= ~(PwrCnt_UARTBAUD);
+ bus_space_write_4(iot, syscon_ioh, EP93XX_SYSCON_PwrCnt, pwrcnt);
+ bus_space_unmap(iot, syscon_ioh, EP93XX_APB_SYSCON_SIZE);
+
+ bus_space_write_4(iot, ioh, EPCOM_LinCtrlLow, lcrlo);
+ bus_space_write_4(iot, ioh, EPCOM_LinCtrlMid, lcrmid);
+ bus_space_write_4(iot, ioh, EPCOM_LinCtrlHigh, lcrhi);
+ bus_space_write_4(iot, ioh, EPCOM_Ctrl, ctrl);
+}
Index: arch/arm/ep93xx/epcomvar.h
===================================================================
RCS file: /vol/src/rsync-src/src/sys/arch/arm/ep93xx/epcomvar.h,v
retrieving revision 1.3
diff -u -r1.3 epcomvar.h
--- arch/arm/ep93xx/epcomvar.h 11 Dec 2005 12:16:45 -0000 1.3
+++ arch/arm/ep93xx/epcomvar.h 31 Dec 2008 02:32:06 -0000
@@ -98,5 +98,6 @@
int epcomintr(void* arg);
int epcomcnattach(bus_space_tag_t, bus_addr_t, bus_space_handle_t,
int, tcflag_t);
+int epcom_kgdb_attach(bus_space_tag_t, bus_addr_t, int, tcflag_t);
#endif /* _EPCOMVAR_H_ */
Index: arch/evbarm/tsarm/tsarm_machdep.c
===================================================================
RCS file: /vol/src/rsync-src/src/sys/arch/evbarm/tsarm/tsarm_machdep.c,v
retrieving revision 1.10
diff -u -r1.10 tsarm_machdep.c
--- arch/evbarm/tsarm/tsarm_machdep.c 30 Nov 2008 18:21:33 -0000 1.10
+++ arch/evbarm/tsarm/tsarm_machdep.c 31 Dec 2008 04:09:23 -0000
@@ -853,8 +853,8 @@
#if KGDB
#if NEPCOM > 0
if (strcmp(kgdb_devname, "epcom") == 0) {
- com_kgdb_attach(&ep93xx_bs_tag, kgdb_devaddr, kgdb_devrate,
- kgdb_devmode);
+ epcom_kgdb_attach(&ep93xx_bs_tag, kgdb_devaddr, kgdb_devrate,
+ kgdb_devmode);
}
#endif /* NEPCOM > 0 */
#endif /* KGDB */
Home |
Main Index |
Thread Index |
Old Index