BSD 4_3_Net_2 release
[unix-history] / usr / src / sys / vm / vm_page.c
index 0bae906..ee451b1 100644 (file)
@@ -1,30 +1,77 @@
 /* 
 /* 
- * Copyright (c) 1985, Avadis Tevanian, Jr., Michael Wayne Young
- * Copyright (c) 1987 Carnegie-Mellon University
  * Copyright (c) 1991 Regents of the University of California.
  * All rights reserved.
  *
  * This code is derived from software contributed to Berkeley by
  * The Mach Operating System project at Carnegie-Mellon University.
  *
  * Copyright (c) 1991 Regents of the University of California.
  * All rights reserved.
  *
  * This code is derived from software contributed to Berkeley by
  * The Mach Operating System project at Carnegie-Mellon University.
  *
- * The CMU software License Agreement specifies the terms and conditions
- * for use and redistribution.
+ * 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.
  *
  *
- *     @(#)vm_page.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.
+ *
+ *     @(#)vm_page.c   7.4 (Berkeley) 5/7/91
+ *
+ *
+ * Copyright (c) 1987, 1990 Carnegie-Mellon University.
+ * All rights reserved.
+ *
+ * Authors: Avadis Tevanian, Jr., Michael Wayne Young
+ * 
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ * 
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 
+ * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND 
+ * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ * 
+ * Carnegie Mellon requests users of this software to return to
+ *
+ *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
+ *  School of Computer Science
+ *  Carnegie Mellon University
+ *  Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie the
+ * rights to redistribute these changes.
  */
 
 /*
  *     Resident memory management module.
  */
 
  */
 
 /*
  *     Resident memory management module.
  */
 
-#include "types.h"
-#include "../vm/vm_param.h"
-#include "../vm/vm_map.h"
-#include "../vm/vm_page.h"
-#include "../vm/vm_prot.h"
-#include "../vm/vm_statistics.h"
-#include "../vm/vm_pageout.h"
-#include "../vm/pmap.h"
+#include "param.h"
+
+#include "vm.h"
+#include "vm_map.h"
+#include "vm_page.h"
+#include "vm_pageout.h"
 
 /*
  *     Associated with page of user-allocatable memory is a
 
 /*
  *     Associated with page of user-allocatable memory is a
@@ -222,7 +269,7 @@ vm_offset_t vm_page_startup(start, end, vaddr)
        last_page  = first_page + npages - 1;
 
        first_phys_addr = ptoa(first_page);
        last_page  = first_page + npages - 1;
 
        first_phys_addr = ptoa(first_page);
-       last_phys_addr  = ptoa(last_page) + PAGE_MASK;
+       last_phys_addr  = ptoa(last_page) + page_mask;
 
        /*
         *      Validate these addresses.
 
        /*
         *      Validate these addresses.
@@ -245,7 +292,7 @@ vm_offset_t vm_page_startup(start, end, vaddr)
                m->inactive = FALSE;
                m->active = FALSE;
                m->busy = FALSE;
                m->inactive = FALSE;
                m->active = FALSE;
                m->busy = FALSE;
-               m->object = VM_OBJECT_NULL;
+               m->object = NULL;
                m->phys_addr = pa;
                queue_enter(&vm_page_queue_free, m, vm_page_t, pageq);
                m++;
                m->phys_addr = pa;
                queue_enter(&vm_page_queue_free, m, vm_page_t, pageq);
                m++;
@@ -377,7 +424,7 @@ void vm_page_remove(mem)
  *     vm_page_lookup:
  *
  *     Returns the page associated with the object/offset
  *     vm_page_lookup:
  *
  *     Returns the page associated with the object/offset
- *     pair specified; if none is found, VM_PAGE_NULL is returned.
+ *     pair specified; if none is found, NULL is returned.
  *
  *     The object must be locked.  No side effects.
  */
  *
  *     The object must be locked.  No side effects.
  */
@@ -411,7 +458,7 @@ vm_page_t vm_page_lookup(object, offset)
 
        simple_unlock(&bucket_lock);
        splx(spl);
 
        simple_unlock(&bucket_lock);
        splx(spl);
-       return(VM_PAGE_NULL);
+       return(NULL);
 }
 
 /*
 }
 
 /*
@@ -442,6 +489,26 @@ void               vm_page_init(mem, object, offset)
        vm_object_t     object;
        vm_offset_t     offset;
 {
        vm_object_t     object;
        vm_offset_t     offset;
 {
+#ifdef DEBUG
+#define        vm_page_init(mem, object, offset)  {\
+               (mem)->busy = TRUE; \
+               (mem)->tabled = FALSE; \
+               vm_page_insert((mem), (object), (offset)); \
+               (mem)->absent = FALSE; \
+               (mem)->fictitious = FALSE; \
+               (mem)->page_lock = VM_PROT_NONE; \
+               (mem)->unlock_request = VM_PROT_NONE; \
+               (mem)->laundry = FALSE; \
+               (mem)->active = FALSE; \
+               (mem)->inactive = FALSE; \
+               (mem)->wire_count = 0; \
+               (mem)->clean = TRUE; \
+               (mem)->copy_on_write = FALSE; \
+               (mem)->fake = TRUE; \
+               (mem)->pagerowned = FALSE; \
+               (mem)->ptpage = FALSE; \
+       }
+#else
 #define        vm_page_init(mem, object, offset)  {\
                (mem)->busy = TRUE; \
                (mem)->tabled = FALSE; \
 #define        vm_page_init(mem, object, offset)  {\
                (mem)->busy = TRUE; \
                (mem)->tabled = FALSE; \
@@ -458,6 +525,7 @@ void                vm_page_init(mem, object, offset)
                (mem)->copy_on_write = FALSE; \
                (mem)->fake = TRUE; \
        }
                (mem)->copy_on_write = FALSE; \
                (mem)->fake = TRUE; \
        }
+#endif
 
        vm_page_init(mem, object, offset);
 }
 
        vm_page_init(mem, object, offset);
 }
@@ -482,7 +550,7 @@ vm_page_t vm_page_alloc(object, offset)
        if (queue_empty(&vm_page_queue_free)) {
                simple_unlock(&vm_page_queue_free_lock);
                splx(spl);
        if (queue_empty(&vm_page_queue_free)) {
                simple_unlock(&vm_page_queue_free_lock);
                splx(spl);
-               return(VM_PAGE_NULL);
+               return(NULL);
        }
 
        queue_remove_first(&vm_page_queue_free, mem, vm_page_t, pageq);
        }
 
        queue_remove_first(&vm_page_queue_free, mem, vm_page_t, pageq);