support for ec driver
authorBrian Feldman <feldman@ucbvax.Berkeley.EDU>
Sun, 11 Apr 1982 16:09:22 +0000 (08:09 -0800)
committerBrian Feldman <feldman@ucbvax.Berkeley.EDU>
Sun, 11 Apr 1982 16:09:22 +0000 (08:09 -0800)
SCCS-vsn: sys/vax/vax/locore.s 4.64
SCCS-vsn: sys/kern/subr_rmap.c 4.5
SCCS-vsn: sys/kern/subr_rmap.c.sav 4.5
SCCS-vsn: sys/vax/vax/autoconf.c 4.35
SCCS-vsn: sys/vax/uba/uba.c 4.43
SCCS-vsn: sys/vax/uba/ubareg.h 4.28
SCCS-vsn: sys/vax/uba/ubavar.h 4.25

usr/src/sys/kern/subr_rmap.c
usr/src/sys/kern/subr_rmap.c.sav
usr/src/sys/vax/uba/uba.c
usr/src/sys/vax/uba/ubareg.h
usr/src/sys/vax/uba/ubavar.h
usr/src/sys/vax/vax/autoconf.c
usr/src/sys/vax/vax/locore.s

index a841721..e34447b 100644 (file)
@@ -1,4 +1,4 @@
-/*     subr_rmap.c     4.4     81/03/09        */
+/*     subr_rmap.c     4.5     82/04/11        */
 
 #include "../h/param.h"
 #include "../h/systm.h"
 
 #include "../h/param.h"
 #include "../h/systm.h"
@@ -247,3 +247,88 @@ done:
 badrmfree:
        panic("bad rmfree");
 }
 badrmfree:
        panic("bad rmfree");
 }
+
+/*
+ * Allocate 'size' units from the given map, starting at address 'addr'.
+ * Return 'addr' if successful, 0 if not.
+ * This may cause the creation or destruction of a resource map segment.
+ *
+ * This routine will return failure status if there is not enough room
+ * for a required additional map segment.
+ *
+ * An attempt to use this on 'swapmap' will result in
+ * a failure return.  This is due mainly to laziness and could be fixed
+ * to do the right thing, although it probably will never be used.
+ */
+rmget(mp, size, addr)
+       register struct map *mp;
+{
+       register struct mapent *ep = (struct mapent *)(mp+1);
+       register struct mapent *bp, *bp2;
+
+       if (size <= 0)
+               panic("rmget");
+       if (mp == swapmap)
+               return (0);
+       /*
+        * Look for a map segment containing the requested address.
+        * If none found, return failure.
+        */
+       for (bp = ep; bp->m_size; bp++)
+               if (bp->m_addr <= addr && bp->m_addr + bp->m_size > addr)
+                       break;
+       if (bp->m_size == 0)
+               return (0);
+
+       /*
+        * If segment is too small, return failure.
+        * If big enough, allocate the block, compressing or expanding
+        * the map as necessary.
+        */
+       if (bp->m_addr + bp->m_size < addr + size)
+               return (0);
+       if (bp->m_addr == addr)
+               if (bp->m_addr + bp->m_size == addr + size) {
+                       /*
+                        * Allocate entire segment and compress map
+                        */
+                       bp2 = bp;
+                       while (bp2->m_size) {
+                               bp2++;
+                               (bp2-1)->m_addr = bp2->m_addr;
+                               (bp2-1)->m_size = bp2->m_size;
+                       }
+               } else {
+                       /*
+                        * Allocate first part of segment
+                        */
+                       bp->m_addr += size;
+                       bp->m_size -= size;
+               }
+       else
+               if (bp->m_addr + bp->m_size == addr + size) {
+                       /*
+                        * Allocate last part of segment
+                        */
+                       bp->m_size -= size;
+               } else {
+                       /*
+                        * Allocate from middle of segment, but only
+                        * if table can be expanded.
+                        */
+                       for (bp2=bp; bp2->m_size; bp2++)
+                               ;
+                       if (bp2 == mp->m_limit)
+                               return (0);
+                       while (bp2 > bp) {
+                               (bp2+1)->m_addr = bp2->m_addr;
+                               (bp2+1)->m_size = bp2->m_size;
+                               bp2--;
+                       }
+                       (bp+1)->m_addr = addr + size;
+                       (bp+1)->m_size =
+                           bp->m_addr + bp->m_size - (addr + size);
+                       bp->m_size = addr - bp->m_addr;
+               }
+       return (addr);
+}
index b28c880..ff11cb2 100644 (file)
@@ -1,4 +1,4 @@
-/*     subr_rmap.c.sav 4.4     81/03/09        */
+/*     subr_rmap.c.sav 4.5     82/04/11        */
 
 #include "../h/param.h"
 #include "../h/systm.h"
 
 #include "../h/param.h"
 #include "../h/systm.h"
@@ -247,3 +247,88 @@ done:
 badrmfree:
        panic("bad rmfree");
 }
 badrmfree:
        panic("bad rmfree");
 }
