fix to silo and bk bug
[unix-history] / usr / src / sys / vax / uba / tm.c
index 0474635..2df067a 100644 (file)
@@ -1,4 +1,4 @@
-/*     tm.c    4.36    81/04/15        */
+/*     tm.c    4.41    81/08/30        */
 
 #include "te.h"
 #include "ts.h"
 
 #include "te.h"
 #include "ts.h"
@@ -222,13 +222,19 @@ get:
                goto get;
        }
        sc->sc_dens = olddens;
                goto get;
        }
        sc->sc_dens = olddens;
-       if ((sc->sc_erreg&(TMER_SELR|TMER_TUR)) != (TMER_SELR|TMER_TUR) ||
-           (flag&FWRITE) && (sc->sc_erreg&TMER_WRL) ||
-           (sc->sc_erreg&TMER_BOT) == 0 && (flag&FWRITE) &&
-               dens != sc->sc_dens) {
-               /*
-                * Not online or density switch in mid-tape or write locked.
-                */
+       if ((sc->sc_erreg&(TMER_SELR|TMER_TUR)) != (TMER_SELR|TMER_TUR)) {
+               uprintf("te%d: not online\n", teunit);
+               u.u_error = EIO;
+               return;
+       }
+       if ((flag&FWRITE) && (sc->sc_erreg&TMER_WRL)) {
+               uprintf("te%d: no write ring\n", teunit);
+               u.u_error = EIO;
+               return;
+       }
+       if ((sc->sc_erreg&TMER_BOT) == 0 && (flag&FWRITE) &&
+           dens != sc->sc_dens) {
+               uprintf("te%d: can't change density in mid-tape\n", teunit);
                u.u_error = EIO;
                return;
        }
                u.u_error = EIO;
                return;
        }
@@ -241,7 +247,7 @@ get:
        if (sc->sc_tact == 0) {
                sc->sc_timo = INF;
                sc->sc_tact = 1;
        if (sc->sc_tact == 0) {
                sc->sc_timo = INF;
                sc->sc_tact = 1;
-               timeout(tmtimer, dev, 5*hz);
+               timeout(tmtimer, (caddr_t)dev, 5*hz);
        }
        (void) spl0();
 }
        }
        (void) spl0();
 }
@@ -333,6 +339,7 @@ tmstrategy(bp)
        dp = &teutab[teunit];
        bp->av_forw = NULL;
        (void) spl5();
        dp = &teutab[teunit];
        bp->av_forw = NULL;
        (void) spl5();
+       um = tedinfo[teunit]->ui_mi;
        if (dp->b_actf == NULL) {
                dp->b_actf = bp;
                /*
        if (dp->b_actf == NULL) {
                dp->b_actf = bp;
                /*
@@ -340,7 +347,6 @@ tmstrategy(bp)
                 * put at end of controller queue.
                 */
                dp->b_forw = NULL;
                 * put at end of controller queue.
                 */
                dp->b_forw = NULL;
-               um = tedinfo[teunit]->ui_mi;
                if (um->um_tab.b_actf == NULL)
                        um->um_tab.b_actf = dp;
                else
                if (um->um_tab.b_actf == NULL)
                        um->um_tab.b_actf = dp;
                else
@@ -415,14 +421,15 @@ loop:
                /*
                 * Set next state; give 5 minutes to complete
                 * rewind, or 10 seconds per iteration (minimum 60
                /*
                 * Set next state; give 5 minutes to complete
                 * rewind, or 10 seconds per iteration (minimum 60
-                * seconds and max 5 minute) to complete other ops.
+                * seconds and max 5 minutes) to complete other ops.
                 */
                if (bp->b_command == TM_REW) {
                        um->um_tab.b_active = SREW;
                        sc->sc_timo = 5 * 60;
                } else {
                        um->um_tab.b_active = SCOM;
                 */
                if (bp->b_command == TM_REW) {
                        um->um_tab.b_active = SREW;
                        sc->sc_timo = 5 * 60;
                } else {
                        um->um_tab.b_active = SCOM;
-                       sc->sc_timo = min(max(10 * bp->b_repcnt, 60), 5 * 60);
+                       sc->sc_timo =
+                           imin(imax(10*(int)-bp->b_repcnt,60),5*60);
                }
                if (bp->b_command == TM_SFORW || bp->b_command == TM_SREV)
                        addr->tmbc = bp->b_repcnt;
                }
                if (bp->b_command == TM_SFORW || bp->b_command == TM_SREV)
                        addr->tmbc = bp->b_repcnt;
@@ -496,7 +503,7 @@ loop:
                bp->b_command = TM_SREV;
                addr->tmbc = dbtofsb(bp->b_blkno) - blkno;
        }
                bp->b_command = TM_SREV;
                addr->tmbc = dbtofsb(bp->b_blkno) - blkno;
        }
-       sc->sc_timo = min(max(10 * -addr->tmbc, 60), 5 * 60);
+       sc->sc_timo = imin(imax(10 * -addr->tmbc, 60), 5 * 60);
 dobpcmd:
 #ifdef notdef
        /*
 dobpcmd:
 #ifdef notdef
        /*
@@ -715,7 +722,7 @@ tmtimer(dev)
                tmintr(TMUNIT(dev));
                (void) spl0();
        }
                tmintr(TMUNIT(dev));
                (void) spl0();
        }
-       timeout(tmtimer, dev, 5*hz);
+       timeout(tmtimer, (caddr_t)dev, 5*hz);
 }
 
 tmseteof(bp)
 }
 
 tmseteof(bp)