summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/ata/ata.c23
-rw-r--r--sys/dev/atapiscsi/atapiscsi.c41
-rw-r--r--sys/dev/ic/wdc.c87
-rw-r--r--sys/dev/ic/wdcdbg.h29
4 files changed, 90 insertions, 90 deletions
diff --git a/sys/dev/ata/ata.c b/sys/dev/ata/ata.c
index 0f4eb3adea0..61f6180276e 100644
--- a/sys/dev/ata/ata.c
+++ b/sys/dev/ata/ata.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ata.c,v 1.6 2000/07/20 07:40:32 csapuntz Exp $ */
+/* $OpenBSD: ata.c,v 1.7 2000/10/28 18:08:45 csapuntz Exp $ */
/* $NetBSD: ata.c,v 1.9 1999/04/15 09:41:09 bouyer Exp $ */
/*
* Copyright (c) 1998 Manuel Bouyer. All rights reserved.
@@ -44,19 +44,7 @@
#include <dev/ata/atavar.h>
#include <dev/ic/wdcreg.h>
#include <dev/ic/wdcvar.h>
-
-#define WDCDEBUG
-
-#define DEBUG_FUNCS 0x08
-#define DEBUG_PROBE 0x10
-#ifdef WDCDEBUG
-extern int wdcdebug_mask; /* init'ed in wdc.c */
-#define WDCDEBUG_PRINT(args, level) \
- if (wdcdebug_mask & (level)) \
- printf args
-#else
-#define WDCDEBUG_PRINT(args, level)
-#endif
+#include <dev/ic/wdcdbg.h>
#define ATAPARAMS_SIZE 512
@@ -101,7 +89,6 @@ ata_get_params(drvp, flags, prms)
{
int ret;
if ((ret = wdc_exec_command(drvp, &wdc_c)) != WDC_COMPLETE) {
- printf ("WDC_EXEC_COMMAND: %d\n");
return CMD_AGAIN;
}
}
@@ -109,8 +96,7 @@ ata_get_params(drvp, flags, prms)
if (wdc_c.flags & (AT_ERROR | AT_TIMEOU | AT_DF)) {
struct channel_softc *chp = drvp->chnl_softc;
- WDCDEBUG_PRINT(("IDENTIFY failed: 0x%x\n", wdc_c.flags)
- , DEBUG_PROBE);
+ WDCDEBUG_PRINT_PROBE(("IDENTIFY failed: 0x%x\n", wdc_c.flags));
/* Andreas Gunnarsson reports a setup with a flash
disk where the ATA drive remains comatose until
@@ -118,7 +104,8 @@ ata_get_params(drvp, flags, prms)
if (try == 0 && (drvp->drive_flags & DRIVE_ATA) &&
(wdc_c.flags & AT_TIMEOU) &&
!(chp->ch_flags & WDCS_BSY)) {
- WDCDEBUG_PRINT(("Retrying IDENTIFY\n"), DEBUG_PROBE);
+ WDCDEBUG_PRINT_PROBE
+ (("Retrying IDENTIFY\n"));
try++;
goto again;
}
diff --git a/sys/dev/atapiscsi/atapiscsi.c b/sys/dev/atapiscsi/atapiscsi.c
index 3dc606903ac..2fb1b67c2b5 100644
--- a/sys/dev/atapiscsi/atapiscsi.c
+++ b/sys/dev/atapiscsi/atapiscsi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: atapiscsi.c,v 1.30 2000/08/11 03:59:47 csapuntz Exp $ */
+/* $OpenBSD: atapiscsi.c,v 1.31 2000/10/28 18:08:45 csapuntz Exp $ */
/*
* This code is derived from code with the copyright below.
@@ -78,7 +78,7 @@
#define READY 6
-#define WDCDEBUG
+#define WDCDEBUG_PROBE
#define DEBUG_INTR 0x01
#define DEBUG_XFERS 0x02
@@ -89,8 +89,9 @@
#define DEBUG_POLL 0x40
#define DEBUG_ERRORS 0x80 /* Debug error handling code */
-#if defined(WDCDEBUG)
int wdcdebug_atapi_mask = 0;
+
+#if defined(WDCDEBUG)
#define WDCDEBUG_PRINT(args, level) \
if (wdcdebug_atapi_mask & (level)) \
printf args
@@ -98,6 +99,12 @@ int wdcdebug_atapi_mask = 0;
#define WDCDEBUG_PRINT(args, level)
#endif
+#if defined(WDCDEBUG) || defined(WDCDEBUG_PROBE)
+#define WDCDEBUG_PRINT_PROBE(args) if (wdcdebug_atapi_mask & DEBUG_PROBE) printf args
+#else
+#define WDCDEBUG_PRINT_PROBE(args)
+#endif
+
/* 10 ms, this is used only before sending a cmd. */
#define ATAPI_DELAY 10
#define ATAPI_RESET_WAIT 2000
@@ -236,10 +243,8 @@ atapiscsi_attach(parent, self, aux)
printf("\n");
-#ifdef WDCDEBUG
if (chp->wdc->sc_dev.dv_cfdata->cf_flags & WDC_OPTION_PROBE_VERBOSE)
wdcdebug_atapi_mask |= DEBUG_PROBE;
-#endif
as->chp = chp;
as->sc_adapterlink.adapter_softc = as;
@@ -264,10 +269,9 @@ atapiscsi_attach(parent, self, aux)
wdc_probe_caps(drvp, id);
- WDCDEBUG_PRINT(
- ("general config %04x capabilities %04x ",
- id->atap_config, id->atap_capabilities1),
- DEBUG_PROBE);
+ WDCDEBUG_PRINT_PROBE(
+ ("general config %04x capabilities %04x ",
+ id->atap_config, id->atap_capabilities1));
/* Tape drives do funny DSC stuff */
if (ATAPI_CFG_TYPE(id->atap_config) ==
@@ -281,8 +285,8 @@ atapiscsi_attach(parent, self, aux)
drvp->atapi_cap |=
(id->atap_config & ATAPI_CFG_DRQ_MASK);
- WDCDEBUG_PRINT(("driver caps %04x\n", drvp->atapi_cap),
- DEBUG_PROBE);
+ WDCDEBUG_PRINT_PROBE(
+ ("driver caps %04x\n", drvp->atapi_cap));
} else
drvp->drive_flags &= ~DRIVE_ATAPI;
}
@@ -313,10 +317,8 @@ atapiscsi_attach(parent, self, aux)
}
}
-#ifdef WDCDEBUG
if (chp->wdc->sc_dev.dv_cfdata->cf_flags & WDC_OPTION_PROBE_VERBOSE)
wdcdebug_atapi_mask &= ~DEBUG_PROBE;
-#endif
}
void
@@ -364,8 +366,8 @@ wdc_atapi_get_params(chp, drive, id)
* ATAPI devices one day.
*/
if ((drvp->drive_flags & DRIVE_ATAPI) == 0) {
- WDCDEBUG_PRINT(("wdc_atapi_get_params: drive %d not present\n",
- drive), DEBUG_PROBE);
+ WDCDEBUG_PRINT_PROBE(("wdc_atapi_get_params: drive %d not present\n",
+ drive));
return (-1);
}
bzero(&wdc_c, sizeof(struct wdc_command));
@@ -381,10 +383,10 @@ wdc_atapi_get_params(chp, drive, id)
panic("wdc_atapi_get_params");
}
if (wdc_c.flags & (AT_ERROR | AT_TIMEOU | AT_DF)) {
- WDCDEBUG_PRINT(("wdc_atapi_get_params: ATAPI_SOFT_RESET "
+ WDCDEBUG_PRINT_PROBE(("wdc_atapi_get_params: ATAPI_SOFT_RESET "
"failed for drive %s:%d:%d: error 0x%x\n",
chp->wdc->sc_dev.dv_xname, chp->channel, drive,
- wdc_c.r_error), DEBUG_PROBE);
+ wdc_c.r_error));
return (-1);
}
drvp->state = 0;
@@ -396,10 +398,9 @@ wdc_atapi_get_params(chp, drive, id)
retry:
if (ata_get_params(drvp, at_poll, id) != 0) {
- WDCDEBUG_PRINT(("wdc_atapi_get_params: ATAPI_IDENTIFY_DEVICE "
+ WDCDEBUG_PRINT_PROBE(("wdc_atapi_get_params: ATAPI_IDENTIFY_DEVICE "
"failed for drive %s:%d:%d\n",
- chp->wdc->sc_dev.dv_xname, chp->channel, drive),
- DEBUG_PROBE);
+ chp->wdc->sc_dev.dv_xname, chp->channel, drive));
if (retries--) {
delay(100000);
diff --git a/sys/dev/ic/wdc.c b/sys/dev/ic/wdc.c
index 107c7ac49e2..a200e8a5488 100644
--- a/sys/dev/ic/wdc.c
+++ b/sys/dev/ic/wdc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wdc.c,v 1.21 2000/10/27 20:29:27 csapuntz Exp $ */
+/* $OpenBSD: wdc.c,v 1.22 2000/10/28 18:08:46 csapuntz Exp $ */
/* $NetBSD: wdc.c,v 1.68 1999/06/23 19:00:17 bouyer Exp $ */
@@ -91,10 +91,9 @@
#include <dev/ata/atareg.h>
#include <dev/ic/wdcreg.h>
#include <dev/ic/wdcvar.h>
-
#include "atapiscsi.h"
+#include <dev/ic/wdcdbg.h>
-#define WDCDEBUG
#define WDCDELAY 100 /* 100 microseconds */
#define WDCNDELAY_RST (WDC_RESET_WAIT * 1000 / WDCDELAY)
@@ -113,23 +112,7 @@ int __wdccommand_intr __P((struct channel_softc *, struct wdc_xfer *, int));
int wdprint __P((void *, const char *));
void wdc_kill_pending __P((struct channel_softc *));
-
-#define DEBUG_INTR 0x01
-#define DEBUG_XFERS 0x02
-#define DEBUG_STATUS 0x04
-#define DEBUG_FUNCS 0x08
-#define DEBUG_PROBE 0x10
-#define DEBUG_STATUSX 0x20
-#define DEBUG_SDRIVE 0x40
-#define DEBUG_DETACH 0x80
-
-#ifdef WDCDEBUG
int wdcdebug_mask = 0;
-int wdc_nxfer = 0;
-#define WDCDEBUG_PRINT(args, level) if (wdcdebug_mask & (level)) printf args
-#else
-#define WDCDEBUG_PRINT(args, level)
-#endif
int at_poll = AT_POLL;
@@ -403,26 +386,26 @@ wdc_preata_drive(chp, drive)
{
if (wdc_floating_bus(chp, drive)) {
- WDCDEBUG_PRINT(("%s:%d:%d: floating bus detected\n",
+ WDCDEBUG_PRINT_PROBE(("%s:%d:%d: floating bus detected\n",
chp->wdc->sc_dev.dv_xname,
- chp->channel, drive), DEBUG_PROBE);
+ chp->channel, drive));
return 0;
}
CHP_WRITE_REG(chp, wdr_sdh, WDSD_IBM | (drive << 4));
delay(100);
if (wdcwait(chp, WDCS_DRDY | WDCS_DRQ, WDCS_DRDY, 10000) != 0) {
- WDCDEBUG_PRINT(("%s:%d:%d: not ready\n",
+ WDCDEBUG_PRINT_PROBE(("%s:%d:%d: not ready\n",
chp->wdc->sc_dev.dv_xname,
- chp->channel, drive), DEBUG_PROBE);
+ chp->channel, drive));
return 0;
}
CHP_WRITE_REG(chp, wdr_command, WDCC_RECAL);
if (wdcwait(chp, WDCS_DRDY | WDCS_DRQ, WDCS_DRDY, 10000) != 0) {
- WDCDEBUG_PRINT(("%s:%d:%d: WDCC_RECAL failed\n",
+ WDCDEBUG_PRINT_PROBE(("%s:%d:%d: WDCC_RECAL failed\n",
chp->wdc->sc_dev.dv_xname,
- chp->channel, drive), DEBUG_PROBE);
+ chp->channel, drive));
return 0;
}
@@ -449,9 +432,9 @@ wdc_ata_present(chp, drive)
time_to_done = wdc_wait_for_status(chp, WDCS_DRDY, WDCS_DRDY, 1000);
if (time_to_done == -1) return 0;
- WDCDEBUG_PRINT(("%s:%d:%d: waiting for ready %d msec\n",
+ WDCDEBUG_PRINT_PROBE(("%s:%d:%d: waiting for ready %d msec\n",
chp->wdc ? chp->wdc->sc_dev.dv_xname : "wdcprobe",
- chp->channel, drive, time_to_done), DEBUG_PROBE);
+ chp->channel, drive, time_to_done));
/*
This section has been disabled because my Promise Ultra/66
@@ -480,21 +463,22 @@ wdc_ata_present(chp, drive)
time_to_done = wdc_wait_for_status(chp, 0, 0, 1000);
if (time_to_done == -1) {
- WDCDEBUG_PRINT(("%s:%d:%d: timeout waiting for NOP to complete\n",
+ WDCDEBUG_PRINT_PROBE((
+ "%s:%d:%d: timeout waiting for NOP to complete\n",
chp->wdc ? chp->wdc->sc_dev.dv_xname : "wdcprobe",
- chp->channel, drive), DEBUG_PROBE);
+ chp->channel, drive));
return 0;
}
- WDCDEBUG_PRINT(("%s:%d:%d: NOP completed in %d msec\n",
+ WDCDEBUG_PRINT_PROBE(("%s:%d:%d: NOP completed in %d msec\n",
chp->wdc ? chp->wdc->sc_dev.dv_xname : "wdcprobe",
- chp->channel, drive, time_to_done), DEBUG_PROBE);
+ chp->channel, drive, time_to_done));
if (!(chp->ch_status & WDCS_ERR) &&
!(chp->ch_error & WDCE_ABRT)) {
- WDCDEBUG_PRINT(("%s:%d:%d: NOP command did not ABORT command\n",
+ WDCDEBUG_PRINT_PROBE(("%s:%d:%d: NOP command did not ABORT command\n",
chp->wdc ? chp->wdc->sc_dev.dv_xname : "wdcprobe",
- chp->channel, drive), DEBUG_PROBE);
+ chp->channel, drive));
return 0;
}
#endif
@@ -537,9 +521,9 @@ wdcprobe(chp)
delay(10);
st1 = CHP_READ_REG(chp, wdr_status);
- WDCDEBUG_PRINT(("%s:%d: before reset, st0=0x%x, st1=0x%x\n",
+ WDCDEBUG_PRINT_PROBE(("%s:%d: before reset, st0=0x%x, st1=0x%x\n",
chp->wdc ? chp->wdc->sc_dev.dv_xname : "wdcprobe",
- chp->channel, st0, st1), DEBUG_PROBE);
+ chp->channel, st0, st1));
/*
If the status is 0x7f or 0xff, then it's
@@ -560,9 +544,9 @@ wdcprobe(chp)
delay(2000);
ret_value = __wdcwait_reset(chp, ret_value);
- WDCDEBUG_PRINT(("%s:%d: after reset, ret_value=0x%d\n",
+ WDCDEBUG_PRINT_PROBE(("%s:%d: after reset, ret_value=0x%d\n",
chp->wdc ? chp->wdc->sc_dev.dv_xname : "wdcprobe", chp->channel,
- ret_value), DEBUG_PROBE);
+ ret_value));
if (ret_value == 0)
return 0;
@@ -584,10 +568,10 @@ wdcprobe(chp)
cl = CHP_READ_REG(chp, wdr_cyl_lo);
ch = CHP_READ_REG(chp, wdr_cyl_hi);
- WDCDEBUG_PRINT(("%s:%d:%d: after reset, st=0x%x, sc=0x%x"
+ WDCDEBUG_PRINT_PROBE(("%s:%d:%d: after reset, st=0x%x, sc=0x%x"
" sn=0x%x cl=0x%x ch=0x%x\n",
chp->wdc ? chp->wdc->sc_dev.dv_xname : "wdcprobe",
- chp->channel, drive, st0, sc, sn, cl, ch), DEBUG_PROBE);
+ chp->channel, drive, st0, sc, sn, cl, ch));
/*
* This is a simplification of the test in the ATAPI
* spec since not all drives seem to set the other regs
@@ -605,12 +589,12 @@ wdcprobe(chp)
}
}
-#ifdef WDCDEBUG
+
if ((chp->ch_flags & WDCF_VERBOSE_PROBE) ||
(chp->wdc &&
(chp->wdc->sc_dev.dv_cfdata->cf_flags & WDC_OPTION_PROBE_VERBOSE)))
wdcdebug_mask &= ~DEBUG_PROBE;
-#endif
+
return (ret_value);
}
@@ -666,10 +650,10 @@ wdcattach(chp)
return;
}
-#ifdef WDCDEBUG
+
if (chp->wdc->sc_dev.dv_cfdata->cf_flags & WDC_OPTION_PROBE_VERBOSE)
wdcdebug_mask |= DEBUG_PROBE;
-#endif
+
/* init list only once */
if (inited == 0) {
@@ -704,9 +688,9 @@ wdcattach(chp)
} else {
chp->ch_drive[i].drive_flags &=
~(DRIVE_ATA | DRIVE_ATAPI);
- WDCDEBUG_PRINT(("%s:%d:%d: IDENTIFY failed\n",
+ WDCDEBUG_PRINT_PROBE(("%s:%d:%d: IDENTIFY failed\n",
chp->wdc->sc_dev.dv_xname,
- chp->channel, i), DEBUG_PROBE);
+ chp->channel, i));
if (!wdc_preata_drive(chp, i))
chp->ch_drive[i].drive_flags &= ~DRIVE_OLD;
@@ -715,9 +699,8 @@ wdcattach(chp)
ctrl_flags = chp->wdc->sc_dev.dv_cfdata->cf_flags;
channel_flags = (ctrl_flags >> (NBBY * chp->channel)) & 0xff;
- WDCDEBUG_PRINT(("wdcattach: ch_drive_flags 0x%x 0x%x\n",
- chp->ch_drive[0].drive_flags, chp->ch_drive[1].drive_flags),
- DEBUG_PROBE);
+ WDCDEBUG_PRINT_PROBE(("wdcattach: ch_drive_flags 0x%x 0x%x\n",
+ chp->ch_drive[0].drive_flags, chp->ch_drive[1].drive_flags));
/* If no drives, abort here */
if ((chp->ch_drive[0].drive_flags & DRIVE) == 0 &&
@@ -798,10 +781,10 @@ wdcattach(chp)
#endif
exit:
-#ifdef WDCDEBUG
+
if (chp->wdc->sc_dev.dv_cfdata->cf_flags & WDC_OPTION_PROBE_VERBOSE)
wdcdebug_mask &= ~DEBUG_PROBE;
-#endif
+
return;
}
@@ -1008,10 +991,10 @@ __wdcwait_reset(chp, drv_mask)
if (st1 & WDCS_BSY)
drv_mask &= ~0x02;
end:
- WDCDEBUG_PRINT(("%s:%d: wdcwait_reset() end, st0=0x%x, st1=0x%x, "
+ WDCDEBUG_PRINT_PROBE(("%s:%d: wdcwait_reset() end, st0=0x%x, st1=0x%x, "
"reset time=%d msec\n",
chp->wdc ? chp->wdc->sc_dev.dv_xname : "wdcprobe", chp->channel,
- st0, st1, timeout*WDCDELAY/1000), DEBUG_PROBE);
+ st0, st1, timeout*WDCDELAY/1000));
return drv_mask;
}
diff --git a/sys/dev/ic/wdcdbg.h b/sys/dev/ic/wdcdbg.h
new file mode 100644
index 00000000000..ed7c6031922
--- /dev/null
+++ b/sys/dev/ic/wdcdbg.h
@@ -0,0 +1,29 @@
+/* $OpenBSD: wdcdbg.h,v 1.1 2000/10/28 18:08:46 csapuntz Exp $ */
+
+#define WDCDEBUG_PROBE
+
+#define DEBUG_INTR 0x01
+#define DEBUG_XFERS 0x02
+#define DEBUG_STATUS 0x04
+#define DEBUG_FUNCS 0x08
+#define DEBUG_PROBE 0x10
+#define DEBUG_STATUSX 0x20
+#define DEBUG_SDRIVE 0x40
+#define DEBUG_DETACH 0x80
+
+extern int wdcdebug_mask; /* init'ed in wdc.c */
+
+#ifdef WDCDEBUG
+extern int wdcdebug_mask; /* init'ed in wdc.c */
+#define WDCDEBUG_PRINT(args, level) \
+ if (wdcdebug_mask & (level)) \
+ printf args
+#else
+#define WDCDEBUG_PRINT(args, level)
+#endif
+
+#if defined(WDCDEBUG) || defined(WDCDEBUG_PROBE)
+#define WDCDEBUG_PRINT_PROBE(args) if (wdcdebug_mask & DEBUG_PROBE) printf args
+#else
+#define WDCDEBUG_PRINT_PROBE(args)
+#endif