diff options
author | Artur Grabowski <art@cvs.openbsd.org> | 2001-11-06 01:35:05 +0000 |
---|---|---|
committer | Artur Grabowski <art@cvs.openbsd.org> | 2001-11-06 01:35:05 +0000 |
commit | c40da229a2b8863dc5e8391bcf995784e71c9ca3 (patch) | |
tree | 43acd53cc5611454b5f62fd69b7f5cc806d36ca6 /sys | |
parent | db54c5228ebca1e9fcf986c2c042c4475999f208 (diff) |
Move the last content from vm/ to uvm/
The only thing left in vm/ are just dumb wrappers.
vm/vm.h includes uvm/uvm_extern.h
vm/pmap.h includes uvm/uvm_pmap.h
vm/vm_page.h includes uvm/uvm_page.h
Diffstat (limited to 'sys')
-rw-r--r-- | sys/uvm/uvm_amap.c | 6 | ||||
-rw-r--r-- | sys/uvm/uvm_anon.c | 6 | ||||
-rw-r--r-- | sys/uvm/uvm_aobj.c | 6 | ||||
-rw-r--r-- | sys/uvm/uvm_device.c | 14 | ||||
-rw-r--r-- | sys/uvm/uvm_extern.h | 131 | ||||
-rw-r--r-- | sys/uvm/uvm_fault.c | 7 | ||||
-rw-r--r-- | sys/uvm/uvm_glue.c | 6 | ||||
-rw-r--r-- | sys/uvm/uvm_init.c | 7 | ||||
-rw-r--r-- | sys/uvm/uvm_io.c | 6 | ||||
-rw-r--r-- | sys/uvm/uvm_km.c | 6 | ||||
-rw-r--r-- | sys/uvm/uvm_loan.c | 6 | ||||
-rw-r--r-- | sys/uvm/uvm_map.c | 6 | ||||
-rw-r--r-- | sys/uvm/uvm_meter.c | 6 | ||||
-rw-r--r-- | sys/uvm/uvm_mmap.c | 6 | ||||
-rw-r--r-- | sys/uvm/uvm_page.c | 6 | ||||
-rw-r--r-- | sys/uvm/uvm_page.h | 357 | ||||
-rw-r--r-- | sys/uvm/uvm_pager.c | 6 | ||||
-rw-r--r-- | sys/uvm/uvm_pdaemon.c | 6 | ||||
-rw-r--r-- | sys/uvm/uvm_pglist.c | 6 | ||||
-rw-r--r-- | sys/uvm/uvm_pmap.h | 164 | ||||
-rw-r--r-- | sys/uvm/uvm_stat.c | 6 | ||||
-rw-r--r-- | sys/uvm/uvm_swap.c | 5 | ||||
-rw-r--r-- | sys/uvm/uvm_unix.c | 6 | ||||
-rw-r--r-- | sys/uvm/uvm_user.c | 5 | ||||
-rw-r--r-- | sys/uvm/uvm_vnode.c | 6 | ||||
-rw-r--r-- | sys/vm/pmap.h | 167 | ||||
-rw-r--r-- | sys/vm/vm.h | 93 | ||||
-rw-r--r-- | sys/vm/vm_page.h | 335 |
28 files changed, 687 insertions, 700 deletions
diff --git a/sys/uvm/uvm_amap.c b/sys/uvm/uvm_amap.c index ea08c4670e2..0a9abcbde4f 100644 --- a/sys/uvm/uvm_amap.c +++ b/sys/uvm/uvm_amap.c @@ -1,5 +1,5 @@ -/* $OpenBSD: uvm_amap.c,v 1.11 2001/11/05 22:14:54 art Exp $ */ -/* $NetBSD: uvm_amap.c,v 1.23 2000/06/26 14:21:16 mrg Exp $ */ +/* $OpenBSD: uvm_amap.c,v 1.12 2001/11/06 01:35:04 art Exp $ */ +/* $NetBSD: uvm_amap.c,v 1.24 2000/06/27 17:29:17 mrg Exp $ */ /* * @@ -50,8 +50,6 @@ #include <sys/malloc.h> #include <sys/pool.h> -#include <vm/vm.h> - #define UVM_AMAP_C /* ensure disabled inlines are in */ #include <uvm/uvm.h> #include <uvm/uvm_swap.h> diff --git a/sys/uvm/uvm_anon.c b/sys/uvm/uvm_anon.c index 170368c6212..0f74c4eff86 100644 --- a/sys/uvm/uvm_anon.c +++ b/sys/uvm/uvm_anon.c @@ -1,5 +1,5 @@ -/* $OpenBSD: uvm_anon.c,v 1.11 2001/11/05 22:14:54 art Exp $ */ -/* $NetBSD: uvm_anon.c,v 1.6 2000/06/26 14:21:16 mrg Exp $ */ +/* $OpenBSD: uvm_anon.c,v 1.12 2001/11/06 01:35:04 art Exp $ */ +/* $NetBSD: uvm_anon.c,v 1.7 2000/06/27 17:29:18 mrg Exp $ */ /* * @@ -44,8 +44,6 @@ #include <sys/pool.h> #include <sys/kernel.h> -#include <vm/vm.h> - #include <uvm/uvm.h> #include <uvm/uvm_swap.h> diff --git a/sys/uvm/uvm_aobj.c b/sys/uvm/uvm_aobj.c index 7aa9589ca0b..3b0a07dccb5 100644 --- a/sys/uvm/uvm_aobj.c +++ b/sys/uvm/uvm_aobj.c @@ -1,5 +1,5 @@ -/* $OpenBSD: uvm_aobj.c,v 1.16 2001/11/05 22:14:54 art Exp $ */ -/* $NetBSD: uvm_aobj.c,v 1.32 2000/06/26 14:21:17 mrg Exp $ */ +/* $OpenBSD: uvm_aobj.c,v 1.17 2001/11/06 01:35:04 art Exp $ */ +/* $NetBSD: uvm_aobj.c,v 1.33 2000/06/27 17:29:19 mrg Exp $ */ /* * Copyright (c) 1998 Chuck Silvers, Charles D. Cranor and @@ -50,8 +50,6 @@ #include <sys/pool.h> #include <sys/kernel.h> -#include <vm/vm.h> - #include <uvm/uvm.h> /* diff --git a/sys/uvm/uvm_device.c b/sys/uvm/uvm_device.c index 0c93389c59d..a2542a7de68 100644 --- a/sys/uvm/uvm_device.c +++ b/sys/uvm/uvm_device.c @@ -1,5 +1,5 @@ -/* $OpenBSD: uvm_device.c,v 1.15 2001/11/05 22:14:54 art Exp $ */ -/* $NetBSD: uvm_device.c,v 1.26 2000/06/26 14:21:17 mrg Exp $ */ +/* $OpenBSD: uvm_device.c,v 1.16 2001/11/06 01:35:04 art Exp $ */ +/* $NetBSD: uvm_device.c,v 1.28 2000/06/27 17:29:20 mrg Exp $ */ /* * @@ -46,8 +46,6 @@ #include <sys/malloc.h> #include <sys/vnode.h> -#include <vm/vm.h> - #include <uvm/uvm.h> #include <uvm/uvm_device.h> @@ -406,7 +404,7 @@ udv_fault(ufi, vaddr, pps, npages, centeridx, fault_type, access_type, flags) struct uvm_object *uobj = entry->object.uvm_obj; struct uvm_device *udv = (struct uvm_device *)uobj; vaddr_t curr_va; - int curr_offset; + off_t curr_offset; paddr_t paddr, mdpgno; int lcv, retval; dev_t device; @@ -447,7 +445,7 @@ udv_fault(ufi, vaddr, pps, npages, centeridx, fault_type, access_type, flags) * addresses in a submap must match the main map, this is ok. */ /* udv offset = (offset from start of entry) + entry's offset */ - curr_offset = (int)((vaddr - entry->start) + entry->offset); + curr_offset = entry->offset + (vaddr - entry->start); /* pmap va = vaddr (virtual address of pps[0]) */ curr_va = vaddr; @@ -472,8 +470,8 @@ udv_fault(ufi, vaddr, pps, npages, centeridx, fault_type, access_type, flags) paddr = pmap_phys_address(mdpgno); mapprot = ufi->entry->protection; UVMHIST_LOG(maphist, - " MAPPING: device: pm=0x%x, va=0x%x, pa=0x%x, at=%d", - ufi->orig_map->pmap, curr_va, (int)paddr, mapprot); + " MAPPING: device: pm=0x%x, va=0x%x, pa=0x%lx, at=%d", + ufi->orig_map->pmap, curr_va, paddr, mapprot); if (pmap_enter(ufi->orig_map->pmap, curr_va, paddr, mapprot, PMAP_CANFAIL | mapprot) != KERN_SUCCESS) { /* diff --git a/sys/uvm/uvm_extern.h b/sys/uvm/uvm_extern.h index 55ea4f9be02..0d7b9122a8e 100644 --- a/sys/uvm/uvm_extern.h +++ b/sys/uvm/uvm_extern.h @@ -1,5 +1,5 @@ -/* $OpenBSD: uvm_extern.h,v 1.25 2001/11/06 00:24:55 art Exp $ */ -/* $NetBSD: uvm_extern.h,v 1.43 2000/06/26 14:21:17 mrg Exp $ */ +/* $OpenBSD: uvm_extern.h,v 1.26 2001/11/06 01:35:04 art Exp $ */ +/* $NetBSD: uvm_extern.h,v 1.45 2000/06/27 16:16:43 mrg Exp $ */ /* * @@ -35,6 +35,41 @@ * from: Id: uvm_extern.h,v 1.1.2.21 1998/02/07 01:16:53 chs Exp */ +/*- + * Copyright (c) 1991, 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * 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. + * + * 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_extern.h 8.5 (Berkeley) 5/3/95 + */ + #ifndef _UVM_UVM_EXTERN_H_ #define _UVM_UVM_EXTERN_H_ @@ -50,6 +85,28 @@ */ /* + * typedefs, necessary for standard UVM headers. + */ + +typedef unsigned int uvm_flag_t; +typedef int vm_fault_t; + +typedef int vm_inherit_t; /* XXX: inheritance codes */ +typedef off_t voff_t; /* XXX: offset within a uvm_object */ + +union vm_map_object; +typedef union vm_map_object vm_map_object_t; + +struct vm_map_entry; +typedef struct vm_map_entry *vm_map_entry_t; + +struct vm_map; +typedef struct vm_map *vm_map_t; + +struct vm_page; +typedef struct vm_page *vm_page_t; + +/* * defines */ @@ -302,6 +359,44 @@ struct uvmexp { }; #ifdef _KERNEL +extern struct uvmexp uvmexp; +#endif + +/* + * Finally, bring in standard UVM headers. + */ +#include <sys/vmmeter.h> +#include <sys/queue.h> +#include <uvm/uvm_param.h> +#include <sys/lock.h> +#include <uvm/uvm_page.h> +#include <uvm/uvm_pmap.h> +#include <uvm/uvm_map.h> +#include <uvm/uvm_fault.h> +#include <uvm/uvm_pager.h> + +/* + * Shareable process virtual address space. + * May eventually be merged with vm_map. + * Several fields are temporary (text, data stuff). + */ +struct vmspace { + struct vm_map vm_map; /* VM address map */ + int vm_refcnt; /* number of references */ + caddr_t vm_shm; /* SYS5 shared memory private data XXX */ +/* we copy from vm_startcopy to the end of the structure on fork */ +#define vm_startcopy vm_rssize + segsz_t vm_rssize; /* current resident set size in pages */ + segsz_t vm_swrss; /* resident set size before last swap */ + segsz_t vm_tsize; /* text size (pages) XXX */ + segsz_t vm_dsize; /* data size (pages) XXX */ + segsz_t vm_ssize; /* stack size (pages) */ + caddr_t vm_taddr; /* user virtual address of text XXX */ + caddr_t vm_daddr; /* user virtual address of data XXX */ + caddr_t vm_maxsaddr; /* user VA at max stack growth */ +}; + +#ifdef _KERNEL /* * the various kernel maps, owned by MD code @@ -312,7 +407,6 @@ extern struct vm_map *kmem_map; extern struct vm_map *mb_map; extern struct vm_map *phys_map; -extern struct uvmexp uvmexp; /* * macros @@ -324,15 +418,36 @@ extern struct uvmexp uvmexp; #endif /* _KERNEL */ -/* - * typedefs - */ +#ifdef pmap_resident_count +#define vm_resident_count(vm) (pmap_resident_count((vm)->vm_map.pmap)) +#else +#define vm_resident_count(vm) ((vm)->vm_rssize) +#endif -typedef unsigned int uvm_flag_t; -typedef int vm_fault_t; +/* XXX clean up later */ +struct buf; +struct loadavg; +struct proc; +struct pmap; +struct vmspace; +struct vmtotal; +struct mount; +struct vnode; +struct core; #ifdef _KERNEL +/* vm_machdep.c */ +void vmapbuf __P((struct buf *, vsize_t)); +void vunmapbuf __P((struct buf *, vsize_t)); +void pagemove __P((caddr_t, caddr_t, size_t)); +#ifndef cpu_swapin +void cpu_swapin __P((struct proc *)); +#endif +#ifndef cpu_swapout +void cpu_swapout __P((struct proc *)); +#endif + /* uvm_aobj.c */ struct uvm_object *uao_create __P((vsize_t, int)); void uao_detach __P((struct uvm_object *)); diff --git a/sys/uvm/uvm_fault.c b/sys/uvm/uvm_fault.c index b1304ced2f8..1f61a2e45a5 100644 --- a/sys/uvm/uvm_fault.c +++ b/sys/uvm/uvm_fault.c @@ -1,5 +1,5 @@ -/* $OpenBSD: uvm_fault.c,v 1.20 2001/11/05 22:14:54 art Exp $ */ -/* $NetBSD: uvm_fault.c,v 1.49 2000/06/26 14:21:17 mrg Exp $ */ +/* $OpenBSD: uvm_fault.c,v 1.21 2001/11/06 01:35:04 art Exp $ */ +/* $NetBSD: uvm_fault.c,v 1.50 2000/06/27 17:29:21 mrg Exp $ */ /* * @@ -47,9 +47,6 @@ #include <sys/mman.h> #include <sys/user.h> -#include <vm/vm.h> -#include <vm/vm_page.h> - #include <uvm/uvm.h> /* diff --git a/sys/uvm/uvm_glue.c b/sys/uvm/uvm_glue.c index 970bcec90d2..71c28281e64 100644 --- a/sys/uvm/uvm_glue.c +++ b/sys/uvm/uvm_glue.c @@ -1,5 +1,5 @@ -/* $OpenBSD: uvm_glue.c,v 1.21 2001/11/05 22:14:54 art Exp $ */ -/* $NetBSD: uvm_glue.c,v 1.37 2000/06/26 14:21:17 mrg Exp $ */ +/* $OpenBSD: uvm_glue.c,v 1.22 2001/11/06 01:35:04 art Exp $ */ +/* $NetBSD: uvm_glue.c,v 1.38 2000/06/27 17:29:22 mrg Exp $ */ /* * Copyright (c) 1997 Charles D. Cranor and Washington University. @@ -81,8 +81,6 @@ #include <sys/shm.h> #endif -#include <vm/vm.h> - #include <uvm/uvm.h> #include <machine/cpu.h> diff --git a/sys/uvm/uvm_init.c b/sys/uvm/uvm_init.c index 76810c1e3b9..a9915e88040 100644 --- a/sys/uvm/uvm_init.c +++ b/sys/uvm/uvm_init.c @@ -1,5 +1,5 @@ -/* $OpenBSD: uvm_init.c,v 1.9 2001/11/05 22:14:54 art Exp $ */ -/* $NetBSD: uvm_init.c,v 1.13 2000/06/26 14:21:18 mrg Exp $ */ +/* $OpenBSD: uvm_init.c,v 1.10 2001/11/06 01:35:04 art Exp $ */ +/* $NetBSD: uvm_init.c,v 1.14 2000/06/27 17:29:23 mrg Exp $ */ /* * @@ -49,9 +49,6 @@ #include <sys/malloc.h> #include <sys/vnode.h> - -#include <vm/vm.h> - #include <uvm/uvm.h> /* diff --git a/sys/uvm/uvm_io.c b/sys/uvm/uvm_io.c index 404d89140cf..5cb29a07715 100644 --- a/sys/uvm/uvm_io.c +++ b/sys/uvm/uvm_io.c @@ -1,5 +1,5 @@ -/* $OpenBSD: uvm_io.c,v 1.9 2001/11/05 22:14:54 art Exp $ */ -/* $NetBSD: uvm_io.c,v 1.11 2000/06/26 14:21:18 mrg Exp $ */ +/* $OpenBSD: uvm_io.c,v 1.10 2001/11/06 01:35:04 art Exp $ */ +/* $NetBSD: uvm_io.c,v 1.12 2000/06/27 17:29:23 mrg Exp $ */ /* * @@ -46,8 +46,6 @@ #include <sys/malloc.h> #include <sys/uio.h> -#include <vm/vm.h> - #include <uvm/uvm.h> /* diff --git a/sys/uvm/uvm_km.c b/sys/uvm/uvm_km.c index 714f2446967..729fcced29b 100644 --- a/sys/uvm/uvm_km.c +++ b/sys/uvm/uvm_km.c @@ -1,5 +1,5 @@ -/* $OpenBSD: uvm_km.c,v 1.16 2001/11/05 22:14:54 art Exp $ */ -/* $NetBSD: uvm_km.c,v 1.36 2000/06/26 14:21:18 mrg Exp $ */ +/* $OpenBSD: uvm_km.c,v 1.17 2001/11/06 01:35:04 art Exp $ */ +/* $NetBSD: uvm_km.c,v 1.37 2000/06/27 17:29:24 mrg Exp $ */ /* * Copyright (c) 1997 Charles D. Cranor and Washington University. @@ -145,8 +145,6 @@ #include <sys/systm.h> #include <sys/proc.h> -#include <vm/vm.h> - #include <uvm/uvm.h> /* diff --git a/sys/uvm/uvm_loan.c b/sys/uvm/uvm_loan.c index 436a85ad57d..5c20fbe2f60 100644 --- a/sys/uvm/uvm_loan.c +++ b/sys/uvm/uvm_loan.c @@ -1,5 +1,5 @@ -/* $OpenBSD: uvm_loan.c,v 1.10 2001/11/05 22:14:54 art Exp $ */ -/* $NetBSD: uvm_loan.c,v 1.21 2000/06/26 14:21:18 mrg Exp $ */ +/* $OpenBSD: uvm_loan.c,v 1.11 2001/11/06 01:35:04 art Exp $ */ +/* $NetBSD: uvm_loan.c,v 1.22 2000/06/27 17:29:25 mrg Exp $ */ /* * @@ -46,8 +46,6 @@ #include <sys/malloc.h> #include <sys/mman.h> -#include <vm/vm.h> - #include <uvm/uvm.h> /* diff --git a/sys/uvm/uvm_map.c b/sys/uvm/uvm_map.c index 28487cab6aa..6144ef4a222 100644 --- a/sys/uvm/uvm_map.c +++ b/sys/uvm/uvm_map.c @@ -1,5 +1,5 @@ -/* $OpenBSD: uvm_map.c,v 1.25 2001/11/05 22:14:54 art Exp $ */ -/* $NetBSD: uvm_map.c,v 1.78 2000/06/26 14:21:18 mrg Exp $ */ +/* $OpenBSD: uvm_map.c,v 1.26 2001/11/06 01:35:04 art Exp $ */ +/* $NetBSD: uvm_map.c,v 1.79 2000/06/27 17:29:26 mrg Exp $ */ /* * Copyright (c) 1997 Charles D. Cranor and Washington University. @@ -82,8 +82,6 @@ #include <sys/shm.h> #endif -#include <vm/vm.h> - #define UVM_MAP #include <uvm/uvm.h> diff --git a/sys/uvm/uvm_meter.c b/sys/uvm/uvm_meter.c index 31c783c027c..25af71e70f1 100644 --- a/sys/uvm/uvm_meter.c +++ b/sys/uvm/uvm_meter.c @@ -1,5 +1,5 @@ -/* $OpenBSD: uvm_meter.c,v 1.12 2001/08/11 10:57:22 art Exp $ */ -/* $NetBSD: uvm_meter.c,v 1.12 2000/05/26 00:36:53 thorpej Exp $ */ +/* $OpenBSD: uvm_meter.c,v 1.13 2001/11/06 01:35:04 art Exp $ */ +/* $NetBSD: uvm_meter.c,v 1.13 2000/06/27 17:29:27 mrg Exp $ */ /* * Copyright (c) 1997 Charles D. Cranor and Washington University. @@ -45,7 +45,7 @@ #include <sys/proc.h> #include <sys/systm.h> #include <sys/kernel.h> -#include <vm/vm.h> +#include <uvm/uvm_extern.h> #include <sys/sysctl.h> #include <sys/exec.h> diff --git a/sys/uvm/uvm_mmap.c b/sys/uvm/uvm_mmap.c index 19b48f6cbeb..44b831447fe 100644 --- a/sys/uvm/uvm_mmap.c +++ b/sys/uvm/uvm_mmap.c @@ -1,5 +1,5 @@ -/* $OpenBSD: uvm_mmap.c,v 1.22 2001/11/05 22:14:54 art Exp $ */ -/* $NetBSD: uvm_mmap.c,v 1.42 2000/06/26 14:21:18 mrg Exp $ */ +/* $OpenBSD: uvm_mmap.c,v 1.23 2001/11/06 01:35:04 art Exp $ */ +/* $NetBSD: uvm_mmap.c,v 1.43 2000/06/27 17:29:28 mrg Exp $ */ /* * Copyright (c) 1997 Charles D. Cranor and Washington University. @@ -65,8 +65,6 @@ #include <miscfs/specfs/specdev.h> -#include <vm/vm.h> - #include <sys/syscallargs.h> #include <uvm/uvm.h> diff --git a/sys/uvm/uvm_page.c b/sys/uvm/uvm_page.c index 95d5d35739f..56ff88e56fa 100644 --- a/sys/uvm/uvm_page.c +++ b/sys/uvm/uvm_page.c @@ -1,5 +1,5 @@ -/* $OpenBSD: uvm_page.c,v 1.25 2001/11/05 22:14:54 art Exp $ */ -/* $NetBSD: uvm_page.c,v 1.38 2000/06/26 14:21:18 mrg Exp $ */ +/* $OpenBSD: uvm_page.c,v 1.26 2001/11/06 01:35:04 art Exp $ */ +/* $NetBSD: uvm_page.c,v 1.39 2000/06/27 17:29:31 mrg Exp $ */ /* * Copyright (c) 1997 Charles D. Cranor and Washington University. @@ -76,8 +76,6 @@ #include <sys/malloc.h> #include <sys/sched.h> -#include <vm/vm.h> - #define UVM_PAGE /* pull in uvm_page.h functions */ #include <uvm/uvm.h> diff --git a/sys/uvm/uvm_page.h b/sys/uvm/uvm_page.h index e2a9541d828..cd8105d010d 100644 --- a/sys/uvm/uvm_page.h +++ b/sys/uvm/uvm_page.h @@ -1,5 +1,5 @@ -/* $OpenBSD: uvm_page.h,v 1.9 2001/08/11 10:57:22 art Exp $ */ -/* $NetBSD: uvm_page.h,v 1.15 2000/04/24 17:12:01 thorpej Exp $ */ +/* $OpenBSD: uvm_page.h,v 1.10 2001/11/06 01:35:04 art Exp $ */ +/* $NetBSD: uvm_page.h,v 1.16 2000/06/27 09:00:14 mrg Exp $ */ /* * Copyright (c) 1997 Charles D. Cranor and Washington University. @@ -74,6 +74,148 @@ * uvm_page.h */ +/* + * Resident memory system definitions. + */ + +/* + * Management of resident (logical) pages. + * + * A small structure is kept for each resident + * page, indexed by page number. Each structure + * is an element of several lists: + * + * A hash table bucket used to quickly + * perform object/offset lookups + * + * A list of all pages for a given object, + * so they can be quickly deactivated at + * time of deallocation. + * + * An ordered list of pages due for pageout. + * + * In addition, the structure contains the object + * and offset to which this page belongs (for pageout), + * and sundry status bits. + * + * Fields in this structure are locked either by the lock on the + * object that the page belongs to (O) or by the lock on the page + * queues (P) [or both]. + */ + +/* + * locking note: the mach version of this data structure had bit + * fields for the flags, and the bit fields were divided into two + * items (depending on who locked what). some time, in BSD, the bit + * fields were dumped and all the flags were lumped into one short. + * that is fine for a single threaded uniprocessor OS, but bad if you + * want to actual make use of locking (simple_lock's). so, we've + * seperated things back out again. + * + * note the page structure has no lock of its own. + */ + +#include <uvm/uvm_extern.h> +#include <uvm/uvm_pglist.h> + +struct vm_page { + TAILQ_ENTRY(vm_page) pageq; /* queue info for FIFO + * queue or free list (P) */ + TAILQ_ENTRY(vm_page) hashq; /* hash table links (O)*/ + TAILQ_ENTRY(vm_page) listq; /* pages in same object (O)*/ + + struct vm_anon *uanon; /* anon (O,P) */ + struct uvm_object *uobject; /* object (O,P) */ + voff_t offset; /* offset into object (O,P) */ + + u_short flags; /* object flags [O] */ + u_short version; /* version count [O] */ + u_short wire_count; /* wired down map refs [P] */ + u_short pqflags; /* page queue flags [P] */ + u_int loan_count; /* number of active loans + * to read: [O or P] + * to modify: [O _and_ P] */ + paddr_t phys_addr; /* physical address of page */ +#if defined(UVM_PAGE_TRKOWN) + /* debugging fields to track page ownership */ + pid_t owner; /* proc that set PG_BUSY */ + char *owner_tag; /* why it was set busy */ +#endif +}; + +/* + * These are the flags defined for vm_page. + * + * Note: PG_FILLED and PG_DIRTY are added for the filesystems. + */ + +/* + * locking rules: + * PG_ ==> locked by object lock + * PQ_ ==> lock by page queue lock + * PQ_FREE is locked by free queue lock and is mutex with all other PQs + * + * PG_ZERO is used to indicate that a page has been pre-zero'd. This flag + * is only set when the page is on no queues, and is cleared when the page + * is placed on the free list. + * + * possible deadwood: PG_FAULTING, PQ_LAUNDRY + */ +#define PG_CLEAN 0x0008 /* page has not been modified */ +#define PG_BUSY 0x0010 /* page is in transit */ +#define PG_WANTED 0x0020 /* someone is waiting for page */ +#define PG_TABLED 0x0040 /* page is in VP table */ +#define PG_ZERO 0x0100 /* page is pre-zero'd */ +#define PG_FAKE 0x0200 /* page is placeholder for pagein */ +#define PG_FILLED 0x0400 /* client flag to set when filled */ +#define PG_DIRTY 0x0800 /* client flag to set when dirty */ +#define PG_RELEASED 0x1000 /* page released while paging */ +#define PG_FAULTING 0x2000 /* page is being faulted in */ +#define PG_CLEANCHK 0x4000 /* clean bit has been checked */ + +#define PQ_FREE 0x0001 /* page is on free list */ +#define PQ_INACTIVE 0x0002 /* page is in inactive list */ +#define PQ_ACTIVE 0x0004 /* page is in active list */ +#define PQ_LAUNDRY 0x0008 /* page is being cleaned now */ +#define PQ_ANON 0x0010 /* page is part of an anon, rather + than an uvm_object */ +#define PQ_AOBJ 0x0020 /* page is part of an anonymous + uvm_object */ +#define PQ_SWAPBACKED (PQ_ANON|PQ_AOBJ) +#define PQ_ENCRYPT 0x0040 /* page needs {en,de}cryption */ + +/* + * physical memory layout structure + * + * MD vmparam.h must #define: + * VM_PHYSEG_MAX = max number of physical memory segments we support + * (if this is "1" then we revert to a "contig" case) + * VM_PHYSSEG_STRAT: memory sort/search options (for VM_PHYSEG_MAX > 1) + * - VM_PSTRAT_RANDOM: linear search (random order) + * - VM_PSTRAT_BSEARCH: binary search (sorted by address) + * - VM_PSTRAT_BIGFIRST: linear search (sorted by largest segment first) + * - others? + * XXXCDC: eventually we should remove contig and old non-contig cases + * and purge all left-over global variables... + */ +#define VM_PSTRAT_RANDOM 1 +#define VM_PSTRAT_BSEARCH 2 +#define VM_PSTRAT_BIGFIRST 3 + +/* + * vm_physmemseg: describes one segment of physical memory + */ +struct vm_physseg { + paddr_t start; /* PF# of first page in segment */ + paddr_t end; /* (PF# of last page in segment) + 1 */ + paddr_t avail_start; /* PF# of first free page in segment */ + paddr_t avail_end; /* (PF# of last free page in segment) +1 */ + int free_list; /* which free list they belong on */ + struct vm_page *pgs; /* vm_page structures (from start) */ + struct vm_page *lastpg; /* vm_page structure for end */ + struct pmap_physseg pmseg; /* pmap specific (MD) data */ +}; + #ifdef _KERNEL /* @@ -83,16 +225,34 @@ extern boolean_t vm_page_zero_enable; /* - * macros + * Each pageable resident page falls into one of three lists: + * + * free + * Available for allocation now. + * inactive + * Not referenced in any map, but still has an + * object/offset-page mapping, and may be dirty. + * This is the list of pages that should be + * paged out next. + * active + * A list of pages which have been placed in + * at least one physical map. This list is + * ordered, in LRU-like fashion. */ -#define uvm_lock_pageq() simple_lock(&uvm.pageqlock) -#define uvm_unlock_pageq() simple_unlock(&uvm.pageqlock) +extern +struct pglist vm_page_queue_free; /* memory free queue */ +extern +struct pglist vm_page_queue_active; /* active memory queue */ +extern +struct pglist vm_page_queue_inactive; /* inactive memory queue */ -#define uvm_pagehash(obj,off) \ - (((unsigned long)obj+(unsigned long)atop(off)) & uvm.page_hashmask) +/* + * physical memory config is stored in vm_physmem. + */ -#define UVM_PAGEZERO_TARGET (uvmexp.free) +extern struct vm_physseg vm_physmem[VM_PHYSSEG_MAX]; +extern int vm_nphysseg; /* * handle inline options @@ -137,6 +297,187 @@ PAGE_INLINE void uvm_pagezero __P((struct vm_page *)); PAGE_INLINE int uvm_page_lookup_freelist __P((struct vm_page *)); +static struct vm_page *PHYS_TO_VM_PAGE __P((paddr_t)); +static int vm_physseg_find __P((paddr_t, int *)); + +/* + * macros + */ + +#define uvm_lock_pageq() simple_lock(&uvm.pageqlock) +#define uvm_unlock_pageq() simple_unlock(&uvm.pageqlock) + +#define uvm_pagehash(obj,off) \ + (((unsigned long)obj+(unsigned long)atop(off)) & uvm.page_hashmask) + +#define UVM_PAGEZERO_TARGET (uvmexp.free) + +#define VM_PAGE_TO_PHYS(entry) ((entry)->phys_addr) + +/* + * when VM_PHYSSEG_MAX is 1, we can simplify these functions + */ + +/* + * vm_physseg_find: find vm_physseg structure that belongs to a PA + */ +static __inline int +vm_physseg_find(pframe, offp) + paddr_t pframe; + int *offp; +{ +#if VM_PHYSSEG_MAX == 1 + + /* 'contig' case */ + if (pframe >= vm_physmem[0].start && pframe < vm_physmem[0].end) { + if (offp) + *offp = pframe - vm_physmem[0].start; + return(0); + } + return(-1); + +#elif (VM_PHYSSEG_STRAT == VM_PSTRAT_BSEARCH) + /* binary search for it */ + int start, len, try; + + /* + * if try is too large (thus target is less than than try) we reduce + * the length to trunc(len/2) [i.e. everything smaller than "try"] + * + * if the try is too small (thus target is greater than try) then + * we set the new start to be (try + 1). this means we need to + * reduce the length to (round(len/2) - 1). + * + * note "adjust" below which takes advantage of the fact that + * (round(len/2) - 1) == trunc((len - 1) / 2) + * for any value of len we may have + */ + + for (start = 0, len = vm_nphysseg ; len != 0 ; len = len / 2) { + try = start + (len / 2); /* try in the middle */ + + /* start past our try? */ + if (pframe >= vm_physmem[try].start) { + /* was try correct? */ + if (pframe < vm_physmem[try].end) { + if (offp) + *offp = pframe - vm_physmem[try].start; + return(try); /* got it */ + } + start = try + 1; /* next time, start here */ + len--; /* "adjust" */ + } else { + /* + * pframe before try, just reduce length of + * region, done in "for" loop + */ + } + } + return(-1); + +#else + /* linear search for it */ + int lcv; + + for (lcv = 0; lcv < vm_nphysseg; lcv++) { + if (pframe >= vm_physmem[lcv].start && + pframe < vm_physmem[lcv].end) { + if (offp) + *offp = pframe - vm_physmem[lcv].start; + return(lcv); /* got it */ + } + } + return(-1); + +#endif +} + + +/* + * IS_VM_PHYSADDR: only used my mips/pmax/pica trap/pmap. + */ + +#define IS_VM_PHYSADDR(PA) (vm_physseg_find(atop(PA), NULL) != -1) + +/* + * PHYS_TO_VM_PAGE: find vm_page for a PA. used by MI code to get vm_pages + * back from an I/O mapping (ugh!). used in some MD code as well. + */ +static __inline struct vm_page * +PHYS_TO_VM_PAGE(pa) + paddr_t pa; +{ + paddr_t pf = atop(pa); + int off; + int psi; + + psi = vm_physseg_find(pf, &off); + if (psi != -1) + return(&vm_physmem[psi].pgs[off]); + return(NULL); +} + +#define VM_PAGE_IS_FREE(entry) ((entry)->pqflags & PQ_FREE) + +extern +simple_lock_data_t vm_page_queue_lock; /* lock on active and inactive + page queues */ +extern /* lock on free page queue */ +simple_lock_data_t vm_page_queue_free_lock; + +#define PAGE_ASSERT_WAIT(m, interruptible) { \ + (m)->flags |= PG_WANTED; \ + assert_wait((m), (interruptible)); \ + } + +#define PAGE_WAKEUP(m) { \ + (m)->flags &= ~PG_BUSY; \ + if ((m)->flags & PG_WANTED) { \ + (m)->flags &= ~PG_WANTED; \ + wakeup((m)); \ + } \ + } + +#define vm_page_lock_queues() simple_lock(&vm_page_queue_lock) +#define vm_page_unlock_queues() simple_unlock(&vm_page_queue_lock) + +#define vm_page_set_modified(m) { (m)->flags &= ~PG_CLEAN; } + +#define VM_PAGE_INIT(mem, obj, offset) { \ + (mem)->flags = PG_BUSY | PG_CLEAN | PG_FAKE; \ + if (obj) \ + vm_page_insert((mem), (obj), (offset)); \ + else \ + (mem)->object = NULL; \ + (mem)->wire_count = 0; \ +} + +#if VM_PAGE_DEBUG + +/* + * VM_PAGE_CHECK: debugging check of a vm_page structure + */ +static __inline void +VM_PAGE_CHECK(mem) + struct vm_page *mem; +{ + int lcv; + + for (lcv = 0 ; lcv < vm_nphysseg ; lcv++) { + if ((unsigned int) mem >= (unsigned int) vm_physmem[lcv].pgs && + (unsigned int) mem <= (unsigned int) vm_physmem[lcv].lastpg) + break; + } + if (lcv == vm_nphysseg || + (mem->flags & (PG_ACTIVE|PG_INACTIVE)) == (PG_ACTIVE|PG_INACTIVE)) + panic("vm_page_check: not valid!"); + return; +} + +#else /* VM_PAGE_DEBUG */ +#define VM_PAGE_CHECK(mem) +#endif /* VM_PAGE_DEBUG */ + #endif /* _KERNEL */ #endif /* _UVM_UVM_PAGE_H_ */ diff --git a/sys/uvm/uvm_pager.c b/sys/uvm/uvm_pager.c index 57003313dc7..15dce897e17 100644 --- a/sys/uvm/uvm_pager.c +++ b/sys/uvm/uvm_pager.c @@ -1,5 +1,5 @@ -/* $OpenBSD: uvm_pager.c,v 1.17 2001/11/05 22:14:54 art Exp $ */ -/* $NetBSD: uvm_pager.c,v 1.31 2000/06/26 14:21:18 mrg Exp $ */ +/* $OpenBSD: uvm_pager.c,v 1.18 2001/11/06 01:35:04 art Exp $ */ +/* $NetBSD: uvm_pager.c,v 1.32 2000/06/27 17:29:32 mrg Exp $ */ /* * @@ -44,8 +44,6 @@ #include <sys/proc.h> #include <sys/malloc.h> -#include <vm/vm.h> - #define UVM_PAGER #include <uvm/uvm.h> diff --git a/sys/uvm/uvm_pdaemon.c b/sys/uvm/uvm_pdaemon.c index 42b0aaa70b1..612d8b8d04d 100644 --- a/sys/uvm/uvm_pdaemon.c +++ b/sys/uvm/uvm_pdaemon.c @@ -1,5 +1,5 @@ -/* $OpenBSD: uvm_pdaemon.c,v 1.14 2001/11/05 22:14:54 art Exp $ */ -/* $NetBSD: uvm_pdaemon.c,v 1.20 2000/06/26 14:21:18 mrg Exp $ */ +/* $OpenBSD: uvm_pdaemon.c,v 1.15 2001/11/06 01:35:04 art Exp $ */ +/* $NetBSD: uvm_pdaemon.c,v 1.21 2000/06/27 17:29:33 mrg Exp $ */ /* * Copyright (c) 1997 Charles D. Cranor and Washington University. @@ -77,8 +77,6 @@ #include <sys/kernel.h> #include <sys/pool.h> -#include <vm/vm.h> - #include <uvm/uvm.h> /* diff --git a/sys/uvm/uvm_pglist.c b/sys/uvm/uvm_pglist.c index 1bafc44c2a1..94b81596eeb 100644 --- a/sys/uvm/uvm_pglist.c +++ b/sys/uvm/uvm_pglist.c @@ -1,5 +1,5 @@ -/* $OpenBSD: uvm_pglist.c,v 1.7 2001/08/11 10:57:22 art Exp $ */ -/* $NetBSD: uvm_pglist.c,v 1.10 2000/05/20 19:54:01 thorpej Exp $ */ +/* $OpenBSD: uvm_pglist.c,v 1.8 2001/11/06 01:35:04 art Exp $ */ +/* $NetBSD: uvm_pglist.c,v 1.11 2000/06/27 17:29:34 mrg Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -47,8 +47,6 @@ #include <sys/malloc.h> #include <sys/proc.h> -#include <vm/vm.h> - #include <uvm/uvm.h> #ifdef VM_PAGE_ALLOC_MEMORY_STATS diff --git a/sys/uvm/uvm_pmap.h b/sys/uvm/uvm_pmap.h new file mode 100644 index 00000000000..325ed9e19d3 --- /dev/null +++ b/sys/uvm/uvm_pmap.h @@ -0,0 +1,164 @@ +/* $NetBSD: uvm_pmap.h,v 1.1 2000/06/27 09:00:14 mrg Exp $ */ + +/* + * 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 Mach Operating System project at Carnegie-Mellon University. + * + * 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. + * + * 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. + * + * @(#)pmap.h 8.1 (Berkeley) 6/11/93 + * + * + * Copyright (c) 1987, 1990 Carnegie-Mellon University. + * All rights reserved. + * + * Author: Avadis Tevanian, Jr. + * + * 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. + */ + +/* + * Machine address mapping definitions -- machine-independent + * section. [For machine-dependent section, see "machine/pmap.h".] + */ + +#ifndef _PMAP_VM_ +#define _PMAP_VM_ + +struct proc; /* for pmap_activate()/pmap_deactivate() proto */ + +/* + * Each machine dependent implementation is expected to + * keep certain statistics. They may do this anyway they + * so choose, but are expected to return the statistics + * in the following structure. + */ +struct pmap_statistics { + long resident_count; /* # of pages mapped (total)*/ + long wired_count; /* # of pages wired */ +}; +typedef struct pmap_statistics *pmap_statistics_t; + +#include <machine/pmap.h> + +/* + * Flags passed to pmap_enter(). Note the bottom 3 bits are VM_PROT_* + * bits, used to indicate the access type that was made (to seed modified + * and referenced information). + */ +#define PMAP_WIRED 0x00000010 /* wired mapping */ +#define PMAP_CANFAIL 0x00000020 /* can fail if resource shortage */ + +#ifndef PMAP_EXCLUDE_DECLS /* Used in Sparc port to virtualize pmap mod */ +#ifdef _KERNEL +__BEGIN_DECLS +void *pmap_bootstrap_alloc __P((int)); +void pmap_activate __P((struct proc *)); +void pmap_deactivate __P((struct proc *)); +void pmap_unwire __P((pmap_t, vaddr_t)); + +#if !defined(pmap_clear_modify) +boolean_t pmap_clear_modify __P((struct vm_page *)); +#endif +#if !defined(pmap_clear_reference) +boolean_t pmap_clear_reference __P((struct vm_page *)); +#endif + +void pmap_collect __P((pmap_t)); +void pmap_copy __P((pmap_t, + pmap_t, vaddr_t, vsize_t, vaddr_t)); +void pmap_copy_page __P((paddr_t, paddr_t)); +struct pmap *pmap_create __P((void)); +void pmap_destroy __P((pmap_t)); +int pmap_enter __P((pmap_t, + vaddr_t, paddr_t, vm_prot_t, int)); +boolean_t pmap_extract __P((pmap_t, vaddr_t, paddr_t *)); +#if defined(PMAP_GROWKERNEL) +vaddr_t pmap_growkernel __P((vaddr_t)); +#endif + +void pmap_init __P((void)); + +void pmap_kenter_pa __P((vaddr_t, paddr_t, vm_prot_t)); +void pmap_kenter_pgs __P((vaddr_t, struct vm_page **, int)); +void pmap_kremove __P((vaddr_t, vsize_t)); +#if !defined(pmap_is_modified) +boolean_t pmap_is_modified __P((struct vm_page *)); +#endif +#if !defined(pmap_is_referenced) +boolean_t pmap_is_referenced __P((struct vm_page *)); +#endif + +void pmap_page_protect __P((struct vm_page *, vm_prot_t)); + +#if !defined(pmap_phys_address) +paddr_t pmap_phys_address __P((int)); +#endif +void pmap_protect __P((pmap_t, + vaddr_t, vaddr_t, vm_prot_t)); +void pmap_reference __P((pmap_t)); +void pmap_remove __P((pmap_t, vaddr_t, vaddr_t)); +void pmap_update __P((void)); +void pmap_zero_page __P((paddr_t)); + +#if defined(PMAP_STEAL_MEMORY) +vaddr_t pmap_steal_memory __P((vsize_t, vaddr_t *, vaddr_t *)); +#else +void pmap_virtual_space __P((vaddr_t *, vaddr_t *)); +#endif + +#if defined(PMAP_FORK) +void pmap_fork __P((pmap_t, pmap_t)); +#endif +__END_DECLS +#endif /* kernel*/ +#endif /* PMAP_EXCLUDE_DECLS */ + +#endif /* _PMAP_VM_ */ diff --git a/sys/uvm/uvm_stat.c b/sys/uvm/uvm_stat.c index 5cc7045457d..34a0921a818 100644 --- a/sys/uvm/uvm_stat.c +++ b/sys/uvm/uvm_stat.c @@ -1,5 +1,5 @@ -/* $OpenBSD: uvm_stat.c,v 1.6 2001/07/26 19:37:13 art Exp $ */ -/* $NetBSD: uvm_stat.c,v 1.13 2000/01/11 06:57:50 chs Exp $ */ +/* $OpenBSD: uvm_stat.c,v 1.7 2001/11/06 01:35:04 art Exp $ */ +/* $NetBSD: uvm_stat.c,v 1.14 2000/06/27 17:29:35 mrg Exp $ */ /* * @@ -42,8 +42,6 @@ #include <sys/param.h> #include <sys/systm.h> -#include <vm/vm.h> - #include <uvm/uvm.h> /* diff --git a/sys/uvm/uvm_swap.c b/sys/uvm/uvm_swap.c index 370573e78aa..ada8eee8464 100644 --- a/sys/uvm/uvm_swap.c +++ b/sys/uvm/uvm_swap.c @@ -1,5 +1,5 @@ -/* $OpenBSD: uvm_swap.c,v 1.36 2001/09/05 19:22:23 deraadt Exp $ */ -/* $NetBSD: uvm_swap.c,v 1.37 2000/05/19 03:45:04 thorpej Exp $ */ +/* $OpenBSD: uvm_swap.c,v 1.37 2001/11/06 01:35:04 art Exp $ */ +/* $NetBSD: uvm_swap.c,v 1.38 2000/06/27 17:29:35 mrg Exp $ */ /* * Copyright (c) 1995, 1996, 1997 Matthew R. Green @@ -50,7 +50,6 @@ #include <sys/syscallargs.h> #include <sys/swap.h> -#include <vm/vm.h> #include <uvm/uvm.h> #ifdef UVM_SWAP_ENCRYPT #include <sys/syslog.h> diff --git a/sys/uvm/uvm_unix.c b/sys/uvm/uvm_unix.c index b0645679815..69c8dc5210b 100644 --- a/sys/uvm/uvm_unix.c +++ b/sys/uvm/uvm_unix.c @@ -1,5 +1,5 @@ -/* $OpenBSD: uvm_unix.c,v 1.13 2001/08/11 10:57:22 art Exp $ */ -/* $NetBSD: uvm_unix.c,v 1.12 2000/03/30 12:31:50 augustss Exp $ */ +/* $OpenBSD: uvm_unix.c,v 1.14 2001/11/06 01:35:04 art Exp $ */ +/* $NetBSD: uvm_unix.c,v 1.13 2000/06/27 17:29:36 mrg Exp $ */ /* * Copyright (c) 1997 Charles D. Cranor and Washington University. @@ -60,10 +60,8 @@ #include <sys/mount.h> #include <sys/syscallargs.h> -#include <vm/vm.h> #include <uvm/uvm.h> - /* * sys_obreak: set break */ diff --git a/sys/uvm/uvm_user.c b/sys/uvm/uvm_user.c index dc3eda91ca4..cd2cacbe837 100644 --- a/sys/uvm/uvm_user.c +++ b/sys/uvm/uvm_user.c @@ -1,5 +1,5 @@ -/* $OpenBSD: uvm_user.c,v 1.5 2001/01/29 02:07:50 niklas Exp $ */ -/* $NetBSD: uvm_user.c,v 1.7 1999/03/25 18:48:56 mrg Exp $ */ +/* $OpenBSD: uvm_user.c,v 1.6 2001/11/06 01:35:04 art Exp $ */ +/* $NetBSD: uvm_user.c,v 1.8 2000/06/27 17:29:37 mrg Exp $ */ /* * @@ -44,7 +44,6 @@ #include <sys/systm.h> #include <sys/proc.h> -#include <vm/vm.h> #include <uvm/uvm.h> /* diff --git a/sys/uvm/uvm_vnode.c b/sys/uvm/uvm_vnode.c index 3bcf1d8ce6c..019e71e8a00 100644 --- a/sys/uvm/uvm_vnode.c +++ b/sys/uvm/uvm_vnode.c @@ -1,5 +1,5 @@ -/* $OpenBSD: uvm_vnode.c,v 1.21 2001/11/05 22:14:54 art Exp $ */ -/* $NetBSD: uvm_vnode.c,v 1.34 2000/06/26 14:21:19 mrg Exp $ */ +/* $OpenBSD: uvm_vnode.c,v 1.22 2001/11/06 01:35:04 art Exp $ */ +/* $NetBSD: uvm_vnode.c,v 1.35 2000/06/27 17:29:37 mrg Exp $ */ /* * Copyright (c) 1997 Charles D. Cranor and Washington University. @@ -62,8 +62,6 @@ #include <miscfs/specfs/specdev.h> -#include <vm/vm.h> - #include <uvm/uvm.h> #include <uvm/uvm_vnode.h> diff --git a/sys/vm/pmap.h b/sys/vm/pmap.h index 404830e76e0..88ecb8f3238 100644 --- a/sys/vm/pmap.h +++ b/sys/vm/pmap.h @@ -1,166 +1 @@ -/* $OpenBSD: pmap.h,v 1.22 2001/08/18 20:50:18 art Exp $ */ -/* $NetBSD: pmap.h,v 1.36 1999/11/13 00:24:39 thorpej Exp $ */ - -/* - * 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 Mach Operating System project at Carnegie-Mellon University. - * - * 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. - * - * 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. - * - * @(#)pmap.h 8.1 (Berkeley) 6/11/93 - * - * - * Copyright (c) 1987, 1990 Carnegie-Mellon University. - * All rights reserved. - * - * Author: Avadis Tevanian, Jr. - * - * 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. - */ - -/* - * Machine address mapping definitions -- machine-independent - * section. [For machine-dependent section, see "machine/pmap.h".] - */ - -#ifndef _PMAP_VM_ -#define _PMAP_VM_ - -/* - * Each machine dependent implementation is expected to - * keep certain statistics. They may do this anyway they - * so choose, but are expected to return the statistics - * in the following structure. - */ -struct pmap_statistics { - long resident_count; /* # of pages mapped (total)*/ - long wired_count; /* # of pages wired */ -}; -typedef struct pmap_statistics *pmap_statistics_t; - -#include <machine/pmap.h> - -/* - * Flags passed to pmap_enter(). Note the bottom 3 bits are VM_PROT_* - * bits, used to indicate the access type that was made (to seed modified - * and referenced information). - */ -#define PMAP_WIRED 0x00000010 /* wired mapping */ -#define PMAP_CANFAIL 0x00000020 /* can fail if resource shortage */ - -#ifndef PMAP_EXCLUDE_DECLS /* Used in Sparc port to virtualize pmap mod */ -#ifdef _KERNEL -__BEGIN_DECLS -void *pmap_bootstrap_alloc __P((int)); -#ifndef pmap_activate -void pmap_activate __P((struct proc *)); -#endif -#ifndef pmap_deactivate -void pmap_deactivate __P((struct proc *)); -#endif -void pmap_unwire __P((pmap_t, vaddr_t)); - -#if !defined(pmap_clear_modify) -boolean_t pmap_clear_modify __P((struct vm_page *)); -#endif -#if !defined(pmap_clear_reference) -boolean_t pmap_clear_reference __P((struct vm_page *)); -#endif - -void pmap_collect __P((pmap_t)); -void pmap_copy __P((pmap_t, pmap_t, vaddr_t, vsize_t, vaddr_t)); -void pmap_copy_page __P((paddr_t, paddr_t)); -struct pmap *pmap_create __P((void)); -void pmap_destroy __P((pmap_t)); -int pmap_enter __P((pmap_t, vaddr_t, paddr_t, vm_prot_t, int)); -boolean_t pmap_extract __P((pmap_t, vaddr_t, paddr_t *)); -#if defined(PMAP_GROWKERNEL) -vaddr_t pmap_growkernel __P((vaddr_t)); -#endif - -void pmap_init __P((void)); - -void pmap_kenter_pa __P((vaddr_t, paddr_t, vm_prot_t)); -void pmap_kenter_pgs __P((vaddr_t, struct vm_page **, int)); -void pmap_kremove __P((vaddr_t, vsize_t)); -#if !defined(pmap_is_modified) -boolean_t pmap_is_modified __P((struct vm_page *)); -#endif -#if !defined(pmap_is_referenced) -boolean_t pmap_is_referenced __P((struct vm_page *)); -#endif -void pmap_page_protect __P((struct vm_page *, vm_prot_t)); - -#if !defined(pmap_phys_address) -paddr_t pmap_phys_address __P((int)); -#endif -void pmap_pinit __P((pmap_t)); -void pmap_protect __P((pmap_t, - vaddr_t, vaddr_t, vm_prot_t)); -void pmap_reference __P((pmap_t)); -void pmap_release __P((pmap_t)); -void pmap_remove __P((pmap_t, vaddr_t, vaddr_t)); -void pmap_update __P((void)); -void pmap_zero_page __P((paddr_t)); - -#if defined(PMAP_STEAL_MEMORY) -vaddr_t pmap_steal_memory __P((vsize_t, vaddr_t *, vaddr_t *)); -#else -void pmap_virtual_space __P((vaddr_t *, vaddr_t *)); -#endif - -#if defined(PMAP_FORK) -void pmap_fork __P((pmap_t, pmap_t)); -#endif -__END_DECLS -#endif /* kernel*/ -#endif /* PMAP_EXCLUDE_DECLS */ - -#endif /* _PMAP_VM_ */ +#include <uvm/uvm_pmap.h> diff --git a/sys/vm/vm.h b/sys/vm/vm.h index 0d035292cb8..85b91503dbc 100644 --- a/sys/vm/vm.h +++ b/sys/vm/vm.h @@ -1,94 +1 @@ -/* $OpenBSD: vm.h,v 1.21 2001/11/06 00:30:38 art Exp $ */ -/* $NetBSD: vm.h,v 1.22 2000/03/26 20:54:48 kleink Exp $ */ - -/* - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * 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. - * - * 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.h 8.5 (Berkeley) 5/11/95 - */ - -#ifndef VM_H -#define VM_H - -typedef int vm_inherit_t; /* XXX: inheritance codes */ -typedef off_t voff_t; /* XXX: offset within a uvm_object */ - -union vm_map_object; -typedef union vm_map_object vm_map_object_t; - -struct vm_map_entry; -typedef struct vm_map_entry *vm_map_entry_t; - -struct vm_map; -typedef struct vm_map *vm_map_t; - -struct vm_page; -typedef struct vm_page *vm_page_t; - -#include <sys/types.h> -#include <sys/vmmeter.h> -#include <sys/queue.h> -#include <uvm/uvm_param.h> -#include <sys/lock.h> #include <uvm/uvm_extern.h> -#include <vm/vm_page.h> -#include <vm/pmap.h> -#include <uvm/uvm_map.h> - -/* - * Shareable process virtual address space. - * May eventually be merged with vm_map. - * Several fields are temporary (text, data stuff). - */ -struct vmspace { - struct vm_map vm_map; /* VM address map */ - int vm_refcnt; /* number of references */ - caddr_t vm_shm; /* SYS5 shared memory private data XXX */ -/* we copy from vm_startcopy to the end of the structure on fork */ -#define vm_startcopy vm_rssize - segsz_t vm_rssize; /* current resident set size in pages */ - segsz_t vm_swrss; /* resident set size before last swap */ - segsz_t vm_tsize; /* text size (pages) XXX */ - segsz_t vm_dsize; /* data size (pages) XXX */ - segsz_t vm_ssize; /* stack size (pages) */ - caddr_t vm_taddr; /* user virtual address of text XXX */ - caddr_t vm_daddr; /* user virtual address of data XXX */ - caddr_t vm_maxsaddr; /* user VA at max stack growth */ -}; - -#ifdef pmap_resident_count -#define vm_resident_count(vm) (pmap_resident_count((vm)->vm_map.pmap)) -#else -#define vm_resident_count(vm) ((vm)->vm_rssize) -#endif - -#endif /* VM_H */ diff --git a/sys/vm/vm_page.h b/sys/vm/vm_page.h index 1ee07adca87..6a481a6301d 100644 --- a/sys/vm/vm_page.h +++ b/sys/vm/vm_page.h @@ -1,334 +1 @@ -/* $OpenBSD: vm_page.h,v 1.18 2001/08/12 17:55:56 mickey Exp $ */ -/* $NetBSD: vm_page.h,v 1.35 2000/03/26 20:54:48 kleink Exp $ */ - -/* - * 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 Mach Operating System project at Carnegie-Mellon University. - * - * 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. - * - * 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.h 7.3 (Berkeley) 4/21/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 system definitions. - */ -#ifndef _VM_PAGE_ -#define _VM_PAGE_ - -/* - * Management of resident (logical) pages. - * - * A small structure is kept for each resident - * page, indexed by page number. Each structure - * is an element of several lists: - * - * A hash table bucket used to quickly - * perform object/offset lookups - * - * A list of all pages for a given object, - * so they can be quickly deactivated at - * time of deallocation. - * - * An ordered list of pages due for pageout. - * - * In addition, the structure contains the object - * and offset to which this page belongs (for pageout), - * and sundry status bits. - * - * Fields in this structure are locked either by the lock on the - * object that the page belongs to (O) or by the lock on the page - * queues (P) [or both]. - */ - -/* - * locking note: the mach version of this data structure had bit - * fields for the flags, and the bit fields were divided into two - * items (depending on who locked what). some time, in BSD, the bit - * fields were dumped and all the flags were lumped into one short. - * that is fine for a single threaded uniprocessor OS, but bad if you - * want to actual make use of locking (simple_lock's). so, we've - * separated things back out again. - * - * note the page structure has no lock of its own. - */ - -#include <uvm/uvm_extern.h> -#include <uvm/uvm_pglist.h> - -struct vm_page { - TAILQ_ENTRY(vm_page) pageq; /* queue info for FIFO - * queue or free list (P) */ - TAILQ_ENTRY(vm_page) hashq; /* hash table links (O)*/ - TAILQ_ENTRY(vm_page) listq; /* pages in same object (O)*/ - - struct vm_anon *uanon; /* anon (O,P) */ - struct uvm_object *uobject; /* object (O,P) */ - voff_t offset; /* offset into object (O,P) */ - - u_short flags; /* object flags [O] */ - u_short version; /* version count [O] */ - u_short wire_count; /* wired down map refs [P] */ - u_short pqflags; /* page queue flags [P] */ - u_int loan_count; /* number of active loans - * to read: [O or P] - * to modify: [O _and_ P] */ - - paddr_t phys_addr; /* physical address of page */ -#if defined(UVM_PAGE_TRKOWN) - /* debugging fields to track page ownership */ - pid_t owner; /* proc that set PG_BUSY */ - char *owner_tag; /* why it was set busy */ -#endif -}; - -/* - * These are the flags defined for vm_page. - * - * Note: PG_FILLED and PG_DIRTY are added for the filesystems. - */ - -/* - * locking rules: - * PG_ ==> locked by object lock - * PQ_ ==> lock by page queue lock - * PQ_FREE is locked by free queue lock and is mutex with all other PQs - * - * PG_ZERO is used to indicate that a page has been pre-zero'd. This flag - * is only set when the page is on no queues, and is cleared when the page - * is placed on the free list. - * - * possible deadwood: PG_FAULTING, PQ_LAUNDRY - */ -#define PG_CLEAN 0x0008 /* page has not been modified */ -#define PG_BUSY 0x0010 /* page is in transit */ -#define PG_WANTED 0x0020 /* someone is waiting for page */ -#define PG_TABLED 0x0040 /* page is in VP table */ -#define PG_ZERO 0x0100 /* page is pre-zero'd */ -#define PG_FAKE 0x0200 /* page is placeholder for pagein */ -#define PG_FILLED 0x0400 /* client flag to set when filled */ -#define PG_DIRTY 0x0800 /* client flag to set when dirty */ -#define PG_RELEASED 0x1000 /* page released while paging */ -#define PG_FAULTING 0x2000 /* page is being faulted in */ -#define PG_CLEANCHK 0x4000 /* clean bit has been checked */ - -#define PQ_FREE 0x0001 /* page is on free list */ -#define PQ_INACTIVE 0x0002 /* page is in inactive list */ -#define PQ_ACTIVE 0x0004 /* page is in active list */ -#define PQ_LAUNDRY 0x0008 /* page is being cleaned now */ -#define PQ_ANON 0x0010 /* page is part of an anon, rather - than an uvm_object */ -#define PQ_AOBJ 0x0020 /* page is part of an anonymous - uvm_object */ -#define PQ_SWAPBACKED (PQ_ANON|PQ_AOBJ) -#define PQ_ENCRYPT 0x0040 /* page needs {en,de}cryption */ - -/* - * physical memory layout structure - * - * MD vmparam.h must #define: - * VM_PHYSEG_MAX = max number of physical memory segments we support - * (if this is "1" then we revert to a "contig" case) - * VM_PHYSSEG_STRAT: memory sort/search options (for VM_PHYSEG_MAX > 1) - * - VM_PSTRAT_RANDOM: linear search (random order) - * - VM_PSTRAT_BSEARCH: binary search (sorted by address) - * - VM_PSTRAT_BIGFIRST: linear search (sorted by largest segment first) - * - others? - * XXXCDC: eventually we should remove contig and old non-contig cases - * and purge all left-over global variables... - */ -#define VM_PSTRAT_RANDOM 1 -#define VM_PSTRAT_BSEARCH 2 -#define VM_PSTRAT_BIGFIRST 3 - -/* - * vm_physmemseg: describes one segment of physical memory - */ -struct vm_physseg { - paddr_t start; /* PF# of first page in segment */ - paddr_t end; /* (PF# of last page in segment) + 1 */ - paddr_t avail_start; /* PF# of first free page in segment */ - paddr_t avail_end; /* (PF# of last free page in segment) +1 */ - int free_list; /* which free list they belong on */ - struct vm_page *pgs; /* vm_page structures (from start) */ - struct vm_page *lastpg; /* vm_page structure for end */ - struct pmap_physseg pmseg; /* pmap specific (MD) data */ -}; - -#if defined(_KERNEL) - -/* - * physical memory config is stored in vm_physmem. - */ - -extern struct vm_physseg vm_physmem[VM_PHYSSEG_MAX]; -extern int vm_nphysseg; - -/* - * prototypes - */ - -static struct vm_page *PHYS_TO_VM_PAGE __P((paddr_t)); -static int vm_physseg_find __P((paddr_t, int *)); - -/* - * macros and inlines - */ -#define VM_PAGE_TO_PHYS(entry) ((entry)->phys_addr) - -/* - * when VM_PHYSSEG_MAX is 1, we can simplify these functions - */ - -/* - * vm_physseg_find: find vm_physseg structure that belongs to a PA - */ -static __inline int -vm_physseg_find(pframe, offp) - paddr_t pframe; - int *offp; -{ -#if VM_PHYSSEG_MAX == 1 - - /* 'contig' case */ - if (pframe >= vm_physmem[0].start && pframe < vm_physmem[0].end) { - if (offp) - *offp = pframe - vm_physmem[0].start; - return(0); - } - return(-1); - -#elif (VM_PHYSSEG_STRAT == VM_PSTRAT_BSEARCH) - /* binary search for it */ - int start, len, try; - - /* - * if try is too large (thus target is less than than try) we reduce - * the length to trunc(len/2) [i.e. everything smaller than "try"] - * - * if the try is too small (thus target is greater than try) then - * we set the new start to be (try + 1). this means we need to - * reduce the length to (round(len/2) - 1). - * - * note "adjust" below which takes advantage of the fact that - * (round(len/2) - 1) == trunc((len - 1) / 2) - * for any value of len we may have - */ - - for (start = 0, len = vm_nphysseg ; len != 0 ; len = len / 2) { - try = start + (len / 2); /* try in the middle */ - - /* start past our try? */ - if (pframe >= vm_physmem[try].start) { - /* was try correct? */ - if (pframe < vm_physmem[try].end) { - if (offp) - *offp = pframe - vm_physmem[try].start; - return(try); /* got it */ - } - start = try + 1; /* next time, start here */ - len--; /* "adjust" */ - } else { - /* - * pframe before try, just reduce length of - * region, done in "for" loop - */ - } - } - return(-1); - -#else - /* linear search for it */ - int lcv; - - for (lcv = 0; lcv < vm_nphysseg; lcv++) { - if (pframe >= vm_physmem[lcv].start && - pframe < vm_physmem[lcv].end) { - if (offp) - *offp = pframe - vm_physmem[lcv].start; - return(lcv); /* got it */ - } - } - return(-1); - -#endif -} - - -/* - * PHYS_TO_VM_PAGE: find vm_page for a PA. used by MI code to get vm_pages - * back from an I/O mapping (ugh!). used in some MD code as well. - */ -static __inline struct vm_page * -PHYS_TO_VM_PAGE(pa) - paddr_t pa; -{ - paddr_t pf = atop(pa); - int off; - int psi; - - psi = vm_physseg_find(pf, &off); - if (psi != -1) - return(&vm_physmem[psi].pgs[off]); - return(NULL); -} - -#define VM_PAGE_IS_FREE(entry) ((entry)->pqflags & PQ_FREE) - -#endif /* _KERNEL */ -#endif /* !_VM_PAGE_ */ +#include <uvm/uvm_page.h> |