| 1 | /*	$NetBSD: uvm_pager.h,v 1.45 2018/12/09 20:33:04 jdolecek Exp $	*/ | 
| 2 |  | 
| 3 | /* | 
| 4 |  * Copyright (c) 1997 Charles D. Cranor and Washington University. | 
| 5 |  * All rights reserved. | 
| 6 |  * | 
| 7 |  * Redistribution and use in source and binary forms, with or without | 
| 8 |  * modification, are permitted provided that the following conditions | 
| 9 |  * are met: | 
| 10 |  * 1. Redistributions of source code must retain the above copyright | 
| 11 |  *    notice, this list of conditions and the following disclaimer. | 
| 12 |  * 2. Redistributions in binary form must reproduce the above copyright | 
| 13 |  *    notice, this list of conditions and the following disclaimer in the | 
| 14 |  *    documentation and/or other materials provided with the distribution. | 
| 15 |  * | 
| 16 |  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | 
| 17 |  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | 
| 18 |  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | 
| 19 |  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | 
| 20 |  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | 
| 21 |  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 
| 22 |  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 
| 23 |  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 
| 24 |  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 
| 25 |  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 
| 26 |  * | 
| 27 |  * from: Id: uvm_pager.h,v 1.1.2.14 1998/01/13 19:00:50 chuck Exp | 
| 28 |  */ | 
| 29 |  | 
| 30 | /* | 
| 31 |  * Copyright (c) 1991, 1993 | 
| 32 |  *	The Regents of the University of California.  All rights reserved. | 
| 33 |  * | 
| 34 |  * This code is derived from software contributed to Berkeley by | 
| 35 |  * the Systems Programming Group of the University of Utah Computer | 
| 36 |  * Science Department. | 
| 37 |  * | 
| 38 |  * Redistribution and use in source and binary forms, with or without | 
| 39 |  * modification, are permitted provided that the following conditions | 
| 40 |  * are met: | 
| 41 |  * 1. Redistributions of source code must retain the above copyright | 
| 42 |  *    notice, this list of conditions and the following disclaimer. | 
| 43 |  * 2. Redistributions in binary form must reproduce the above copyright | 
| 44 |  *    notice, this list of conditions and the following disclaimer in the | 
| 45 |  *    documentation and/or other materials provided with the distribution. | 
| 46 |  * 3. Neither the name of the University nor the names of its contributors | 
| 47 |  *    may be used to endorse or promote products derived from this software | 
| 48 |  *    without specific prior written permission. | 
| 49 |  * | 
| 50 |  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | 
| 51 |  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 
| 52 |  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 
| 53 |  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | 
| 54 |  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 
| 55 |  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 
| 56 |  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 
| 57 |  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 
| 58 |  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 
| 59 |  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 
| 60 |  * SUCH DAMAGE. | 
| 61 |  * | 
| 62 |  *	@(#)vm_pager.h	8.5 (Berkeley) 7/7/94 | 
| 63 |  */ | 
| 64 |  | 
| 65 | /* | 
| 66 |  * Copyright (c) 1990 University of Utah. | 
| 67 |  * | 
| 68 |  * This code is derived from software contributed to Berkeley by | 
| 69 |  * the Systems Programming Group of the University of Utah Computer | 
| 70 |  * Science Department. | 
| 71 |  * | 
| 72 |  * Redistribution and use in source and binary forms, with or without | 
| 73 |  * modification, are permitted provided that the following conditions | 
| 74 |  * are met: | 
| 75 |  * 1. Redistributions of source code must retain the above copyright | 
| 76 |  *    notice, this list of conditions and the following disclaimer. | 
| 77 |  * 2. Redistributions in binary form must reproduce the above copyright | 
| 78 |  *    notice, this list of conditions and the following disclaimer in the | 
| 79 |  *    documentation and/or other materials provided with the distribution. | 
| 80 |  * 3. Neither the name of the University nor the names of its contributors | 
| 81 |  *    may be used to endorse or promote products derived from this software | 
| 82 |  *    without specific prior written permission. | 
| 83 |  * | 
| 84 |  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | 
| 85 |  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 
| 86 |  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 
| 87 |  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | 
| 88 |  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 
| 89 |  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 
| 90 |  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 
| 91 |  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 
| 92 |  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 
| 93 |  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 
| 94 |  * SUCH DAMAGE. | 
| 95 |  * | 
| 96 |  *	@(#)vm_pager.h	8.5 (Berkeley) 7/7/94 | 
| 97 |  */ | 
| 98 |  | 
| 99 | #ifndef _UVM_UVM_PAGER_H_ | 
| 100 | #define  | 
| 101 |  | 
| 102 | /* | 
| 103 |  * uvm_pager.h | 
| 104 |  */ | 
| 105 |  | 
| 106 | /* | 
| 107 |  * forward structure declarations | 
| 108 |  */ | 
| 109 |  | 
| 110 | struct uvm_faultinfo; | 
| 111 | struct uvm_object; | 
| 112 |  | 
| 113 | /* | 
| 114 |  * pager ops | 
| 115 |  */ | 
| 116 |  | 
| 117 | struct  { | 
| 118 |  | 
| 119 | 	/* init pager */ | 
| 120 | 	void	(*)(void); | 
| 121 |  | 
| 122 | 	/* add reference to obj */ | 
| 123 | 	void	(*)(struct uvm_object *); | 
| 124 |  | 
| 125 | 	/* drop reference to obj */ | 
| 126 | 	void	(*)(struct uvm_object *); | 
| 127 |  | 
| 128 | 	/* special non-standard fault processing */ | 
| 129 | 	int	(*)(struct uvm_faultinfo *, vaddr_t, struct vm_page **, | 
| 130 | 			     int, int, vm_prot_t, int); | 
| 131 |  | 
| 132 | 	/* get/read pages */ | 
| 133 | 	int	(*)(struct uvm_object *, voff_t, struct vm_page **, | 
| 134 | 			   int *, int, vm_prot_t, int, int); | 
| 135 |  | 
| 136 | 	/* put/write pages */ | 
| 137 | 	int	(*)(struct uvm_object *, voff_t, voff_t, int); | 
| 138 | }; | 
| 139 |  | 
| 140 | /* pager flags [mostly for flush] */ | 
| 141 |  | 
| 142 | #define PGO_CLEANIT	0x001	/* write dirty pages to backing store */ | 
| 143 | #define PGO_SYNCIO	0x002	/* use sync I/O */ | 
| 144 | #define PGO_DEACTIVATE	0x004	/* deactivate flushed pages */ | 
| 145 | #define PGO_FREE	0x008	/* free flushed pages */ | 
| 146 | /* if PGO_FREE is not set then the pages stay where they are. */ | 
| 147 |  | 
| 148 | #define PGO_ALLPAGES	0x010	/* flush whole object/get all pages */ | 
| 149 | #define PGO_JOURNALLOCKED 0x020	/* journal is already locked [get/put] */ | 
| 150 | #define PGO_LOCKED	0x040	/* fault data structures are locked [get] */ | 
| 151 | #define PGO_BUSYFAIL	0x080	/* fail if a page is busy [put] */ | 
| 152 | #define PGO_OVERWRITE	0x200	/* pages will be overwritten before unlocked */ | 
| 153 | #define PGO_PASTEOF	0x400	/* allow allocation of pages past EOF */ | 
| 154 | #define PGO_NOBLOCKALLOC 0x800	/* backing block allocation is not needed */ | 
| 155 | #define PGO_NOTIMESTAMP 0x1000	/* don't mark object accessed/modified */ | 
| 156 | #define PGO_RECLAIM	0x2000	/* object is being reclaimed */ | 
| 157 | #define PGO_GLOCKHELD	0x4000	/* genfs_node's lock is already held */ | 
| 158 | #define PGO_LAZY	0x8000	/* equivalent of MNT_LAZY / FSYNC_LAZY */ | 
| 159 |  | 
| 160 | /* page we are not interested in getting */ | 
| 161 | #define PGO_DONTCARE ((struct vm_page *) -1L)	/* [get only] */ | 
| 162 |  | 
| 163 | #ifdef _KERNEL | 
| 164 |  | 
| 165 | /* | 
| 166 |  * prototypes | 
| 167 |  */ | 
| 168 |  | 
| 169 | void	uvm_pager_init(void); | 
| 170 | void	uvm_pager_realloc_emerg(void); | 
| 171 | struct vm_page *uvm_pageratop(vaddr_t); | 
| 172 | vaddr_t	uvm_pagermapin(struct vm_page **, int, int); | 
| 173 | void	uvm_pagermapout(vaddr_t, int); | 
| 174 |  | 
| 175 | extern size_t pager_map_size; | 
| 176 |  | 
| 177 | /* Flags to uvm_pagermapin() */ | 
| 178 | #define	UVMPAGER_MAPIN_WAITOK	0x01	/* it's okay to wait */ | 
| 179 | #define	UVMPAGER_MAPIN_READ	0x02	/* device -> host */ | 
| 180 | #define	UVMPAGER_MAPIN_WRITE	0x00	/* host -> device (pseudo flag) */ | 
| 181 |  | 
| 182 | #endif /* _KERNEL */ | 
| 183 |  | 
| 184 | #endif /* _UVM_UVM_PAGER_H_ */ | 
| 185 |  |