almost working versions
[unix-history] / usr / src / sys / vax / uba / tm.c
index 9a3376c..50d6592 100644 (file)
@@ -1,9 +1,10 @@
-/*     tm.c    4.15    %G%     */
+/*     tm.c    4.18    %G%     */
 
 #include "tm.h"
 
 #include "tm.h"
-#if NTM03 > 0
+#if NTM > 0
+int    tmgapsdcnt;             /* DEBUG */
 /*
 /*
- * TM tape driver
+ * TM11/TE10 tape driver
  *
  * THIS DRIVER HAS NOT BEEN TESTED WITH MORE THAN ONE TRANSPORT.
  */
  *
  * THIS DRIVER HAS NOT BEEN TESTED WITH MORE THAN ONE TRANSPORT.
  */
 
 #include "../h/tmreg.h"
 
 
 #include "../h/tmreg.h"
 
-struct buf     ctmbuf[NTM11];
-struct buf     rtmbuf[NTM11];
+struct buf     ctmbuf[NTE];
+struct buf     rtmbuf[NTE];
 
 int    tmprobe(), tmslave(), tmattach(), tmdgo(), tmintr();
 
 int    tmprobe(), tmslave(), tmattach(), tmdgo(), tmintr();
-struct uba_minfo *tmminfo[NTM03];
-struct uba_dinfo *tmdinfo[NTM11];
-struct buf tmutab[NTM11];
+struct uba_minfo *tmminfo[NTM];
+struct uba_dinfo *tmdinfo[NTE];
+struct buf tmutab[NTE];
 #ifdef notyet
 #ifdef notyet
-struct uba_dinfo *tmip[NTM03][4];
+struct uba_dinfo *tmip[NTM][4];
 #endif
 u_short        tmstd[] = { 0772520, 0 };
 struct uba_driver tmdriver =
 #endif
 u_short        tmstd[] = { 0772520, 0 };
 struct uba_driver tmdriver =
 { tmprobe, tmslave, tmattach, tmdgo, tmstd, "mtm", tmdinfo, "tm", tmminfo };
{ tmprobe, tmslave, tmattach, tmdgo, tmstd, "te", tmdinfo, "tm", tmminfo, 0 };
 
 /* bits in minor device */
 #define        TMUNIT(dev)     (minor(dev)&03)
 
 /* bits in minor device */
 #define        TMUNIT(dev)     (minor(dev)&03)
@@ -57,7 +58,8 @@ struct        tm_softc {
        u_short sc_erreg;       /* copy of last erreg */
        u_short sc_dsreg;       /* copy of last dsreg */
        short   sc_resid;       /* copy of last bc */
        u_short sc_erreg;       /* copy of last erreg */
        u_short sc_dsreg;       /* copy of last dsreg */
        short   sc_resid;       /* copy of last bc */
-} tm_softc[NTM03];
+       short   sc_lastcmd;     /* last command to handle direction changes */
+} tm_softc[NTM];
 
 /*
  * States for um->um_tab.b_active, the
 
 /*
  * States for um->um_tab.b_active, the
@@ -87,7 +89,7 @@ tmprobe(reg)
 #endif
        ((struct device *)reg)->tmcs = TM_IE;
        /*
 #endif
        ((struct device *)reg)->tmcs = TM_IE;
        /*
-        * If this is a tm03, it ought to have interrupted
+        * If this is a tm11, it ought to have interrupted
         * by now, if it isn't (ie: it is a ts04) then we just
         * hope that it didn't interrupt, so autoconf will ignore it.
         * Just in case, we will reference one
         * by now, if it isn't (ie: it is a ts04) then we just
         * hope that it didn't interrupt, so autoconf will ignore it.
         * Just in case, we will reference one
@@ -146,7 +148,7 @@ tmopen(dev, flag)
        register struct tm_softc *sc;
 
        unit = TMUNIT(dev);
        register struct tm_softc *sc;
 
        unit = TMUNIT(dev);
-       if (unit>=NTM11 || (sc = &tm_softc[unit])->sc_openf ||
+       if (unit>=NTE || (sc = &tm_softc[unit])->sc_openf ||
            (ui = tmdinfo[unit]) == 0 || ui->ui_alive == 0) {
                u.u_error = ENXIO;
                return;
            (ui = tmdinfo[unit]) == 0 || ui->ui_alive == 0) {
                u.u_error = ENXIO;
                return;
@@ -345,13 +347,11 @@ loop:
        if (bp == &ctmbuf[unit]) {
                if (bp->b_command == TM_SENSE)
                        goto next;
        if (bp == &ctmbuf[unit]) {
                if (bp->b_command == TM_SENSE)
                        goto next;
-               cmd |= bp->b_command;
                um->um_tab.b_active =
                    bp->b_command == TM_REW ? SREW : SCOM;
                if (bp->b_command == TM_SFORW || bp->b_command == TM_SREV)
                        addr->tmbc = bp->b_repcnt;
                um->um_tab.b_active =
                    bp->b_command == TM_REW ? SREW : SCOM;
                if (bp->b_command == TM_SFORW || bp->b_command == TM_SREV)
                        addr->tmbc = bp->b_repcnt;
-               addr->tmcs = cmd;
-               return;
+               goto dobpcmd;
        }
        /*
         * If the data transfer command is in the correct place,
        }
        /*
         * If the data transfer command is in the correct place,
@@ -370,6 +370,12 @@ loop:
                        cmd |= TM_RCOM;
                um->um_tab.b_active = SIO;
                um->um_cmd = cmd;
                        cmd |= TM_RCOM;
                um->um_tab.b_active = SIO;
                um->um_cmd = cmd;
+/*
+               if (tmreverseop(sc->sc_lastcmd))
+                       while (addr->tmer & TM_SDWN)
+                               tmgapsdcnt++;
+*/
+               sc->sc_lastcmd = TM_RCOM;               /* will serve */
                ubago(ui);
                return;
        }
                ubago(ui);
                return;
        }
