fix to silo and bk bug
[unix-history] / usr / src / sys / vax / uba / uba.c
index 6f7e849..ec450bd 100644 (file)
@@ -1,4 +1,4 @@
-/*     uba.c   4.26    81/03/22        */
+/*     uba.c   4.35    81/07/22        */
 
 #include "../h/param.h"
 #include "../h/systm.h"
 
 #include "../h/param.h"
 #include "../h/systm.h"
@@ -62,7 +62,7 @@ ubago(ui)
        (*um->um_driver->ud_dgo)(um);
        if (ui->ui_dk >= 0) {
                dk_xfer[unit]++;
        (*um->um_driver->ud_dgo)(um);
        if (ui->ui_dk >= 0) {
                dk_xfer[unit]++;
-               dk_wds[unit] += um->um_tab.b_actf->b_bcount>>6;
+               dk_wds[unit] += um->um_tab.b_actf->b_actf->b_bcount>>6;
        }
        return (1);
 rwait:
        }
        return (1);
 rwait:
@@ -111,8 +111,8 @@ ubasetup(uban, bp, flags)
        struct proc *rp;
        int a, o, ubinfo;
 
        struct proc *rp;
        int a, o, ubinfo;
 
-#if VAX730
-       if (cpu == VAX_730)
+#if VAX7ZZ
+       if (cpu == VAX_7ZZ)
                flags &= ~UBA_NEEDBDP;
 #endif
        v = btop(bp->b_un.b_addr);
                flags &= ~UBA_NEEDBDP;
 #endif
        v = btop(bp->b_un.b_addr);
@@ -120,8 +120,10 @@ ubasetup(uban, bp, flags)
        npf = btoc(bp->b_bcount + o) + 1;
        a = spl6();
        while ((reg = rmalloc(uh->uh_map, npf)) == 0) {
        npf = btoc(bp->b_bcount + o) + 1;
        a = spl6();
        while ((reg = rmalloc(uh->uh_map, npf)) == 0) {
-               if (flags & UBA_CANTWAIT)
+               if (flags & UBA_CANTWAIT) {
+                       splx(a);
                        return (0);
                        return (0);
+               }
                uh->uh_mrwant++;
                sleep((caddr_t)uh->uh_map, PSWP);
        }
                uh->uh_mrwant++;
                sleep((caddr_t)uh->uh_map, PSWP);
        }
@@ -130,6 +132,7 @@ ubasetup(uban, bp, flags)
                while ((bdp = ffs(uh->uh_bdpfree)) == 0) {
                        if (flags & UBA_CANTWAIT) {
                                rmfree(uh->uh_map, npf, reg);
                while ((bdp = ffs(uh->uh_bdpfree)) == 0) {
                        if (flags & UBA_CANTWAIT) {
                                rmfree(uh->uh_map, npf, reg);
+                               splx(a);
                                return (0);
                        }
                        uh->uh_bdpwant++;
                                return (0);
                        }
                        uh->uh_bdpwant++;
@@ -334,10 +337,10 @@ ubainit(uba)
 #if VAX750
        case VAX_750:
 #endif
 #if VAX750
        case VAX_750:
 #endif
-#if VAX730
-       case VAX_730:
+#if VAX7ZZ
+       case VAX_7ZZ:
 #endif
 #endif
-#if defined(VAX750) || defined(VAX730)
+#if defined(VAX750) || defined(VAX7ZZ)
                mtpr(IUR, 0);
                /* give devices time to recover from power fail */
 /* THIS IS PROBABLY UNNECESSARY */
                mtpr(IUR, 0);
                /* give devices time to recover from power fail */
 /* THIS IS PROBABLY UNNECESSARY */
@@ -364,6 +367,7 @@ unhang()
 
                if (up->uba_sr == 0)
                        return;
 
                if (up->uba_sr == 0)
                        return;
+               up->uba_sr = UBASR_CRD|UBASR_LEB;
                uh->uh_hangcnt++;
                if (uh->uh_hangcnt > 5*hz) {
                        uh->uh_hangcnt = 0;
                uh->uh_hangcnt++;
                if (uh->uh_hangcnt > 5*hz) {
                        uh->uh_hangcnt = 0;
@@ -393,6 +397,8 @@ ubawatch()
        }
 }
 
        }
 }
 
