Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev Allow wd to attach to something else than wdc/pciide...
details: https://anonhg.NetBSD.org/src/rev/128a357a4bec
branches: trunk
changeset: 518643:128a357a4bec
user: bouyer <bouyer%NetBSD.org@localhost>
date: Mon Dec 03 00:11:15 2001 +0000
description:
Allow wd to attach to something else than wdc/pciide (like USB<->ATA bridges):
- move some functions from ata.c to ata_wdc.c or wdc.c.
- add callbacks to struct ata_bustype so that wd.c doesn't call directly
functions from the lower level driver.
diffstat:
sys/dev/ata/ata.c | 45 +++++----------------------------
sys/dev/ata/ata_wdc.c | 20 +++++++++++++-
sys/dev/ata/atavar.h | 15 +----------
sys/dev/ata/wd.c | 68 +++++++++++++++++++++++++++++++++++++++-----------
sys/dev/ata/wdvar.h | 16 +++++++++--
sys/dev/ic/wdc.c | 9 +++---
sys/dev/ic/wdcvar.h | 8 +++++-
7 files changed, 103 insertions(+), 78 deletions(-)
diffs (truncated from 458 to 300 lines):
diff -r 773a4c08f651 -r 128a357a4bec sys/dev/ata/ata.c
--- a/sys/dev/ata/ata.c Mon Dec 03 00:10:14 2001 +0000
+++ b/sys/dev/ata/ata.c Mon Dec 03 00:11:15 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ata.c,v 1.14 2001/11/13 12:53:09 lukem Exp $ */
+/* $NetBSD: ata.c,v 1.15 2001/12/03 00:11:15 bouyer Exp $ */
/*
* Copyright (c) 1998 Manuel Bouyer. All rights reserved.
*
@@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.14 2001/11/13 12:53:09 lukem Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.15 2001/12/03 00:11:15 bouyer Exp $");
#ifndef WDCDEBUG
#define WDCDEBUG
@@ -44,9 +44,13 @@
#include <sys/device.h>
#include <sys/syslog.h>
-#include <dev/ic/wdcreg.h>
+#include <machine/intr.h>
+#include <machine/bus.h>
+
#include <dev/ata/atareg.h>
#include <dev/ata/atavar.h>
+#include <dev/ic/wdcreg.h>
+#include <dev/ic/wdcvar.h>
#define DEBUG_FUNCS 0x08
#define DEBUG_PROBE 0x10
@@ -188,38 +192,3 @@
drvp->n_xfers = 1; /* restart counting from this error */
}
}
-
-void
-ata_perror(drvp, errno, buf)
- struct ata_drive_datas *drvp;
- int errno;
- char *buf;
-{
- static char *errstr0_3[] = {"address mark not found",
- "track 0 not found", "aborted command", "media change requested",
- "id not found", "media changed", "uncorrectable data error",
- "bad block detected"};
- static char *errstr4_5[] = {"obsolete (address mark not found)",
- "no media/write protected", "aborted command",
- "media change requested", "id not found", "media changed",
- "uncorrectable data error", "interface CRC error"};
- char **errstr;
- int i;
- char *sep = "";
-
- if (drvp->ata_vers >= 4)
- errstr = errstr4_5;
- else
- errstr = errstr0_3;
-
- if (errno == 0) {
- sprintf(buf, "error not notified");
- }
-
- for (i = 0; i < 8; i++) {
- if (errno & (1 << i)) {
- buf += sprintf(buf, "%s%s", sep, errstr[i]);
- sep = ", ";
- }
- }
-}
diff -r 773a4c08f651 -r 128a357a4bec sys/dev/ata/ata_wdc.c
--- a/sys/dev/ata/ata_wdc.c Mon Dec 03 00:10:14 2001 +0000
+++ b/sys/dev/ata/ata_wdc.c Mon Dec 03 00:11:15 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ata_wdc.c,v 1.31 2001/11/13 12:53:09 lukem Exp $ */
+/* $NetBSD: ata_wdc.c,v 1.32 2001/12/03 00:11:15 bouyer Exp $ */
/*
* Copyright (c) 1998 Manuel Bouyer.
@@ -69,7 +69,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ata_wdc.c,v 1.31 2001/11/13 12:53:09 lukem Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ata_wdc.c,v 1.32 2001/12/03 00:11:15 bouyer Exp $");
#ifndef WDCDEBUG
#define WDCDEBUG
@@ -118,6 +118,7 @@
#define ATA_DELAY 10000 /* 10s for a drive I/O */
+int wdc_ata_bio __P((struct ata_drive_datas*, struct ata_bio*));
void wdc_ata_bio_start __P((struct channel_softc *,struct wdc_xfer *));
void _wdc_ata_bio_start __P((struct channel_softc *,struct wdc_xfer *));
int wdc_ata_bio_intr __P((struct channel_softc *, struct wdc_xfer *, int));
@@ -128,6 +129,21 @@
#define WDC_ATA_NOERR 0x00 /* Drive doesn't report an error */
#define WDC_ATA_RECOV 0x01 /* There was a recovered error */
#define WDC_ATA_ERR 0x02 /* Drive reports an error */
+int wdc_ata_addref __P((struct ata_drive_datas *));
+void wdc_ata_delref __P((struct ata_drive_datas *));
+void wdc_ata_kill_pending __P((struct ata_drive_datas *));
+
+const struct ata_bustype wdc_ata_bustype = {
+ SCSIPI_BUSTYPE_ATA,
+ wdc_ata_bio,
+ wdc_reset_channel,
+ wdc_exec_command,
+ ata_get_params,
+ wdc_ata_addref,
+ wdc_ata_delref,
+ wdc_ata_kill_pending,
+};
+
/*
* Handle block I/O operation. Return WDC_COMPLETE, WDC_QUEUED, or
diff -r 773a4c08f651 -r 128a357a4bec sys/dev/ata/atavar.h
--- a/sys/dev/ata/atavar.h Mon Dec 03 00:10:14 2001 +0000
+++ b/sys/dev/ata/atavar.h Mon Dec 03 00:11:15 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: atavar.h,v 1.21 2001/12/02 22:44:32 bouyer Exp $ */
+/* $NetBSD: atavar.h,v 1.22 2001/12/03 00:11:16 bouyer Exp $ */
/*
* Copyright (c) 1998 Manuel Bouyer.
@@ -144,20 +144,8 @@
void *callback_arg; /* argument passed to *callback() */
};
-int wdc_exec_command __P((struct ata_drive_datas *, struct wdc_command*));
-#define WDC_COMPLETE 0x01
-#define WDC_QUEUED 0x02
-#define WDC_TRY_AGAIN 0x03
-
-void wdc_probe_caps __P((struct ata_drive_datas*));
int wdc_downgrade_mode __P((struct ata_drive_datas*));
-void wdc_reset_channel __P((struct ata_drive_datas *));
-
-int wdc_ata_addref __P((struct ata_drive_datas *));
-void wdc_ata_delref __P((struct ata_drive_datas *));
-void wdc_ata_kill_pending __P((struct ata_drive_datas *));
-
struct ataparams;
int ata_get_params __P((struct ata_drive_datas*, u_int8_t,
struct ataparams *));
@@ -168,4 +156,3 @@
#define CMD_AGAIN 2
void ata_dmaerr __P((struct ata_drive_datas *));
-void ata_perror __P((struct ata_drive_datas *, int, char *));
diff -r 773a4c08f651 -r 128a357a4bec sys/dev/ata/wd.c
--- a/sys/dev/ata/wd.c Mon Dec 03 00:10:14 2001 +0000
+++ b/sys/dev/ata/wd.c Mon Dec 03 00:11:15 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: wd.c,v 1.216 2001/12/02 22:44:32 bouyer Exp $ */
+/* $NetBSD: wd.c,v 1.217 2001/12/03 00:11:16 bouyer Exp $ */
/*
* Copyright (c) 1998 Manuel Bouyer. All rights reserved.
@@ -66,7 +66,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.216 2001/12/02 22:44:32 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.217 2001/12/03 00:11:16 bouyer Exp $");
#ifndef WDCDEBUG
#define WDCDEBUG
@@ -141,6 +141,7 @@
struct buf *sc_bp; /* buf being transfered */
void *wdc_softc; /* pointer to our parent */
struct ata_drive_datas *drvp; /* Our controller's infos */
+ const struct ata_bustype *atabus;
int openings;
struct ataparams sc_params;/* drive characteistics found */
int sc_flags;
@@ -179,6 +180,7 @@
int wddetach __P((struct device *, int));
int wdactivate __P((struct device *, enum devact));
int wdprint __P((void *, char *));
+void wdperror __P((struct ata_drive_datas *, int, char *));
struct cfattach wd_ca = {
sizeof(struct wd_softc), wdprobe, wdattach, wddetach, wdactivate
@@ -266,6 +268,7 @@
callout_init(&wd->sc_restart_ch);
BUFQ_INIT(&wd->sc_q);
+ wd->atabus = adev->adev_bustype;
wd->openings = adev->adev_openings;
wd->drvp = adev->adev_drv_data;;
wd->wdc_softc = parent;
@@ -554,7 +557,7 @@
wd->sc_wdc_bio.databuf = bp->b_data;
/* Instrumentation. */
disk_busy(&wd->sc_dk);
- switch (wdc_ata_bio(wd->drvp, &wd->sc_wdc_bio)) {
+ switch (wd->atabus->ata_bio(wd->drvp, &wd->sc_wdc_bio)) {
case WDC_TRY_AGAIN:
callout_reset(&wd->sc_restart_ch, hz, wdrestart, wd);
break;
@@ -562,7 +565,7 @@
case WDC_COMPLETE:
break;
default:
- panic("__wdstart: bad return code from wdc_ata_bio()");
+ panic("__wdstart: bad return code from ata_bio()");
}
}
@@ -595,9 +598,9 @@
if (wd->sc_wdc_bio.r_error != 0 &&
(wd->sc_wdc_bio.r_error & ~(WDCE_MC | WDCE_MCR)) == 0)
goto noerror;
- ata_perror(wd->drvp, wd->sc_wdc_bio.r_error, errbuf);
+ wdperror(wd->drvp, wd->sc_wdc_bio.r_error, errbuf);
retry: /* Just reset and retry. Can we do more ? */
- wdc_reset_channel(wd->drvp);
+ wd->atabus->ata_reset_channel(wd->drvp);
diskerr(bp, "wd", errbuf, LOG_PRINTF,
wd->sc_wdc_bio.blkdone, wd->sc_dk.dk_label);
if (wd->retries++ < WDIORETRIES) {
@@ -732,7 +735,7 @@
* to the adapter.
*/
if (wd->sc_dk.dk_openmask == 0 &&
- (error = wdc_ata_addref(wd->drvp)) != 0)
+ (error = wd->atabus->ata_addref(wd->drvp)) != 0)
return (error);
if ((error = wdlock(wd)) != 0)
@@ -792,7 +795,7 @@
wdunlock(wd);
bad4:
if (wd->sc_dk.dk_openmask == 0)
- wdc_ata_delref(wd->drvp);
+ wd->atabus->ata_delref(wd->drvp);
return error;
}
@@ -828,7 +831,7 @@
if (! (wd->sc_flags & WDF_KLABEL))
wd->sc_flags &= ~WDF_LOADED;
- wdc_ata_delref(wd->drvp);
+ wd->atabus->ata_delref(wd->drvp);
}
wdunlock(wd);
@@ -920,6 +923,40 @@
#endif
}
+void
+wdperror(drvp, errno, buf)
+ struct ata_drive_datas *drvp;
+ int errno;
+ char *buf;
+{
+ static char *errstr0_3[] = {"address mark not found",
+ "track 0 not found", "aborted command", "media change requested",
+ "id not found", "media changed", "uncorrectable data error",
+ "bad block detected"};
+ static char *errstr4_5[] = {"obsolete (address mark not found)",
+ "no media/write protected", "aborted command",
+ "media change requested", "id not found", "media changed",
+ "uncorrectable data error", "interface CRC error"};
+ char **errstr;
+ int i;
+ char *sep = "";
+
+ if (drvp->ata_vers >= 4)
+ errstr = errstr4_5;
+ else
+ errstr = errstr0_3;
+
+ if (errno == 0)
+ sprintf(buf, "error not notified");
+
+ for (i = 0; i < 8; i++) {
+ if (errno & (1 << i)) {
+ buf += sprintf(buf, "%s%s", sep, errstr[i]);
+ sep = ", ";
+ }
+ }
+}
+
int
wdioctl(dev, xfer, addr, flag, p)
dev_t dev;
@@ -1235,7 +1272,7 @@
min(nblks, wddumpmulti) * lp->d_secsize;
wd->sc_wdc_bio.databuf = va;
#ifndef WD_DUMP_NOT_TRUSTED
- switch (wdc_ata_bio(wd->drvp, &wd->sc_wdc_bio)) {
Home |
Main Index |
Thread Index |
Old Index