summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Downs <downsj@cvs.openbsd.org>1996-11-28 08:23:41 +0000
committerJason Downs <downsj@cvs.openbsd.org>1996-11-28 08:23:41 +0000
commitb762afc41292bac65d9c249baec0d167c5067991 (patch)
tree18da7962f473a992442e70f94a7963e97816f2dc
parent8730a7ccff4c5ed419045f57690fb82fd2c9fc85 (diff)
Pull in laptop changes from cgd, a couple from me, and a few slight formatting
nits.
-rw-r--r--sys/dev/isa/wd.c4
-rw-r--r--sys/dev/isa/wdc.c68
-rw-r--r--sys/dev/isa/wdlink.h4
3 files changed, 39 insertions, 37 deletions
diff --git a/sys/dev/isa/wd.c b/sys/dev/isa/wd.c
index 810b6412091..f7598ef038e 100644
--- a/sys/dev/isa/wd.c
+++ b/sys/dev/isa/wd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wd.c,v 1.21 1996/11/23 21:46:48 kstailey Exp $ */
+/* $OpenBSD: wd.c,v 1.22 1996/11/28 08:23:38 downsj Exp $ */
/* $NetBSD: wd.c,v 1.150 1996/05/12 23:54:03 mycroft Exp $ */
/*
@@ -790,7 +790,7 @@ wddump(dev, blkno, va, size)
part = WDPART(dev);
/* Make sure it was initialized. */
- if (d_link->sc_state < OPEN)
+ if (d_link->sc_state < READY)
return ENXIO;
wdc = (void *)wd->sc_dev.dv_parent;
diff --git a/sys/dev/isa/wdc.c b/sys/dev/isa/wdc.c
index 687edb41343..98c2a2595a9 100644
--- a/sys/dev/isa/wdc.c
+++ b/sys/dev/isa/wdc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wdc.c,v 1.15 1996/11/23 21:46:49 kstailey Exp $ */
+/* $OpenBSD: wdc.c,v 1.16 1996/11/28 08:23:39 downsj Exp $ */
/* $NetBSD: wd.c,v 1.150 1996/05/12 23:54:03 mycroft Exp $ */
/*
@@ -341,21 +341,19 @@ wdc_ata_start(wdc, xfer)
{
bus_chipset_tag_t bc = wdc->sc_bc;
bus_io_handle_t ioh = wdc->sc_ioh;
- struct wd_link *d_link;
+ struct wd_link *d_link = xfer->d_link;
struct buf *bp = xfer->c_bp;
int nblks;
- d_link=xfer->d_link;
-
if (wdc->sc_errors >= WDIORETRIES) {
- wderror(d_link, bp, "hard error");
+ wderror(d_link, bp, "wdcstart hard error");
xfer->c_flags |= C_ERROR;
wdc_ata_done(wdc, xfer);
return;
}
/* Do control operations specially. */
- if (d_link->sc_state < OPEN) {
+ if (d_link->sc_state < READY) {
/*
* Actually, we want to be careful not to mess with the control
* state if the device is currently busy, but we can assume
@@ -674,11 +672,11 @@ wdcintr(arg)
void *arg;
{
struct wdc_softc *wdc = arg;
- bus_chipset_tag_t bc = wdc->sc_bc;
- bus_io_handle_t ioh = wdc->sc_ioh;
struct wdc_xfer *xfer;
if ((wdc->sc_flags & WDCF_IRQ_WAIT) == 0) {
+ bus_chipset_tag_t bc = wdc->sc_bc;
+ bus_io_handle_t ioh = wdc->sc_ioh;
u_char s;
#ifdef ATAPI_DEBUG_WDC
u_char e, i;
@@ -687,24 +685,26 @@ wdcintr(arg)
/* Clear the pending interrupt and abort. */
s = bus_io_read_1(bc, ioh, wd_status);
+ if (s != (WDCS_DRDY|WDCS_DSC)) {
#ifdef ATAPI_DEBUG_WDC
- e = bus_io_read_1(bc, ioh, wd_error);
- i = bus_io_read_1(bc, ioh, wd_seccnt);
+ e = bus_io_read_1(bc, ioh, wd_error);
+ i = bus_io_read_1(bc, ioh, wd_seccnt);
- printf("wdcintr: inactive controller, "
- "punting st=%02x er=%02x irr=%02x\n", s, e, i);
+ printf("wdcintr: inactive controller, "
+ "punting st=%02x er=%02x irr=%02x\n", s, e, i);
#else
- (void)bus_io_read_1(bc, ioh, wd_error);
- (void)bus_io_read_1(bc, ioh, wd_seccnt);
+ (void)bus_io_read_1(bc, ioh, wd_error);
+ (void)bus_io_read_1(bc, ioh, wd_seccnt);
#endif
- if (s & WDCS_DRQ) {
- int len = bus_io_read_1(bc, ioh, wd_cyl_lo) +
- 256 * bus_io_read_1(bc, ioh, wd_cyl_hi);
+ if (s & WDCS_DRQ) {
+ int len = bus_io_read_1(bc, ioh, wd_cyl_lo) +
+ 256 * bus_io_read_1(bc, ioh, wd_cyl_hi);
#ifdef ATAPI_DEBUG_WDC
- printf ("wdcintr: clearing up %d bytes\n", len);
+ printf ("wdcintr: clearing up %d bytes\n", len);
#endif
- wdcbit_bucket (wdc, len);
+ wdcbit_bucket (wdc, len);
+ }
}
return 0;
}
@@ -714,10 +714,10 @@ wdcintr(arg)
wdc->sc_flags &= ~WDCF_IRQ_WAIT;
xfer = wdc->sc_xfer.tqh_first;
if (xfer->c_flags & C_ATAPI) {
- (void) wdc_atapi_intr(wdc,xfer);
+ (void) wdc_atapi_intr(wdc, xfer);
return 0;
} else {
- return wdc_ata_intr(wdc,xfer);
+ return wdc_ata_intr(wdc, xfer);
}
}
@@ -729,9 +729,7 @@ wdc_ata_intr(wdc,xfer)
{
bus_chipset_tag_t bc = wdc->sc_bc;
bus_io_handle_t ioh = wdc->sc_ioh;
- struct wd_link *d_link;
-
- d_link = xfer->d_link;
+ struct wd_link *d_link = xfer->d_link;
if (wait_for_unbusy(wdc) < 0) {
wdcerror(wdc, "wdcintr: timeout waiting for unbusy");
@@ -741,7 +739,7 @@ wdc_ata_intr(wdc,xfer)
untimeout(wdctimeout, wdc);
/* Is it not a transfer, but a control operation? */
- if (d_link->sc_state < OPEN) {
+ if (d_link->sc_state < READY) {
if (wdccontrol(d_link) == 0) {
/* The drive is busy. Wait. */
return 1;
@@ -776,9 +774,13 @@ wdc_ata_intr(wdc,xfer)
goto bad;
#endif
- wdcunwedge(wdc);
- if (wdc->sc_errors < WDIORETRIES)
+ if (wdc->sc_errors == (WDIORETRIES + 1) / 2) {
+ wderror(d_link, NULL, "wedgie");
+ wdcunwedge(wdc);
return 1;
+ }
+ if (++wdc->sc_errors < WDIORETRIES)
+ goto restart;
wderror(d_link, xfer->c_bp, "hard error");
@@ -1118,7 +1120,7 @@ wdc_exec_xfer(d_link, xfer)
struct wd_link *d_link;
struct wdc_xfer *xfer;
{
- struct wdc_softc *wdc=(struct wdc_softc *)d_link->wdc_softc;
+ struct wdc_softc *wdc = (struct wdc_softc *)d_link->wdc_softc;
int s;
WDDEBUG_PRINT(("wdc_exec_xfer\n"));
@@ -1170,7 +1172,7 @@ wdc_get_xfer(c_link,flags)
if ((xfer->c_flags & C_INUSE) != 0)
panic("wdc_get_xfer: xfer already in use\n");
#endif
- bzero(xfer,sizeof(struct wdc_xfer));
+ bzero(xfer, sizeof(struct wdc_xfer));
xfer->c_flags = C_INUSE;
xfer->c_link = c_link;
return xfer;
@@ -1238,7 +1240,7 @@ wdccontrol(d_link)
case MULTIMODE:
multimode:
if (d_link->sc_mode != WDM_PIOMULTI)
- goto open;
+ goto ready;
bus_io_write_1(bc, ioh, wd_seccnt, d_link->sc_multiple);
if (wdccommandshort(wdc, d_link->sc_drive,
WDCC_SETMULTI) != 0) {
@@ -1257,10 +1259,10 @@ wdccontrol(d_link)
}
/* fall through */
- case OPEN:
- open:
+ case READY:
+ ready:
wdc->sc_errors = 0;
- d_link->sc_state = OPEN;
+ d_link->sc_state = READY;
/*
* The rest of the initialization can be done by normal means.
*/
diff --git a/sys/dev/isa/wdlink.h b/sys/dev/isa/wdlink.h
index d72d677447a..36945bdb5e6 100644
--- a/sys/dev/isa/wdlink.h
+++ b/sys/dev/isa/wdlink.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: wdlink.h,v 1.4 1996/09/11 07:27:04 downsj Exp $ */
+/* $OpenBSD: wdlink.h,v 1.5 1996/11/28 08:23:40 downsj Exp $ */
/*
* Copyright (c) 1994, 1995 Charles M. Hannum. All rights reserved.
@@ -85,7 +85,7 @@ struct wd_link {
#define GEOMETRY_WAIT 3 /* done uploading geometry */
#define MULTIMODE 4 /* set multiple mode */
#define MULTIMODE_WAIT 5 /* done setting multiple mode */
-#define OPEN 6 /* done with open */
+#define READY 6 /* done with open */
int sc_mode; /* transfer mode */
#define WDM_PIOSINGLE 0 /* single-sector PIO */
#define WDM_PIOMULTI 1 /* multi-sector PIO */