with tracing, it works!?!
authorBill Joy <bill@ucbvax.Berkeley.EDU>
Thu, 19 Jun 1980 22:35:10 +0000 (14:35 -0800)
committerBill Joy <bill@ucbvax.Berkeley.EDU>
Thu, 19 Jun 1980 22:35:10 +0000 (14:35 -0800)
SCCS-vsn: sys/vax/uba/up.c 3.5

usr/src/sys/vax/uba/up.c

index a8ff02b..eb22040 100644 (file)
@@ -1,7 +1,7 @@
+#define        UTRACE
 int    asdel = 500;
 int    csdel3 = 100;
 int    asdel = 500;
 int    csdel3 = 100;
-int    printsw;
-/*     %H%     3.4     %G%     */
+/*     %H%     3.5     %G%     */
 
 /*
  * Emulex UNIBUS disk driver with overlapped seeks and ECC recovery.
 
 /*
  * Emulex UNIBUS disk driver with overlapped seeks and ECC recovery.
@@ -254,6 +254,10 @@ register struct buf *bp;
        dp = &uputab[unit];
        (void) spl5();
        disksort(dp, bp);
        dp = &uputab[unit];
        (void) spl5();
        disksort(dp, bp);
+#ifdef UTRACE
+       ttime();
+       trace("upstrat bn %d unit %d\n", bp->b_blkno, unit);
+#endif
        if (dp->b_active == 0) {
                (void) upustart(unit);
                if (uptab.b_actf && uptab.b_active == 0)
        if (dp->b_active == 0) {
                (void) upustart(unit);
                if (uptab.b_actf && uptab.b_active == 0)
@@ -276,9 +280,12 @@ register unit;
        int sn, cn, csn;
        int didie = 0;
 
        int sn, cn, csn;
        int didie = 0;
 
-       if (printsw&1) printf("upustart\n");
        if (unit >= NUP)
                goto out;
        if (unit >= NUP)
                goto out;
+#ifdef UTRACE
+       ttime();
+       trace("upustart %d active %d", unit, uputab[unit].b_active);
+#endif
        /*
         * Whether or not it was before, this unit is no longer busy.
         * Check to see if there is (still or now) a request in this
        /*
         * Whether or not it was before, this unit is no longer busy.
         * Check to see if there is (still or now) a request in this
@@ -301,6 +308,9 @@ register unit;
         * the drive, preset it and put in 16bit/word mode.
         */
        if ((upaddr->upds & VV) == 0) {
         * the drive, preset it and put in 16bit/word mode.
         */
        if ((upaddr->upds & VV) == 0) {
+#ifdef UTRACE
+               trace(" not VV");
+#endif
                upaddr->upcs1 = IE|DCLR|GO;
                DELAY(idelay);
                upaddr->upcs1 = IE|PRESET|GO;
                upaddr->upcs1 = IE|DCLR|GO;
                DELAY(idelay);
                upaddr->upcs1 = IE|PRESET|GO;
@@ -360,6 +370,10 @@ register unit;
                goto done;
 
 search:
                goto done;
 
 search:
+#ifdef UTRACE
+       trace(" search %d@%d to %d@%d", upaddr->updc, (upaddr->upla>>6),
+           cn, sn);
+#endif
        upaddr->updc = cn;
        upaddr->upda = sn;
        upaddr->upcs1 = IE|SEARCH|GO;
        upaddr->updc = cn;
        upaddr->upda = sn;
        upaddr->upcs1 = IE|SEARCH|GO;
@@ -380,6 +394,9 @@ done:
         * we won't get called again (by upintr() because upas&(1<<unit))
         * and link us onto the chain of ready disks.
         */
         * we won't get called again (by upintr() because upas&(1<<unit))
         * and link us onto the chain of ready disks.
         */
+#ifdef UTRACE
+       trace(" done");
+#endif
        dp->b_active = 2;
        dp->b_forw = NULL;
        if (uptab.b_actf == NULL)
        dp->b_active = 2;
        dp->b_forw = NULL;
        if (uptab.b_actf == NULL)
@@ -389,6 +406,9 @@ done:
        uptab.b_actl = dp;
 
 out:
        uptab.b_actl = dp;
 
 out:
+#ifdef UTRACE
+       trace("\n");
+#endif
        return (didie);
 }
 
        return (didie);
 }
 
