BSD 4_4 release
[unix-history] / usr / src / sys / vax / uba / rx.c
index fdee00e..05de40f 100644 (file)
@@ -1,4 +1,10 @@
-/*     rx.c    4.15    83/04/15        */
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved.  The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ *     @(#)rx.c        7.5 (Berkeley) 12/16/90
+ */
 
 #include "rx.h"
 #if NFX > 0
 
 #include "rx.h"
 #if NFX > 0
  *     powered off at boot time, the controller won't interrupt!
  */
 
  *     powered off at boot time, the controller won't interrupt!
  */
 
-#include "../machine/pte.h"
+#include "../include/pte.h"
 
 
-#include "../h/param.h"
-#include "../h/buf.h"
-#include "../h/systm.h"
-#include "../h/conf.h"
-#include "../h/errno.h"
-#include "../h/time.h"
-#include "../h/kernel.h"
-#include "../h/uio.h"
-#include "../h/file.h"
+#include "sys/param.h"
+#include "sys/buf.h"
+#include "sys/systm.h"
+#include "sys/conf.h"
+#include "sys/errno.h"
+#include "sys/time.h"
+#include "sys/kernel.h"
+#include "sys/uio.h"
+#include "sys/file.h"
 
 
-#include "../vax/cpu.h"
+#include "../include/cpu.h"
 #include "../vax/nexus.h"
 
 #include "../vax/nexus.h"
 
-#include "../vaxuba/ubavar.h"
-#include "../vaxuba/ubareg.h"
-#include "../vaxuba/rxreg.h"
+#include "ubavar.h"
+#include "ubareg.h"
+#include "rxreg.h"
 
 #define b_cylin        b_resid
 
 
 #define b_cylin        b_resid
 
@@ -65,14 +71,15 @@ struct buf  rxutab[NRX];    /* per drive buffers */
 /* per-drive data */
 struct rx_softc {
        int     sc_flags;       /* drive status flags */
 /* per-drive data */
 struct rx_softc {
        int     sc_flags;       /* drive status flags */
-#define        RXF_TRKZERO     0x01    /* start mapping on track 0 */
-#define        RXF_DIRECT      0x02    /* use direct sector mapping */
+#define        RXF_DIRECT      0x01    /* if set: use direct sector mapping */
+#define        RXF_TRKONE      0x02    /* if set: start mapping on track 1 */
 #define        RXF_DBLDEN      0x04    /* use double density */
 #define        RXF_DEVTYPE     0x07    /* mapping flags */
 #define        RXF_LOCK        0x10    /* exclusive use */
 #define        RXF_DDMK        0x20    /* deleted-data mark detected */
 #define        RXF_USEWDDS     0x40    /* write deleted-data sector */
 #define        RXF_FORMAT      0x80    /* format in progress */
 #define        RXF_DBLDEN      0x04    /* use double density */
 #define        RXF_DEVTYPE     0x07    /* mapping flags */
 #define        RXF_LOCK        0x10    /* exclusive use */
 #define        RXF_DDMK        0x20    /* deleted-data mark detected */
 #define        RXF_USEWDDS     0x40    /* write deleted-data sector */
 #define        RXF_FORMAT      0x80    /* format in progress */
+#define        RXF_BAD         0x100   /* drive bad, cannot be used */
        int     sc_csbits;      /* constant bits for CS register */
        int     sc_open;        /* count number of opens */
        int     sc_offset;      /* raw mode kludge to avoid restricting */
        int     sc_csbits;      /* constant bits for CS register */
        int     sc_open;        /* count number of opens */
        int     sc_offset;      /* raw mode kludge to avoid restricting */
@@ -98,6 +105,8 @@ struct rxerr {
 struct uba_device *rxdinfo[NRX];
 struct uba_ctlr *rxminfo[NFX];
 
 struct uba_device *rxdinfo[NRX];
 struct uba_ctlr *rxminfo[NFX];
 
+struct buf *savebp;
+
 int rxprobe(), rxslave(), rxattach(), rxdgo(), rxintr(), rxwatch(), rxphys();
 u_short rxstd[] = { 0177170, 0177150, 0 };
 struct uba_driver fxdriver =
 int rxprobe(), rxslave(), rxattach(), rxdgo(), rxintr(), rxwatch(), rxphys();
 u_short rxstd[] = { 0177170, 0177150, 0 };
 struct uba_driver fxdriver =
@@ -134,12 +143,11 @@ rxprobe (reg)
        return (sizeof (*rxaddr));
 }
 
        return (sizeof (*rxaddr));
 }
 
+/*ARGSUSED*/
 rxslave(ui, reg)
        struct uba_device *ui;
        caddr_t reg;
 {
 rxslave(ui, reg)
        struct uba_device *ui;
        caddr_t reg;
 {
-
-       ui->ui_dk = 1;
        return (ui->ui_slave == 0 || ui->ui_slave == 1);
 }
 
        return (ui->ui_slave == 0 || ui->ui_slave == 1);
 }
 
@@ -153,7 +161,6 @@ rxattach(ui)
 /*ARGSUSED1*/
 rxopen(dev, flag)
        dev_t dev;
 /*ARGSUSED1*/
 rxopen(dev, flag)
        dev_t dev;
-       int flag;
 { 
        register int unit = RXUNIT(dev);
        register struct rx_softc *sc;
 { 
        register int unit = RXUNIT(dev);
        register struct rx_softc *sc;
@@ -169,7 +176,7 @@ rxopen(dev, flag)
                 * lock the device while an open 
                 * is in progress
                 */
                 * lock the device while an open 
                 * is in progress
                 */
-               sc->sc_flags = (minor(dev) & RXF_DEVTYPE) || RXF_LOCK;
+               sc->sc_flags = (minor(dev) & RXF_DEVTYPE) | RXF_LOCK;
                sc->sc_csbits = RX_INTR;
                sc->sc_csbits |= ui->ui_slave == 0 ? RX_DRV0 : RX_DRV1;
 
                sc->sc_csbits = RX_INTR;
                sc->sc_csbits |= ui->ui_slave == 0 ? RX_DRV0 : RX_DRV1;
 
@@ -177,6 +184,8 @@ rxopen(dev, flag)
                bp->b_flags = B_RDSTAT | B_BUSY;
                bp->b_error = 0;
                bp->b_blkno = 0;
                bp->b_flags = B_RDSTAT | B_BUSY;
                bp->b_error = 0;
                bp->b_blkno = 0;
+               sc->sc_offset = 0;
+               sc->sc_resid  = 0;
                /*
                 * read device status to determine if
                 * a floppy is present in the drive and
                /*
                 * read device status to determine if
                 * a floppy is present in the drive and
@@ -186,12 +195,13 @@ rxopen(dev, flag)
                iowait(bp);
                if (bp->b_flags & B_ERROR) {
                        sc->sc_csbits = 0;
                iowait(bp);
                if (bp->b_flags & B_ERROR) {
                        sc->sc_csbits = 0;
+                       sc->sc_flags &= ~RXF_LOCK;
                        return (bp->b_error);
                }
                if (rxwstart++ == 0) {
                        rxc = &rx_ctlr[ui->ui_mi->um_ctlr];
                        rxc->rxc_tocnt = 0;
                        return (bp->b_error);
                }
                if (rxwstart++ == 0) {
                        rxc = &rx_ctlr[ui->ui_mi->um_ctlr];
                        rxc->rxc_tocnt = 0;
-                       timeout(rxtimo(), (caddr_t)0, hz);  /* start watchdog */
+                       timeout(rxwatch, (caddr_t)0, hz);  /* start watchdog */
                }
 #ifdef RXDEBUG
                printf("rxopen: csbits=0x%x\n", sc->sc_csbits);
                }
 #ifdef RXDEBUG
                printf("rxopen: csbits=0x%x\n", sc->sc_csbits);
@@ -201,19 +211,21 @@ rxopen(dev, flag)
                if (sc->sc_flags & RXF_LOCK)
                        return(EBUSY);
        }
                if (sc->sc_flags & RXF_LOCK)
                        return(EBUSY);
        }