+
+/*
+ * Allocate 'size' units from the given map, starting at address 'addr'.
+ * Return 'addr' if successful, 0 if not.
+ * This may cause the creation or destruction of a resource map segment.
+ *
+ * This routine will return failure status if there is not enough room
+ * for a required additional map segment.
+ *
+ * An attempt to use this on 'swapmap' will result in
+ * a failure return.  This is due mainly to laziness and could be fixed
+ * to do the right thing, although it probably will never be used.
+ */
+rmget(mp, size, addr)
+       register struct map *mp;
+{
+       register struct mapent *ep = (struct mapent *)(mp+1);
+       register struct mapent *bp, *bp2;
+
+       if (size <= 0)
+               panic("rmget");
+       if (mp == swapmap)
+               return (0);
+       /*
+        * Look for a map segment containing the requested address.
+        * If none found, return failure.
+        */
+       for (bp = ep; bp->m_size; bp++)
+               if (bp->m_addr <= addr && bp->m_addr + bp->m_size > addr)
+                       break;
+       if (bp->m_size == 0)
+               return (0);
+
+       /*
+        * If segment is too small, return failure.
+        * If big enough, allocate the block, compressing or expanding
+        * the map as necessary.
+        */
+       if (bp->m_addr + bp->m_size < addr + size)
+               return (0);
+       if (bp->m_addr == addr)
+               if (bp->m_addr + bp->m_size == addr + size) {
+                       /*
+                        * Allocate entire segment and compress map
+                        */
+                       bp2 = bp;
+                       while (bp2->m_size) {
+                               bp2++;
+                               (bp2-1)->m_addr = bp2->m_addr;
+                               (bp2-1)->m_size = bp2->m_size;
+                       }
+               } else {
+                       /*
+                        * Allocate first part of segment
+                        */
+                       bp->m_addr += size;
+                       bp->m_size -= size;
+               }
+       else
+               if (bp->m_addr + bp->m_size == addr + size) {
+                       /*
+                        * Allocate last part of segment
+                        */
+                       bp->m_size -= size;
+               } else {
+                       /*
+                        * Allocate from middle of segment, but only
+                        * if table can be expanded.
+                        */
+                       for (bp2=bp; bp2->m_size; bp2++)
+                               ;
+                       if (bp2 == mp->m_limit)
+                               return (0);
+                       while (bp2 > bp) {
+                               (bp2+1)->m_addr = bp2->m_addr;
+                               (bp2+1)->m_size = bp2->m_size;
+                               bp2--;
+                       }
+                       (bp+1)->m_addr = addr + size;
+                       (bp+1)->m_size =
+                           bp->m_addr + bp->m_size - (addr + size);
+                       bp->m_size = addr - bp->m_addr;
+               }
+       return (addr);
+}
index f9b1bd2..3884a71 100644 (file)
@@ -1,4 +1,4 @@
-/*     uba.c   4.42    82/03/31        */
+/*     uba.c   4.43    82/04/11        */
 
 #include "../h/param.h"
 #include "../h/systm.h"
 
 #include "../h/param.h"
 #include "../h/systm.h"
@@ -510,3 +510,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);
+}
index f736bc3..e9d756d 100644 (file)
@@ -1,4 +1,4 @@
-/*     ubareg.h        4.27    82/03/18        */
+/*     ubareg.h        4.28    82/04/11        */
 
 /*
  * VAX UNIBUS adapter registers
 
 /*
  * VAX UNIBUS adapter registers
@@ -158,11 +158,11 @@ struct uba_regs
  * for each possible uba.
  */
 #if VAX7ZZ
  * for each possible uba.
  */
 #if VAX7ZZ
-#define        UMEM7ZZ         ((u_short *)(0xffe000))
+#define        UMEM7ZZ         ((u_short *)(0xfc0000))
 #endif
 #if VAX750
 #endif
 #if VAX750
-#define        UMEM750(i)      ((u_short *)(0xffe000-(i)*0x40000))
+#define        UMEM750(i)      ((u_short *)(0xfc0000-(i)*0x40000))
 #endif
 #if VAX780
 #endif
 #if VAX780
-#define        UMEM780(i)      ((u_short *)(0x2013e000+(i)*0x40000))
+#define        UMEM780(i)      ((u_short *)(0x20100000+(i)*0x40000))
 #endif
 #endif
index 45fc594..9ec4b61 100644 (file)
@@ -1,4 +1,4 @@
-/*     ubavar.h        4.24    82/04/01        */
+/*     ubavar.h        4.25    82/04/11        */
 
 /*
  * This file contains definitions related to the kernel structures
 
 /*
  * This file contains definitions related to the kernel structures
@@ -169,8 +169,8 @@ extern      struct  uba_device ubdinit[];
  * UNIbus device address space is mapped by UMEMmap
  * into virtual address umem[][].
  */
  * UNIbus device address space is mapped by UMEMmap
  * into virtual address umem[][].
  */
