Annotation of src/sys/uvm/uvm_extern.h, Revision 1.42
1.42 ! thorpej 1: /* $NetBSD: uvm_extern.h,v 1.41 2000/05/28 05:49:06 thorpej Exp $ */
1.1 mrg 2:
3: /*
4: *
5: * Copyright (c) 1997 Charles D. Cranor and Washington University.
6: * All rights reserved.
7: *
8: * Redistribution and use in source and binary forms, with or without
9: * modification, are permitted provided that the following conditions
10: * are met:
11: * 1. Redistributions of source code must retain the above copyright
12: * notice, this list of conditions and the following disclaimer.
13: * 2. Redistributions in binary form must reproduce the above copyright
14: * notice, this list of conditions and the following disclaimer in the
15: * documentation and/or other materials provided with the distribution.
16: * 3. All advertising materials mentioning features or use of this software
17: * must display the following acknowledgement:
18: * This product includes software developed by Charles D. Cranor and
19: * Washington University.
20: * 4. The name of the author may not be used to endorse or promote products
21: * derived from this software without specific prior written permission.
22: *
23: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
24: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
27: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1.4 mrg 33: *
34: * from: Id: uvm_extern.h,v 1.1.2.21 1998/02/07 01:16:53 chs Exp
1.1 mrg 35: */
36:
1.8 perry 37: #ifndef _UVM_UVM_EXTERN_H_
38: #define _UVM_UVM_EXTERN_H_
1.1 mrg 39:
40: /*
41: * uvm_extern.h: this file defines the external interface to the VM system.
42: *
43: * this should be the only file included by non-VM parts of the kernel
44: * which need access to VM services. if you want to know the interface
45: * to the MI VM layer without knowing the details, this is the file to
46: * learn.
47: *
48: * NOTE: vm system calls are prototyped in syscallargs.h
49: */
50:
51: /*
52: * defines
53: */
54:
55: /*
56: * the following defines are for uvm_map and functions which call it.
57: */
58:
59: /* protections bits */
60: #define UVM_PROT_MASK 0x07 /* protection mask */
61: #define UVM_PROT_NONE 0x00 /* protection none */
62: #define UVM_PROT_ALL 0x07 /* everything */
63: #define UVM_PROT_READ 0x01 /* read */
64: #define UVM_PROT_WRITE 0x02 /* write */
65: #define UVM_PROT_EXEC 0x04 /* exec */
66:
67: /* protection short codes */
68: #define UVM_PROT_R 0x01 /* read */
69: #define UVM_PROT_W 0x02 /* write */
70: #define UVM_PROT_RW 0x03 /* read-write */
71: #define UVM_PROT_X 0x04 /* exec */
72: #define UVM_PROT_RX 0x05 /* read-exec */
73: #define UVM_PROT_WX 0x06 /* write-exec */
74: #define UVM_PROT_RWX 0x07 /* read-write-exec */
75:
76: /* 0x08: not used */
77:
78: /* inherit codes */
79: #define UVM_INH_MASK 0x30 /* inherit mask */
80: #define UVM_INH_SHARE 0x00 /* "share" */
81: #define UVM_INH_COPY 0x10 /* "copy" */
82: #define UVM_INH_NONE 0x20 /* "none" */
83: #define UVM_INH_DONATE 0x30 /* "donate" << not used */
84:
85: /* 0x40, 0x80: not used */
86:
87: /* bits 0x700: max protection, 0x800: not used */
88:
89: /* bits 0x7000: advice, 0x8000: not used */
90: /* advice: matches MADV_* from sys/mman.h */
91: #define UVM_ADV_NORMAL 0x0 /* 'normal' */
92: #define UVM_ADV_RANDOM 0x1 /* 'random' */
93: #define UVM_ADV_SEQUENTIAL 0x2 /* 'sequential' */
94: /* 0x3: will need, 0x4: dontneed */
95: #define UVM_ADV_MASK 0x7 /* mask */
96:
97: /* mapping flags */
98: #define UVM_FLAG_FIXED 0x010000 /* find space */
99: #define UVM_FLAG_OVERLAY 0x020000 /* establish overlay */
100: #define UVM_FLAG_NOMERGE 0x040000 /* don't merge map entries */
101: #define UVM_FLAG_COPYONW 0x080000 /* set copy_on_write flag */
102: #define UVM_FLAG_AMAPPAD 0x100000 /* for bss: pad amap to reduce malloc() */
103: #define UVM_FLAG_TRYLOCK 0x200000 /* fail if we can not lock map */
104:
105: /* macros to extract info */
106: #define UVM_PROTECTION(X) ((X) & UVM_PROT_MASK)
107: #define UVM_INHERIT(X) (((X) & UVM_INH_MASK) >> 4)
108: #define UVM_MAXPROTECTION(X) (((X) >> 8) & UVM_PROT_MASK)
109: #define UVM_ADVICE(X) (((X) >> 12) & UVM_ADV_MASK)
110:
111: #define UVM_MAPFLAG(PROT,MAXPROT,INH,ADVICE,FLAGS) \
112: ((MAXPROT << 8)|(PROT)|(INH)|((ADVICE) << 12)|(FLAGS))
113:
114: /* magic offset value */
1.38 kleink 115: #define UVM_UNKNOWN_OFFSET ((voff_t) -1)
1.1 mrg 116: /* offset not known(obj) or don't care(!obj) */
117:
118: /*
119: * the following defines are for uvm_km_kmemalloc's flags
120: */
121: #define UVM_KMF_NOWAIT 0x1 /* matches M_NOWAIT */
122: #define UVM_KMF_VALLOC 0x2 /* allocate VA only */
123: #define UVM_KMF_TRYLOCK UVM_FLAG_TRYLOCK /* try locking only */
124:
125: /*
1.15 thorpej 126: * the following defines the strategies for uvm_pagealloc_strat()
127: */
128: #define UVM_PGA_STRAT_NORMAL 0 /* high -> low free list walk */
129: #define UVM_PGA_STRAT_ONLY 1 /* only specified free list */
130: #define UVM_PGA_STRAT_FALLBACK 2 /* ONLY falls back on NORMAL */
131:
132: /*
1.24 chs 133: * flags for uvm_pagealloc_strat()
134: */
1.39 thorpej 135: #define UVM_PGA_USERESERVE 0x0001 /* ok to use reserve pages */
136: #define UVM_PGA_ZERO 0x0002 /* returned page must be zero'd */
1.24 chs 137:
138: /*
1.33 thorpej 139: * lockflags that control the locking behavior of various functions.
140: */
141: #define UVM_LK_ENTER 0x00000001 /* map locked on entry */
142: #define UVM_LK_EXIT 0x00000002 /* leave map locked on exit */
143:
144: /*
1.1 mrg 145: * structures
146: */
147:
148: struct core;
149: struct mount;
150: struct pglist;
151: struct proc;
152: struct ucred;
153: struct uio;
154: struct uvm_object;
155: struct vm_anon;
156: struct vmspace;
1.10 thorpej 157: struct pmap;
1.1 mrg 158: struct vnode;
1.34 thorpej 159: struct simplelock;
1.1 mrg 160:
161: /*
162: * uvmexp: global data structures that are exported to parts of the kernel
163: * other than the vm system.
164: */
165:
166: struct uvmexp {
1.9 mrg 167: /* vm_page constants */
1.1 mrg 168: int pagesize; /* size of a page (PAGE_SIZE): must be power of 2 */
169: int pagemask; /* page mask */
170: int pageshift; /* page shift */
171:
1.9 mrg 172: /* vm_page counters */
1.1 mrg 173: int npages; /* number of pages we manage */
174: int free; /* number of free pages */
175: int active; /* number of active pages */
176: int inactive; /* number of pages that we free'd but may want back */
1.3 chs 177: int paging; /* number of pages in the process of being paged out */
1.1 mrg 178: int wired; /* number of wired pages */
1.40 thorpej 179: int zeropages; /* number of zero'd pages */
1.3 chs 180: int reserve_pagedaemon; /* number of pages reserved for pagedaemon */
181: int reserve_kernel; /* number of pages reserved for kernel */
1.1 mrg 182:
1.9 mrg 183: /* pageout params */
184: int freemin; /* min number of free pages */
185: int freetarg; /* target number of free pages */
186: int inactarg; /* target number of inactive pages */
187: int wiredmax; /* max number of wired pages */
1.1 mrg 188:
1.9 mrg 189: /* swap */
1.1 mrg 190: int nswapdev; /* number of configured swap devices in system */
191: int swpages; /* number of PAGE_SIZE'ed swap pages */
1.32 thorpej 192: int swpguniq; /* number of swap pages in use, not also in RAM */
1.3 chs 193: int swpginuse; /* number of swap pages in use */
1.23 chs 194: int swpgonly; /* number of swap pages in use, not also in RAM */
1.1 mrg 195: int nswget; /* number of times fault calls uvm_swap_get() */
196: int nanon; /* number total of anon's in system */
1.32 thorpej 197: int nanonneeded;/* number of anons currently needed */
1.1 mrg 198: int nfreeanon; /* number of free anon's */
199:
1.9 mrg 200: /* stat counters */
1.7 mrg 201: int faults; /* page fault count */
202: int traps; /* trap count */
203: int intrs; /* interrupt count */
204: int swtch; /* context switch count */
205: int softs; /* software interrupt count */
206: int syscalls; /* system calls */
207: int pageins; /* pagein operation count */
208: /* pageouts are in pdpageouts below */
209: int swapins; /* swapins */
210: int swapouts; /* swapouts */
211: int pgswapin; /* pages swapped in */
212: int pgswapout; /* pages swapped out */
213: int forks; /* forks */
1.1 mrg 214: int forks_ppwait; /* forks where parent waits */
215: int forks_sharevm; /* forks where vmspace is shared */
1.40 thorpej 216: int pga_zerohit; /* pagealloc where zero wanted and zero
217: was available */
218: int pga_zeromiss; /* pagealloc where zero wanted and zero
219: not available */
1.1 mrg 220:
1.9 mrg 221: /* fault subcounters */
1.1 mrg 222: int fltnoram; /* number of times fault was out of ram */
223: int fltnoanon; /* number of times fault was out of anons */
224: int fltpgwait; /* number of times fault had to wait on a page */
225: int fltpgrele; /* number of times fault found a released page */
226: int fltrelck; /* number of times fault relock called */
227: int fltrelckok; /* number of times fault relock is a success */
228: int fltanget; /* number of times fault gets anon page */
229: int fltanretry; /* number of times fault retrys an anon get */
230: int fltamcopy; /* number of times fault clears "needs copy" */
231: int fltnamap; /* number of times fault maps a neighbor anon page */
232: int fltnomap; /* number of times fault maps a neighbor obj page */
233: int fltlget; /* number of times fault does a locked pgo_get */
234: int fltget; /* number of times fault does an unlocked get */
235: int flt_anon; /* number of times fault anon (case 1a) */
236: int flt_acow; /* number of times fault anon cow (case 1b) */
237: int flt_obj; /* number of times fault is on object page (2a) */
238: int flt_prcopy; /* number of times fault promotes with copy (2b) */
239: int flt_przero; /* number of times fault promotes with zerofill (2b) */
240:
1.9 mrg 241: /* daemon counters */
1.1 mrg 242: int pdwoke; /* number of times daemon woke up */
243: int pdrevs; /* number of times daemon rev'd clock hand */
244: int pdswout; /* number of times daemon called for swapout */
245: int pdfreed; /* number of pages daemon freed since boot */
246: int pdscans; /* number of pages daemon scaned since boot */
247: int pdanscan; /* number of anonymous pages scanned by daemon */
248: int pdobscan; /* number of object pages scanned by daemon */
249: int pdreact; /* number of pages daemon reactivated since boot */
250: int pdbusy; /* number of times daemon found a busy page */
251: int pdpageouts; /* number of times daemon started a pageout */
252: int pdpending; /* number of times daemon got a pending pagout */
253: int pddeact; /* number of pages daemon deactivates */
254:
1.9 mrg 255: /* kernel memory objects: managed by uvm_km_kmemalloc() only! */
1.1 mrg 256: struct uvm_object *kmem_object;
257: struct uvm_object *mb_object;
258: };
259:
1.31 thorpej 260: #ifdef _KERNEL
1.1 mrg 261:
262: extern struct uvmexp uvmexp;
263:
264: /*
265: * macros
266: */
267:
268: /* zalloc zeros memory, alloc does not */
269: #define uvm_km_zalloc(MAP,SIZE) uvm_km_alloc1(MAP,SIZE,TRUE)
270: #define uvm_km_alloc(MAP,SIZE) uvm_km_alloc1(MAP,SIZE,FALSE)
271:
1.31 thorpej 272: #endif /* _KERNEL */
273:
1.1 mrg 274: /*
275: * typedefs
276: */
277:
278: typedef unsigned int uvm_flag_t;
279: typedef int vm_fault_t;
280:
1.31 thorpej 281: #ifdef _KERNEL
282:
1.1 mrg 283: /* uvm_aobj.c */
1.19 eeh 284: struct uvm_object *uao_create __P((vsize_t, int));
1.1 mrg 285: void uao_detach __P((struct uvm_object *));
1.36 chs 286: void uao_detach_locked __P((struct uvm_object *));
1.1 mrg 287: void uao_reference __P((struct uvm_object *));
1.36 chs 288: void uao_reference_locked __P((struct uvm_object *));
1.1 mrg 289:
290: /* uvm_fault.c */
1.19 eeh 291: int uvm_fault __P((vm_map_t, vaddr_t,
1.9 mrg 292: vm_fault_t, vm_prot_t));
1.1 mrg 293: /* handle a page fault */
294:
295: /* uvm_glue.c */
296: #if defined(KGDB)
1.13 kleink 297: void uvm_chgkprot __P((caddr_t, size_t, int));
1.1 mrg 298: #endif
1.25 thorpej 299: void uvm_fork __P((struct proc *, struct proc *, boolean_t,
1.41 thorpej 300: void *, size_t, void (*)(void *), void *));
1.21 thorpej 301: void uvm_exit __P((struct proc *));
1.1 mrg 302: void uvm_init_limits __P((struct proc *));
1.13 kleink 303: boolean_t uvm_kernacc __P((caddr_t, size_t, int));
1.11 mycroft 304: __dead void uvm_scheduler __P((void)) __attribute__((noreturn));
1.1 mrg 305: void uvm_swapin __P((struct proc *));
1.13 kleink 306: boolean_t uvm_useracc __P((caddr_t, size_t, int));
1.29 thorpej 307: int uvm_vslock __P((struct proc *, caddr_t, size_t,
1.26 thorpej 308: vm_prot_t));
1.13 kleink 309: void uvm_vsunlock __P((struct proc *, caddr_t, size_t));
1.1 mrg 310:
311:
312: /* uvm_init.c */
313: void uvm_init __P((void));
314: /* init the uvm system */
315:
316: /* uvm_io.c */
317: int uvm_io __P((vm_map_t, struct uio *));
318:
319: /* uvm_km.c */
1.19 eeh 320: vaddr_t uvm_km_alloc1 __P((vm_map_t, vsize_t, boolean_t));
321: void uvm_km_free __P((vm_map_t, vaddr_t, vsize_t));
322: void uvm_km_free_wakeup __P((vm_map_t, vaddr_t,
323: vsize_t));
324: vaddr_t uvm_km_kmemalloc __P((vm_map_t, struct uvm_object *,
325: vsize_t, int));
326: struct vm_map *uvm_km_suballoc __P((vm_map_t, vaddr_t *,
1.27 thorpej 327: vaddr_t *, vsize_t, int,
1.6 thorpej 328: boolean_t, vm_map_t));
1.19 eeh 329: vaddr_t uvm_km_valloc __P((vm_map_t, vsize_t));
330: vaddr_t uvm_km_valloc_wait __P((vm_map_t, vsize_t));
331: vaddr_t uvm_km_alloc_poolpage1 __P((vm_map_t,
1.20 thorpej 332: struct uvm_object *, boolean_t));
1.19 eeh 333: void uvm_km_free_poolpage1 __P((vm_map_t, vaddr_t));
1.1 mrg 334:
1.20 thorpej 335: #define uvm_km_alloc_poolpage(waitok) uvm_km_alloc_poolpage1(kmem_map, \
336: uvmexp.kmem_object, (waitok))
1.17 thorpej 337: #define uvm_km_free_poolpage(addr) uvm_km_free_poolpage1(kmem_map, (addr))
1.1 mrg 338:
339: /* uvm_map.c */
1.19 eeh 340: int uvm_map __P((vm_map_t, vaddr_t *, vsize_t,
1.38 kleink 341: struct uvm_object *, voff_t, uvm_flag_t));
1.19 eeh 342: int uvm_map_pageable __P((vm_map_t, vaddr_t,
1.33 thorpej 343: vaddr_t, boolean_t, int));
1.28 thorpej 344: int uvm_map_pageable_all __P((vm_map_t, int, vsize_t));
1.19 eeh 345: boolean_t uvm_map_checkprot __P((vm_map_t, vaddr_t,
346: vaddr_t, vm_prot_t));
347: int uvm_map_protect __P((vm_map_t, vaddr_t,
348: vaddr_t, vm_prot_t, boolean_t));
349: struct vmspace *uvmspace_alloc __P((vaddr_t, vaddr_t,
1.10 thorpej 350: boolean_t));
351: void uvmspace_init __P((struct vmspace *, struct pmap *,
1.19 eeh 352: vaddr_t, vaddr_t, boolean_t));
1.1 mrg 353: void uvmspace_exec __P((struct proc *));
354: struct vmspace *uvmspace_fork __P((struct vmspace *));
355: void uvmspace_free __P((struct vmspace *));
356: void uvmspace_share __P((struct proc *, struct proc *));
357: void uvmspace_unshare __P((struct proc *));
358:
359:
360: /* uvm_meter.c */
361: void uvm_meter __P((void));
362: int uvm_sysctl __P((int *, u_int, void *, size_t *,
363: void *, size_t, struct proc *));
364:
365: /* uvm_mmap.c */
1.19 eeh 366: int uvm_mmap __P((vm_map_t, vaddr_t *, vsize_t,
1.1 mrg 367: vm_prot_t, vm_prot_t, int,
1.38 kleink 368: caddr_t, voff_t, vsize_t));
1.1 mrg 369:
370: /* uvm_page.c */
1.15 thorpej 371: struct vm_page *uvm_pagealloc_strat __P((struct uvm_object *,
1.38 kleink 372: voff_t, struct vm_anon *, int, int, int));
1.24 chs 373: #define uvm_pagealloc(obj, off, anon, flags) \
374: uvm_pagealloc_strat((obj), (off), (anon), (flags), \
375: UVM_PGA_STRAT_NORMAL, 0)
1.1 mrg 376: void uvm_pagerealloc __P((struct vm_page *,
1.38 kleink 377: struct uvm_object *, voff_t));
1.19 eeh 378: /* Actually, uvm_page_physload takes PF#s which need their own type */
1.35 eeh 379: void uvm_page_physload __P((paddr_t, paddr_t,
380: paddr_t, paddr_t, int));
1.1 mrg 381: void uvm_setpagesize __P((void));
382:
383: /* uvm_pdaemon.c */
384: void uvm_pageout __P((void));
385:
386: /* uvm_pglist.c */
1.19 eeh 387: int uvm_pglistalloc __P((psize_t, paddr_t,
388: paddr_t, paddr_t, paddr_t,
1.1 mrg 389: struct pglist *, int, int));
390: void uvm_pglistfree __P((struct pglist *));
391:
392: /* uvm_swap.c */
393: void uvm_swap_init __P((void));
394:
395: /* uvm_unix.c */
396: int uvm_coredump __P((struct proc *, struct vnode *,
397: struct ucred *, struct core *));
1.19 eeh 398: int uvm_grow __P((struct proc *, vaddr_t));
1.35 eeh 399: /* should only be needed if COMPAT_NETBSD32 is defined */
400: struct core32;
401: int uvm_coredump32 __P((struct proc *, struct vnode *,
402: struct ucred *, struct core32 *));
1.1 mrg 403:
404: /* uvm_user.c */
1.19 eeh 405: int uvm_deallocate __P((vm_map_t, vaddr_t, vsize_t));
1.1 mrg 406:
407: /* uvm_vnode.c */
1.38 kleink 408: void uvm_vnp_setsize __P((struct vnode *, voff_t));
1.1 mrg 409: void uvm_vnp_sync __P((struct mount *));
410: void uvm_vnp_terminate __P((struct vnode *));
411: /* terminate a uvm/uvn object */
412: boolean_t uvm_vnp_uncache __P((struct vnode *));
413: struct uvm_object *uvn_attach __P((void *, vm_prot_t));
1.37 thorpej 414:
415: /* kern_malloc.c */
416: void kmeminit_nkmempages __P((void));
417: void kmeminit __P((void));
418: extern int nkmempages;
1.1 mrg 419:
1.31 thorpej 420: #endif /* _KERNEL */
421:
1.8 perry 422: #endif /* _UVM_UVM_EXTERN_H_ */
CVSweb <webmaster@jp.NetBSD.org>