+int    ubawedgecnt = 10;
+int    ubacrazy = 500;
 /*
  * This routine is called by the locore code to
  * process a UBA error on an 11/780.  The arguments are passed
 /*
  * This routine is called by the locore code to
  * process a UBA error on an 11/780.  The arguments are passed
@@ -429,11 +435,82 @@ ubaerror(uban, uh, xx, uvec, uba)
        }
        sr = uba->uba_sr;
        s = spl7();
        }
        sr = uba->uba_sr;
        s = spl7();
-       printf("uba%d: uba error sr=%x fmer=%x fubar=%o\n",
-           uban, uba->uba_sr, uba->uba_fmer, 4*uba->uba_fubar);
+       printf("uba%d: uba error sr=%b fmer=%x fubar=%o\n",
+           uban, uba->uba_sr, ubasr_bits, uba->uba_fmer, 4*uba->uba_fubar);
        splx(s);
        uba->uba_sr = sr;
        uvec &= UBABRRVR_DIV;
        splx(s);
        uba->uba_sr = sr;
        uvec &= UBABRRVR_DIV;
+       if (++uh->uh_errcnt % ubawedgecnt == 0) {
+               if (uh->uh_errcnt > ubacrazy)
+                       panic("uba crazy");
+               printf("ERROR LIMIT ");
+               ubareset(uban);
+               uvec = 0;
+               return;
+       }
        return;
 }
 #endif
        return;
 }
 #endif
+
+/*
+ * This routine allows remapping of previously
+ * allocated UNIBUS bdp and map resources
+ * onto different memory addresses.
+ * It should only be used by routines which need
+ * small fixed length mappings for long periods of time
+ * (like the ARPANET ACC IMP interface).
+ * It only maps kernel addresses.
+ */
+ubaremap(uban, ubinfo, addr)
+       int uban;
+       register unsigned ubinfo;
+       caddr_t addr;
+{
+       register struct uba_hd *uh = &uba_hd[uban];
+       register struct pte *pte, *io;
+       register int temp, bdp;
+       int npf, o;
+
+       o = (int)addr & PGOFSET;
+       bdp = (ubinfo >> 28) & 0xf;
+       npf = (ubinfo >> 18) & 0x3ff;
+       io = &uh->uh_uba->uba_map[(ubinfo >> 9) & 0x1ff];
+       temp = (bdp << 21) | UBAMR_MRV;
+
+       /*
+        * If using buffered data path initiate purge
+        * of old data and set byte offset bit if next
+        * transfer will be from odd address.
+        */
+       if (bdp) {
+               switch (cpu) {
+#if VAX780
+               case VAX_780:
+                       uh->uh_uba->uba_dpr[bdp] |= UBADPR_BNE;
+                       break;
+#endif
+#if VAX750
+               case VAX_750:
+                       uh->uh_uba->uba_dpr[bdp] |=
+                           UBADPR_PURGE|UBADPR_NXM|UBADPR_UCE;
+                       break;
+#endif
+               }
+               if (o & 1)
+                       temp |= UBAMR_BO;
+       }
+
+       /*
+        * Set up the map registers, leaving an invalid reg
+        * at the end to guard against wild unibus transfers.
+        */
+       pte = &Sysmap[btop(((int)addr)&0x7fffffff)];
+       while (--npf != 0)
+               *(int *)io++ = pte++->pg_pfnum | temp;
+       *(int *)io = 0;
+
+       /*
+        * Return effective UNIBUS address.
+        */
+       return (ubinfo | o);
+}