-extern struct pte UMEMmap[][16];       /* uba device addr pte's */
-extern char umem[][16*NBPG];           /* uba device addr space */
+extern struct pte UMEMmap[][512];      /* uba device addr pte's */
+extern char umem[][512*NBPG];          /* uba device addr space */
 
 /*
  * Since some VAXen vector their first (and only) unibus interrupt
 
 /*
  * Since some VAXen vector their first (and only) unibus interrupt
index faa7556..db865dc 100644 (file)
@@ -1,4 +1,4 @@
-/*     autoconf.c      4.34    82/03/31        */
+/*     autoconf.c      4.35    82/04/11        */
 
 /*
  * Setup the system to run on the current machine.
 
 /*
  * Setup the system to run on the current machine.
@@ -401,8 +401,7 @@ unifind(vubp, pubp, vumem, pumem, memmap)
         */
        uhp->uh_lastiv = 0x200;
 
         */
        uhp->uh_lastiv = 0x200;
 
-       /* THIS IS A CHEAT: USING THE FACT THAT UMEM and NEXI ARE SAME SIZE */
-       nxaccess((struct nexus *)pumem, memmap);
+       ubaaccess(pumem, memmap);
 #if VAX780
        if (haveubasr) {
                vubp->uba_sr = vubp->uba_sr;
 #if VAX780
        if (haveubasr) {
                vubp->uba_sr = vubp->uba_sr;
@@ -417,7 +416,7 @@ unifind(vubp, pubp, vumem, pumem, memmap)
         */
        *(int *)(&vubp->uba_map[0]) = UBAMR_MRV;
 
         */
        *(int *)(&vubp->uba_map[0]) = UBAMR_MRV;
 
-#define        ubaddr(off)     (u_short *)((int)vumem + ((off)&0x1fff))
+#define        ubaddr(off)     (u_short *)((int)vumem + ((off)&0x3ffff))
        /*
         * Check each unibus mass storage controller.
         * For each one which is potentially on this uba,
        /*
         * Check each unibus mass storage controller.
         * For each one which is potentially on this uba,
@@ -428,7 +427,7 @@ unifind(vubp, pubp, vumem, pumem, memmap)
                if (um->um_ubanum != numuba && um->um_ubanum != '?')
                        continue;
                addr = (u_short)um->um_addr;
                if (um->um_ubanum != numuba && um->um_ubanum != '?')
                        continue;
                addr = (u_short)um->um_addr;
-               reg = ubaddr(addr);
+               reg = ubaddr(addr|0x3e000);
                if (badaddr((caddr_t)reg, 2))
                        continue;
 #if VAX780
                if (badaddr((caddr_t)reg, 2))
                        continue;
 #if VAX780
@@ -502,7 +501,7 @@ unifind(vubp, pubp, vumem, pumem, memmap)
                    ui->ui_alive || ui->ui_slave != -1)
                        continue;
                addr = (u_short)ui->ui_addr;
                    ui->ui_alive || ui->ui_slave != -1)
                        continue;
                addr = (u_short)ui->ui_addr;
-               reg = ubaddr(addr);
+               reg = ubaddr(addr|0x3e000);
                if (badaddr((caddr_t)reg, 2))
                        continue;
 #if VAX780
                if (badaddr((caddr_t)reg, 2))
                        continue;
 #if VAX780
@@ -579,3 +578,16 @@ nxaccess(physa, pte)
        while (--i > 0);
        mtpr(TBIA, 0);
 }
        while (--i > 0);
        mtpr(TBIA, 0);
 }
+
+ubaaccess(pumem, pte)
+       caddr_t pumem;
+       register struct pte *pte;
+{
+       register int i = 512;
+       register unsigned v = btop(pumem);
+       
+       do
+               *(int *)pte++ = PG_V|PG_KW|v++;
+       while (--i > 0);
+       mtpr(TBIA, 0);
+}
index f81ebe0..f89152a 100644 (file)
@@ -1,4 +1,4 @@
-/*     locore.s        4.63    82/03/19        */
+/*     locore.s        4.64    82/04/11        */
 
 #include "../h/mtpr.h"
 #include "../h/trap.h"
 
 #include "../h/mtpr.h"
 #include "../h/trap.h"
@@ -343,7 +343,7 @@ _/**/mname: .globl  _/**/mname;             \
        SYSMAP(Sysmap   ,Sysbase        ,SYSPTSIZE      )
        SYSMAP(UMBAbeg  ,umbabeg        ,0              )
        SYSMAP(Nexmap   ,nexus          ,16*MAXNNEXUS   )
        SYSMAP(Sysmap   ,Sysbase        ,SYSPTSIZE      )
        SYSMAP(UMBAbeg  ,umbabeg        ,0              )
        SYSMAP(Nexmap   ,nexus          ,16*MAXNNEXUS   )
-       SYSMAP(UMEMmap  ,umem           ,16*MAXNUBA     )
+       SYSMAP(UMEMmap  ,umem           ,512*MAXNUBA    )
        SYSMAP(UMBAend  ,umbaend        ,0              )
        SYSMAP(Usrptmap ,usrpt          ,USRPTSIZE      )
        SYSMAP(Forkmap  ,forkutl        ,UPAGES         )
        SYSMAP(UMBAend  ,umbaend        ,0              )
        SYSMAP(Usrptmap ,usrpt          ,USRPTSIZE      )
        SYSMAP(Forkmap  ,forkutl        ,UPAGES         )