@@ -403,8 +423,11 @@ upstart()
        daddr_t bn;
        int dn, sn, tn, cn, cmd;
 
        daddr_t bn;
        int dn, sn, tn, cn, cmd;
 
-       if (printsw&2) printf("upstart\n");
 loop:
 loop:
+#ifdef UTRACE
+       ttime();
+       trace("upstart");
+#endif
        /*
         * Pick a drive off the queue of ready drives, and
         * perform the first transfer on its queue.
        /*
         * Pick a drive off the queue of ready drives, and
         * perform the first transfer on its queue.
@@ -413,8 +436,12 @@ loop:
         * are not present and on-line, for which we completely clear the
         * request queue.
         */
         * are not present and on-line, for which we completely clear the
         * request queue.
         */
-       if ((dp = uptab.b_actf) == NULL)
+       if ((dp = uptab.b_actf) == NULL) {
+#ifdef UTRACE
+               trace("\n");
+#endif
                return (0);
                return (0);
+       }
        if ((bp = dp->b_actf) == NULL) {
                uptab.b_actf = dp->b_forw;
                goto loop;
        if ((bp = dp->b_actf) == NULL) {
                uptab.b_actf = dp->b_forw;
                goto loop;
@@ -433,7 +460,13 @@ loop:
        tn = sn/NSECT;
        sn %= NSECT;
        upaddr = UPADDR;
        tn = sn/NSECT;
        sn %= NSECT;
        upaddr = UPADDR;
+#ifdef UTRACE
+       trace(" unit %d", dn);
+#endif
        if ((upaddr->upcs2 & 07) != dn) {
        if ((upaddr->upcs2 & 07) != dn) {
+#ifdef UTRACE
+               trace(" select");
+#endif
                upaddr->upcs2 = dn;
                DELAY(sdelay);
                nwaitcs2++;
                upaddr->upcs2 = dn;
                DELAY(sdelay);
                nwaitcs2++;
@@ -447,6 +480,9 @@ loop:
         * (Then on to any other ready drives.)
         */
        if ((upaddr->upds & (DPR|MOL)) != (DPR|MOL)) {
         * (Then on to any other ready drives.)
         */
        if ((upaddr->upds & (DPR|MOL)) != (DPR|MOL)) {
+#ifdef UTRACE
+               trace(" !(DPR && MOL)");
+#endif
                uptab.b_active = 0;
                uptab.b_errcnt = 0;
                dp->b_actf = bp->av_forw;
                uptab.b_active = 0;
                uptab.b_errcnt = 0;
                dp->b_actf = bp->av_forw;
@@ -461,6 +497,9 @@ loop:
         * begin to try offsetting the heads to recover the data.
         */
        if (uptab.b_errcnt >= 16) {
         * begin to try offsetting the heads to recover the data.
         */
        if (uptab.b_errcnt >= 16) {
+#ifdef UTRACE
+               trace(" offset");
+#endif
                upaddr->upof = up_offset[uptab.b_errcnt & 017] | FMT22;
                upaddr->upcs1 = IE|OFFSET|GO;
                DELAY(idelay);
                upaddr->upof = up_offset[uptab.b_errcnt & 017] | FMT22;
                upaddr->upcs1 = IE|OFFSET|GO;
                DELAY(idelay);
@@ -472,6 +511,11 @@ loop:
         * 2 bits of the UNIBUS address from the information
         * returned by ubasetup() for the cs1 register bits 8 and 9.
         */
         * 2 bits of the UNIBUS address from the information
         * returned by ubasetup() for the cs1 register bits 8 and 9.
         */
+#ifdef UTRACE
+       trace(" %s %d.%d@%d cnt %d ba %x\n",
+           (bp->b_flags&B_READ) ? "read" : "write",
+           cn, tn, sn, bp->b_bcount, up_ubinfo & 0x3ffff);
+#endif
        upaddr->updc = cn;
        upaddr->upda = (tn << 8) + sn;
        upaddr->upba = up_ubinfo;
        upaddr->updc = cn;
        upaddr->upda = (tn << 8) + sn;
        upaddr->upba = up_ubinfo;
@@ -520,7 +564,10 @@ upintr()
        int as = upaddr->upas & 0377;
        int needie = 1;
 
        int as = upaddr->upas & 0377;
        int needie = 1;
 
-       if (printsw&4) printf("upintr as=%d act %d %d %d\n", as, uptab.b_active, uputab[0].b_active, uputab[1].b_active);
+#ifdef UTRACE
+       ttime();
+       trace("upintr as %d act %d %d %d;", as, uptab.b_active, uputab[0].b_active, uputab[1].b_active);
+#endif
        if (uptab.b_active) {
                /*
                 * The drive is transferring, thus the hardware
        if (uptab.b_active) {
                /*
                 * The drive is transferring, thus the hardware
@@ -528,9 +575,12 @@ upintr()
                 * completes; check for it anyways.
                 */
                if ((upaddr->upcs1 & RDY) == 0) {
                 * completes; check for it anyways.
                 */
                if ((upaddr->upcs1 & RDY) == 0) {
+#ifdef UTRACE
+                       trace(" !RDY");
+#endif
                        printf("!RDY in upintr: cs1 %o\n", upaddr->upcs1);
 printf("as=%d act %d %d %d\n", as, uptab.b_active, uputab[0].b_active, uputab[1].b_active);
                        printf("!RDY in upintr: cs1 %o\n", upaddr->upcs1);
 printf("as=%d act %d %d %d\n", as, uptab.b_active, uputab[0].b_active, uputab[1].b_active);
-}
+               }
                /*
                 * Mark controller or drive not busy, and check for an
                 * error condition which may have resulted from the transfer.
                /*
                 * Mark controller or drive not busy, and check for an
                 * error condition which may have resulted from the transfer.
@@ -543,6 +593,9 @@ printf("as=%d act %d %d %d\n", as, uptab.b_active, uputab[0].b_active, uputab[1]
                else if (DK_N+unit <= DK_NMAX)
                        dk_busy &= ~(1<<(DK_N+unit));
                if (upaddr->upcs1 & TRE) {
                else if (DK_N+unit <= DK_NMAX)
                        dk_busy &= ~(1<<(DK_N+unit));
                if (upaddr->upcs1 & TRE) {
+#ifdef UTRACE
+                       trace(" TRE");
+#endif
                        /*
                         * An error occurred, indeed.  Select this unit
                         * to get at the drive status (a SEARCH may have
                        /*
                         * An error occurred, indeed.  Select this unit
                         * to get at the drive status (a SEARCH may have
@@ -607,13 +660,22 @@ printf("as=%d act %d %d %d\n", as, uptab.b_active, uputab[0].b_active, uputab[1]
                 * on this drive with the upustart routine (if any).
                 */
                if (uptab.b_active) {
                 * on this drive with the upustart routine (if any).
                 */
                if (uptab.b_active) {
+#ifdef UTRACE
+                       trace(" unit %d", unit);
+#endif
                        if ((upaddr->upcs2 & 07) != unit) {
                        if ((upaddr->upcs2 & 07) != unit) {
+#ifdef UTRACE
+                               trace(" select");
+#endif
                                upaddr->upcs2 = unit;
                                DELAY(sdelay);
                                nwaitcs2++;
                        } else
                                neasycs2++;
                        if (uptab.b_errcnt >= 16) {
                                upaddr->upcs2 = unit;
                                DELAY(sdelay);
                                nwaitcs2++;
                        } else
                                neasycs2++;
                        if (uptab.b_errcnt >= 16) {
+#ifdef UTRACE
+                               trace(" rtc");
+#endif
                                upaddr->upcs1 = RTC|GO|IE;
                                DELAY(idelay);
                                while (upaddr->upds & PIP)
                                upaddr->upcs1 = RTC|GO|IE;
                                DELAY(idelay);
                                while (upaddr->upds & PIP)
@@ -637,13 +699,12 @@ printf("as=%d act %d %d %d\n", as, uptab.b_active, uputab[0].b_active, uputab[1]
        }
 #ifndef notdef
        else {
        }
 #ifndef notdef
        else {
-               if (printsw&64) printf("cs1 %o\n", upaddr->upcs1);
                if (upaddr->upcs1 & TRE) {
                if (upaddr->upcs1 & TRE) {
-                       printf("TRE in upintr: cs1 %o\n", upaddr->upcs1);
-printf("as=%d act %d %d %d\n", as, uptab.b_active, uputab[0].b_active, uputab[1].b_active);
+#ifdef UTRACE
+                       trace(" TRE");
+#endif
                        upaddr->upcs1 = TRE;
                        DELAY(idelay);
                        upaddr->upcs1 = TRE;
                        DELAY(idelay);
-                       if (printsw&64) printf("after TRE cs1 %o\n", upaddr->upcs1);
                }
        }
 #endif
                }
        }
 #endif
@@ -654,26 +715,36 @@ printf("as=%d act %d %d %d\n", as, uptab.b_active, uputab[0].b_active, uputab[1]
         * Finally, if the controller is not transferring
         * start it if any drives are now ready to transfer.
         */
         * Finally, if the controller is not transferring
         * start it if any drives are now ready to transfer.
         */
+#ifdef UTRACE
+       trace("\n");
+#endif
        for (unit = 0; unit < NUP; unit++)
                if (as & (1<<unit))
                        if (uputab[unit].b_active == 1) {
                                upaddr->upas = 1<<unit;
        for (unit = 0; unit < NUP; unit++)
                if (as & (1<<unit))
                        if (uputab[unit].b_active == 1) {
                                upaddr->upas = 1<<unit;
+#ifdef UTRACE
+                               trace("as clear %d\n", unit);
+#endif
                                if (asdel) DELAY(asdel);
                                if (upustart(unit))
                                        needie = 0;
                        } else {
                                if (asdel) DELAY(asdel);
                                if (upustart(unit))
                                        needie = 0;
                        } else {
-                       printf("as in upintr: cs1 %o\n", upaddr->upcs1);
-printf("as=%d act %d %d %d\n", as, uptab.b_active, uputab[0].b_active, uputab[1].b_active);
                                upaddr->upas = 1<<unit;
                                upaddr->upas = 1<<unit;
+#ifdef UTRACE
+                               trace("spurious as clear %d\n", unit);
+#endif
                                DELAY(1000);
                        }
        if (uptab.b_actf && uptab.b_active == 0)
                if (upstart())
                        needie = 0;
 out:
                                DELAY(1000);
                        }
        if (uptab.b_actf && uptab.b_active == 0)
                if (upstart())
                        needie = 0;
 out:
-       if (needie)
+       if (needie) {
+#ifdef UTRACE
+               trace("upintr set IE\n");
+#endif
                upaddr->upcs1 = IE;
                upaddr->upcs1 = IE;
-       if (printsw&128) printf("exit cs1 %o\n", upaddr->upcs1);
+       }
 }
 
 upread(dev)
 }
 
 upread(dev)
@@ -704,7 +775,6 @@ register struct buf *bp;
        int reg, bit, byte, npf, mask, o, cmd, ubaddr;
        int bn, cn, tn, sn;
 
        int reg, bit, byte, npf, mask, o, cmd, ubaddr;
        int bn, cn, tn, sn;
 
-       if (printsw&8) printf("upecc\n");
        /*
         * Npf is the number of sectors transferred before the sector
         * containing the ECC error, and reg is the UBA register
        /*
         * Npf is the number of sectors transferred before the sector
         * containing the ECC error, and reg is the UBA register