New version of scsi code from Julian
[unix-history] / sys / i386 / isa / wx.c
index f4b5697..4d8dbc3 100644 (file)
@@ -36,7 +36,7 @@ static int wdtest = 0;
  * SUCH DAMAGE.
  *
  *     from: @(#)wx.c  7.2 (Berkeley) 5/9/91
  * SUCH DAMAGE.
  *
  *     from: @(#)wx.c  7.2 (Berkeley) 5/9/91
- *     $Id: wx.c,v 1.11 1993/10/16 13:46:31 rgrimes Exp $
+ *     $Id: wx.c,v 1.3 1993/11/03 18:04:15 nate Exp $
  */
 
 /* TODO:peel out buffer at low ipl, speed improvement */
  */
 
 /* TODO:peel out buffer at low ipl, speed improvement */
@@ -868,6 +868,9 @@ wdcommand(struct disk *du, u_int cylinder, u_int head, u_int sector,
        outb(wdc + wd_cyl_lo, cylinder);
        outb(wdc + wd_cyl_hi, cylinder >> 8);
        outb(wdc + wd_sdh, WDSD_IBM | (du->dk_unit << 4) | head);
        outb(wdc + wd_cyl_lo, cylinder);
        outb(wdc + wd_cyl_hi, cylinder >> 8);
        outb(wdc + wd_sdh, WDSD_IBM | (du->dk_unit << 4) | head);
+       DELAY(10);                      /* XXX give drive time to see change */
+       if (wdwait(du, WDCS_READY) < 0)
+               return(1);
        outb(wdc + wd_sector, sector + 1);
        outb(wdc + wd_seccnt, count);
        outb(du->dk_port + wd_command, command);
        outb(wdc + wd_sector, sector + 1);
        outb(wdc + wd_seccnt, count);
        outb(du->dk_port + wd_command, command);
@@ -922,10 +925,24 @@ wdgetctlr(struct disk *du) {
        if (wdcommand(du, 0, 0, 0, 0, WDCC_READP) != 0
            || wdwait(du, WDCS_READY | WDCS_SEEKCMPLT | WDCS_DRQ) != 0) {
 
        if (wdcommand(du, 0, 0, 0, 0, WDCC_READP) != 0
            || wdwait(du, WDCS_READY | WDCS_SEEKCMPLT | WDCS_DRQ) != 0) {
 
+#ifndef        MFM
                /* Old drives don't support WDCC_READP.  Try a seek to 0. */
                if (wdcommand(du, 0, 0, 0, 0, WDCC_RESTORE | WD_STEP) != 0
                    || wdwait(du, WDCS_READY | WDCS_SEEKCMPLT) != 0)
                        return (1);
                /* Old drives don't support WDCC_READP.  Try a seek to 0. */
                if (wdcommand(du, 0, 0, 0, 0, WDCC_RESTORE | WD_STEP) != 0
                    || wdwait(du, WDCS_READY | WDCS_SEEKCMPLT) != 0)
                        return (1);
+#else  /* IDE */
+               /*
+                * Some IDE drives return trash if there is not a unit 1
+                * out there, need to make sure that it is READY and not BUSY
+                * before you assume it is there !
+                */
+               outb(du->dk_port+wd_sdh, WDSD_IBM | (du->dk_unit<<4));
+               DELAY(5000);
+               if ((inb(du->dk_port+wd_status) & (WDCS_READY|WDCS_BUSY)) !=
+                       WDCS_READY) {
+                       return (1);
+               }
+#endif /* MFM */
 
                /* Fake minimal drive geometry for reading the MBR or label. */
                du->dk_dd.d_secsize = DEV_BSIZE;
 
                /* Fake minimal drive geometry for reading the MBR or label. */
                du->dk_dd.d_secsize = DEV_BSIZE;
@@ -1106,7 +1123,7 @@ wdioctl(dev_t dev, int cmd, caddr_t addr, int flag)
                        auio.uio_segflg = 0;
                        auio.uio_offset =
                                fop->df_startblk * du->dk_dd.d_secsize;
                        auio.uio_segflg = 0;
                        auio.uio_offset =
                                fop->df_startblk * du->dk_dd.d_secsize;
-                       error = physio(wdformat, &rwdbuf[unit], dev, B_WRITE,
+                       error = physio(wdformat, &rwdbuf[unit], 0, dev, B_WRITE,
                                minphys, &auio);
                        fop->df_count -= auio.uio_resid;
                        fop->df_reg[0] = du->dk_status;
                                minphys, &auio);
                        fop->df_count -= auio.uio_resid;
                        fop->df_reg[0] = du->dk_status;