BSD 4_4_Lite1 release
[unix-history] / usr / src / sys / luna68k / luna68k / vm_machdep.c
index 3301c97..b921b89 100644 (file)
@@ -37,9 +37,9 @@
  * SUCH DAMAGE.
  *
  * from: Utah $Hdr: vm_machdep.c 1.21 91/04/06$
  * SUCH DAMAGE.
  *
  * from: Utah $Hdr: vm_machdep.c 1.21 91/04/06$
- * from: hp300/hp300/vm_machdep.c      7.14 (Berkeley) 12/27/92
+ * from: hp300/hp300/vm_machdep.c      8.4 (Berkeley) 11/14/93
  *
  *
- *     @(#)vm_machdep.c        8.1 (Berkeley) 6/10/93
+ *     @(#)vm_machdep.c        8.3 (Berkeley) 12/6/93
  */
 
 #include <sys/param.h>
  */
 
 #include <sys/param.h>
@@ -82,7 +82,7 @@ cpu_fork(p1, p2)
         * part of the stack.  The stack and pcb need to agree;
         * this is tricky, as the final pcb is constructed by savectx,
         * but its frame isn't yet on the stack when the stack is copied.
         * part of the stack.  The stack and pcb need to agree;
         * this is tricky, as the final pcb is constructed by savectx,
         * but its frame isn't yet on the stack when the stack is copied.
-        * swtch compensates for this when the child eventually runs.
+        * switch compensates for this when the child eventually runs.
         * This should be done differently, with a single call
         * that copies and updates the pcb+stack,
         * replacing the bcopy and savectx.
         * This should be done differently, with a single call
         * that copies and updates the pcb+stack,
         * replacing the bcopy and savectx.
@@ -111,9 +111,9 @@ cpu_fork(p1, p2)
  * cpu_exit is called as the last action during exit.
  * We release the address space and machine-dependent resources,
  * including the memory for the user structure and kernel stack.
  * cpu_exit is called as the last action during exit.
  * We release the address space and machine-dependent resources,
  * including the memory for the user structure and kernel stack.
- * Once finished, we call swtch_exit, which switches to a temporary
+ * Once finished, we call switch_exit, which switches to a temporary
  * pcb and stack and never returns.  We block memory allocation
  * pcb and stack and never returns.  We block memory allocation
- * until swtch_exit has made things safe again.
+ * until switch_exit has made things safe again.
  */
 cpu_exit(p)
        struct proc *p;
  */
 cpu_exit(p)
        struct proc *p;
@@ -123,7 +123,7 @@ cpu_exit(p)
 
        (void) splimp();
        kmem_free(kernel_map, (vm_offset_t)p->p_addr, ctob(UPAGES));
 
        (void) splimp();
        kmem_free(kernel_map, (vm_offset_t)p->p_addr, ctob(UPAGES));
-       swtch_exit();
+       switch_exit();
        /* NOTREACHED */
 }
 
        /* NOTREACHED */
 }
 
@@ -259,12 +259,12 @@ vmapbuf(bp)
 
        if ((flags & B_PHYS) == 0)
                panic("vmapbuf");
 
        if ((flags & B_PHYS) == 0)
                panic("vmapbuf");
-       addr = bp->b_saveaddr = bp->b_un.b_addr;
+       addr = bp->b_saveaddr = bp->b_data;
        off = (int)addr & PGOFSET;
        p = bp->b_proc;
        npf = btoc(round_page(bp->b_bcount + off));
        kva = kmem_alloc_wait(phys_map, ctob(npf));
        off = (int)addr & PGOFSET;
        p = bp->b_proc;
        npf = btoc(round_page(bp->b_bcount + off));
        kva = kmem_alloc_wait(phys_map, ctob(npf));
