1 /* $NetBSD: uvm_pager.h,v 1.16 2000/06/26 14:21:18 mrg Exp $ */ 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. 33 * 34 * from: Id: uvm_pager.h,v 1.1.2.14 1998/01/13 19:00:50 chuck Exp 35 */ 36 37 /* 38 * Copyright (c) 1990 University of Utah. 39 * Copyright (c) 1991, 1993 40 * The Regents of the University of California. All rights reserved. 41 * 42 * This code is derived from software contributed to Berkeley by 43 * the Systems Programming Group of the University of Utah Computer 44 * Science Department. 45 * 46 * Redistribution and use in source and binary forms, with or without 47 * modification, are permitted provided that the following conditions 48 * are met: 49 * 1. Redistributions of source code must retain the above copyright 50 * notice, this list of conditions and the following disclaimer. 51 * 2. Redistributions in binary form must reproduce the above copyright 52 * notice, this list of conditions and the following disclaimer in the 53 * documentation and/or other materials provided with the distribution. 54 * 3. All advertising materials mentioning features or use of this software 55 * must display the following acknowledgement: 56 * This product includes software developed by the University of 57 * California, Berkeley and its contributors. 58 * 4. Neither the name of the University nor the names of its contributors 59 * may be used to endorse or promote products derived from this software 60 * without specific prior written permission. 61 * 62 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 63 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 64 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 65 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 66 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 67 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 68 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 69 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 70 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 71 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 72 * SUCH DAMAGE. 73 * 74 * @(#)vm_pager.h 8.5 (Berkeley) 7/7/94 75 */ 76 77 #ifndef _UVM_UVM_PAGER_H_ 78 #define _UVM_UVM_PAGER_H_ 79 80 /* 81 * uvm_pager.h 82 */ 83 84 /* 85 * async pager i/o descriptor structure 86 */ 87 88 TAILQ_HEAD(uvm_aiohead, uvm_aiodesc); 89 90 struct uvm_aiodesc { 91 void (*aiodone) __P((struct uvm_aiodesc *)); 92 /* aio done function */ 93 vaddr_t kva; /* KVA of mapped page(s) */ 94 int npages; /* # of pages in I/O req */ 95 void *pd_ptr; /* pager-dependent pointer */ 96 TAILQ_ENTRY(uvm_aiodesc) aioq; /* linked list of aio's */ 97 }; 98 99 /* 100 * pager ops 101 */ 102 103 struct uvm_pagerops { 104 void (*pgo_init) __P((void));/* init pager */ 105 void (*pgo_reference) /* add reference to obj */ 106 __P((struct uvm_object *)); 107 void (*pgo_detach) /* drop reference to obj */ 108 __P((struct uvm_object *)); 109 int (*pgo_fault) /* special nonstd fault fn */ 110 __P((struct uvm_faultinfo *, vaddr_t, 111 vm_page_t *, int, int, vm_fault_t, 112 vm_prot_t, int)); 113 boolean_t (*pgo_flush) /* flush pages out of obj */ 114 __P((struct uvm_object *, voff_t, voff_t, int)); 115 int (*pgo_get) /* get/read page */ 116 __P((struct uvm_object *, voff_t, 117 vm_page_t *, int *, int, vm_prot_t, int, int)); 118 int (*pgo_asyncget) /* start async get */ 119 __P((struct uvm_object *, voff_t, int)); 120 int (*pgo_put) /* put/write page */ 121 __P((struct uvm_object *, vm_page_t *, 122 int, boolean_t)); 123 void (*pgo_cluster) /* return range of cluster */ 124 __P((struct uvm_object *, voff_t, voff_t *, 125 voff_t *)); 126 struct vm_page ** (*pgo_mk_pcluster) /* make "put" cluster */ 127 __P((struct uvm_object *, struct vm_page **, 128 int *, struct vm_page *, int, voff_t, 129 voff_t)); 130 void (*pgo_aiodone) /* async iodone */ 131 __P((struct uvm_aiodesc *)); 132 boolean_t (*pgo_releasepg) /* release page */ 133 __P((struct vm_page *, struct vm_page **)); 134 }; 135 136 /* pager flags [mostly for flush] */ 137 138 #define PGO_CLEANIT 0x001 /* write dirty pages to backing store */ 139 #define PGO_SYNCIO 0x002 /* if PGO_CLEAN: use sync I/O? */ 140 /* 141 * obviously if neither PGO_INVALIDATE or PGO_FREE are set then the pages 142 * stay where they are. 143 */ 144 #define PGO_DEACTIVATE 0x004 /* deactivate flushed pages */ 145 #define PGO_FREE 0x008 /* free flushed pages */ 146 147 #define PGO_ALLPAGES 0x010 /* flush whole object/get all pages */ 148 #define PGO_DOACTCLUST 0x020 /* flag to mk_pcluster to include active */ 149 #define PGO_LOCKED 0x040 /* fault data structures are locked [get] */ 150 #define PGO_PDFREECLUST 0x080 /* daemon's free cluster flag [uvm_pager_put] */ 151 #define PGO_REALLOCSWAP 0x100 /* reallocate swap area [pager_dropcluster] */ 152 153 /* page we are not interested in getting */ 154 #define PGO_DONTCARE ((struct vm_page *) -1) /* [get only] */ 155 156 #ifdef _KERNEL 157 158 /* 159 * handle inline options 160 */ 161 162 #ifdef UVM_PAGER_INLINE 163 #define PAGER_INLINE static __inline 164 #else 165 #define PAGER_INLINE /* nothing */ 166 #endif /* UVM_PAGER_INLINE */ 167 168 /* 169 * prototypes 170 */ 171 172 void uvm_pager_dropcluster __P((struct uvm_object *, 173 struct vm_page *, struct vm_page **, 174 int *, int)); 175 void uvm_pager_init __P((void)); 176 int uvm_pager_put __P((struct uvm_object *, struct vm_page *, 177 struct vm_page ***, int *, int, 178 voff_t, voff_t)); 179 180 PAGER_INLINE struct vm_page *uvm_pageratop __P((vaddr_t)); 181 182 vaddr_t uvm_pagermapin __P((struct vm_page **, int, 183 struct uvm_aiodesc **, int)); 184 void uvm_pagermapout __P((vaddr_t, int)); 185 struct vm_page **uvm_mk_pcluster __P((struct uvm_object *, struct vm_page **, 186 int *, struct vm_page *, int, 187 voff_t, voff_t)); 188 189 /* Flags to uvm_pagermapin() */ 190 #define UVMPAGER_MAPIN_WAITOK 0x01 /* it's okay to wait */ 191 #define UVMPAGER_MAPIN_READ 0x02 /* host <- device */ 192 #define UVMPAGER_MAPIN_WRITE 0x00 /* device -> host (pseudo flag) */ 193 194 /* 195 * get/put return values 196 * OK operation was successful 197 * BAD specified data was out of the accepted range 198 * FAIL specified data was in range, but doesn't exist 199 * PEND operations was initiated but not completed 200 * ERROR error while accessing data that is in range and exists 201 * AGAIN temporary resource shortage prevented operation from happening 202 * UNLOCK unlock the map and try again 203 * REFAULT [uvm_fault internal use only!] unable to relock data structures, 204 * thus the mapping needs to be reverified before we can procede 205 */ 206 #define VM_PAGER_OK 0 207 #define VM_PAGER_BAD 1 208 #define VM_PAGER_FAIL 2 209 #define VM_PAGER_PEND 3 210 #define VM_PAGER_ERROR 4 211 #define VM_PAGER_AGAIN 5 212 #define VM_PAGER_UNLOCK 6 213 #define VM_PAGER_REFAULT 7 214 215 #endif /* _KERNEL */ 216 217 #endif /* _UVM_UVM_PAGER_H_ */ 218