1/* $NetBSD: uvm_pager.h,v 1.43 2012/04/29 22:54:01 chs 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 _UVM_UVM_PAGER_H_
101
102/*
103 * uvm_pager.h
104 */
105
106/*
107 * forward structure declarations
108 */
109
110struct uvm_faultinfo;
111
112/*
113 * pager ops
114 */
115
116struct uvm_pagerops {
117
118 /* init pager */
119 void (*pgo_init)(void);
120
121 /* add reference to obj */
122 void (*pgo_reference)(struct uvm_object *);
123
124 /* drop reference to obj */
125 void (*pgo_detach)(struct uvm_object *);
126
127 /* special non-standard fault processing */
128 int (*pgo_fault)(struct uvm_faultinfo *, vaddr_t, struct vm_page **,
129 int, int, vm_prot_t, int);
130
131 /* get/read pages */
132 int (*pgo_get)(struct uvm_object *, voff_t, struct vm_page **,
133 int *, int, vm_prot_t, int, int);
134
135 /* put/write pages */
136 int (*pgo_put)(struct uvm_object *, voff_t, voff_t, int);
137};
138
139/* pager flags [mostly for flush] */
140
141#define PGO_CLEANIT 0x001 /* write dirty pages to backing store */
142#define PGO_SYNCIO 0x002 /* use sync I/O */
143#define PGO_DEACTIVATE 0x004 /* deactivate flushed pages */
144#define PGO_FREE 0x008 /* free flushed pages */
145/* if PGO_FREE is not set then the pages stay where they are. */
146
147#define PGO_ALLPAGES 0x010 /* flush whole object/get all pages */
148#define PGO_JOURNALLOCKED 0x020 /* journal is already locked [put] */
149#define PGO_LOCKED 0x040 /* fault data structures are locked [get] */
150#define PGO_BUSYFAIL 0x080 /* fail if a page is busy [put] */
151#define PGO_OVERWRITE 0x200 /* pages will be overwritten before unlocked */
152#define PGO_PASTEOF 0x400 /* allow allocation of pages past EOF */
153#define PGO_NOBLOCKALLOC 0x800 /* backing block allocation is not needed */
154#define PGO_NOTIMESTAMP 0x1000 /* don't mark object accessed/modified */
155#define PGO_RECLAIM 0x2000 /* object is being reclaimed */
156#define PGO_GLOCKHELD 0x4000 /* genfs_node's lock is already held */
157#define PGO_LAZY 0x8000 /* equivalent of MNT_LAZY / FSYNC_LAZY */
158
159/* page we are not interested in getting */
160#define PGO_DONTCARE ((struct vm_page *) -1L) /* [get only] */
161
162#ifdef _KERNEL
163
164/*
165 * prototypes
166 */
167
168void uvm_pager_init(void);
169void uvm_pager_realloc_emerg(void);
170struct vm_page *uvm_pageratop(vaddr_t);
171vaddr_t uvm_pagermapin(struct vm_page **, int, int);
172void uvm_pagermapout(vaddr_t, int);
173
174extern size_t pager_map_size;
175
176/* Flags to uvm_pagermapin() */
177#define UVMPAGER_MAPIN_WAITOK 0x01 /* it's okay to wait */
178#define UVMPAGER_MAPIN_READ 0x02 /* device -> host */
179#define UVMPAGER_MAPIN_WRITE 0x00 /* host -> device (pseudo flag) */
180
181#endif /* _KERNEL */
182
183#endif /* _UVM_UVM_PAGER_H_ */
184