BSD 4_4 release
[unix-history] / usr / src / sys / luna68k / dev / st.c
index a5bec7a..8e1709d 100644 (file)
@@ -1,14 +1,40 @@
 /*
  * Copyright (c) 1992 OMRON Corporation.
 /*
  * Copyright (c) 1992 OMRON Corporation.
- * Copyright (c) 1992 The Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1992, 1993
+ *     The Regents of the University of California.  All rights reserved.
  *
  * This code is derived from software contributed to Berkeley by
  * OMRON Corporation.
  *
  *
  * This code is derived from software contributed to Berkeley by
  * OMRON Corporation.
  *
- * %sccs.include.redist.c%
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
  *
  *
- *     @(#)st.c        7.5 (Berkeley) %G%
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *     @(#)st.c        8.1 (Berkeley) 6/10/93
  */
 
 /*
  */
 
 /*
@@ -102,7 +128,10 @@ stinit(hd)
        register struct hp_device *hd;
 {
        register struct st_softc *sc = &st_softc[hd->hp_unit];
        register struct hp_device *hd;
 {
        register struct st_softc *sc = &st_softc[hd->hp_unit];
+       register struct buf *bp;
 
 
+       for (bp = sttab; bp < &sttab[NST]; bp++)
+               bp->b_actb = &bp->b_actf;
        sc->sc_hd = hd;
        sc->sc_punit = stpunit(hd->hp_flags);
        sc->sc_type = stident(sc, hd);
        sc->sc_hd = hd;
        sc->sc_punit = stpunit(hd->hp_flags);
        sc->sc_type = stident(sc, hd);
@@ -266,17 +295,11 @@ ststrategy(bp)
        register struct buf *dp = &sttab[unit];
        int s;
 
        register struct buf *dp = &sttab[unit];
        int s;
 
-       bp->av_forw = NULL;
-
+       bp->b_actf = NULL;
        s = splbio();
        s = splbio();
-
-       if (dp->b_actf == NULL)
-               dp->b_actf = bp;
-       else
-               dp->b_actl->av_forw = bp;
-
-       dp->b_actl = bp;
-
+       bp->b_actb = dp->b_actb;
+       *dp->b_actb = bp;
+       dp->b_actb = &bp->b_actf;
        if (dp->b_active == 0) {
                dp->b_active = 1;
                stustart(unit);
        if (dp->b_active == 0) {
                dp->b_active = 1;
                stustart(unit);
@@ -292,7 +315,7 @@ stustart(unit)
        register struct st_softc *sc = &st_softc[unit];
        register struct hp_device *hp = sc->sc_hd;
        register struct scsi_queue *dq = &sc->sc_dq;
        register struct st_softc *sc = &st_softc[unit];
        register struct hp_device *hp = sc->sc_hd;
        register struct scsi_queue *dq = &sc->sc_dq;
-       register struct buf *bp = sttab[unit].b_actf;
+       register struct buf *dp, *bp = sttab[unit].b_actf;
        register struct scsi_fmt_cdb *cmd;
        long nblks;
 
        register struct scsi_fmt_cdb *cmd;
        long nblks;
 
@@ -315,8 +338,11 @@ stustart(unit)
                bp->b_error = EIO;
                
                sttab[unit].b_errcnt = 0;
                bp->b_error = EIO;
                
                sttab[unit].b_errcnt = 0;
-               sttab[unit].b_actf = bp->b_actf;
-               
+               if (dp = bp->b_actf)
+                       dp->b_actb = bp->b_actb;
+               else
+                       sttab[unit].b_actb = bp->b_actb;
+               *bp->b_actb = dp;
                bp->b_resid = 0;
                
                biodone(bp);
                bp->b_resid = 0;
                
                biodone(bp);
@@ -394,7 +420,7 @@ stintr(unit, stat)
        register struct st_softc *sc = &st_softc[unit];
        register struct scsi_xsense *xp = (struct scsi_xsense *) xsense_buff;
        register struct scsi_queue *dq = &sc->sc_dq;
        register struct st_softc *sc = &st_softc[unit];
        register struct scsi_xsense *xp = (struct scsi_xsense *) xsense_buff;
        register struct scsi_queue *dq = &sc->sc_dq;
-       register struct buf *bp = dq->dq_bp;
+       register struct buf *dp, *bp = dq->dq_bp;
        int ctlr  = dq->dq_ctlr;
        int slave = dq->dq_slave;
 
        int ctlr  = dq->dq_ctlr;
        int slave = dq->dq_slave;
 
@@ -480,8 +506,11 @@ stintr(unit, stat)
 
 done:
        sttab[unit].b_errcnt = 0;
 
 done:
        sttab[unit].b_errcnt = 0;
-       sttab[unit].b_actf = bp->b_actf;
-       
+       if (dp = bp->b_actf)
+               dp->b_actb = bp->b_actb;
+       else
+               sttab[unit].b_actb = bp->b_actb;
+       *bp->b_actb = dp;
        bp->b_resid = 0;
 
        biodone(bp);
        bp->b_resid = 0;
 
        biodone(bp);