uvm.h revision 1.54
1/* $OpenBSD: uvm.h,v 1.54 2014/07/08 14:22:43 deraadt Exp $ */ 2/* $NetBSD: uvm.h,v 1.24 2000/11/27 08:40:02 chs Exp $ */ 3 4/* 5 * 6 * Copyright (c) 1997 Charles D. Cranor and Washington University. 7 * All rights reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 3. All advertising materials mentioning features or use of this software 18 * must display the following acknowledgement: 19 * This product includes software developed by Charles D. Cranor and 20 * Washington University. 21 * 4. The name of the author may not be used to endorse or promote products 22 * derived from this software without specific prior written permission. 23 * 24 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 25 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 26 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 27 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 28 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 29 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 33 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 * 35 * from: Id: uvm.h,v 1.1.2.14 1998/02/02 20:07:19 chuck Exp 36 */ 37 38#ifndef _UVM_UVM_H_ 39#define _UVM_UVM_H_ 40 41#include <uvm/uvm_extern.h> 42#include <uvm/uvm_amap.h> 43#include <uvm/uvm_aobj.h> 44#include <uvm/uvm_fault.h> 45#include <uvm/uvm_glue.h> 46#include <uvm/uvm_km.h> 47#include <uvm/uvm_swap.h> 48#include <uvm/uvm_pmemrange.h> 49#ifdef UVM_SWAP_ENCRYPT 50#include <uvm/uvm_swap_encrypt.h> 51#endif 52 53/* 54 * uvm structure (vm global state: collected in one structure for ease 55 * of reference...) 56 */ 57 58struct uvm { 59 /* vm_page related parameters */ 60 61 /* vm_page queues */ 62 struct pglist page_active; /* allocated pages, in use */ 63 struct pglist page_inactive_swp;/* pages inactive (reclaim or free) */ 64 struct pglist page_inactive_obj;/* pages inactive (reclaim or free) */ 65 /* Lock order: pageqlock, then fpageqlock. */ 66 struct mutex fpageqlock; /* lock for free page q + pdaemon */ 67 boolean_t page_init_done; /* TRUE if uvm_page_init() finished */ 68 boolean_t page_idle_zero; /* TRUE if we should try to zero 69 pages in the idle loop */ 70 struct uvm_pmr_control pmr_control; /* pmemrange data */ 71 72 /* page daemon trigger */ 73 int pagedaemon; /* daemon sleeps on this */ 74 struct proc *pagedaemon_proc; /* daemon's pid */ 75 76 /* aiodone daemon trigger */ 77 int aiodoned; /* daemon sleeps on this */ 78 struct proc *aiodoned_proc; /* daemon's pid */ 79 struct mutex aiodoned_lock; 80 81 /* static kernel map entry pool */ 82 vm_map_entry_t kentry_free; /* free page pool */ 83 84 /* aio_done is locked by uvm.aiodoned_lock. */ 85 TAILQ_HEAD(, buf) aio_done; /* done async i/o reqs */ 86 87 /* kernel object: to support anonymous pageable kernel memory */ 88 struct uvm_object *kernel_object; 89}; 90 91/* 92 * vm_map_entry etype bits: 93 */ 94 95#define UVM_ET_OBJ 0x01 /* it is a uvm_object */ 96#define UVM_ET_SUBMAP 0x02 /* it is a vm_map submap */ 97#define UVM_ET_COPYONWRITE 0x04 /* copy_on_write */ 98#define UVM_ET_NEEDSCOPY 0x08 /* needs_copy */ 99#define UVM_ET_HOLE 0x10 /* no backend */ 100#define UVM_ET_FREEMAPPED 0x80 /* map entry is on free list (DEBUG) */ 101 102#define UVM_ET_ISOBJ(E) (((E)->etype & UVM_ET_OBJ) != 0) 103#define UVM_ET_ISSUBMAP(E) (((E)->etype & UVM_ET_SUBMAP) != 0) 104#define UVM_ET_ISCOPYONWRITE(E) (((E)->etype & UVM_ET_COPYONWRITE) != 0) 105#define UVM_ET_ISNEEDSCOPY(E) (((E)->etype & UVM_ET_NEEDSCOPY) != 0) 106#define UVM_ET_ISHOLE(E) (((E)->etype & UVM_ET_HOLE) != 0) 107 108#ifdef _KERNEL 109 110/* 111 * holds all the internal UVM data 112 */ 113extern struct uvm uvm; 114 115/* 116 * UVM_WAIT: wait... wrapper around the tsleep() function. 117 */ 118 119#define UVM_WAIT(event, intr, msg, timo) \ 120do { \ 121 tsleep(event, PVM|(intr ? PCATCH : 0), msg, timo); \ 122} while (0) 123 124/* 125 * UVM_PAGE_OWN: track page ownership (only if UVM_PAGE_TRKOWN) 126 */ 127 128#if defined(UVM_PAGE_TRKOWN) 129#define UVM_PAGE_OWN(PG, TAG) uvm_page_own(PG, TAG) 130#else 131#define UVM_PAGE_OWN(PG, TAG) /* nothing */ 132#endif /* UVM_PAGE_TRKOWN */ 133 134/* 135 * uvm_map internal functions. 136 * Used by uvm_map address selectors. 137 */ 138struct vm_map_entry *uvm_map_entrybyaddr(struct uvm_map_addr *, vaddr_t); 139int uvm_map_isavail(struct vm_map *, 140 struct uvm_addr_state *, 141 struct vm_map_entry **, struct vm_map_entry**, 142 vaddr_t, vsize_t); 143struct uvm_addr_state *uvm_map_uaddr(struct vm_map *, vaddr_t); 144struct uvm_addr_state *uvm_map_uaddr_e(struct vm_map *, struct vm_map_entry *); 145 146#define VMMAP_FREE_START(_entry) ((_entry)->end + (_entry)->guard) 147#define VMMAP_FREE_END(_entry) ((_entry)->end + (_entry)->guard + \ 148 (_entry)->fspace) 149 150#endif /* _KERNEL */ 151 152#endif /* _UVM_UVM_H_ */ 153