-       sc->sc_open++;
+       sc->sc_open = 1;
        return (0);
 }
 
 /*ARGSUSED1*/
 rxclose(dev, flag)
        dev_t dev;
        return (0);
 }
 
 /*ARGSUSED1*/
 rxclose(dev, flag)
        dev_t dev;
-       int flag;
 {
        register struct rx_softc *sc = &rx_softc[RXUNIT(dev)];
 
 {
        register struct rx_softc *sc = &rx_softc[RXUNIT(dev)];
 
-       --sc->sc_open;
+       sc->sc_open = 0;
+#ifdef RXDEBUG
        printf("rxclose: dev=0x%x, sc_open=%d\n", dev, sc->sc_open);
        printf("rxclose: dev=0x%x, sc_open=%d\n", dev, sc->sc_open);
+#endif
+       return (0);
 }
 
 rxstrategy(bp)
 }
 
 rxstrategy(bp)
@@ -230,13 +242,17 @@ rxstrategy(bp)
        if (ui == 0 || ui->ui_alive == 0) 
                goto bad;
        sc = &rx_softc[unit];
        if (ui == 0 || ui->ui_alive == 0) 
                goto bad;
        sc = &rx_softc[unit];
-       if (bp->b_blkno < 0 || (bp->b_blkno * DEV_BSIZE) > RXSIZE )
+       if (bp->b_blkno < 0 || dbtob(bp->b_blkno) > RXSIZE)
                goto bad;
                goto bad;
