Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/next68k/dev fix sprintf debugging mess.
details: https://anonhg.NetBSD.org/src/rev/ef0d3535e204
branches: trunk
changeset: 328080:ef0d3535e204
user: christos <christos%NetBSD.org@localhost>
date: Tue Mar 25 19:41:32 2014 +0000
description:
fix sprintf debugging mess.
diffstat:
sys/arch/next68k/dev/esp.c | 155 +++++++++++++++++--------------------
sys/arch/next68k/dev/if_xe.c | 9 +-
sys/arch/next68k/dev/nextdma.c | 82 +++++++++++++++----
sys/arch/next68k/dev/nextdmavar.h | 8 +-
4 files changed, 146 insertions(+), 108 deletions(-)
diffs (truncated from 722 to 300 lines):
diff -r 51f165f97517 -r ef0d3535e204 sys/arch/next68k/dev/esp.c
--- a/sys/arch/next68k/dev/esp.c Tue Mar 25 18:35:32 2014 +0000
+++ b/sys/arch/next68k/dev/esp.c Tue Mar 25 19:41:32 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: esp.c,v 1.60 2012/10/27 17:18:05 chs Exp $ */
+/* $NetBSD: esp.c,v 1.61 2014/03/25 19:41:32 christos Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -75,7 +75,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: esp.c,v 1.60 2012/10/27 17:18:05 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: esp.c,v 1.61 2014/03/25 19:41:32 christos Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -118,10 +118,7 @@
#ifdef ESP_DEBUG
int esp_debug = 0;
#define DPRINTF(x) if (esp_debug) printf x;
-extern char *ndtracep;
-extern char ndtrace[];
-extern int ndtraceshow;
-#define NDTRACEIF(x) if (10 && ndtracep < (ndtrace + 8192)) do {x;} while (0)
+#define NDTRACEIF(x) if (10) do {x;} while (0)
#else
#define DPRINTF(x)
#define NDTRACEIF(x)
@@ -145,6 +142,7 @@
void esp_dma_store(struct ncr53c9x_softc *);
void esp_dma_print(struct ncr53c9x_softc *);
int esp_dma_nest = 0;
+int esptraceshow;
#endif
@@ -461,7 +459,7 @@
struct esp_softc *esc = (struct esp_softc *)sc;
if (INTR_OCCURRED(NEXT_I_SCSI)) {
- NDTRACEIF (*ndtracep++ = 'i');
+ NDTRACEIF (ndtrace_addc('i'));
NCR_WRITE_REG(sc, ESP_DCTL,
ESPDCTL_16MHZ | ESPDCTL_INTENB |
(esc->sc_datain ? ESPDCTL_DMARD : 0));
@@ -487,7 +485,7 @@
r = 1;
- NDTRACEIF (*ndtracep++ = 'I');
+ NDTRACEIF (ndtrace_addc('I'));
if (r) {
/* printf ("esp_dma_isintr start\n"); */
{
@@ -513,14 +511,13 @@
while (!nextdma_finished(nsc)) {
/* esp_dma_isactive(sc)) { */
- NDTRACEIF (*ndtracep++ = 'w');
+ NDTRACEIF (ndtrace_addc('w'));
NDTRACEIF (
- sprintf(ndtracep, "f%dm%dl%dw",
+ ndtrace_printf("f%dm%dl%dw",
NCR_READ_REG(sc, NCR_FFLAG) &
NCRFIFO_FF,
NCR_READ_REG((sc), NCR_TCM),
NCR_READ_REG((sc), NCR_TCL));
- ndtracep += strlen(ndtracep);
);
if (NCR_READ_REG(sc, NCR_FFLAG) & NCRFIFO_FF)
flushcount = 5;
@@ -535,7 +532,7 @@
(nd_bsr4 (DD_CSR) & 0x08000000) == 0&&
++flushcount < 5) {
splx(s);
- NDTRACEIF (*ndtracep++ = 'F');
+ NDTRACEIF (ndtrace_addc('F'));
NCR_WRITE_REG(sc, ESP_DCTL,
ESPDCTL_FLUSH | ESPDCTL_16MHZ |
ESPDCTL_INTENB | ESPDCTL_DMAMOD |
@@ -550,7 +547,7 @@
doze(0x32);
s = spldma();
}
- NDTRACEIF (*ndtracep++ = '0' + flushcount);
+ NDTRACEIF (ndtrace_addc('0' + flushcount));
if (flushcount > 4) {
int next;
int onext = 0;
@@ -563,18 +560,17 @@
onext = next;
DELAY(50);
}
- NDTRACEIF (*ndtracep++ = 'R');
+ NDTRACEIF (ndtrace_addc('R'));
NCR_WRITE_REG(sc, ESP_DCTL,
ESPDCTL_16MHZ | ESPDCTL_INTENB);
NDTRACEIF (
- sprintf(ndtracep,
+ ndtrace_printf(
"ff:%d tcm:%d tcl:%d ",
NCR_READ_REG(sc, NCR_FFLAG)
& NCRFIFO_FF,
NCR_READ_REG((sc), NCR_TCM),
NCR_READ_REG((sc),
NCR_TCL));
- ndtracep += strlen (ndtracep);
);
s = spldma();
nextdma_reset (nsc);
@@ -585,7 +581,7 @@
#ifdef DIAGNOSTIC
if (flushcount > 4) {
- NDTRACEIF (*ndtracep++ = '+');
+ NDTRACEIF (ndtrace_addc('+'));
printf("%s: unexpected flushcount"
" %d on %s\n",
device_xname(sc->sc_dev),
@@ -596,7 +592,7 @@
if (!nextdma_finished(nsc)) {
/* esp_dma_isactive(sc)) { */
- NDTRACEIF (*ndtracep++ = '1');
+ NDTRACEIF (ndtrace_addc('1'));
}
flushcount = 0;
s = spldma();
@@ -618,7 +614,7 @@
NCR_WRITE_REG(sc, ESP_DCTL,
ESPDCTL_16MHZ | ESPDCTL_INTENB |
(esc->sc_datain ? ESPDCTL_DMARD : 0));
- NDTRACEIF (*ndtracep++ = 'b');
+ NDTRACEIF (ndtrace_addc('b'));
while (esc->sc_datain != -1)
DELAY(50);
@@ -643,7 +639,7 @@
16 ||
NCR_READ_REG((sc),
NCR_TCL) != 240)
- ndtraceshow++;
+ esptraceshow++;
#endif
}
xfer_len = esc->sc_dmasize - resid;
@@ -709,12 +705,11 @@
}
NDTRACEIF(
- sprintf(ndtracep, "f%dm%dl%ds%dx%dr%dS",
+ ndtrace_printf("f%dm%dl%ds%dx%dr%dS",
NCR_READ_REG(sc, NCR_FFLAG) & NCRFIFO_FF,
NCR_READ_REG((sc), NCR_TCM),
NCR_READ_REG((sc), NCR_TCL),
esc->sc_dmasize, (int)xfer_len, resid);
- ndtracep += strlen(ndtracep);
);
*esc->sc_dmaaddr += xfer_len;
@@ -724,7 +719,7 @@
esc->sc_dmasize = 0;
}
- NDTRACEIF (*ndtracep++ = 'B');
+ NDTRACEIF (ndtrace_addc('B'));
sc->sc_espstat = NCR_READ_REG(sc, NCR_STAT) |
(sc->sc_espstat & NCRSTAT_INT);
@@ -803,7 +798,7 @@
{
struct esp_softc *esc = (struct esp_softc *)sc;
- NDTRACEIF (*ndtracep++ = 'h');
+ NDTRACEIF (ndtrace_addc('h'));
#ifdef DIAGNOSTIC
#ifdef ESP_DEBUG
/* if this is a read DMA, pre-fill the buffer with 0xdeadbeef
@@ -972,10 +967,12 @@
"_dm_segcnt = %d\n",
device_xname(sc->sc_dev),
esc->sc_main_dmamap->_dm_segcnt);
+#ifdef notdef
printf("%s: esc->sc_main_dmamap->"
"_dm_maxsegsz = %ld\n",
device_xname(sc->sc_dev),
esc->sc_main_dmamap->_dm_maxsegsz);
+#endif
printf("%s: esc->sc_main_dmamap->"
"_dm_boundary = %ld\n",
device_xname(sc->sc_dev),
@@ -1152,42 +1149,44 @@
esp_dma_store(struct ncr53c9x_softc *sc)
{
struct esp_softc *esc = (struct esp_softc *)sc;
- char *p = &esp_dma_dump[0];
+ char *p = esp_dma_dump;
+ size_t l = 0;
+ size_t len = sizeof(esp_dma_dump);
- p += sprintf(p, "%s: sc_datain=%d\n",
+ l += snprintf(p + l, len - l, "%s: sc_datain=%d\n",
device_xname(sc->sc_dev), esc->sc_datain);
- p += sprintf(p, "%s: sc_loaded=0x%08x\n",
+ l += snprintf(p + l, len - l, "%s: sc_loaded=0x%08x\n",
device_xname(sc->sc_dev), esc->sc_loaded);
if (esc->sc_dmaaddr) {
- p += sprintf(p, "%s: sc_dmaaddr=%p\n",
+ l += snprintf(p + l, len - l, "%s: sc_dmaaddr=%p\n",
device_xname(sc->sc_dev), *esc->sc_dmaaddr);
} else {
- p += sprintf(p, "%s: sc_dmaaddr=NULL\n",
+ l += snprintf(p + l, len - l, "%s: sc_dmaaddr=NULL\n",
device_xname(sc->sc_dev));
}
if (esc->sc_dmalen) {
- p += sprintf(p, "%s: sc_dmalen=0x%08x\n",
+ l += snprintf(p + l, len - l, "%s: sc_dmalen=0x%08x\n",
device_xname(sc->sc_dev), *esc->sc_dmalen);
} else {
- p += sprintf(p, "%s: sc_dmalen=NULL\n",
+ l += snprintf(p + l, len - l, "%s: sc_dmalen=NULL\n",
device_xname(sc->sc_dev));
}
- p += sprintf(p, "%s: sc_dmasize=0x%08x\n",
+ l += snprintf(p + l, len - l, "%s: sc_dmasize=0x%08x\n",
device_xname(sc->sc_dev), esc->sc_dmasize);
- p += sprintf(p, "%s: sc_begin = %p, sc_begin_size = 0x%08x\n",
+ l += snprintf(p + l, len - l, "%s: sc_begin = %p, sc_begin_size = 0x%08x\n",
device_xname(sc->sc_dev), esc->sc_begin, esc->sc_begin_size);
- p += sprintf(p, "%s: sc_main = %p, sc_main_size = 0x%08x\n",
+ l += snprintf(p + l, len - l, "%s: sc_main = %p, sc_main_size = 0x%08x\n",
device_xname(sc->sc_dev), esc->sc_main, esc->sc_main_size);
/* if (esc->sc_main) */ {
int i;
bus_dmamap_t map = esc->sc_main_dmamap;
- p += sprintf(p, "%s: sc_main_dmamap."
+ l += snprintf(p + l, len - l, "%s: sc_main_dmamap."
" mapsize = 0x%08lx, nsegs = %d\n",
device_xname(sc->sc_dev), map->dm_mapsize, map->dm_nsegs);
for(i = 0; i < map->dm_nsegs; i++) {
- p += sprintf(p, "%s:"
+ l += snprintf(p + l, len - l, "%s:"
" map->dm_segs[%d].ds_addr = 0x%08lx,"
" len = 0x%08lx\n",
device_xname(sc->sc_dev),
@@ -1195,16 +1194,16 @@
map->dm_segs[i].ds_len);
}
}
- p += sprintf(p, "%s: sc_tail = %p, sc_tail_size = 0x%08x\n",
+ l += snprintf(p + l, len - l, "%s: sc_tail = %p, sc_tail_size = 0x%08x\n",
device_xname(sc->sc_dev), esc->sc_tail, esc->sc_tail_size);
/* if (esc->sc_tail) */ {
int i;
bus_dmamap_t map = esc->sc_tail_dmamap;
- p += sprintf(p, "%s: sc_tail_dmamap."
+ l += snprintf(p + l, len - l, "%s: sc_tail_dmamap."
" mapsize = 0x%08lx, nsegs = %d\n",
device_xname(sc->sc_dev), map->dm_mapsize, map->dm_nsegs);
for (i = 0; i < map->dm_nsegs; i++) {
- p += sprintf(p, "%s:"
+ l += snprintf(p + l, len - l, "%s:"
" map->dm_segs[%d].ds_addr = 0x%08lx,"
" len = 0x%08lx\n",
device_xname(sc->sc_dev),
@@ -1232,15 +1231,14 @@
/* int s = spldma(); */
#ifdef ESP_DEBUG
- if (ndtracep != ndtrace) {
- if (ndtraceshow) {
- *ndtracep = '\0';
- printf("esp ndtrace: %s\n", ndtrace);
- ndtraceshow = 0;
+ if (!ndtrace_empty()) {
+ if (esptraceshow) {
+ printf("esp ndtrace: %s\n", ndtrace_get());
+ esptraceshow = 0;
} else {
DPRINTF(("X"));
}
- ndtracep = ndtrace;
+ ndtrace_reset();
}
#endif
@@ -1339,20 +1337,20 @@
NDTRACEIF(
if (esc->sc_begin_size) {
- *ndtracep++ = '1';
- *ndtracep++ = 'A' + esc->sc_begin_size;
+ ndtrace_addc('1');
+ ndtrace_addc('A' + esc->sc_begin_size);
}
Home |
Main Index |
Thread Index |
Old Index