ioctl/open return errors, not u.u_error; remove ubarelses (it is
[unix-history] / usr / src / sys / vax / uba / uba.c
index 64d6154..9f66c11 100644 (file)
@@ -1,22 +1,23 @@
-/*     uba.c   4.44    82/05/19        */
+/*     uba.c   4.51    82/10/17        */
 
 #include "../h/param.h"
 #include "../h/systm.h"
 
 #include "../h/param.h"
 #include "../h/systm.h"
-#include "../h/cpu.h"
 #include "../h/map.h"
 #include "../h/pte.h"
 #include "../h/buf.h"
 #include "../h/vm.h"
 #include "../h/map.h"
 #include "../h/pte.h"
 #include "../h/buf.h"
 #include "../h/vm.h"
-#include "../h/ubareg.h"
-#include "../h/ubavar.h"
 #include "../h/dir.h"
 #include "../h/user.h"
 #include "../h/proc.h"
 #include "../h/conf.h"
 #include "../h/dir.h"
 #include "../h/user.h"
 #include "../h/proc.h"
 #include "../h/conf.h"
-#include "../h/mtpr.h"
-#include "../h/nexus.h"
 #include "../h/dk.h"
 
 #include "../h/dk.h"
 
+#include "../vax/cpu.h"
+#include "../vax/mtpr.h"
+#include "../vax/nexus.h"
+#include "../vaxuba/ubareg.h"
+#include "../vaxuba/ubavar.h"
+
 #if VAX780
 char   ubasr_bits[] = UBASR_BITS;
 #endif
 #if VAX780
 char   ubasr_bits[] = UBASR_BITS;
 #endif
@@ -109,8 +110,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);
@@ -290,8 +291,8 @@ ubainitmaps(uhp)
                uhp->uh_bdpfree = (1<<NBDP750) - 1;
                break;
 #endif
                uhp->uh_bdpfree = (1<<NBDP750) - 1;
                break;
 #endif
-#if VAX7ZZ
-       case VAX_7ZZ:
+#if VAX730
+       case VAX_730:
                break;
 #endif
        }
                break;
 #endif
        }
@@ -355,10 +356,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 */
@@ -541,24 +542,54 @@ ubaremap(uban, ubinfo, addr)
  * and clears the map registers for the block.
  *
  * Arguments are the Unibus number, the Unibus address of the memory
  * 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.
+ * block, its size in blocks of 512 bytes, and a flag indicating whether
+ * to allocate the unibus space form the resource map or whether it already
+ * has been.
  *
  *
- * Returns addr if successful, 0 if not.
+ * Returns > 0 if successful, 0 if not.
  */
 
  */
 
-ubamem(uban, addr, size)
+ubamem(uban, addr, size, alloc)
 {
        register struct uba_hd *uh = &uba_hd[uban];
        register int *m;
        register int i, a, s;
 
 {
        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 (alloc) {
+               s = spl6();
+               a = rmget(uh->uh_map, size, (addr>>9)+1); /* starts at ONE! */
+               splx(s);
+       } else
+               a = (addr>>9)+1;
        if (a) {
        if (a) {
-               m = (int *) &uh->uh_uba->uba_map[a];
+               m = (int *) &uh->uh_uba->uba_map[a-1];
                for (i=0; i<size; i++)
                        *m++ = 0;       /* All off, especially 'valid' */
                for (i=0; i<size; i++)
                        *m++ = 0;       /* All off, especially 'valid' */
+#if VAX780
+               if (cpu == VAX_780) {           /* map disable */
+                       i = (addr+size*512+8191)/8192;
+                       uh->uh_uba->uba_cr |= i<<26;
+               }
+#endif
        }
        return(a);
 }
        }
        return(a);
 }
+
+/*
+ * Map a virtual address into users address space. Actually all we
+ * do is turn on the user mode write protection bits for the particular
+ * page of memory involved.
+ */
+maptouser(vaddress)
+       caddr_t vaddress;
+{
+
+       Sysmap[(((unsigned)(vaddress))-0x80000000) >> 9].pg_prot = (PG_UW>>27);
+}
+
+unmaptouser(vaddress)
+       caddr_t vaddress;
+{
+
+       Sysmap[(((unsigned)(vaddress))-0x80000000) >> 9].pg_prot = (PG_KW>>27);
+}