+       if (sc->sc_flags & RXF_BAD) {
+               bp->b_error = EIO;
+               goto dbad;
+       }
+       s = spl5();
 #ifdef RXDEBUG
 #ifdef RXDEBUG
-       printf("rxstrategy: bp=0x%x, flgs=0x%x, unit=%d, block=%d, count=%d\n", 
+       printf("rxstrat: bp=0x%x, fl=0x%x, un=%d, bl=%d, cnt=%d\n", 
                bp, bp->b_flags, unit, bp->b_blkno, bp->b_bcount);
 #endif
                bp, bp->b_flags, unit, bp->b_blkno, bp->b_bcount);
 #endif
-       s = spl5();
        bp->b_cylin = bp->b_blkno;      /* don't care to calculate trackno */
        dp = &rxutab[unit];
        disksort(dp, bp);
        bp->b_cylin = bp->b_blkno;      /* don't care to calculate trackno */
        dp = &rxutab[unit];
        disksort(dp, bp);
@@ -250,9 +266,10 @@ rxstrategy(bp)
        return;
 
 bad:
        return;
 
 bad:
+       bp->b_error = ENXIO;
+dbad:
        bp->b_flags |= B_ERROR;
        iodone(bp);
        bp->b_flags |= B_ERROR;
        iodone(bp);
-       bp->b_error = ENXIO;
        return;
 }
 
        return;
 }
 
@@ -305,7 +322,7 @@ rxmap(bp, psector, ptrack)
        register int lt, ls, ptoff;
        struct rx_softc *sc = &rx_softc[RXUNIT(bp->b_dev)];
 
        register int lt, ls, ptoff;
        struct rx_softc *sc = &rx_softc[RXUNIT(bp->b_dev)];
 
