BSD 4_3_Net_2 release
[unix-history] / usr / src / sys / vm / device_pager.c
index 50b5bc7..90c4d10 100644 (file)
@@ -7,9 +7,35 @@
  * the Systems Programming Group of the University of Utah Computer
  * Science Department.
  *
  * 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.1 (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      7.2 (Berkeley) 4/20/91
  */
 
 /*
  */
 
 /*
 #if NDEVPAGER > 0
 
 #include "param.h"
 #if NDEVPAGER > 0
 
 #include "param.h"
-#include "queue.h"
 #include "conf.h"
 #include "mman.h"
 #include "malloc.h"
 #include "conf.h"
 #include "mman.h"
 #include "malloc.h"
-#include "uio.h"
 
 
-#include "../vm/vm_param.h"
-#include "../vm/vm_map.h"
-#include "../vm/vm_pager.h"
-#include "../vm/vm_page.h"
-#include "../vm/vm_kern.h"
-#include "../vm/device_pager.h"
+#include "vm.h"
+#include "vm_page.h"
+#include "vm_kern.h"
+#include "device_pager.h"
 
 queue_head_t   dev_pager_list; /* list of managed devices */
 
 
 queue_head_t   dev_pager_list; /* list of managed devices */
 
@@ -66,7 +88,7 @@ dev_pager_alloc(handle, size, prot)
        register vm_page_t page;
        register dev_pager_t devp;
        register int npages, off;
        register vm_page_t page;
        register dev_pager_t devp;
        register int npages, off;
-       extern int nulldev(), nodev();
+       extern int nullop(), enodev();
 
 
 #ifdef DEBUG
 
 
 #ifdef DEBUG
@@ -83,15 +105,15 @@ dev_pager_alloc(handle, size, prot)
         * Look it up, creating as necessary
         */
        pager = vm_pager_lookup(&dev_pager_list, handle);
         * Look it up, creating as necessary
         */
        pager = vm_pager_lookup(&dev_pager_list, handle);
-       if (pager == VM_PAGER_NULL) {
+       if (pager == NULL) {
                /*
                 * Validation.  Make sure this device can be mapped
                 * and that range to map is acceptible to device.
                 */
                dev = (dev_t)handle;
                mapfunc = cdevsw[major(dev)].d_mmap;
                /*
                 * Validation.  Make sure this device can be mapped
                 * and that range to map is acceptible to device.
                 */
                dev = (dev_t)handle;
                mapfunc = cdevsw[major(dev)].d_mmap;
-               if (!mapfunc || mapfunc == nodev || mapfunc == nulldev)
-                       return(VM_PAGER_NULL);
+               if (!mapfunc || mapfunc == enodev || mapfunc == nullop)
+                       return(NULL);
                nprot = 0;
                if (prot & VM_PROT_READ)
                        nprot |= PROT_READ;
                nprot = 0;
                if (prot & VM_PROT_READ)
                        nprot |= PROT_READ;
@@ -102,17 +124,17 @@ dev_pager_alloc(handle, size, prot)
                npages = atop(round_page(size));
                for (off = 0; npages--; off += PAGE_SIZE)
                        if ((*mapfunc)(dev, off, nprot) == -1)
                npages = atop(round_page(size));
                for (off = 0; npages--; off += PAGE_SIZE)
                        if ((*mapfunc)(dev, off, nprot) == -1)
-                               return(VM_PAGER_NULL);
+                               return(NULL);
                /*
                 * Allocate and initialize pager structs
                 */
                pager = (vm_pager_t)malloc(sizeof *pager, M_VMPAGER, M_WAITOK);
                /*
                 * Allocate and initialize pager structs
                 */
                pager = (vm_pager_t)malloc(sizeof *pager, M_VMPAGER, M_WAITOK);
-               if (pager == VM_PAGER_NULL)
-                       return(VM_PAGER_NULL);
+               if (pager == NULL)
+                       return(NULL);
                devp = (dev_pager_t)malloc(sizeof *devp, M_VMPGDATA, M_WAITOK);
                devp = (dev_pager_t)malloc(sizeof *devp, M_VMPGDATA, M_WAITOK);
-               if (devp == DEV_PAGER_NULL) {
+               if (devp == NULL) {
                        free((caddr_t)pager, M_VMPAGER);
                        free((caddr_t)pager, M_VMPAGER);
-                       return(VM_PAGER_NULL);
+                       return(NULL);
                }
                devp->devp_dev = dev;
                devp->devp_npages = atop(round_page(size));
                }
                devp->devp_dev = dev;
                devp->devp_npages = atop(round_page(size));
@@ -218,7 +240,7 @@ dev_pager_putpage(pager, m, sync)
        if (dpagerdebug & DDB_FOLLOW)
                printf("dev_pager_putpage(%x, %x)\n", pager, m);
 #endif
        if (dpagerdebug & DDB_FOLLOW)
                printf("dev_pager_putpage(%x, %x)\n", pager, m);
 #endif
-       if (pager == VM_PAGER_NULL)
+       if (pager == NULL)
                return;
        panic("dev_pager_putpage called");
 }
                return;
        panic("dev_pager_putpage called");
 }