@@ -379,13 +385,20 @@ loop:
         */
        um->um_tab.b_active = SSEEK;
        if (blkno < dbtofsb(bp->b_blkno)) {
         */
        um->um_tab.b_active = SSEEK;
        if (blkno < dbtofsb(bp->b_blkno)) {
-               cmd |= TM_SFORW;
+               bp->b_command = TM_SFORW;
                addr->tmbc = blkno - dbtofsb(bp->b_blkno);
        } else {
                addr->tmbc = blkno - dbtofsb(bp->b_blkno);
        } else {
-               cmd |= TM_SREV;
+               bp->b_command = TM_SREV;
                addr->tmbc = dbtofsb(bp->b_blkno) - blkno;
        }
                addr->tmbc = dbtofsb(bp->b_blkno) - blkno;
        }
-       addr->tmcs = cmd;
+dobpcmd:
+/*
+       if (tmreverseop(sc->sc_lastcmd) != tmreverseop(bp->b_command))
+               while (addr->tmer & TM_SDWN)
+                       tmgapsdcnt++;
+*/
+       sc->sc_lastcmd = bp->b_command;
+       addr->tmcs = (cmd | bp->b_command);
        return;
 
 next:
        return;
 
 next:
@@ -420,13 +433,13 @@ tmdgo(um)
  * Tm interrupt routine.
  */
 /*ARGSUSED*/
  * Tm interrupt routine.
  */
 /*ARGSUSED*/
-tmintr(tm03)
-       int tm03;
+tmintr(tm11)
+       int tm11;
 {
        struct buf *dp;
        register struct buf *bp;
 {
        struct buf *dp;
        register struct buf *bp;
-       register struct uba_minfo *um = tmminfo[tm03];
-       register struct device *addr = (struct device *)tmdinfo[tm03]->ui_addr;
+       register struct uba_minfo *um = tmminfo[tm11];
+       register struct device *addr = (struct device *)tmdinfo[tm11]->ui_addr;
        register struct tm_softc *sc;
        int unit;
        register state;
        register struct tm_softc *sc;
        int unit;
        register state;
@@ -505,7 +518,9 @@ tmintr(tm03)
                /*
                 * Couldn't recover error
                 */
                /*
                 * Couldn't recover error
                 */
-               deverror(bp, sc->sc_erreg, sc->sc_dsreg);
+               harderr(bp);
+               printf("tm%d er %b\n", dkunit(bp),
+                   sc->sc_erreg, TMEREG_BITS);
                bp->b_flags |= B_ERROR;
                goto opdone;
        }
                bp->b_flags |= B_ERROR;
                goto opdone;
        }
@@ -642,12 +657,12 @@ tmreset(uban)
 {
        int printed = 0;
        register struct uba_minfo *um;
 {
        int printed = 0;
        register struct uba_minfo *um;
-       register tm03, unit;
+       register tm11, unit;
        register struct uba_dinfo *ui;
        register struct buf *dp;
 
        register struct uba_dinfo *ui;
        register struct buf *dp;
 
-       for (tm03 = 0; tm03 < NTM03; tm03++) {
-               if ((um = tmminfo[tm03]) == 0 || um->um_alive == 0 ||
+       for (tm11 = 0; tm11 < NTM; tm11++) {
+               if ((um = tmminfo[tm11]) == 0 || um->um_alive == 0 ||
                   um->um_ubanum != uban)
                        continue;
                if (printed == 0) {
                   um->um_ubanum != uban)
                        continue;
                if (printed == 0) {
@@ -662,7 +677,7 @@ tmreset(uban)
                        ubadone(um);
                }
                ((struct device *)(um->um_addr))->tmcs = TM_DCLR;
                        ubadone(um);
                }
                ((struct device *)(um->um_addr))->tmcs = TM_DCLR;
-               for (unit = 0; unit < NTM11; unit++) {
+               for (unit = 0; unit < NTE; unit++) {
                        if ((ui = tmdinfo[unit]) == 0)
                                continue;
                        if (ui->ui_alive == 0)
                        if ((ui = tmdinfo[unit]) == 0)
                                continue;
                        if (ui->ui_alive == 0)