-       ls = ( bp->b_blkno * DEV_BSIZE + ( sc->sc_offset - sc->sc_resid ))/NBPS;
+       ls = (dbtob(bp->b_blkno) + (sc->sc_offset - sc->sc_resid)) / NBPS;
        lt = ls / 26;
        ls %= 26;
        /*
        lt = ls / 26;
        ls %= 26;
        /*
@@ -317,7 +334,7 @@ rxmap(bp, psector, ptrack)
        ptoff = 0;
        if (sc->sc_flags & RXF_DIRECT)
                ptoff = 77;
        ptoff = 0;
        if (sc->sc_flags & RXF_DIRECT)
                ptoff = 77;
-       if (sc->sc_flags & RXF_TRKZERO)
+       if (sc->sc_flags & RXF_TRKONE)
                ptoff++;
        if (lt + ptoff < 77)
                ls = ((ls << 1) + (ls >= 13) + (6*lt)) % 26;
                ptoff++;
        if (lt + ptoff < 77)
                ls = ((ls << 1) + (ls >= 13) + (6*lt)) % 26;
@@ -355,6 +372,10 @@ loop:
        um->um_tab.b_active++;
        unit = RXUNIT(bp->b_dev);
        sc = &rx_softc[unit];
        um->um_tab.b_active++;
        unit = RXUNIT(bp->b_dev);
        sc = &rx_softc[unit];
+       if (sc->sc_flags & RXF_BAD) {
+               rxpurge(um);
+               return;
+       }
        if (dp->b_active == 1) {
                sc->sc_resid = bp->b_bcount;
                sc->sc_uaddr = bp->b_un.b_addr;
        if (dp->b_active == 1) {
                sc->sc_resid = bp->b_bcount;
                sc->sc_uaddr = bp->b_un.b_addr;
@@ -466,8 +487,8 @@ rxintr(ctlr)
        rxc->rxc_tocnt = 0;
        er = &rxerr[unit];
 #ifdef RXDEBUG
        rxc->rxc_tocnt = 0;
        er = &rxerr[unit];
 #ifdef RXDEBUG
-       printf("rxintr: dev=%x, state=%d, status=0x%x", 
-               bp->b_dev, rxc->rxc_state, rxaddr->rxcs);
+       printf("rxint: dev=%x, st=%d, cs=0x%x, db=0x%x\n", 
+               bp->b_dev, rxc->rxc_state, rxaddr->rxcs, rxaddr->rxdb);
 #endif
        if ((rxaddr->rxcs & RX_ERR) &&
            (rxc->rxc_state != RXS_RDSTAT) && (rxc->rxc_state != RXS_RDERR))
 #endif
        if ((rxaddr->rxcs & RX_ERR) &&
            (rxc->rxc_state != RXS_RDSTAT) && (rxc->rxc_state != RXS_RDERR))
@@ -487,9 +508,6 @@ rxintr(ctlr)
                rxc->rxc_state = RXS_EMPTY;
                um->um_cmd = RX_EMPTY;
                (void) ubago(ui);
                rxc->rxc_state = RXS_EMPTY;
                um->um_cmd = RX_EMPTY;
                (void) ubago(ui);
-#ifdef RXDEBUG
-               printf("\n");
-#endif
                return;
 
        case RXS_FILL:
                return;
 
        case RXS_FILL:
@@ -506,9 +524,6 @@ rxintr(ctlr)
                while ((rxaddr->rxcs&RX_TREQ) == 0)
                        ;
                rxaddr->rxdb = track;
                while ((rxaddr->rxcs&RX_TREQ) == 0)
                        ;
                rxaddr->rxdb = track;
-#ifdef RXDEBUG
-               printf("\n");
-#endif
                return;
 
        /*
                return;
 
        /*
@@ -527,7 +542,7 @@ rxintr(ctlr)
                }
                if (rxaddr->rxdb&RXES_READY)
                        goto rderr;
                }
                if (rxaddr->rxdb&RXES_READY)
                        goto rderr;
-               bp->b_error = EBUSY;
+               bp->b_error = ENODEV;
                bp->b_flags |= B_ERROR;
                goto done;
 
                bp->b_flags |= B_ERROR;
                goto done;
 
@@ -542,13 +557,13 @@ rxintr(ctlr)
                goto rdone;
 
        case RXS_RDERR:
                goto rdone;
 
        case RXS_RDERR:
-               bp = bp->b_back;                /* kludge, see 'rderr:' */
+               bp = savebp;
                rxmap(bp, &sector, &track);
                printf("rx%d: hard error, trk %d psec %d ",
                        unit, track, sector);
                printf("cs=%b, db=%b, err=", MASKREG(er->rxcs), 
                        RXCS_BITS, MASKREG(er->rxdb), RXES_BITS);
                rxmap(bp, &sector, &track);
                printf("rx%d: hard error, trk %d psec %d ",
                        unit, track, sector);
                printf("cs=%b, db=%b, err=", MASKREG(er->rxcs), 
                        RXCS_BITS, MASKREG(er->rxdb), RXES_BITS);
