1*0a6a1f1dSLionel Sambuc /* $NetBSD: uvm_extern.h,v 1.194 2015/03/20 15:41:43 riastradh Exp $ */ 26c8f7fc3SBen Gras 36c8f7fc3SBen Gras /* 46c8f7fc3SBen Gras * Copyright (c) 1997 Charles D. Cranor and Washington University. 56c8f7fc3SBen Gras * All rights reserved. 66c8f7fc3SBen Gras * 76c8f7fc3SBen Gras * Redistribution and use in source and binary forms, with or without 86c8f7fc3SBen Gras * modification, are permitted provided that the following conditions 96c8f7fc3SBen Gras * are met: 106c8f7fc3SBen Gras * 1. Redistributions of source code must retain the above copyright 116c8f7fc3SBen Gras * notice, this list of conditions and the following disclaimer. 126c8f7fc3SBen Gras * 2. Redistributions in binary form must reproduce the above copyright 136c8f7fc3SBen Gras * notice, this list of conditions and the following disclaimer in the 146c8f7fc3SBen Gras * documentation and/or other materials provided with the distribution. 156c8f7fc3SBen Gras * 166c8f7fc3SBen Gras * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 176c8f7fc3SBen Gras * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 186c8f7fc3SBen Gras * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 196c8f7fc3SBen Gras * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 206c8f7fc3SBen Gras * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 216c8f7fc3SBen Gras * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 226c8f7fc3SBen Gras * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 236c8f7fc3SBen Gras * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 246c8f7fc3SBen Gras * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 256c8f7fc3SBen Gras * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 266c8f7fc3SBen Gras * 276c8f7fc3SBen Gras * from: Id: uvm_extern.h,v 1.1.2.21 1998/02/07 01:16:53 chs Exp 286c8f7fc3SBen Gras */ 296c8f7fc3SBen Gras 306c8f7fc3SBen Gras /*- 316c8f7fc3SBen Gras * Copyright (c) 1991, 1992, 1993 326c8f7fc3SBen Gras * The Regents of the University of California. All rights reserved. 336c8f7fc3SBen Gras * 346c8f7fc3SBen Gras * Redistribution and use in source and binary forms, with or without 356c8f7fc3SBen Gras * modification, are permitted provided that the following conditions 366c8f7fc3SBen Gras * are met: 376c8f7fc3SBen Gras * 1. Redistributions of source code must retain the above copyright 386c8f7fc3SBen Gras * notice, this list of conditions and the following disclaimer. 396c8f7fc3SBen Gras * 2. Redistributions in binary form must reproduce the above copyright 406c8f7fc3SBen Gras * notice, this list of conditions and the following disclaimer in the 416c8f7fc3SBen Gras * documentation and/or other materials provided with the distribution. 426c8f7fc3SBen Gras * 3. Neither the name of the University nor the names of its contributors 436c8f7fc3SBen Gras * may be used to endorse or promote products derived from this software 446c8f7fc3SBen Gras * without specific prior written permission. 456c8f7fc3SBen Gras * 466c8f7fc3SBen Gras * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 476c8f7fc3SBen Gras * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 486c8f7fc3SBen Gras * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 496c8f7fc3SBen Gras * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 506c8f7fc3SBen Gras * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 516c8f7fc3SBen Gras * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 526c8f7fc3SBen Gras * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 536c8f7fc3SBen Gras * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 546c8f7fc3SBen Gras * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 556c8f7fc3SBen Gras * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 566c8f7fc3SBen Gras * SUCH DAMAGE. 576c8f7fc3SBen Gras * 586c8f7fc3SBen Gras * @(#)vm_extern.h 8.5 (Berkeley) 5/3/95 596c8f7fc3SBen Gras */ 606c8f7fc3SBen Gras 616c8f7fc3SBen Gras #ifndef _UVM_UVM_EXTERN_H_ 626c8f7fc3SBen Gras #define _UVM_UVM_EXTERN_H_ 636c8f7fc3SBen Gras 646c8f7fc3SBen Gras /* 656c8f7fc3SBen Gras * uvm_extern.h: this file defines the external interface to the VM system. 666c8f7fc3SBen Gras * 676c8f7fc3SBen Gras * this should be the only file included by non-VM parts of the kernel 686c8f7fc3SBen Gras * which need access to VM services. if you want to know the interface 696c8f7fc3SBen Gras * to the MI VM layer without knowing the details, this is the file to 706c8f7fc3SBen Gras * learn. 716c8f7fc3SBen Gras * 726c8f7fc3SBen Gras * NOTE: vm system calls are prototyped in syscallargs.h 736c8f7fc3SBen Gras */ 746c8f7fc3SBen Gras 756c8f7fc3SBen Gras /* 766c8f7fc3SBen Gras * defines 776c8f7fc3SBen Gras */ 786c8f7fc3SBen Gras 796c8f7fc3SBen Gras /* 806c8f7fc3SBen Gras * the following defines are for uvm_map and functions which call it. 816c8f7fc3SBen Gras */ 826c8f7fc3SBen Gras 836c8f7fc3SBen Gras /* protections bits */ 846c8f7fc3SBen Gras #define UVM_PROT_MASK 0x07 /* protection mask */ 856c8f7fc3SBen Gras #define UVM_PROT_NONE 0x00 /* protection none */ 866c8f7fc3SBen Gras #define UVM_PROT_ALL 0x07 /* everything */ 876c8f7fc3SBen Gras #define UVM_PROT_READ 0x01 /* read */ 886c8f7fc3SBen Gras #define UVM_PROT_WRITE 0x02 /* write */ 896c8f7fc3SBen Gras #define UVM_PROT_EXEC 0x04 /* exec */ 906c8f7fc3SBen Gras 916c8f7fc3SBen Gras /* protection short codes */ 926c8f7fc3SBen Gras #define UVM_PROT_R 0x01 /* read */ 936c8f7fc3SBen Gras #define UVM_PROT_W 0x02 /* write */ 946c8f7fc3SBen Gras #define UVM_PROT_RW 0x03 /* read-write */ 956c8f7fc3SBen Gras #define UVM_PROT_X 0x04 /* exec */ 966c8f7fc3SBen Gras #define UVM_PROT_RX 0x05 /* read-exec */ 976c8f7fc3SBen Gras #define UVM_PROT_WX 0x06 /* write-exec */ 986c8f7fc3SBen Gras #define UVM_PROT_RWX 0x07 /* read-write-exec */ 996c8f7fc3SBen Gras 1006c8f7fc3SBen Gras /* 0x08: not used */ 1016c8f7fc3SBen Gras 1026c8f7fc3SBen Gras /* inherit codes */ 1036c8f7fc3SBen Gras #define UVM_INH_MASK 0x30 /* inherit mask */ 1046c8f7fc3SBen Gras #define UVM_INH_SHARE 0x00 /* "share" */ 1056c8f7fc3SBen Gras #define UVM_INH_COPY 0x10 /* "copy" */ 1066c8f7fc3SBen Gras #define UVM_INH_NONE 0x20 /* "none" */ 1076c8f7fc3SBen Gras #define UVM_INH_DONATE 0x30 /* "donate" << not used */ 1086c8f7fc3SBen Gras 1096c8f7fc3SBen Gras /* 0x40, 0x80: not used */ 1106c8f7fc3SBen Gras 1116c8f7fc3SBen Gras /* bits 0x700: max protection, 0x800: not used */ 1126c8f7fc3SBen Gras 1136c8f7fc3SBen Gras /* bits 0x7000: advice, 0x8000: not used */ 1146c8f7fc3SBen Gras /* advice: matches MADV_* from sys/mman.h and POSIX_FADV_* from sys/fcntl.h */ 1156c8f7fc3SBen Gras #define UVM_ADV_NORMAL 0x0 /* 'normal' */ 1166c8f7fc3SBen Gras #define UVM_ADV_RANDOM 0x1 /* 'random' */ 1176c8f7fc3SBen Gras #define UVM_ADV_SEQUENTIAL 0x2 /* 'sequential' */ 1186c8f7fc3SBen Gras #define UVM_ADV_WILLNEED 0x3 /* pages will be needed */ 1196c8f7fc3SBen Gras #define UVM_ADV_DONTNEED 0x4 /* pages won't be needed */ 1206c8f7fc3SBen Gras #define UVM_ADV_NOREUSE 0x5 /* pages will be used only once */ 1216c8f7fc3SBen Gras #define UVM_ADV_MASK 0x7 /* mask */ 1226c8f7fc3SBen Gras 1236c8f7fc3SBen Gras /* bits 0xffff0000: mapping flags */ 1246c8f7fc3SBen Gras #define UVM_FLAG_FIXED 0x010000 /* find space */ 1256c8f7fc3SBen Gras #define UVM_FLAG_OVERLAY 0x020000 /* establish overlay */ 1266c8f7fc3SBen Gras #define UVM_FLAG_NOMERGE 0x040000 /* don't merge map entries */ 1276c8f7fc3SBen Gras #define UVM_FLAG_COPYONW 0x080000 /* set copy_on_write flag */ 1286c8f7fc3SBen Gras #define UVM_FLAG_AMAPPAD 0x100000 /* for bss: pad amap to reduce allocations */ 1296c8f7fc3SBen Gras #define UVM_FLAG_TRYLOCK 0x200000 /* fail if we can not lock map */ 1306c8f7fc3SBen Gras #define UVM_FLAG_NOWAIT 0x400000 /* not allowed to sleep */ 1316c8f7fc3SBen Gras #define UVM_FLAG_WAITVA 0x800000 /* wait for va */ 1326c8f7fc3SBen Gras #define UVM_FLAG_VAONLY 0x2000000 /* unmap: no pages are mapped */ 1336c8f7fc3SBen Gras #define UVM_FLAG_COLORMATCH 0x4000000 /* match color given in off */ 1346c8f7fc3SBen Gras 1356c8f7fc3SBen Gras /* macros to extract info */ 1366c8f7fc3SBen Gras #define UVM_PROTECTION(X) ((X) & UVM_PROT_MASK) 1376c8f7fc3SBen Gras #define UVM_INHERIT(X) (((X) & UVM_INH_MASK) >> 4) 1386c8f7fc3SBen Gras #define UVM_MAXPROTECTION(X) (((X) >> 8) & UVM_PROT_MASK) 1396c8f7fc3SBen Gras #define UVM_ADVICE(X) (((X) >> 12) & UVM_ADV_MASK) 1406c8f7fc3SBen Gras 1416c8f7fc3SBen Gras #define UVM_MAPFLAG(PROT,MAXPROT,INH,ADVICE,FLAGS) \ 1426c8f7fc3SBen Gras (((MAXPROT) << 8)|(PROT)|(INH)|((ADVICE) << 12)|(FLAGS)) 1436c8f7fc3SBen Gras 1446c8f7fc3SBen Gras /* magic offset value: offset not known(obj) or don't care(!obj) */ 1456c8f7fc3SBen Gras #define UVM_UNKNOWN_OFFSET ((voff_t) -1) 1466c8f7fc3SBen Gras 1476c8f7fc3SBen Gras /* 1486c8f7fc3SBen Gras * the following defines are for uvm_km_alloc/free's flags 1496c8f7fc3SBen Gras */ 1506c8f7fc3SBen Gras #define UVM_KMF_WIRED 0x1 /* allocation type: wired */ 1516c8f7fc3SBen Gras #define UVM_KMF_PAGEABLE 0x2 /* allocation type: pageable */ 1526c8f7fc3SBen Gras #define UVM_KMF_VAONLY 0x4 /* allocation type: VA only */ 1536c8f7fc3SBen Gras #define UVM_KMF_TYPEMASK (UVM_KMF_VAONLY | UVM_KMF_PAGEABLE | UVM_KMF_WIRED) 1546c8f7fc3SBen Gras #define UVM_KMF_CANFAIL 0x8 /* caller handles failure */ 1556c8f7fc3SBen Gras #define UVM_KMF_ZERO 0x10 /* want zero filled memory */ 1566c8f7fc3SBen Gras #define UVM_KMF_EXEC 0x20 /* need executable mapping */ 1576c8f7fc3SBen Gras #define UVM_KMF_TRYLOCK UVM_FLAG_TRYLOCK /* try locking only */ 1586c8f7fc3SBen Gras #define UVM_KMF_NOWAIT UVM_FLAG_NOWAIT /* not allowed to sleep */ 1596c8f7fc3SBen Gras #define UVM_KMF_WAITVA UVM_FLAG_WAITVA /* sleep for va */ 1606c8f7fc3SBen Gras #define UVM_KMF_COLORMATCH UVM_FLAG_COLORMATCH /* start at color in align */ 1616c8f7fc3SBen Gras 1626c8f7fc3SBen Gras /* 1636c8f7fc3SBen Gras * the following defines the strategies for uvm_pagealloc_strat() 1646c8f7fc3SBen Gras */ 1656c8f7fc3SBen Gras #define UVM_PGA_STRAT_NORMAL 0 /* priority (low id to high) walk */ 1666c8f7fc3SBen Gras #define UVM_PGA_STRAT_ONLY 1 /* only specified free list */ 1676c8f7fc3SBen Gras #define UVM_PGA_STRAT_FALLBACK 2 /* ONLY falls back on NORMAL */ 1686c8f7fc3SBen Gras 1696c8f7fc3SBen Gras /* 1706c8f7fc3SBen Gras * flags for uvm_pagealloc_strat() 1716c8f7fc3SBen Gras */ 1726c8f7fc3SBen Gras #define UVM_PGA_USERESERVE 0x0001 /* ok to use reserve pages */ 1736c8f7fc3SBen Gras #define UVM_PGA_ZERO 0x0002 /* returned page must be zero'd */ 1746c8f7fc3SBen Gras 1756c8f7fc3SBen Gras /* 1766c8f7fc3SBen Gras * flags for ubc_alloc() 1776c8f7fc3SBen Gras */ 178*0a6a1f1dSLionel Sambuc #define UBC_READ 0x001 /* reading from object */ 179*0a6a1f1dSLionel Sambuc #define UBC_WRITE 0x002 /* writing to object */ 180*0a6a1f1dSLionel Sambuc #define UBC_FAULTBUSY 0x004 /* nobody else is using these pages, so busy 181*0a6a1f1dSLionel Sambuc * them at alloc and unbusy at release (e.g., 182*0a6a1f1dSLionel Sambuc * for writes extending a file) */ 1836c8f7fc3SBen Gras 1846c8f7fc3SBen Gras /* 1856c8f7fc3SBen Gras * flags for ubc_release() 1866c8f7fc3SBen Gras */ 187*0a6a1f1dSLionel Sambuc #define UBC_UNMAP 0x010 /* unmap pages now -- don't leave the 188*0a6a1f1dSLionel Sambuc * mappings cached indefinitely */ 1896c8f7fc3SBen Gras 1906c8f7fc3SBen Gras /* 191*0a6a1f1dSLionel Sambuc * flags for ubc_uiomove() 1926c8f7fc3SBen Gras */ 193*0a6a1f1dSLionel Sambuc #define UBC_PARTIALOK 0x100 /* return early on error; otherwise, zero all 194*0a6a1f1dSLionel Sambuc * remaining bytes after error */ 1956c8f7fc3SBen Gras 1966c8f7fc3SBen Gras /* 1976c8f7fc3SBen Gras * flags for uvn_findpages(). 1986c8f7fc3SBen Gras */ 1996c8f7fc3SBen Gras #define UFP_ALL 0x00 2006c8f7fc3SBen Gras #define UFP_NOWAIT 0x01 2016c8f7fc3SBen Gras #define UFP_NOALLOC 0x02 2026c8f7fc3SBen Gras #define UFP_NOCACHE 0x04 2036c8f7fc3SBen Gras #define UFP_NORDONLY 0x08 2046c8f7fc3SBen Gras #define UFP_DIRTYONLY 0x10 2056c8f7fc3SBen Gras #define UFP_BACKWARD 0x20 2066c8f7fc3SBen Gras 2076c8f7fc3SBen Gras /* 2086c8f7fc3SBen Gras * lockflags that control the locking behavior of various functions. 2096c8f7fc3SBen Gras */ 2106c8f7fc3SBen Gras #define UVM_LK_ENTER 0x00000001 /* map locked on entry */ 2116c8f7fc3SBen Gras #define UVM_LK_EXIT 0x00000002 /* leave map locked on exit */ 2126c8f7fc3SBen Gras 2136c8f7fc3SBen Gras /* 2146c8f7fc3SBen Gras * Default number of pages to allocate on the stack 2156c8f7fc3SBen Gras */ 2166c8f7fc3SBen Gras #define UBC_MAX_PAGES 8 2176c8f7fc3SBen Gras 2186c8f7fc3SBen Gras /* 2196c8f7fc3SBen Gras * Value representing inactive emap. 2206c8f7fc3SBen Gras */ 2216c8f7fc3SBen Gras #define UVM_EMAP_INACTIVE (0) 2226c8f7fc3SBen Gras 2236c8f7fc3SBen Gras /* 2246c8f7fc3SBen Gras * structures 2256c8f7fc3SBen Gras */ 2266c8f7fc3SBen Gras 2276c8f7fc3SBen Gras struct buf; 2286c8f7fc3SBen Gras struct core; 2296c8f7fc3SBen Gras struct loadavg; 2306c8f7fc3SBen Gras struct mount; 2316c8f7fc3SBen Gras struct pglist; 2326c8f7fc3SBen Gras struct proc; 2336c8f7fc3SBen Gras struct uio; 2346c8f7fc3SBen Gras struct uvm_object; 2356c8f7fc3SBen Gras struct vm_anon; 2366c8f7fc3SBen Gras struct vmspace; 2376c8f7fc3SBen Gras struct pmap; 2386c8f7fc3SBen Gras struct vnode; 2396c8f7fc3SBen Gras struct vm_map_entry; 2406c8f7fc3SBen Gras struct vm_map; 2416c8f7fc3SBen Gras struct vm_page; 2426c8f7fc3SBen Gras struct vmtotal; 2436c8f7fc3SBen Gras 2446c8f7fc3SBen Gras /* 2456c8f7fc3SBen Gras * uvm_pctparam: parameter to be shown as percentage to user. 2466c8f7fc3SBen Gras */ 2476c8f7fc3SBen Gras 2486c8f7fc3SBen Gras #define UVM_PCTPARAM_SHIFT 8 2496c8f7fc3SBen Gras #define UVM_PCTPARAM_SCALE (1 << UVM_PCTPARAM_SHIFT) 2506c8f7fc3SBen Gras #define UVM_PCTPARAM_APPLY(pct, x) \ 2516c8f7fc3SBen Gras (((x) * (pct)->pct_scaled) >> UVM_PCTPARAM_SHIFT) 2526c8f7fc3SBen Gras struct uvm_pctparam { 2536c8f7fc3SBen Gras int pct_pct; /* percent [0, 100] */ /* should be the first member */ 2546c8f7fc3SBen Gras int pct_scaled; 2556c8f7fc3SBen Gras int (*pct_check)(struct uvm_pctparam *, int); 2566c8f7fc3SBen Gras }; 2576c8f7fc3SBen Gras 2586c8f7fc3SBen Gras /* 2596c8f7fc3SBen Gras * uvmexp: global data structures that are exported to parts of the kernel 2606c8f7fc3SBen Gras * other than the vm system. 2616c8f7fc3SBen Gras */ 2626c8f7fc3SBen Gras 2636c8f7fc3SBen Gras struct uvmexp { 2646c8f7fc3SBen Gras /* vm_page constants */ 2656c8f7fc3SBen Gras int pagesize; /* size of a page (PAGE_SIZE): must be power of 2 */ 2666c8f7fc3SBen Gras int pagemask; /* page mask */ 2676c8f7fc3SBen Gras int pageshift; /* page shift */ 2686c8f7fc3SBen Gras 2696c8f7fc3SBen Gras /* vm_page counters */ 2706c8f7fc3SBen Gras int npages; /* number of pages we manage */ 2716c8f7fc3SBen Gras int free; /* number of free pages */ 2726c8f7fc3SBen Gras int paging; /* number of pages in the process of being paged out */ 2736c8f7fc3SBen Gras int wired; /* number of wired pages */ 2746c8f7fc3SBen Gras 2756c8f7fc3SBen Gras /* 2766c8f7fc3SBen Gras * Adding anything before this line will break binary compatibility 2776c8f7fc3SBen Gras * with top(1) on NetBSD 1.5. 2786c8f7fc3SBen Gras */ 2796c8f7fc3SBen Gras 2806c8f7fc3SBen Gras int ncolors; /* number of page color buckets: must be p-o-2 */ 2816c8f7fc3SBen Gras int colormask; /* color bucket mask */ 2826c8f7fc3SBen Gras 2836c8f7fc3SBen Gras int zeropages; /* number of zero'd pages */ 2846c8f7fc3SBen Gras int reserve_pagedaemon; /* number of pages reserved for pagedaemon */ 2856c8f7fc3SBen Gras int reserve_kernel; /* number of pages reserved for kernel */ 2866c8f7fc3SBen Gras unsigned anonpages; /* number of pages used by anon mappings */ 2876c8f7fc3SBen Gras unsigned filepages; /* number of pages used by cached file data */ 2886c8f7fc3SBen Gras unsigned execpages; /* number of pages used by cached exec data */ 2896c8f7fc3SBen Gras 2906c8f7fc3SBen Gras /* pageout params */ 2916c8f7fc3SBen Gras int freemin; /* min number of free pages */ 2926c8f7fc3SBen Gras int freetarg; /* target number of free pages */ 2936c8f7fc3SBen Gras int wiredmax; /* max number of wired pages */ 2946c8f7fc3SBen Gras 2956c8f7fc3SBen Gras /* swap */ 2966c8f7fc3SBen Gras int nswapdev; /* number of configured swap devices in system */ 2976c8f7fc3SBen Gras int swpages; /* number of PAGE_SIZE'ed swap pages */ 2986c8f7fc3SBen Gras int swpgavail; /* number of swap pages currently available */ 2996c8f7fc3SBen Gras int swpginuse; /* number of swap pages in use */ 3006c8f7fc3SBen Gras int swpgonly; /* number of swap pages in use, not also in RAM */ 3016c8f7fc3SBen Gras int nswget; /* number of times fault calls uvm_swap_get() */ 3026c8f7fc3SBen Gras 3036c8f7fc3SBen Gras /* stat counters. XXX: should be 64-bit counters */ 3046c8f7fc3SBen Gras int _unused_faults; /* page fault count */ 3056c8f7fc3SBen Gras int _unused_traps; /* trap count */ 3066c8f7fc3SBen Gras int _unused_intrs; /* interrupt count */ 3076c8f7fc3SBen Gras int _unused_swtch; /* context switch count */ 3086c8f7fc3SBen Gras int _unused_softs; /* software interrupt count */ 3096c8f7fc3SBen Gras int _unused_syscalls; /* system calls */ 3106c8f7fc3SBen Gras int pageins; /* pagein operation count */ 3116c8f7fc3SBen Gras /* pageouts are in pdpageouts below */ 3126c8f7fc3SBen Gras int _unused1; 3136c8f7fc3SBen Gras int _unused2; 3146c8f7fc3SBen Gras int pgswapin; /* pages swapped in */ 3156c8f7fc3SBen Gras int pgswapout; /* pages swapped out */ 3166c8f7fc3SBen Gras int forks; /* forks */ 3176c8f7fc3SBen Gras int forks_ppwait; /* forks where parent waits */ 3186c8f7fc3SBen Gras int forks_sharevm; /* forks where vmspace is shared */ 3196c8f7fc3SBen Gras int pga_zerohit; /* pagealloc where zero wanted and zero 3206c8f7fc3SBen Gras was available */ 3216c8f7fc3SBen Gras int pga_zeromiss; /* pagealloc where zero wanted and zero 3226c8f7fc3SBen Gras not available */ 3236c8f7fc3SBen Gras int zeroaborts; /* number of times page zeroing was 3246c8f7fc3SBen Gras aborted */ 3256c8f7fc3SBen Gras int colorhit; /* pagealloc where we got optimal color */ 3266c8f7fc3SBen Gras int colormiss; /* pagealloc where we didn't */ 3276c8f7fc3SBen Gras int cpuhit; /* pagealloc where we allocated locally */ 3286c8f7fc3SBen Gras int cpumiss; /* pagealloc where we didn't */ 3296c8f7fc3SBen Gras 3306c8f7fc3SBen Gras /* fault subcounters. XXX: should be 64-bit counters */ 3316c8f7fc3SBen Gras int fltnoram; /* number of times fault was out of ram */ 3326c8f7fc3SBen Gras int fltnoanon; /* number of times fault was out of anons */ 3336c8f7fc3SBen Gras int fltpgwait; /* number of times fault had to wait on a page */ 3346c8f7fc3SBen Gras int fltpgrele; /* number of times fault found a released page */ 3356c8f7fc3SBen Gras int fltrelck; /* number of times fault relock called */ 3366c8f7fc3SBen Gras int fltrelckok; /* number of times fault relock is a success */ 3376c8f7fc3SBen Gras int fltanget; /* number of times fault gets anon page */ 3386c8f7fc3SBen Gras int fltanretry; /* number of times fault retrys an anon get */ 3396c8f7fc3SBen Gras int fltamcopy; /* number of times fault clears "needs copy" */ 3406c8f7fc3SBen Gras int fltnamap; /* number of times fault maps a neighbor anon page */ 3416c8f7fc3SBen Gras int fltnomap; /* number of times fault maps a neighbor obj page */ 3426c8f7fc3SBen Gras int fltlget; /* number of times fault does a locked pgo_get */ 3436c8f7fc3SBen Gras int fltget; /* number of times fault does an unlocked get */ 3446c8f7fc3SBen Gras int flt_anon; /* number of times fault anon (case 1a) */ 3456c8f7fc3SBen Gras int flt_acow; /* number of times fault anon cow (case 1b) */ 3466c8f7fc3SBen Gras int flt_obj; /* number of times fault is on object page (2a) */ 3476c8f7fc3SBen Gras int flt_prcopy; /* number of times fault promotes with copy (2b) */ 3486c8f7fc3SBen Gras int flt_przero; /* number of times fault promotes with zerofill (2b) */ 3496c8f7fc3SBen Gras 3506c8f7fc3SBen Gras /* daemon counters. XXX: should be 64-bit counters */ 3516c8f7fc3SBen Gras int pdwoke; /* number of times daemon woke up */ 3526c8f7fc3SBen Gras int pdrevs; /* number of times daemon rev'd clock hand */ 3536c8f7fc3SBen Gras int _unused3; 3546c8f7fc3SBen Gras int pdfreed; /* number of pages daemon freed since boot */ 3556c8f7fc3SBen Gras int pdscans; /* number of pages daemon scanned since boot */ 3566c8f7fc3SBen Gras int pdanscan; /* number of anonymous pages scanned by daemon */ 3576c8f7fc3SBen Gras int pdobscan; /* number of object pages scanned by daemon */ 3586c8f7fc3SBen Gras int pdreact; /* number of pages daemon reactivated since boot */ 3596c8f7fc3SBen Gras int pdbusy; /* number of times daemon found a busy page */ 3606c8f7fc3SBen Gras int pdpageouts; /* number of times daemon started a pageout */ 3616c8f7fc3SBen Gras int pdpending; /* number of times daemon got a pending pagout */ 3626c8f7fc3SBen Gras int pddeact; /* number of pages daemon deactivates */ 3636c8f7fc3SBen Gras int pdreanon; /* anon pages reactivated due to thresholds */ 3646c8f7fc3SBen Gras int pdrefile; /* file pages reactivated due to thresholds */ 3656c8f7fc3SBen Gras int pdreexec; /* executable pages reactivated due to thresholds */ 3666c8f7fc3SBen Gras }; 3676c8f7fc3SBen Gras 3686c8f7fc3SBen Gras /* 3696c8f7fc3SBen Gras * The following structure is 64-bit alignment safe. New elements 3706c8f7fc3SBen Gras * should only be added to the end of this structure so binary 3716c8f7fc3SBen Gras * compatibility can be preserved. 3726c8f7fc3SBen Gras */ 3736c8f7fc3SBen Gras struct uvmexp_sysctl { 3746c8f7fc3SBen Gras int64_t pagesize; 3756c8f7fc3SBen Gras int64_t pagemask; 3766c8f7fc3SBen Gras int64_t pageshift; 3776c8f7fc3SBen Gras int64_t npages; 3786c8f7fc3SBen Gras int64_t free; 3796c8f7fc3SBen Gras int64_t active; 3806c8f7fc3SBen Gras int64_t inactive; 3816c8f7fc3SBen Gras int64_t paging; 3826c8f7fc3SBen Gras int64_t wired; 3836c8f7fc3SBen Gras int64_t zeropages; 3846c8f7fc3SBen Gras int64_t reserve_pagedaemon; 3856c8f7fc3SBen Gras int64_t reserve_kernel; 3866c8f7fc3SBen Gras int64_t freemin; 3876c8f7fc3SBen Gras int64_t freetarg; 3886c8f7fc3SBen Gras int64_t inactarg; /* unused */ 3896c8f7fc3SBen Gras int64_t wiredmax; 3906c8f7fc3SBen Gras int64_t nswapdev; 3916c8f7fc3SBen Gras int64_t swpages; 3926c8f7fc3SBen Gras int64_t swpginuse; 3936c8f7fc3SBen Gras int64_t swpgonly; 3946c8f7fc3SBen Gras int64_t nswget; 3956c8f7fc3SBen Gras int64_t unused1; /* unused; was nanon */ 3966c8f7fc3SBen Gras int64_t cpuhit; 3976c8f7fc3SBen Gras int64_t cpumiss; 3986c8f7fc3SBen Gras int64_t faults; 3996c8f7fc3SBen Gras int64_t traps; 4006c8f7fc3SBen Gras int64_t intrs; 4016c8f7fc3SBen Gras int64_t swtch; 4026c8f7fc3SBen Gras int64_t softs; 4036c8f7fc3SBen Gras int64_t syscalls; 4046c8f7fc3SBen Gras int64_t pageins; 4056c8f7fc3SBen Gras int64_t swapins; /* unused */ 4066c8f7fc3SBen Gras int64_t swapouts; /* unused */ 4076c8f7fc3SBen Gras int64_t pgswapin; 4086c8f7fc3SBen Gras int64_t pgswapout; 4096c8f7fc3SBen Gras int64_t forks; 4106c8f7fc3SBen Gras int64_t forks_ppwait; 4116c8f7fc3SBen Gras int64_t forks_sharevm; 4126c8f7fc3SBen Gras int64_t pga_zerohit; 4136c8f7fc3SBen Gras int64_t pga_zeromiss; 4146c8f7fc3SBen Gras int64_t zeroaborts; 4156c8f7fc3SBen Gras int64_t fltnoram; 4166c8f7fc3SBen Gras int64_t fltnoanon; 4176c8f7fc3SBen Gras int64_t fltpgwait; 4186c8f7fc3SBen Gras int64_t fltpgrele; 4196c8f7fc3SBen Gras int64_t fltrelck; 4206c8f7fc3SBen Gras int64_t fltrelckok; 4216c8f7fc3SBen Gras int64_t fltanget; 4226c8f7fc3SBen Gras int64_t fltanretry; 4236c8f7fc3SBen Gras int64_t fltamcopy; 4246c8f7fc3SBen Gras int64_t fltnamap; 4256c8f7fc3SBen Gras int64_t fltnomap; 4266c8f7fc3SBen Gras int64_t fltlget; 4276c8f7fc3SBen Gras int64_t fltget; 4286c8f7fc3SBen Gras int64_t flt_anon; 4296c8f7fc3SBen Gras int64_t flt_acow; 4306c8f7fc3SBen Gras int64_t flt_obj; 4316c8f7fc3SBen Gras int64_t flt_prcopy; 4326c8f7fc3SBen Gras int64_t flt_przero; 4336c8f7fc3SBen Gras int64_t pdwoke; 4346c8f7fc3SBen Gras int64_t pdrevs; 4356c8f7fc3SBen Gras int64_t unused4; 4366c8f7fc3SBen Gras int64_t pdfreed; 4376c8f7fc3SBen Gras int64_t pdscans; 4386c8f7fc3SBen Gras int64_t pdanscan; 4396c8f7fc3SBen Gras int64_t pdobscan; 4406c8f7fc3SBen Gras int64_t pdreact; 4416c8f7fc3SBen Gras int64_t pdbusy; 4426c8f7fc3SBen Gras int64_t pdpageouts; 4436c8f7fc3SBen Gras int64_t pdpending; 4446c8f7fc3SBen Gras int64_t pddeact; 4456c8f7fc3SBen Gras int64_t anonpages; 4466c8f7fc3SBen Gras int64_t filepages; 4476c8f7fc3SBen Gras int64_t execpages; 4486c8f7fc3SBen Gras int64_t colorhit; 4496c8f7fc3SBen Gras int64_t colormiss; 4506c8f7fc3SBen Gras int64_t ncolors; 4516c8f7fc3SBen Gras }; 4526c8f7fc3SBen Gras 4536c8f7fc3SBen Gras #ifdef _KERNEL 4546c8f7fc3SBen Gras /* we need this before including uvm_page.h on some platforms */ 4556c8f7fc3SBen Gras extern struct uvmexp uvmexp; 4566c8f7fc3SBen Gras /* MD code needs this without including <uvm/uvm.h> */ 4576c8f7fc3SBen Gras extern bool vm_page_zero_enable; 4586c8f7fc3SBen Gras #endif 4596c8f7fc3SBen Gras 4606c8f7fc3SBen Gras /* 4616c8f7fc3SBen Gras * Finally, bring in standard UVM headers. 4626c8f7fc3SBen Gras */ 4636c8f7fc3SBen Gras #include <sys/vmmeter.h> 4646c8f7fc3SBen Gras #include <sys/queue.h> 4656c8f7fc3SBen Gras #include <sys/lock.h> 4666c8f7fc3SBen Gras #ifdef _KERNEL 4676c8f7fc3SBen Gras #include <sys/vmem.h> 4686c8f7fc3SBen Gras #endif 4696c8f7fc3SBen Gras #include <uvm/uvm_param.h> 4706c8f7fc3SBen Gras #include <uvm/uvm_prot.h> 4716c8f7fc3SBen Gras #include <uvm/uvm_pmap.h> 4726c8f7fc3SBen Gras #include <uvm/uvm_map.h> 4736c8f7fc3SBen Gras #include <uvm/uvm_pager.h> 4746c8f7fc3SBen Gras 4756c8f7fc3SBen Gras /* 4766c8f7fc3SBen Gras * helpers for calling ubc_release() 4776c8f7fc3SBen Gras */ 4786c8f7fc3SBen Gras #ifdef PMAP_CACHE_VIVT 4796c8f7fc3SBen Gras #define UBC_WANT_UNMAP(vp) (((vp)->v_iflag & VI_TEXT) != 0) 4806c8f7fc3SBen Gras #else 4816c8f7fc3SBen Gras #define UBC_WANT_UNMAP(vp) false 4826c8f7fc3SBen Gras #endif 4836c8f7fc3SBen Gras #define UBC_UNMAP_FLAG(vp) (UBC_WANT_UNMAP(vp) ? UBC_UNMAP : 0) 4846c8f7fc3SBen Gras 4856c8f7fc3SBen Gras /* 4866c8f7fc3SBen Gras * Shareable process virtual address space. 4876c8f7fc3SBen Gras * May eventually be merged with vm_map. 4886c8f7fc3SBen Gras * Several fields are temporary (text, data stuff). 4896c8f7fc3SBen Gras */ 4906c8f7fc3SBen Gras struct vmspace { 4916c8f7fc3SBen Gras struct vm_map vm_map; /* VM address map */ 4926c8f7fc3SBen Gras int vm_refcnt; /* number of references * 4936c8f7fc3SBen Gras * note: protected by vm_map.ref_lock */ 4946c8f7fc3SBen Gras void * vm_shm; /* SYS5 shared memory private data XXX */ 4956c8f7fc3SBen Gras /* we copy from vm_startcopy to the end of the structure on fork */ 4966c8f7fc3SBen Gras #define vm_startcopy vm_rssize 4976c8f7fc3SBen Gras segsz_t vm_rssize; /* current resident set size in pages */ 4986c8f7fc3SBen Gras segsz_t vm_swrss; /* resident set size before last swap */ 4996c8f7fc3SBen Gras segsz_t vm_tsize; /* text size (pages) XXX */ 5006c8f7fc3SBen Gras segsz_t vm_dsize; /* data size (pages) XXX */ 5016c8f7fc3SBen Gras segsz_t vm_ssize; /* stack size (pages) */ 5026c8f7fc3SBen Gras segsz_t vm_issize; /* initial unmapped stack size (pages) */ 5036c8f7fc3SBen Gras void * vm_taddr; /* user virtual address of text XXX */ 5046c8f7fc3SBen Gras void * vm_daddr; /* user virtual address of data XXX */ 5056c8f7fc3SBen Gras void *vm_maxsaddr; /* user VA at max stack growth */ 5066c8f7fc3SBen Gras void *vm_minsaddr; /* user VA at top of stack */ 5076c8f7fc3SBen Gras size_t vm_aslr_delta_mmap; /* mmap() random delta for ASLR */ 5086c8f7fc3SBen Gras }; 5096c8f7fc3SBen Gras #define VMSPACE_IS_KERNEL_P(vm) VM_MAP_IS_KERNEL(&(vm)->vm_map) 5106c8f7fc3SBen Gras 5116c8f7fc3SBen Gras #ifdef _KERNEL 5126c8f7fc3SBen Gras 5136c8f7fc3SBen Gras /* 5146c8f7fc3SBen Gras * used to keep state while iterating over the map for a core dump. 5156c8f7fc3SBen Gras */ 5166c8f7fc3SBen Gras struct uvm_coredump_state { 5176c8f7fc3SBen Gras void *cookie; /* opaque for the caller */ 5186c8f7fc3SBen Gras vaddr_t start; /* start of region */ 5196c8f7fc3SBen Gras vaddr_t realend; /* real end of region */ 5206c8f7fc3SBen Gras vaddr_t end; /* virtual end of region */ 5216c8f7fc3SBen Gras vm_prot_t prot; /* protection of region */ 5226c8f7fc3SBen Gras int flags; /* flags; see below */ 5236c8f7fc3SBen Gras }; 5246c8f7fc3SBen Gras 5256c8f7fc3SBen Gras #define UVM_COREDUMP_STACK 0x01 /* region is user stack */ 5266c8f7fc3SBen Gras 5276c8f7fc3SBen Gras /* 5286c8f7fc3SBen Gras * the various kernel maps, owned by MD code 5296c8f7fc3SBen Gras */ 5306c8f7fc3SBen Gras extern struct vm_map *kernel_map; 5316c8f7fc3SBen Gras extern struct vm_map *phys_map; 5326c8f7fc3SBen Gras 5336c8f7fc3SBen Gras /* 5346c8f7fc3SBen Gras * macros 5356c8f7fc3SBen Gras */ 5366c8f7fc3SBen Gras 5376c8f7fc3SBen Gras #define vm_resident_count(vm) (pmap_resident_count((vm)->vm_map.pmap)) 5386c8f7fc3SBen Gras 5396c8f7fc3SBen Gras 5406c8f7fc3SBen Gras /* vm_machdep.c */ 5416c8f7fc3SBen Gras int vmapbuf(struct buf *, vsize_t); 5426c8f7fc3SBen Gras void vunmapbuf(struct buf *, vsize_t); 5436c8f7fc3SBen Gras 5446c8f7fc3SBen Gras /* uvm_aobj.c */ 5456c8f7fc3SBen Gras struct uvm_object *uao_create(vsize_t, int); 546*0a6a1f1dSLionel Sambuc void uao_set_pgfl(struct uvm_object *, int); 5476c8f7fc3SBen Gras void uao_detach(struct uvm_object *); 5486c8f7fc3SBen Gras void uao_reference(struct uvm_object *); 5496c8f7fc3SBen Gras 5506c8f7fc3SBen Gras /* uvm_bio.c */ 5516c8f7fc3SBen Gras void ubc_init(void); 552*0a6a1f1dSLionel Sambuc void ubchist_init(void); 5536c8f7fc3SBen Gras void * ubc_alloc(struct uvm_object *, voff_t, vsize_t *, int, 5546c8f7fc3SBen Gras int); 5556c8f7fc3SBen Gras void ubc_release(void *, int); 5566c8f7fc3SBen Gras int ubc_uiomove(struct uvm_object *, struct uio *, vsize_t, 5576c8f7fc3SBen Gras int, int); 5586c8f7fc3SBen Gras void ubc_zerorange(struct uvm_object *, off_t, size_t, int); 5596c8f7fc3SBen Gras void ubc_purge(struct uvm_object *); 5606c8f7fc3SBen Gras 5616c8f7fc3SBen Gras /* uvm_emap.c */ 5626c8f7fc3SBen Gras void uvm_emap_sysinit(void); 5636c8f7fc3SBen Gras #ifdef __HAVE_PMAP_EMAP 5646c8f7fc3SBen Gras void uvm_emap_switch(lwp_t *); 5656c8f7fc3SBen Gras #else 5666c8f7fc3SBen Gras #define uvm_emap_switch(l) 5676c8f7fc3SBen Gras #endif 5686c8f7fc3SBen Gras 5696c8f7fc3SBen Gras u_int uvm_emap_gen_return(void); 5706c8f7fc3SBen Gras void uvm_emap_update(u_int); 5716c8f7fc3SBen Gras 5726c8f7fc3SBen Gras vaddr_t uvm_emap_alloc(vsize_t, bool); 5736c8f7fc3SBen Gras void uvm_emap_free(vaddr_t, size_t); 5746c8f7fc3SBen Gras 5756c8f7fc3SBen Gras void uvm_emap_enter(vaddr_t, struct vm_page **, u_int); 5766c8f7fc3SBen Gras void uvm_emap_remove(vaddr_t, vsize_t); 5776c8f7fc3SBen Gras 5786c8f7fc3SBen Gras #ifdef __HAVE_PMAP_EMAP 5796c8f7fc3SBen Gras void uvm_emap_consume(u_int); 5806c8f7fc3SBen Gras u_int uvm_emap_produce(void); 5816c8f7fc3SBen Gras #else 5826c8f7fc3SBen Gras #define uvm_emap_consume(x) 5836c8f7fc3SBen Gras #define uvm_emap_produce() UVM_EMAP_INACTIVE 5846c8f7fc3SBen Gras #endif 5856c8f7fc3SBen Gras 5866c8f7fc3SBen Gras /* uvm_fault.c */ 5876c8f7fc3SBen Gras #define uvm_fault(m, a, p) uvm_fault_internal(m, a, p, 0) 5886c8f7fc3SBen Gras int uvm_fault_internal(struct vm_map *, vaddr_t, vm_prot_t, int); 5896c8f7fc3SBen Gras /* handle a page fault */ 5906c8f7fc3SBen Gras 5916c8f7fc3SBen Gras /* uvm_glue.c */ 5926c8f7fc3SBen Gras #if defined(KGDB) 5936c8f7fc3SBen Gras void uvm_chgkprot(void *, size_t, int); 5946c8f7fc3SBen Gras #endif 5956c8f7fc3SBen Gras void uvm_proc_fork(struct proc *, struct proc *, bool); 5966c8f7fc3SBen Gras void uvm_lwp_fork(struct lwp *, struct lwp *, 5976c8f7fc3SBen Gras void *, size_t, void (*)(void *), void *); 5986c8f7fc3SBen Gras int uvm_coredump_walkmap(struct proc *, 599*0a6a1f1dSLionel Sambuc int (*)(struct uvm_coredump_state *), void *); 600*0a6a1f1dSLionel Sambuc int uvm_coredump_count_segs(struct proc *); 6016c8f7fc3SBen Gras void uvm_proc_exit(struct proc *); 6026c8f7fc3SBen Gras void uvm_lwp_exit(struct lwp *); 6036c8f7fc3SBen Gras void uvm_init_limits(struct proc *); 6046c8f7fc3SBen Gras bool uvm_kernacc(void *, size_t, vm_prot_t); 6056c8f7fc3SBen Gras __dead void uvm_scheduler(void); 6066c8f7fc3SBen Gras vaddr_t uvm_uarea_alloc(void); 6076c8f7fc3SBen Gras void uvm_uarea_free(vaddr_t); 6086c8f7fc3SBen Gras vaddr_t uvm_uarea_system_alloc(struct cpu_info *); 6096c8f7fc3SBen Gras void uvm_uarea_system_free(vaddr_t); 6106c8f7fc3SBen Gras vaddr_t uvm_lwp_getuarea(lwp_t *); 6116c8f7fc3SBen Gras void uvm_lwp_setuarea(lwp_t *, vaddr_t); 6126c8f7fc3SBen Gras int uvm_vslock(struct vmspace *, void *, size_t, vm_prot_t); 6136c8f7fc3SBen Gras void uvm_vsunlock(struct vmspace *, void *, size_t); 6146c8f7fc3SBen Gras void uvm_cpu_attach(struct cpu_info *); 6156c8f7fc3SBen Gras 6166c8f7fc3SBen Gras 6176c8f7fc3SBen Gras /* uvm_init.c */ 6186c8f7fc3SBen Gras void uvm_init(void); 6196c8f7fc3SBen Gras 6206c8f7fc3SBen Gras /* uvm_io.c */ 6216c8f7fc3SBen Gras int uvm_io(struct vm_map *, struct uio *); 6226c8f7fc3SBen Gras 6236c8f7fc3SBen Gras /* uvm_km.c */ 6246c8f7fc3SBen Gras vaddr_t uvm_km_alloc(struct vm_map *, vsize_t, vsize_t, 6256c8f7fc3SBen Gras uvm_flag_t); 6266c8f7fc3SBen Gras void uvm_km_free(struct vm_map *, vaddr_t, vsize_t, 6276c8f7fc3SBen Gras uvm_flag_t); 6286c8f7fc3SBen Gras 6296c8f7fc3SBen Gras struct vm_map *uvm_km_suballoc(struct vm_map *, vaddr_t *, 6306c8f7fc3SBen Gras vaddr_t *, vsize_t, int, bool, 6316c8f7fc3SBen Gras struct vm_map *); 6326c8f7fc3SBen Gras #ifdef _KERNEL 6336c8f7fc3SBen Gras int uvm_km_kmem_alloc(vmem_t *, vmem_size_t, vm_flag_t, 6346c8f7fc3SBen Gras vmem_addr_t *); 6356c8f7fc3SBen Gras void uvm_km_kmem_free(vmem_t *, vmem_addr_t, vmem_size_t); 6366c8f7fc3SBen Gras bool uvm_km_va_starved_p(void); 6376c8f7fc3SBen Gras #endif 6386c8f7fc3SBen Gras 6396c8f7fc3SBen Gras /* uvm_map.c */ 6406c8f7fc3SBen Gras int uvm_map(struct vm_map *, vaddr_t *, vsize_t, 6416c8f7fc3SBen Gras struct uvm_object *, voff_t, vsize_t, 6426c8f7fc3SBen Gras uvm_flag_t); 6436c8f7fc3SBen Gras int uvm_map_pageable(struct vm_map *, vaddr_t, 6446c8f7fc3SBen Gras vaddr_t, bool, int); 6456c8f7fc3SBen Gras int uvm_map_pageable_all(struct vm_map *, int, vsize_t); 6466c8f7fc3SBen Gras bool uvm_map_checkprot(struct vm_map *, vaddr_t, 6476c8f7fc3SBen Gras vaddr_t, vm_prot_t); 6486c8f7fc3SBen Gras int uvm_map_protect(struct vm_map *, vaddr_t, 6496c8f7fc3SBen Gras vaddr_t, vm_prot_t, bool); 65084d9c625SLionel Sambuc struct vmspace *uvmspace_alloc(vaddr_t, vaddr_t, bool); 6516c8f7fc3SBen Gras void uvmspace_init(struct vmspace *, struct pmap *, 65284d9c625SLionel Sambuc vaddr_t, vaddr_t, bool); 65384d9c625SLionel Sambuc void uvmspace_exec(struct lwp *, vaddr_t, vaddr_t, bool); 65484d9c625SLionel Sambuc void uvmspace_spawn(struct lwp *, vaddr_t, vaddr_t, bool); 6556c8f7fc3SBen Gras struct vmspace *uvmspace_fork(struct vmspace *); 6566c8f7fc3SBen Gras void uvmspace_addref(struct vmspace *); 6576c8f7fc3SBen Gras void uvmspace_free(struct vmspace *); 6586c8f7fc3SBen Gras void uvmspace_share(struct proc *, struct proc *); 6596c8f7fc3SBen Gras void uvmspace_unshare(struct lwp *); 6606c8f7fc3SBen Gras 6616c8f7fc3SBen Gras void uvm_whatis(uintptr_t, void (*)(const char *, ...)); 6626c8f7fc3SBen Gras 6636c8f7fc3SBen Gras /* uvm_meter.c */ 6646c8f7fc3SBen Gras int uvm_sysctl(int *, u_int, void *, size_t *, 6656c8f7fc3SBen Gras void *, size_t, struct proc *); 6666c8f7fc3SBen Gras int uvm_pctparam_check(struct uvm_pctparam *, int); 6676c8f7fc3SBen Gras void uvm_pctparam_set(struct uvm_pctparam *, int); 6686c8f7fc3SBen Gras int uvm_pctparam_get(struct uvm_pctparam *); 6696c8f7fc3SBen Gras void uvm_pctparam_init(struct uvm_pctparam *, int, 6706c8f7fc3SBen Gras int (*)(struct uvm_pctparam *, int)); 6716c8f7fc3SBen Gras int uvm_pctparam_createsysctlnode(struct uvm_pctparam *, 6726c8f7fc3SBen Gras const char *, const char *); 6736c8f7fc3SBen Gras 6746c8f7fc3SBen Gras /* uvm_mmap.c */ 675*0a6a1f1dSLionel Sambuc int uvm_mmap_dev(struct proc *, void **, size_t, dev_t, 676*0a6a1f1dSLionel Sambuc off_t); 677*0a6a1f1dSLionel Sambuc int uvm_mmap_anon(struct proc *, void **, size_t); 6786c8f7fc3SBen Gras vaddr_t uvm_default_mapaddr(struct proc *, vaddr_t, vsize_t); 6796c8f7fc3SBen Gras 6806c8f7fc3SBen Gras /* uvm_mremap.c */ 6816c8f7fc3SBen Gras int uvm_mremap(struct vm_map *, vaddr_t, vsize_t, 6826c8f7fc3SBen Gras struct vm_map *, vaddr_t *, vsize_t, 6836c8f7fc3SBen Gras struct proc *, int); 6846c8f7fc3SBen Gras 6856c8f7fc3SBen Gras /* uvm_object.c */ 6866c8f7fc3SBen Gras void uvm_obj_init(struct uvm_object *, 6876c8f7fc3SBen Gras const struct uvm_pagerops *, bool, u_int); 6886c8f7fc3SBen Gras void uvm_obj_setlock(struct uvm_object *, kmutex_t *); 6896c8f7fc3SBen Gras void uvm_obj_destroy(struct uvm_object *, bool); 6906c8f7fc3SBen Gras int uvm_obj_wirepages(struct uvm_object *, off_t, off_t, 6916c8f7fc3SBen Gras struct pglist *); 6926c8f7fc3SBen Gras void uvm_obj_unwirepages(struct uvm_object *, off_t, off_t); 6936c8f7fc3SBen Gras 6946c8f7fc3SBen Gras /* uvm_page.c */ 6956c8f7fc3SBen Gras struct vm_page *uvm_pagealloc_strat(struct uvm_object *, 6966c8f7fc3SBen Gras voff_t, struct vm_anon *, int, int, int); 6976c8f7fc3SBen Gras #define uvm_pagealloc(obj, off, anon, flags) \ 6986c8f7fc3SBen Gras uvm_pagealloc_strat((obj), (off), (anon), (flags), \ 6996c8f7fc3SBen Gras UVM_PGA_STRAT_NORMAL, 0) 7006c8f7fc3SBen Gras void uvm_pagereplace(struct vm_page *, 7016c8f7fc3SBen Gras struct vm_page *); 7026c8f7fc3SBen Gras void uvm_pagerealloc(struct vm_page *, 7036c8f7fc3SBen Gras struct uvm_object *, voff_t); 7046c8f7fc3SBen Gras /* Actually, uvm_page_physload takes PF#s which need their own type */ 7056c8f7fc3SBen Gras void uvm_page_physload(paddr_t, paddr_t, paddr_t, 7066c8f7fc3SBen Gras paddr_t, int); 7076c8f7fc3SBen Gras void uvm_setpagesize(void); 7086c8f7fc3SBen Gras 7096c8f7fc3SBen Gras /* uvm_pager.c */ 7106c8f7fc3SBen Gras void uvm_aio_biodone(struct buf *); 7116c8f7fc3SBen Gras void uvm_aio_aiodone(struct buf *); 7126c8f7fc3SBen Gras void uvm_aio_aiodone_pages(struct vm_page **, int, bool, 7136c8f7fc3SBen Gras int); 7146c8f7fc3SBen Gras 7156c8f7fc3SBen Gras /* uvm_pdaemon.c */ 7166c8f7fc3SBen Gras void uvm_pageout(void *); 7176c8f7fc3SBen Gras struct work; 7186c8f7fc3SBen Gras void uvm_aiodone_worker(struct work *, void *); 7196c8f7fc3SBen Gras void uvm_pageout_start(int); 7206c8f7fc3SBen Gras void uvm_pageout_done(int); 7216c8f7fc3SBen Gras void uvm_estimatepageable(int *, int *); 7226c8f7fc3SBen Gras 7236c8f7fc3SBen Gras /* uvm_pglist.c */ 7246c8f7fc3SBen Gras int uvm_pglistalloc(psize_t, paddr_t, paddr_t, 7256c8f7fc3SBen Gras paddr_t, paddr_t, struct pglist *, int, int); 7266c8f7fc3SBen Gras void uvm_pglistfree(struct pglist *); 7276c8f7fc3SBen Gras 7286c8f7fc3SBen Gras /* uvm_swap.c */ 7296c8f7fc3SBen Gras void uvm_swap_init(void); 7306c8f7fc3SBen Gras 7316c8f7fc3SBen Gras /* uvm_unix.c */ 7326c8f7fc3SBen Gras int uvm_grow(struct proc *, vaddr_t); 7336c8f7fc3SBen Gras 7346c8f7fc3SBen Gras /* uvm_user.c */ 7356c8f7fc3SBen Gras void uvm_deallocate(struct vm_map *, vaddr_t, vsize_t); 7366c8f7fc3SBen Gras 7376c8f7fc3SBen Gras /* uvm_vnode.c */ 7386c8f7fc3SBen Gras void uvm_vnp_setsize(struct vnode *, voff_t); 7396c8f7fc3SBen Gras void uvm_vnp_setwritesize(struct vnode *, voff_t); 7406c8f7fc3SBen Gras int uvn_findpages(struct uvm_object *, voff_t, 7416c8f7fc3SBen Gras int *, struct vm_page **, int); 7426c8f7fc3SBen Gras bool uvn_text_p(struct uvm_object *); 7436c8f7fc3SBen Gras bool uvn_clean_p(struct uvm_object *); 7446c8f7fc3SBen Gras bool uvn_needs_writefault_p(struct uvm_object *); 7456c8f7fc3SBen Gras 7466c8f7fc3SBen Gras /* kern_malloc.c */ 7476c8f7fc3SBen Gras void kmeminit_nkmempages(void); 7486c8f7fc3SBen Gras extern int nkmempages; 7496c8f7fc3SBen Gras 7506c8f7fc3SBen Gras #endif /* _KERNEL */ 7516c8f7fc3SBen Gras 7526c8f7fc3SBen Gras #endif /* _UVM_UVM_EXTERN_H_ */ 753