debugging code for NXM problem added
[unix-history] / usr / src / sys / vax / uba / tm.c
index cf30e0a..a967bb4 100644 (file)
@@ -1,4 +1,4 @@
-/*     tm.c    4.27    81/03/09        */
+/*     tm.c    4.33    81/04/08        */
 
 #include "te.h"
 #if NTM > 0
 
 #include "te.h"
 #if NTM > 0
@@ -9,7 +9,6 @@
  *     test driver with more than one slave
  *     test driver with more than one controller
  *     test reset code
  *     test driver with more than one slave
  *     test driver with more than one controller
  *     test reset code
- *     test rewinds without hanging in driver
  *     what happens if you offline tape during rewind?
  *     test using file system on tape
  */
  *     what happens if you offline tape during rewind?
  *     test using file system on tape
  */
@@ -187,7 +186,7 @@ tmopen(dev, flag)
        register int teunit;
        register struct uba_device *ui;
        register struct te_softc *sc;
        register int teunit;
        register struct uba_device *ui;
        register struct te_softc *sc;
-       int dens;
+       int olddens, dens;
 
        teunit = TEUNIT(dev);
        if (teunit>=NTE || (sc = &te_softc[teunit])->sc_openf ||
 
        teunit = TEUNIT(dev);
        if (teunit>=NTE || (sc = &te_softc[teunit])->sc_openf ||
@@ -195,20 +194,22 @@ tmopen(dev, flag)
                u.u_error = ENXIO;
                return;
        }
                u.u_error = ENXIO;
                return;
        }
+       olddens = sc->sc_dens;
+       dens = TM_IE | TM_GO | (ui->ui_slave << 8);
+       if ((minor(dev) & T_1600BPI) == 0)
+               dens |= TM_D800;
+       sc->sc_dens = dens;
 get:
        tmcommand(dev, TM_SENSE, 1);
        if (sc->sc_erreg&TMER_SDWN) {
                sleep((caddr_t)&lbolt, PZERO+1);
                goto get;
        }
 get:
        tmcommand(dev, TM_SENSE, 1);
        if (sc->sc_erreg&TMER_SDWN) {
                sleep((caddr_t)&lbolt, PZERO+1);
                goto get;
        }
-       dens = TM_IE | TM_GO | (ui->ui_slave << 8);
-       if ((minor(dev) & T_1600BPI) == 0)
-               dens |= TM_D800;
+       sc->sc_dens = olddens;
        if ((sc->sc_erreg&(TMER_SELR|TMER_TUR)) != (TMER_SELR|TMER_TUR) ||
        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) &&
            (sc->sc_erreg&TMER_BOT) == 0 && (flag&FWRITE) &&
-               dens != sc->sc_dens ||
-           (flag&(FREAD|FWRITE)) == FWRITE && sc->sc_erreg&TMER_WRL) {
-               printf("er %o dens %o sc->sc_dens %o flag %o\n", sc->sc_erreg, dens, sc->sc_dens, flag);
+               dens != sc->sc_dens) {
                /*
                 * Not online or density switch in mid-tape or write locked.
                 */
                /*
                 * Not online or density switch in mid-tape or write locked.
                 */
@@ -372,7 +373,7 @@ loop:
         * Default is that last command was NOT a write command;
         * if we do a write command we will notice this in tmintr().
         */
         * Default is that last command was NOT a write command;
         * if we do a write command we will notice this in tmintr().
         */
-       sc->sc_lastiow = 1;
+       sc->sc_lastiow = 0;
        if (sc->sc_openf < 0 || (addr->tmcs&TM_CUR) == 0) {
                /*
                 * Have had a hard error on a non-raw tape
        if (sc->sc_openf < 0 || (addr->tmcs&TM_CUR) == 0) {
                /*
                 * Have had a hard error on a non-raw tape
@@ -832,6 +833,7 @@ tmioctl(dev, cmd, addr, flag)
                mtget.mt_dsreg = sc->sc_dsreg;
                mtget.mt_erreg = sc->sc_erreg;
                mtget.mt_resid = sc->sc_resid;
                mtget.mt_dsreg = sc->sc_dsreg;
                mtget.mt_erreg = sc->sc_erreg;
                mtget.mt_resid = sc->sc_resid;
+               mtget.mt_type = MT_ISTM;
                if (copyout((caddr_t)&mtget, addr, sizeof(mtget)))
                        u.u_error = EFAULT;
                return;
                if (copyout((caddr_t)&mtget, addr, sizeof(mtget)))
                        u.u_error = EFAULT;
                return;
@@ -857,10 +859,7 @@ tmdump()
                return (ENXIO);
        ui = phys(tedinfo[0], struct uba_device *);
        up = phys(ui->ui_hd, struct uba_hd *)->uh_physuba;
                return (ENXIO);
        ui = phys(tedinfo[0], struct uba_device *);
        up = phys(ui->ui_hd, struct uba_hd *)->uh_physuba;
-#if VAX780
-       if (cpu == VAX_780)
-               ubainit(up);
-#endif
+       ubainit(up);
        DELAY(1000000);
        addr = (struct device *)ui->ui_physaddr;
        tmwait(addr);
        DELAY(1000000);
        addr = (struct device *)ui->ui_physaddr;
        tmwait(addr);