-               printf("0x%x, 0x%x, 0x%x, 0x%x\n", MASKREG(er->rxxt[0]),
+               printf("%x, %x, %x, %x\n", MASKREG(er->rxxt[0]),
                        MASKREG(er->rxxt[1]), MASKREG(er->rxxt[2]), 
                        MASKREG(er->rxxt[3]));
                goto done;
                        MASKREG(er->rxxt[1]), MASKREG(er->rxxt[2]), 
                        MASKREG(er->rxxt[3]));
                goto done;
@@ -571,12 +586,12 @@ error:
        if (rxc->rxc_state == RXS_FORMAT || (rxaddr->rxdb&RXES_DENERR))
                goto giveup;
        if (rxaddr->rxdb & RXES_CRCERR) {
        if (rxc->rxc_state == RXS_FORMAT || (rxaddr->rxdb&RXES_DENERR))
                goto giveup;
        if (rxaddr->rxdb & RXES_CRCERR) {
-               if (++bp->b_errcnt >= 10)
+               if (++um->um_tab.b_errcnt >= 10)
                        goto giveup;
                goto retry;
        }
                        goto giveup;
                goto retry;
        }
-       bp->b_errcnt += 9;
-       if (bp->b_errcnt >= 10)
+       um->um_tab.b_errcnt += 9;
+       if (um->um_tab.b_errcnt >= 10)
                goto giveup;
        rxaddr->rxcs = RX_INIT;
        /* no way to get an interrupt for "init done", so just wait */
                goto giveup;
        rxaddr->rxcs = RX_INIT;
        /* no way to get an interrupt for "init done", so just wait */
@@ -599,34 +614,28 @@ retry:
 giveup:
        /*
         * Hard I/O error --
 giveup:
        /*
         * Hard I/O error --
-        * Density errors are not noted on the console since the
-        * only way to determine the density of an unknown disk
-        * is to try one density or the other at random and see
-        * which one doesn't give a density error.
+        * ALL errors are considered fatal and will abort the
+        * transfer and purge the i/o request queue
         */
         */
-       if (rxaddr->rxdb & RXES_DENERR) {
-               bp->b_error = ENODEV;
-               bp->b_flags |= B_ERROR;
-               goto done;
-       }
+       sc->sc_flags |= RXF_BAD;
+       sc->sc_resid = 0;       /* make sure the transfer is terminated */
        rxc->rxc_state = RXS_RDSTAT;
        rxaddr->rxcs = RX_RDSTAT | sc->sc_csbits;
        return;
 
 rderr:
        /*
        rxc->rxc_state = RXS_RDSTAT;
        rxaddr->rxcs = RX_RDSTAT | sc->sc_csbits;
        return;
 
 rderr:
        /*
-        * A hard error (other than not ready or density) has occurred.
+        * A hard error (other than not ready) has occurred.
         * Read the extended error status information.
         * Before doing this, save the current CS and DB register values,
         * because the read error status operation may modify them.
         * Read the extended error status information.
         * Before doing this, save the current CS and DB register values,
         * because the read error status operation may modify them.
-        * Insert buffer with request at the head of the queue, and
-        * save a pointer to the data buffer, so it can be restored
-        * when the read error status operation is finished.
+        * Insert buffer with request at the head of the queue.
         */
        bp->b_error = EIO;
        bp->b_flags |= B_ERROR;
         */
        bp->b_error = EIO;
        bp->b_flags |= B_ERROR;
-       ubadone(um);
-       erxbuf[unit].b_back = bp;       /* save the data buffer pointer */
+       if (um->um_ubinfo)
+               ubadone(um);
+       savebp = bp;
        er->rxcs = rxaddr->rxcs;
        er->rxdb = rxaddr->rxdb;
        bp = &erxbuf[unit];
        er->rxcs = rxaddr->rxcs;
        er->rxdb = rxaddr->rxdb;
        bp = &erxbuf[unit];
