+#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, 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 > 0 if successful, 0 if not.
+ */
+
+ubamem(uban, addr, size, alloc)
+{
+ register struct uba_hd *uh = &uba_hd[uban];
+ register int *m;
+ register int i, a, 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) {
+ m = (int *) &uh->uh_uba->uba_map[a-1];
+ 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);
+}
+
+/*
+ * 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);
+}