BSD 4_4 release
[unix-history] / usr / src / sys / vm / device_pager.c
index 957e146..8158a1c 100644 (file)
@@ -1,33 +1,57 @@
 /*
  * Copyright (c) 1990 University of Utah.
 /*
  * Copyright (c) 1990 University of Utah.
- * Copyright (c) 1991 The Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1991, 1993
+ *     The Regents of the University of California.  All rights reserved.
  *
  * This code is derived from software contributed to Berkeley by
  * the Systems Programming Group of the University of Utah Computer
  * Science Department.
  *
  *
  * This code is derived from software contributed to Berkeley by
  * the Systems Programming Group of the University of Utah Computer
  * Science Department.
  *
- * %sccs.include.redist.c%
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
  *
  *
- *     @(#)device_pager.c      7.4 (Berkeley) %G%
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *     @(#)device_pager.c      8.1 (Berkeley) 6/11/93
  */
 
 /*
  * Page to/from special files.
  */
 
  */
 
 /*
  * Page to/from special files.
  */
 
-#include "devpager.h"
-#if NDEVPAGER > 0
-
-#include "param.h"
-#include "conf.h"
-#include "mman.h"
-#include "malloc.h"
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/conf.h>
+#include <sys/mman.h>
+#include <sys/malloc.h>
 
 
-#include "vm.h"
-#include "vm_page.h"
-#include "vm_kern.h"
-#include "device_pager.h"
+#include <vm/vm.h>
+#include <vm/vm_kern.h>
+#include <vm/vm_page.h>
+#include <vm/device_pager.h>
 
 queue_head_t   dev_pager_list; /* list of managed devices */
 
 
 queue_head_t   dev_pager_list; /* list of managed devices */
 
@@ -39,7 +63,25 @@ int  dpagerdebug = 0;
 #define DDB_FAIL       0x08
 #endif
 
 #define DDB_FAIL       0x08
 #endif
 
-void
+static vm_pager_t       dev_pager_alloc __P((caddr_t, vm_size_t, vm_prot_t));
+static void             dev_pager_dealloc __P((vm_pager_t));
+static int              dev_pager_getpage
+                           __P((vm_pager_t, vm_page_t, boolean_t));
+static boolean_t        dev_pager_haspage __P((vm_pager_t, vm_offset_t));
+static void             dev_pager_init __P((void));
+static int              dev_pager_putpage
+                           __P((vm_pager_t, vm_page_t, boolean_t));
+
+struct pagerops devicepagerops = {
+       dev_pager_init,
+       dev_pager_alloc,
+       dev_pager_dealloc,
+       dev_pager_getpage,
+       dev_pager_putpage,
+       dev_pager_haspage
+};
+
+static void
 dev_pager_init()
 {
 #ifdef DEBUG
 dev_pager_init()
 {
 #ifdef DEBUG
@@ -49,7 +91,7 @@ dev_pager_init()
        queue_init(&dev_pager_list);
 }
 
        queue_init(&dev_pager_list);
 }
 
-vm_pager_t
+static vm_pager_t
 dev_pager_alloc(handle, size, prot)
        caddr_t handle;
        vm_size_t size;
 dev_pager_alloc(handle, size, prot)
        caddr_t handle;
        vm_size_t size;
@@ -133,7 +175,7 @@ dev_pager_alloc(handle, size, prot)
                        page->phys_addr =
                                pmap_phys_address((*mapfunc)(dev, off, nprot));
                        page->wire_count = 1;
                        page->phys_addr =
                                pmap_phys_address((*mapfunc)(dev, off, nprot));
                        page->wire_count = 1;
-                       page->fictitious = TRUE;
+                       page->flags |= PG_FICTITIOUS;
                        PAGE_WAKEUP(page);
                        vm_object_unlock(object);
                        off += PAGE_SIZE;
                        PAGE_WAKEUP(page);
                        vm_object_unlock(object);
                        off += PAGE_SIZE;
@@ -164,7 +206,7 @@ dev_pager_alloc(handle, size, prot)
 
 }
 
 
 }
 
-void
+static void
 dev_pager_dealloc(pager)
        vm_pager_t pager;
 {
 dev_pager_dealloc(pager)
        vm_pager_t pager;
 {
@@ -184,12 +226,13 @@ dev_pager_dealloc(pager)
 #endif
        while (!queue_empty(&object->memq))
                vm_page_remove((vm_page_t)queue_first(&object->memq));
 #endif
        while (!queue_empty(&object->memq))
                vm_page_remove((vm_page_t)queue_first(&object->memq));
-       kmem_free(kernel_map, devp->devp_pages,
+       kmem_free(kernel_map, (vm_offset_t)devp->devp_pages,
                  devp->devp_npages * sizeof(struct vm_page));
        free((caddr_t)devp, M_VMPGDATA);
        pager->pg_data = 0;
 }
 
                  devp->devp_npages * sizeof(struct vm_page));
        free((caddr_t)devp, M_VMPGDATA);
        pager->pg_data = 0;
 }
 
+static int
 dev_pager_getpage(pager, m, sync)
        vm_pager_t pager;
        vm_page_t m;
 dev_pager_getpage(pager, m, sync)
        vm_pager_t pager;
        vm_page_t m;
@@ -202,6 +245,7 @@ dev_pager_getpage(pager, m, sync)
        return(VM_PAGER_BAD);
 }
 
        return(VM_PAGER_BAD);
 }
 
+static int
 dev_pager_putpage(pager, m, sync)
        vm_pager_t pager;
        vm_page_t m;
 dev_pager_putpage(pager, m, sync)
        vm_pager_t pager;
        vm_page_t m;
@@ -216,7 +260,7 @@ dev_pager_putpage(pager, m, sync)
        panic("dev_pager_putpage called");
 }
 
        panic("dev_pager_putpage called");
 }
 
-boolean_t
+static boolean_t
 dev_pager_haspage(pager, offset)
        vm_pager_t pager;
        vm_offset_t offset;
 dev_pager_haspage(pager, offset)
        vm_pager_t pager;
        vm_offset_t offset;
@@ -227,4 +271,3 @@ dev_pager_haspage(pager, offset)
 #endif
        return(TRUE);
 }
 #endif
        return(TRUE);
 }
-#endif