new format of error prints; no more FLAKEY UP resets
[unix-history] / usr / src / sys / vax / uba / uba.c
index 2e77fb5..5d5d830 100644 (file)
@@ -1,4 +1,4 @@
-/*     uba.c   4.14    %G%     */
+/*     uba.c   4.19    %G%     */
 
 #define        DELAY(N)        { register int d; d = N; while (--d > 0); }
 
 
 #define        DELAY(N)        { register int d; d = N; while (--d > 0); }
 
 #include "../h/nexus.h"
 #include "../h/dk.h"
 
 #include "../h/nexus.h"
 #include "../h/dk.h"
 
+#if VAX780
+char   ubasr_bits[] = UBASR_BITS;
+#endif
+
 /*
  * Do transfer on device argument.  The controller
  * and uba involved are implied by the device.
 /*
  * Do transfer on device argument.  The controller
  * and uba involved are implied by the device.
@@ -112,7 +116,7 @@ ubasetup(uban, bp, flags)
        o = (int)bp->b_un.b_addr & PGOFSET;
        npf = btoc(bp->b_bcount + o) + 1;
        a = spl6();
        o = (int)bp->b_un.b_addr & PGOFSET;
        npf = btoc(bp->b_bcount + o) + 1;
        a = spl6();
-       while ((reg = malloc(uh->uh_map, npf)) == 0) {
+       while ((reg = rmalloc(uh->uh_map, npf)) == 0) {
                if (flags & UBA_CANTWAIT)
                        return (0);
                uh->uh_mrwant++;
                if (flags & UBA_CANTWAIT)
                        return (0);
                uh->uh_mrwant++;
@@ -122,7 +126,7 @@ ubasetup(uban, bp, flags)
        if (flags & UBA_NEEDBDP) {
                while ((bdp = ffs(uh->uh_bdpfree)) == 0) {
                        if (flags & UBA_CANTWAIT) {
        if (flags & UBA_NEEDBDP) {
                while ((bdp = ffs(uh->uh_bdpfree)) == 0) {
                        if (flags & UBA_CANTWAIT) {
-                               mfree(uh->uh_map, npf, reg);
+                               rmfree(uh->uh_map, npf, reg);
                                return (0);
                        }
                        uh->uh_bdpwant++;
                                return (0);
                        }
                        uh->uh_bdpwant++;
@@ -209,8 +213,7 @@ ubarelse(uban, amr)
        splx(s);                /* let interrupts in, we're safe for a while */
        bdp = (mr >> 28) & 0x0f;
        if (bdp) {
        splx(s);                /* let interrupts in, we're safe for a while */
        bdp = (mr >> 28) & 0x0f;
        if (bdp) {
-               switch (cpu)
-               {
+               switch (cpu) {
 #if VAX780
                case VAX_780:
                        uh->uh_uba->uba_dpr[bdp] |= UBA_BNE;
 #if VAX780
                case VAX_780:
                        uh->uh_uba->uba_dpr[bdp] |= UBA_BNE;
@@ -236,7 +239,7 @@ ubarelse(uban, amr)
        npf = (mr >> 18) & 0x3ff;
        reg = ((mr >> 9) & 0x1ff) + 1;
        s = spl6();
        npf = (mr >> 18) & 0x3ff;
        reg = ((mr >> 9) & 0x1ff) + 1;
        s = spl6();
-       mfree(uh->uh_map, npf, reg);
+       rmfree(uh->uh_map, npf, reg);
        splx(s);
 
        /*
        splx(s);
 
        /*
@@ -252,6 +255,26 @@ ubarelse(uban, amr)
                ;
 }
 
                ;
 }
 
+ubapurge(um)
+       register struct uba_minfo *um;
+{
+       register struct uba_hd *uh = um->um_hd;
+       register int bdp = (um->um_ubinfo >> 28) & 0x0f;
+
+       switch (cpu) {
+#if VAX780
+       case VAX_780:
+               uh->uh_uba->uba_dpr[bdp] |= UBA_BNE;
+               break;
+#endif
+#if VAX750
+       case VAX_750:
+               uh->uh_uba->uba_dpr[bdp] |= UBA_PURGE|UBA_NXM|UBA_UCE;
+               break;
+#endif
+       }
+}
+
 /*
  * Generate a reset on uba number uban.  Then
  * call each device in the character device table,
 /*
  * Generate a reset on uba number uban.  Then
  * call each device in the character device table,
@@ -275,17 +298,18 @@ ubareset(uban)
        wakeup((caddr_t)&uh->uh_bdpwant);
        wakeup((caddr_t)&uh->uh_mrwant);
        switch (cpu) {
        wakeup((caddr_t)&uh->uh_bdpwant);
        wakeup((caddr_t)&uh->uh_mrwant);
        switch (cpu) {
-#if VAX==780
+#if VAX780
        case VAX_780:
        case VAX_780:
-               printf("UBA RESET %d:", uban);
+               printf("uba%d: reset", uban);
                ubainit(uh->uh_uba);
                break;
 #endif
                ubainit(uh->uh_uba);
                break;
 #endif
-#if VAX==750
+#if VAX750
        case VAX_750:
        case VAX_750:
-               printf("UNIBUS INIT:");
+               printf("uba0: reset");
                mtpr(IUR, 1);
                mtpr(IUR, 1);
-               DELAY(100000);
+               /* give devices time to recover from power fail */
+               DELAY(5000000);
                break;
 #endif
        }
                break;
 #endif
        }
@@ -295,6 +319,7 @@ ubareset(uban)
        splx(s);
 }
 
        splx(s);
 }
 
