date and time created 82/06/14 18:09:52 by peter
[unix-history] / usr / src / sys / vax / uba / uba.c
index 0daabb3..a4e419d 100644 (file)
@@ -1,4 +1,4 @@
-/*     uba.c   4.39    81/12/09        */
+/*     uba.c   4.45    82/05/26        */
 
 #include "../h/param.h"
 #include "../h/systm.h"
 
 #include "../h/param.h"
 #include "../h/systm.h"
@@ -56,14 +56,12 @@ ubago(ui)
        if (ui->ui_dk >= 0) {
                unit = ui->ui_dk;
                dk_busy |= 1<<unit;
        if (ui->ui_dk >= 0) {
                unit = ui->ui_dk;
                dk_busy |= 1<<unit;
+               dk_xfer[unit]++;
+               dk_wds[unit] += um->um_tab.b_actf->b_actf->b_bcount>>6;
        }
        if (uh->uh_actf == ui)
                uh->uh_actf = ui->ui_forw;
        (*um->um_driver->ud_dgo)(um);
        }
        if (uh->uh_actf == ui)
                uh->uh_actf = ui->ui_forw;
        (*um->um_driver->ud_dgo)(um);
-       if (ui->ui_dk >= 0) {
-               dk_xfer[unit]++;
-               dk_wds[unit] += um->um_tab.b_actf->b_actf->b_bcount>>6;
-       }
        return (1);
 rwait:
        if (uh->uh_actf != ui) {
        return (1);
 rwait:
        if (uh->uh_actf != ui) {
@@ -111,8 +109,8 @@ ubasetup(uban, bp, flags)
        struct proc *rp;
        int a, o, ubinfo;
 
        struct proc *rp;
        int a, o, ubinfo;
 
-#if VAX7ZZ
-       if (cpu == VAX_7ZZ)
+#if VAX730
+       if (cpu == VAX_730)
                flags &= ~UBA_NEEDBDP;
 #endif
        v = btop(bp->b_un.b_addr);
                flags &= ~UBA_NEEDBDP;
 #endif
        v = btop(bp->b_un.b_addr);
@@ -144,31 +142,23 @@ ubasetup(uban, bp, flags)
        splx(a);
        reg--;
        ubinfo = (bdp << 28) | (npf << 18) | (reg << 9) | o;
        splx(a);
        reg--;
        ubinfo = (bdp << 28) | (npf << 18) | (reg << 9) | o;
-       io = &uh->uh_uba->uba_map[reg];
        temp = (bdp << 21) | UBAMR_MRV;
        temp = (bdp << 21) | UBAMR_MRV;
-       rp = bp->b_flags&B_DIRTY ? &proc[2] : bp->b_proc;
        if (bdp && (o & 01))
                temp |= UBAMR_BO;
        if (bdp && (o & 01))
                temp |= UBAMR_BO;
-       if (bp->b_flags & B_UAREA) {
-               for (i = UPAGES - bp->b_bcount / NBPG; i < UPAGES; i++) {
-                       if (rp->p_addr[i].pg_pfnum == 0)
-                               panic("uba: zero upage");
-                       *(int *)io++ = rp->p_addr[i].pg_pfnum | temp;
-               }
-       } else if ((bp->b_flags & B_PHYS) == 0) {
+       rp = bp->b_flags&B_DIRTY ? &proc[2] : bp->b_proc;
+       if ((bp->b_flags & B_PHYS) == 0)
                pte = &Sysmap[btop(((int)bp->b_un.b_addr)&0x7fffffff)];
                pte = &Sysmap[btop(((int)bp->b_un.b_addr)&0x7fffffff)];
-               while (--npf != 0)
-                       *(int *)io++ = pte++->pg_pfnum | temp;
-       } else {
-               if (bp->b_flags & B_PAGET)
-                       pte = &Usrptmap[btokmx((struct pte *)bp->b_un.b_addr)];
-               else
-                       pte = vtopte(rp, v);
-               while (--npf != 0) {
-                       if (pte->pg_pfnum == 0)
-                               panic("uba zero uentry");
-                       *(int *)io++ = pte++->pg_pfnum | temp;
-               }
+       else if (bp->b_flags & B_UAREA)
+               pte = &rp->p_addr[v];
+       else if (bp->b_flags & B_PAGET)
+               pte = &Usrptmap[btokmx((struct pte *)bp->b_un.b_addr)];
+       else
+               pte = vtopte(rp, v);
+       io = &uh->uh_uba->uba_map[reg];
+       while (--npf != 0) {
+               if (pte->pg_pfnum == 0)
+                       panic("uba zero uentry");
+               *(int *)io++ = pte++->pg_pfnum | temp;
        }
        *(int *)io++ = 0;
        return (ubinfo);
        }
        *(int *)io++ = 0;
        return (ubinfo);
@@ -284,6 +274,29 @@ ubapurge(um)
        }
 }
 
        }
 }
 