@@ -649,9 +658,6 @@ rdone:
        um->um_tab.b_errcnt = 0;
        if ((sc->sc_resid -= NBPS) > 0) {
                bp->b_un.b_addr += NBPS;
        um->um_tab.b_errcnt = 0;
        if ((sc->sc_resid -= NBPS) > 0) {
                bp->b_un.b_addr += NBPS;
-#ifdef RXDEBUG
-               printf("\n");
-#endif
                rxstart(um);
                return;
        }
                rxstart(um);
                return;
        }
@@ -666,7 +672,7 @@ rdone:
        dp->b_active = 0;
        dp->b_errcnt = 0;
 #ifdef RXDEBUG
        dp->b_active = 0;
        dp->b_errcnt = 0;
 #ifdef RXDEBUG
-       printf(" old bp=0x%x, new=0x%x\n", bp, dp->b_actf);
+       printf(".. bp=%x, new=%x\n", bp, dp->b_actf);
 #endif
        /*
         * If this unit has more work to do,
 #endif
        /*
         * If this unit has more work to do,
@@ -680,7 +686,7 @@ rdone:
 
 /*ARGSUSED*/
 
 
 /*ARGSUSED*/
 
-rxtimo()
+rxwatch()
 {
        register struct uba_device *ui;
        register struct uba_ctlr *um;
 {
        register struct uba_device *ui;
        register struct uba_ctlr *um;
@@ -690,23 +696,26 @@ rxtimo()
 
        for (i=0; i<NRX; i++) {
                ui = rxdinfo[i];
 
        for (i=0; i<NRX; i++) {
                ui = rxdinfo[i];
-               sc = &rx_softc[i];
-               um = ui->ui_mi;
                if (ui == 0 || ui->ui_alive == 0)
                        continue;
                if (ui == 0 || ui->ui_alive == 0)
                        continue;
-               if ((sc->sc_open == 0) && (um->um_tab.b_active == 0)) {
+               sc = &rx_softc[i];
+               if ((sc->sc_open == 0) && (rxutab[i].b_active == 0)) {
                        sc->sc_csbits = 0;
                        continue;
                }
                dopen++;
                        sc->sc_csbits = 0;
                        continue;
                }
                dopen++;
+               um = ui->ui_mi;
                rxc = &rx_ctlr[um->um_ctlr];
                rxc = &rx_ctlr[um->um_ctlr];
-               if (++rxc->rxc_tocnt < RX_MAXTIMEOUT) {
-                       printf("fx%d: timeout\n", um->um_ctlr);
-                       rxintr(um->um_ctlr);
+               if (++rxc->rxc_tocnt >= RX_MAXTIMEOUT) {
+                       rxc->rxc_tocnt = 0;
+                       if (um->um_tab.b_active) {      
+                               printf("rx%d: timeout\n", i);/* for debugging */
+                               rxintr(um->um_ctlr);
+                       }
                }
        }
        if (dopen)
                }
        }
        if (dopen)
-               timeout(rxtimo(), (caddr_t)0, hz);
+               timeout(rxwatch, (caddr_t)0, hz);
        else
                rxwstart = 0;
 }
        else
                rxwstart = 0;
 }
@@ -722,8 +731,11 @@ rxreset(uban)
                if ((um = rxminfo[ctlr]) == 0 || um->um_ubanum != uban ||
                    um->um_alive == 0)
                        continue;
                if ((um = rxminfo[ctlr]) == 0 || um->um_ubanum != uban ||
                    um->um_alive == 0)
                        continue;
-               if (um->um_ubinfo)
+               printf(" fx%d", ctlr);
+               if (um->um_ubinfo) {
+                       printf("<%d>", UBAI_BDP(um->um_ubinfo));
                        um->um_ubinfo = 0;
                        um->um_ubinfo = 0;
+               }
                rx_ctlr[ctlr].rxc_state = RXS_IDLE;
                rxaddr = (struct rxdevice *)um->um_addr;
                rxaddr->rxcs = RX_INIT;
                rx_ctlr[ctlr].rxc_state = RXS_IDLE;
                rxaddr = (struct rxdevice *)um->um_addr;
                rxaddr->rxcs = RX_INIT;