+#if VAX780
 /*
  * Init a uba.  This is called with a pointer
  * rather than a virtual address since it is called
 /*
  * Init a uba.  This is called with a pointer
  * rather than a virtual address since it is called
@@ -313,7 +338,6 @@ ubainit(uba)
                ;
 }
 
                ;
 }
 
-#if VAX780
 /*
  * Check to make sure the UNIBUS adaptor is not hung,
  * with an interrupt in the register to be presented,
 /*
  * Check to make sure the UNIBUS adaptor is not hung,
  * with an interrupt in the register to be presented,
@@ -330,9 +354,9 @@ unhang()
                if (up->uba_sr == 0)
                        return;
                uh->uh_hangcnt++;
                if (up->uba_sr == 0)
                        return;
                uh->uh_hangcnt++;
-               if (uh->uh_hangcnt > 5*HZ) {
+               if (uh->uh_hangcnt > 5*hz) {
                        uh->uh_hangcnt = 0;
                        uh->uh_hangcnt = 0;
-                       printf("HANG ");
+                       printf("uba%d: hung\n", uban);
                        ubareset(uban);
                }
        }
                        ubareset(uban);
                }
        }
@@ -349,6 +373,8 @@ ubawatch()
        register struct uba_hd *uh;
        register int uban;
 
        register struct uba_hd *uh;
        register int uban;
 
+       if (panicstr)
+               return;
        for (uban = 0; uban < numuba; uban++) {
                uh = &uba_hd[uban];
                if (uh->uh_hangcnt)
        for (uban = 0; uban < numuba; uban++) {
                uh = &uba_hd[uban];
                if (uh->uh_hangcnt)
@@ -376,22 +402,23 @@ ubaerror(uban, uh, xx, uvec, uba)
        if (uvec == 0) {
                uh->uh_zvcnt++;
                if (uh->uh_zvcnt > 250000) {
        if (uvec == 0) {
                uh->uh_zvcnt++;
                if (uh->uh_zvcnt > 250000) {
-                       printf("ZERO VECTOR ");
+                       printf("uba%d: too many zero vectors\n");
                        ubareset(uban);
                }
                uvec = 0;
                return;
        }
        if (uba->uba_cnfgr & NEX_CFGFLT) {
                        ubareset(uban);
                }
                uvec = 0;
                return;
        }
        if (uba->uba_cnfgr & NEX_CFGFLT) {
-               printf("UBA%d SBI FAULT sr %x cnfgr %x\n",
-                   uban, uba->uba_sr, uba->uba_cnfgr);
+               printf("uba%d: sbi fault sr=%b cnfgr=%b\n",
+                   uban, uba->uba_sr, ubasr_bits,
+                   uba->uba_cnfgr, nexflt_bits);
                ubareset(uban);
                uvec = 0;
                return;
        }
        sr = uba->uba_sr;
        s = spl7();
                ubareset(uban);
                uvec = 0;
                return;
        }
        sr = uba->uba_sr;
        s = spl7();
-       printf("UBA%d ERROR SR %x FMER %x FUBAR %o\n",
+       printf("uba%d: uba error sr=%x fmer=%x fubar=%o\n",
            uban, uba->uba_sr, uba->uba_fmer, 4*uba->uba_fubar);
        splx(s);
        uba->uba_sr = sr;
            uban, uba->uba_sr, uba->uba_fmer, 4*uba->uba_fubar);
        splx(s);
        uba->uba_sr = sr;