-       bp->b_un.b_addr = (caddr_t) (kva + off);
+       bp->b_data = (caddr_t) (kva + off);
        while (npf--) {
                pa = pmap_extract(vm_map_pmap(&p->p_vmspace->vm_map),
                    (vm_offset_t)addr);
        while (npf--) {
                pa = pmap_extract(vm_map_pmap(&p->p_vmspace->vm_map),
                    (vm_offset_t)addr);
@@ -283,15 +283,105 @@ vmapbuf(bp)
 vunmapbuf(bp)
        register struct buf *bp;
 {
 vunmapbuf(bp)
        register struct buf *bp;
 {
+       register caddr_t addr;
        register int npf;
        register int npf;
-       register caddr_t addr = bp->b_un.b_addr;
        vm_offset_t kva;
 
        if ((bp->b_flags & B_PHYS) == 0)
                panic("vunmapbuf");
        vm_offset_t kva;
 
        if ((bp->b_flags & B_PHYS) == 0)
                panic("vunmapbuf");
+       addr = bp->b_data;
        npf = btoc(round_page(bp->b_bcount + ((int)addr & PGOFSET)));
        kva = (vm_offset_t)((int)addr & ~PGOFSET);
        kmem_free_wakeup(phys_map, kva, ctob(npf));
        npf = btoc(round_page(bp->b_bcount + ((int)addr & PGOFSET)));
        kva = (vm_offset_t)((int)addr & ~PGOFSET);
        kmem_free_wakeup(phys_map, kva, ctob(npf));
-       bp->b_un.b_addr = bp->b_saveaddr;
+       bp->b_data = bp->b_saveaddr;
        bp->b_saveaddr = NULL;
 }
        bp->b_saveaddr = NULL;
 }
+
+#ifdef MAPPEDCOPY
+u_int mappedcopysize = 4096;
+
+mappedcopyin(fromp, top, count)
+       register char *fromp, *top;
+       register int count;
+{
+       register vm_offset_t kva, upa;
+       register int off, len;
+       int alignable;
+       pmap_t upmap;
+       extern caddr_t CADDR1;
+
+       kva = (vm_offset_t) CADDR1;
+       off = (vm_offset_t)fromp & PAGE_MASK;
+       alignable = (off == ((vm_offset_t)top & PAGE_MASK));
+       upmap = vm_map_pmap(&curproc->p_vmspace->vm_map);
+       while (count > 0) {
+               /*
+                * First access of a page, use fubyte to make sure
+                * page is faulted in and read access allowed.
+                */
+               if (fubyte(fromp) == -1)
+                       return (EFAULT);
+               /*
+                * Map in the page and bcopy data in from it
+                */
+               upa = pmap_extract(upmap, trunc_page(fromp));
+               if (upa == 0)
+                       panic("mappedcopyin");
+               len = min(count, PAGE_SIZE-off);
+               pmap_enter(kernel_pmap, kva, upa, VM_PROT_READ, TRUE);
+               if (len == PAGE_SIZE && alignable && off == 0)
+                       copypage(kva, top);
+               else
+                       bcopy((caddr_t)(kva+off), top, len);
+               fromp += len;
+               top += len;
+               count -= len;
+               off = 0;
+       }
+       pmap_remove(kernel_pmap, kva, kva+PAGE_SIZE);
+       return (0);
+}
+
+mappedcopyout(fromp, top, count)
+       register char *fromp, *top;
+       register int count;
+{
+       register vm_offset_t kva, upa;
+       register int off, len;
+       int alignable;
+       pmap_t upmap;
+       extern caddr_t CADDR2;
+
+       kva = (vm_offset_t) CADDR2;
+       off = (vm_offset_t)top & PAGE_MASK;
+       alignable = (off == ((vm_offset_t)fromp & PAGE_MASK));
+       upmap = vm_map_pmap(&curproc->p_vmspace->vm_map);
+       while (count > 0) {
+               /*
+                * First access of a page, use subyte to make sure
+                * page is faulted in and write access allowed.
+                */
+               if (subyte(top, *fromp) == -1)
+                       return (EFAULT);
+               /*
+                * Map in the page and bcopy data out to it
+                */
+               upa = pmap_extract(upmap, trunc_page(top));
+               if (upa == 0)
+                       panic("mappedcopyout");
+               len = min(count, PAGE_SIZE-off);
+               pmap_enter(kernel_pmap, kva, upa,
+                          VM_PROT_READ|VM_PROT_WRITE, TRUE);
+               if (len == PAGE_SIZE && alignable && off == 0)
+                       copypage(fromp, kva);
+               else
+                       bcopy(fromp, (caddr_t)(kva+off), len);
+               fromp += len;
+               top += len;
+               count -= len;
+               off = 0;
+       }
+       pmap_remove(kernel_pmap, kva, kva+PAGE_SIZE);
+       return (0);
+}
+#endif