@@ -765,24 +777,27 @@ rxwrite(dev, uio)
 
 /*
  * Control routine:
 
 /*
  * Control routine:
- * processes three kinds of requests:
+ * processes four kinds of requests:
  *
  *     (1) Set density (i.e., format the diskette) according to 
  *
  *     (1) Set density (i.e., format the diskette) according to 
- *               that specified by the open device.
+ *               that specified data parameter
  *     (2) Arrange for the next sector to be written with a deleted-
  *               data mark.
  *     (3) Report whether the last sector read had a deleted-data mark
  *     (2) Arrange for the next sector to be written with a deleted-
  *               data mark.
  *     (3) Report whether the last sector read had a deleted-data mark
+ *     (4) Report the density of the diskette in the indicated drive
+ *         (since the density it automatically determined by the driver,
+ *          this is the only way to let an application program know the
+ *          density)
  *
  * Requests relating to deleted-data marks can be handled right here.
  * A "set density" (format) request, however, must additionally be 
  * processed through "rxstart", just like a read or write request.
  */
  *
  * Requests relating to deleted-data marks can be handled right here.
  * A "set density" (format) request, however, must additionally be 
  * processed through "rxstart", just like a read or write request.
  */
+
 /*ARGSUSED3*/
 rxioctl(dev, cmd, data, flag)
        dev_t dev;
 /*ARGSUSED3*/
 rxioctl(dev, cmd, data, flag)
        dev_t dev;
-       int cmd;
        caddr_t data;
        caddr_t data;
-       int flag;
 {   
        int unit = RXUNIT(dev);
        struct rx_softc *sc = &rx_softc[unit];
 {   
        int unit = RXUNIT(dev);
        struct rx_softc *sc = &rx_softc[unit];
@@ -792,9 +807,12 @@ rxioctl(dev, cmd, data, flag)
        case RXIOC_FORMAT:
                if ((flag&FWRITE) == 0)
                        return (EBADF);
        case RXIOC_FORMAT:
                if ((flag&FWRITE) == 0)
                        return (EBADF);
-               if (sc->sc_open > 1 )
-                       return(EBUSY);
-               sc->sc_csbits |= *(int *)data ? RX_DDEN : RX_SDEN;
+               if (sc->sc_open > 1)
+                       return (EBUSY);
+               if (*(int *)data)
+                       sc->sc_csbits |= RX_DDEN;
+               else
+                       sc->sc_csbits &= ~RX_DDEN;
                return (rxformat(dev));
 
        case RXIOC_WDDS:
                return (rxformat(dev));
 
        case RXIOC_WDDS:
@@ -821,7 +839,7 @@ rxformat(dev)
        int unit = RXUNIT(dev);
        struct buf *bp;
        struct rx_softc *sc = &rx_softc[unit];
        int unit = RXUNIT(dev);
        struct buf *bp;
        struct rx_softc *sc = &rx_softc[unit];
-       int s, error = 0;
+       int error = 0;
 
        bp = &rrxbuf[unit];
        bp->b_flags = B_BUSY | B_CTRL;
 
        bp = &rrxbuf[unit];
        bp->b_flags = B_BUSY | B_CTRL;
@@ -837,4 +855,24 @@ rxformat(dev)
        sc->sc_flags &= ~RXF_LOCK;
        return (error);
 }
        sc->sc_flags &= ~RXF_LOCK;
        return (error);
 }
+
+/*
+ * A permanent hard error condition has occured,
+ * purge the buffer queue
+ */
+rxpurge(um)
+       register struct uba_ctlr *um;
+{
+       register struct buf *bp, *dp;
+
+       dp = um->um_tab.b_actf;
+       while (dp->b_actf) {
+               dp->b_errcnt++;
+               bp = dp->b_actf;
+               bp->b_error = EIO;
+               bp->b_flags |= B_ERROR;
+               iodone(bp);
+               dp->b_actf = bp->av_forw;
+       }
+}
 #endif
 #endif