+ubainitmaps(uhp)
+       register struct uba_hd *uhp;
+{
+
+       rminit(uhp->uh_map, NUBMREG, 1, "uba", UAMSIZ);
+       switch (cpu) {
+#if VAX780
+       case VAX_780:
+               uhp->uh_bdpfree = (1<<NBDP780) - 1;
+               break;
+#endif
+#if VAX750
+       case VAX_750:
+               uhp->uh_bdpfree = (1<<NBDP750) - 1;
+               break;
+#endif
+#if VAX730
+       case VAX_730:
+               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,
@@ -304,6 +317,7 @@ ubareset(uban)
        uh->uh_actf = uh->uh_actl = 0;
        uh->uh_bdpwant = 0;
        uh->uh_mrwant = 0;
        uh->uh_actf = uh->uh_actl = 0;
        uh->uh_bdpwant = 0;
        uh->uh_mrwant = 0;
+       ubainitmaps(uh);
        wakeup((caddr_t)&uh->uh_bdpwant);
        wakeup((caddr_t)&uh->uh_mrwant);
        printf("uba%d: reset", uban);
        wakeup((caddr_t)&uh->uh_bdpwant);
        wakeup((caddr_t)&uh->uh_mrwant);
        printf("uba%d: reset", uban);
@@ -341,10 +355,10 @@ ubainit(uba)
 #if VAX750
        case VAX_750:
 #endif
 #if VAX750
        case VAX_750:
 #endif
-#if VAX7ZZ
-       case VAX_7ZZ:
+#if VAX730
+       case VAX_730:
 #endif
 #endif
-#if defined(VAX750) || defined(VAX7ZZ)
+#if defined(VAX750) || defined(VAX730)
                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 */
@@ -456,7 +470,7 @@ ubaerror(uban, uh, xx, uvec, uba)
 }
 #endif
 
 }
 #endif
 
-#if 0
+#ifdef notdef
 /*
  * This routine allows remapping of previously
  * allocated UNIBUS bdp and map resources
 /*
  * This routine allows remapping of previously
  * allocated UNIBUS bdp and map resources
@@ -520,3 +534,31 @@ ubaremap(uban, ubinfo, addr)
        return (ubinfo | o);
 }
 #endif
        return (ubinfo | o);
 }
 #endif
+
+/*
+ * This routine is called by a driver for a device with on-board Unibus
+ * memory.  It removes the memory block from the Unibus resource map
+ * and clears the map registers for the block.
+ *
+ * Arguments are the Unibus number, the Unibus address of the memory
+ * block, and its size in blocks of 512 bytes.
+ *
+ * Returns addr if successful, 0 if not.
+ */
+
+ubamem(uban, addr, size)
+{
+       register struct uba_hd *uh = &uba_hd[uban];
+       register int *m;
+       register int i, a, s;
+
+       s = spl6();
+       a = rmget(uh->uh_map, size, addr>>9);
+       splx(s);
+       if (a) {
+               m = (int *) &uh->uh_uba->uba_map[a];
+               for (i=0; i<size; i++)
+                       *m++ = 0;       /* All off, especially 'valid' */
+       }
+       return(a);
+}