*** wdc.c- Mon Oct 27 16:31:35 1997 --- wdc.c Fri Sep 18 09:37:05 1998 *************** *** 1,4 **** ! /* $OpenBSD: wdc.c,v 1.23 1997/08/07 10:24:25 niklas Exp $ */ /* $NetBSD: wd.c,v 1.150 1996/05/12 23:54:03 mycroft Exp $ */ /* --- 1,4 ---- ! /* $OpenBSD: wdc.c,v 1.25 1997/12/10 23:02:01 rees Exp $ */ /* $NetBSD: wd.c,v 1.150 1996/05/12 23:54:03 mycroft Exp $ */ /* *************** *** 180,186 **** if (wdcreset(wdc, WDCRESET_SILENT) != 0) { /* * if the reset failed,, there is no master. test for ATAPI ! * signature on the salve device. If no ATAPI slave, wait 5s * and retry a reset. */ bus_space_write_1(iot, ioh, wd_sdh, WDSD_IBM | 0x10); /* slave */ --- 180,186 ---- if (wdcreset(wdc, WDCRESET_SILENT) != 0) { /* * if the reset failed,, there is no master. test for ATAPI ! * signature on the slave device. If no ATAPI slave, wait 5s * and retry a reset. */ bus_space_write_1(iot, ioh, wd_sdh, WDSD_IBM | 0x10); /* slave */ *************** *** 244,252 **** struct isa_attach_args *ia = aux; #if NWD > 0 int drive; - #endif /* NWD */ bus_space_tag_t iot = wdc->sc_iot; bus_space_handle_t ioh = wdc->sc_ioh; TAILQ_INIT(&wdc->sc_xfer); wdc->sc_drq = ia->ia_drq; --- 244,252 ---- struct isa_attach_args *ia = aux; #if NWD > 0 int drive; bus_space_tag_t iot = wdc->sc_iot; bus_space_handle_t ioh = wdc->sc_ioh; + #endif /* NWD */ TAILQ_INIT(&wdc->sc_xfer); wdc->sc_drq = ia->ia_drq; *************** *** 397,403 **** struct buf *bp = xfer->c_bp; int nblks; ! if (wdc->sc_errors >= WDIORETRIES) { wderror(d_link, bp, "wdcstart hard error"); xfer->c_flags |= C_ERROR; wdc_ata_done(wdc, xfer); --- 397,403 ---- struct buf *bp = xfer->c_bp; int nblks; ! if (xfer->c_errors >= WDIORETRIES) { wderror(d_link, bp, "wdcstart hard error"); xfer->c_flags |= C_ERROR; wdc_ata_done(wdc, xfer); *************** *** 433,447 **** /* When starting a transfer... */ if (xfer->c_skip == 0) { ! daddr_t blkno; WDDEBUG_PRINT(("\n%s: wdc_ata_start %s %d@%d; map ", wdc->sc_dev.dv_xname, (xfer->c_flags & B_READ) ? "read" : "write", xfer->c_bcount, xfer->c_blkno)); - - blkno = xfer->c_blkno+xfer->c_p_offset; - xfer->c_blkno = blkno / (d_link->sc_lp->d_secsize / DEV_BSIZE); } else { WDDEBUG_PRINT((" %d)0x%x", xfer->c_skip, bus_space_read_1(iot, ioh, wd_altsts))); --- 433,446 ---- /* When starting a transfer... */ if (xfer->c_skip == 0) { ! struct buf *bp = xfer->c_bp; + xfer->c_bcount = bp->b_bcount; + xfer->c_blkno = (bp->b_blkno + xfer->c_p_offset) / (d_link->sc_lp->d_secsize / DEV_BSIZE); WDDEBUG_PRINT(("\n%s: wdc_ata_start %s %d@%d; map ", wdc->sc_dev.dv_xname, (xfer->c_flags & B_READ) ? "read" : "write", xfer->c_bcount, xfer->c_blkno)); } else { WDDEBUG_PRINT((" %d)0x%x", xfer->c_skip, bus_space_read_1(iot, ioh, wd_altsts))); *************** *** 651,657 **** /* Have we an error? */ if (wdc->sc_status & WDCS_ERR) { #ifdef WDDEBUG ! wderror(d_link, NULL, "wdc_ata_start"); #endif if ((wdc->sc_flags & WDCF_SINGLE) == 0) { wdc->sc_flags |= WDCF_ERROR; --- 650,656 ---- /* Have we an error? */ if (wdc->sc_status & WDCS_ERR) { #ifdef WDDEBUG ! wderror(d_link, NULL, "wdc_ata_intr"); #endif if ((wdc->sc_flags & WDCF_SINGLE) == 0) { wdc->sc_flags |= WDCF_ERROR; *************** *** 663,674 **** goto bad; #endif ! 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"); --- 662,672 ---- goto bad; #endif ! if (++xfer->c_errors == (WDIORETRIES + 1) / 2) { wdcunwedge(wdc); return 1; } ! if (xfer->c_errors < WDIORETRIES) goto restart; wderror(d_link, xfer->c_bp, "hard error"); *************** *** 700,709 **** } /* If we encountered any abnormalities, flag it as a soft error. */ ! if (wdc->sc_errors > 0 || (wdc->sc_status & WDCS_CORR) != 0) { wderror(d_link, xfer->c_bp, "soft error (corrected)"); ! wdc->sc_errors = 0; } /* Adjust pointers for the next block, if any. */ --- 698,707 ---- } /* If we encountered any abnormalities, flag it as a soft error. */ ! if (xfer->c_errors > 0 || (wdc->sc_status & WDCS_CORR) != 0) { wderror(d_link, xfer->c_bp, "soft error (corrected)"); ! xfer->c_errors = 0; } /* Adjust pointers for the next block, if any. */ *************** *** 744,750 **** s = splbio(); TAILQ_REMOVE(&wdc->sc_xfer, xfer, c_xferchain); wdc->sc_flags &= ~(WDCF_SINGLE | WDCF_ERROR | WDCF_ACTIVE); - wdc->sc_errors = 0; if (bp) { if (xfer->c_flags & C_ERROR) { bp->b_flags |= B_ERROR; --- 742,747 ---- *************** *** 972,978 **** case READY: ready: - wdc->sc_errors = 0; d_link->sc_state = READY; /* * The rest of the initialization can be done by normal means. --- 969,974 ---- *************** *** 1045,1051 **** #ifdef ATAPI_DEBUG_WDC printf("wdc_atapi_start, acp flags %lx\n",acp->flags); #endif ! if (wdc->sc_errors >= WDIORETRIES) { acp->status |= ERROR; acp->error = bus_space_read_1(iot, ioh, wd_error); wdc_atapi_done(wdc, xfer); --- 1041,1047 ---- #ifdef ATAPI_DEBUG_WDC printf("wdc_atapi_start, acp flags %lx\n",acp->flags); #endif ! if (xfer->c_errors >= WDIORETRIES) { acp->status |= ERROR; acp->error = bus_space_read_1(iot, ioh, wd_error); wdc_atapi_done(wdc, xfer); *************** *** 1289,1295 **** delay(1000); wdc->sc_flags &= ~(WDCF_IRQ_WAIT | WDCF_SINGLE | WDCF_ERROR); ! wdc->sc_errors = 0; xfer->c_skip = 0; return; } else { /* POLLED */ --- 1285,1291 ---- delay(1000); wdc->sc_flags &= ~(WDCF_IRQ_WAIT | WDCF_SINGLE | WDCF_ERROR); ! xfer->c_errors = 0; xfer->c_skip = 0; return; } else { /* POLLED */ *************** *** 1471,1477 **** s = splbio(); /* remove this command from xfer queue */ - wdc->sc_errors = 0; xfer->c_skip = 0; if ((xfer->c_flags & A_POLLED) == 0) { untimeout(wdctimeout, wdc); --- 1467,1472 ---- *************** *** 1508,1513 **** --- 1503,1509 ---- struct wdc_xfer *xfer; if ((wdc->sc_flags & WDCF_IRQ_WAIT) == 0) { + #if NATAPIBUS > 0 bus_space_tag_t iot = wdc->sc_iot; bus_space_handle_t ioh = wdc->sc_ioh; u_char s; *************** *** 1540,1545 **** --- 1536,1542 ---- wdcbit_bucket(wdc, len); } } + #endif /* NATAPIBUS > 0 */ return 0; } *************** *** 1630,1636 **** } wdc->sc_flags |= WDCF_ERROR; - ++wdc->sc_errors; /* Wake up in a little bit and restart the operation. */ WDDEBUG_PRINT(("wdcrestart from wdcunwedge\n")); --- 1627,1632 ----