xref: /freebsd/sys/vm/vm_pager.h (revision d48524e21f1a49752485418324538755571ed13f)
160727d8bSWarner Losh /*-
251369649SPedro F. Giffuni  * SPDX-License-Identifier: BSD-3-Clause
351369649SPedro F. Giffuni  *
4df8bae1dSRodney W. Grimes  * Copyright (c) 1990 University of Utah.
5df8bae1dSRodney W. Grimes  * Copyright (c) 1991, 1993
6df8bae1dSRodney W. Grimes  *	The Regents of the University of California.  All rights reserved.
7df8bae1dSRodney W. Grimes  *
8df8bae1dSRodney W. Grimes  * This code is derived from software contributed to Berkeley by
9df8bae1dSRodney W. Grimes  * the Systems Programming Group of the University of Utah Computer
10df8bae1dSRodney W. Grimes  * Science Department.
11df8bae1dSRodney W. Grimes  *
12df8bae1dSRodney W. Grimes  * Redistribution and use in source and binary forms, with or without
13df8bae1dSRodney W. Grimes  * modification, are permitted provided that the following conditions
14df8bae1dSRodney W. Grimes  * are met:
15df8bae1dSRodney W. Grimes  * 1. Redistributions of source code must retain the above copyright
16df8bae1dSRodney W. Grimes  *    notice, this list of conditions and the following disclaimer.
17df8bae1dSRodney W. Grimes  * 2. Redistributions in binary form must reproduce the above copyright
18df8bae1dSRodney W. Grimes  *    notice, this list of conditions and the following disclaimer in the
19df8bae1dSRodney W. Grimes  *    documentation and/or other materials provided with the distribution.
20fbbd9655SWarner Losh  * 3. Neither the name of the University nor the names of its contributors
21df8bae1dSRodney W. Grimes  *    may be used to endorse or promote products derived from this software
22df8bae1dSRodney W. Grimes  *    without specific prior written permission.
23df8bae1dSRodney W. Grimes  *
24df8bae1dSRodney W. Grimes  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25df8bae1dSRodney W. Grimes  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26df8bae1dSRodney W. Grimes  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27df8bae1dSRodney W. Grimes  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28df8bae1dSRodney W. Grimes  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29df8bae1dSRodney W. Grimes  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30df8bae1dSRodney W. Grimes  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31df8bae1dSRodney W. Grimes  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32df8bae1dSRodney W. Grimes  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33df8bae1dSRodney W. Grimes  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34df8bae1dSRodney W. Grimes  * SUCH DAMAGE.
35df8bae1dSRodney W. Grimes  */
36df8bae1dSRodney W. Grimes 
37df8bae1dSRodney W. Grimes /*
38df8bae1dSRodney W. Grimes  * Pager routine interface definition.
39df8bae1dSRodney W. Grimes  */
40df8bae1dSRodney W. Grimes 
41df8bae1dSRodney W. Grimes #ifndef	_VM_PAGER_
42df8bae1dSRodney W. Grimes #define	_VM_PAGER_
43df8bae1dSRodney W. Grimes 
44f4cdb9d7SKonstantin Belousov #include <sys/systm.h>
45e7a58978SBruce Evans 
46e3975643SJake Burkholder TAILQ_HEAD(pagerlst, vm_object);
47192112b7SKonstantin Belousov struct vnode;
48df8bae1dSRodney W. Grimes 
49d20b2f76SPoul-Henning Kamp typedef void pgo_init_t(void);
503364c323SKonstantin Belousov typedef vm_object_t pgo_alloc_t(void *, vm_ooffset_t, vm_prot_t, vm_ooffset_t,
513364c323SKonstantin Belousov     struct ucred *);
52d20b2f76SPoul-Henning Kamp typedef void pgo_dealloc_t(vm_object_t);
53b0cd2017SGleb Smirnoff typedef int pgo_getpages_t(vm_object_t, vm_page_t *, int, int *, int *);
5490effb23SGleb Smirnoff typedef void pgo_getpages_iodone_t(void *, vm_page_t *, int, int);
55b0cd2017SGleb Smirnoff typedef int pgo_getpages_async_t(vm_object_t, vm_page_t *, int, int *, int *,
5690effb23SGleb Smirnoff     pgo_getpages_iodone_t, void *);
57d20b2f76SPoul-Henning Kamp typedef void pgo_putpages_t(vm_object_t, vm_page_t *, int, int, int *);
58d20b2f76SPoul-Henning Kamp typedef boolean_t pgo_haspage_t(vm_object_t, vm_pindex_t, int *, int *);
59c42b43a0SKonstantin Belousov typedef int pgo_populate_t(vm_object_t, vm_pindex_t, int, vm_prot_t,
60c42b43a0SKonstantin Belousov     vm_pindex_t *, vm_pindex_t *);
61d20b2f76SPoul-Henning Kamp typedef void pgo_pageunswapped_t(vm_page_t);
62fe7bcbafSKyle Evans typedef void pgo_writecount_t(vm_object_t, vm_offset_t, vm_offset_t);
63180bcaa4SKonstantin Belousov typedef void pgo_set_writeable_dirty_t(vm_object_t);
64c23c555bSKonstantin Belousov typedef bool pgo_mightbedirty_t(vm_object_t);
65192112b7SKonstantin Belousov typedef void pgo_getvp_t(vm_object_t object, struct vnode **vpp,
66192112b7SKonstantin Belousov     bool *vp_heldp);
671390a5cbSKonstantin Belousov typedef void pgo_freespace_t(vm_object_t object, vm_pindex_t start,
681390a5cbSKonstantin Belousov     vm_size_t size);
69d537d1f1SKonstantin Belousov typedef void pgo_page_inserted_t(vm_object_t object, vm_page_t m);
70d537d1f1SKonstantin Belousov typedef void pgo_page_removed_t(vm_object_t object, vm_page_t m);
71ec201dddSKonstantin Belousov typedef boolean_t pgo_can_alloc_page_t(vm_object_t object, vm_pindex_t pindex);
72d20b2f76SPoul-Henning Kamp 
73df8bae1dSRodney W. Grimes struct pagerops {
7400a3fe96SKonstantin Belousov 	int			pgo_kvme_type;
75d20b2f76SPoul-Henning Kamp 	pgo_init_t		*pgo_init;		/* Initialize pager. */
76d20b2f76SPoul-Henning Kamp 	pgo_alloc_t		*pgo_alloc;		/* Allocate pager. */
77d20b2f76SPoul-Henning Kamp 	pgo_dealloc_t		*pgo_dealloc;		/* Disassociate. */
78d20b2f76SPoul-Henning Kamp 	pgo_getpages_t		*pgo_getpages;		/* Get (read) page. */
7990effb23SGleb Smirnoff 	pgo_getpages_async_t	*pgo_getpages_async;	/* Get page asyncly. */
80d20b2f76SPoul-Henning Kamp 	pgo_putpages_t		*pgo_putpages;		/* Put (write) page. */
81e1a44545SGleb Smirnoff 	pgo_haspage_t		*pgo_haspage;		/* Query page. */
82c42b43a0SKonstantin Belousov 	pgo_populate_t		*pgo_populate;		/* Bulk spec pagein. */
83d20b2f76SPoul-Henning Kamp 	pgo_pageunswapped_t	*pgo_pageunswapped;
84fe7bcbafSKyle Evans 	pgo_writecount_t	*pgo_update_writecount;
85fe7bcbafSKyle Evans 	pgo_writecount_t	*pgo_release_writecount;
86180bcaa4SKonstantin Belousov 	pgo_set_writeable_dirty_t *pgo_set_writeable_dirty;
87c23c555bSKonstantin Belousov 	pgo_mightbedirty_t	*pgo_mightbedirty;
88192112b7SKonstantin Belousov 	pgo_getvp_t		*pgo_getvp;
891390a5cbSKonstantin Belousov 	pgo_freespace_t		*pgo_freespace;
90d537d1f1SKonstantin Belousov 	pgo_page_inserted_t	*pgo_page_inserted;
91d537d1f1SKonstantin Belousov 	pgo_page_removed_t	*pgo_page_removed;
92ec201dddSKonstantin Belousov 	pgo_can_alloc_page_t	*pgo_can_alloc_page;
93df8bae1dSRodney W. Grimes };
94df8bae1dSRodney W. Grimes 
95d474440aSKonstantin Belousov extern const struct pagerops defaultpagerops;
96d474440aSKonstantin Belousov extern const struct pagerops swappagerops;
97d474440aSKonstantin Belousov extern const struct pagerops vnodepagerops;
98d474440aSKonstantin Belousov extern const struct pagerops devicepagerops;
99d474440aSKonstantin Belousov extern const struct pagerops physpagerops;
100d474440aSKonstantin Belousov extern const struct pagerops sgpagerops;
101d474440aSKonstantin Belousov extern const struct pagerops mgtdevicepagerops;
102d474440aSKonstantin Belousov extern const struct pagerops swaptmpfspagerops;
103745f3305SPoul-Henning Kamp 
104df8bae1dSRodney W. Grimes /*
105df8bae1dSRodney W. Grimes  * get/put return values
106df8bae1dSRodney W. Grimes  * OK	 operation was successful
107df8bae1dSRodney W. Grimes  * BAD	 specified data was out of the accepted range
108df8bae1dSRodney W. Grimes  * FAIL	 specified data was in range, but doesn't exist
109df8bae1dSRodney W. Grimes  * PEND	 operations was initiated but not completed
110df8bae1dSRodney W. Grimes  * ERROR error while accessing data that is in range and exists
111df8bae1dSRodney W. Grimes  * AGAIN temporary resource shortage prevented operation from happening
112df8bae1dSRodney W. Grimes  */
113df8bae1dSRodney W. Grimes #define	VM_PAGER_OK	0
114df8bae1dSRodney W. Grimes #define	VM_PAGER_BAD	1
115df8bae1dSRodney W. Grimes #define	VM_PAGER_FAIL	2
116df8bae1dSRodney W. Grimes #define	VM_PAGER_PEND	3
117df8bae1dSRodney W. Grimes #define	VM_PAGER_ERROR	4
118df8bae1dSRodney W. Grimes #define VM_PAGER_AGAIN	5
119df8bae1dSRodney W. Grimes 
12043b7990eSMatthew Dillon #define	VM_PAGER_PUT_SYNC		0x0001
12143b7990eSMatthew Dillon #define	VM_PAGER_PUT_INVAL		0x0002
12299e6e193SMark Johnston #define	VM_PAGER_PUT_NOREUSE		0x0004
12343b7990eSMatthew Dillon #define VM_PAGER_CLUSTER_OK		0x0008
1248f9110f6SJohn Dyson 
125c4473420SPeter Wemm #ifdef _KERNEL
126a1c995b6SPoul-Henning Kamp 
127d474440aSKonstantin Belousov extern const struct pagerops *pagertab[] __read_mostly;
1285f518366SJeff Roberson extern struct mtx_padalign pbuf_mtx;
12928f8db14SBruce Evans 
130cd853791SKonstantin Belousov /*
131cd853791SKonstantin Belousov  * Number of pages that pbuf buffer can store in b_pages.
132cd853791SKonstantin Belousov  * It is +1 to allow for unaligned data buffer of maxphys size.
133cd853791SKonstantin Belousov  */
134cd853791SKonstantin Belousov #define	PBUF_PAGES	(atop(maxphys) + 1)
135cd853791SKonstantin Belousov 
1363364c323SKonstantin Belousov vm_object_t vm_pager_allocate(objtype_t, void *, vm_ooffset_t, vm_prot_t,
1373364c323SKonstantin Belousov     vm_ooffset_t, struct ucred *);
13811caded3SAlfred Perlstein void vm_pager_bufferinit(void);
13911caded3SAlfred Perlstein void vm_pager_deallocate(vm_object_t);
140b0cd2017SGleb Smirnoff int vm_pager_get_pages(vm_object_t, vm_page_t *, int, int *, int *);
141b0cd2017SGleb Smirnoff int vm_pager_get_pages_async(vm_object_t, vm_page_t *, int, int *, int *,
142093ebe1dSGleb Smirnoff     pgo_getpages_iodone_t, void *);
14311caded3SAlfred Perlstein void vm_pager_init(void);
14411caded3SAlfred Perlstein vm_object_t vm_pager_object_lookup(struct pagerlst *, void *);
1451c7c3c6aSMatthew Dillon 
146e4542174SMatthew Dillon static __inline void
vm_pager_put_pages(vm_object_t object,vm_page_t * m,int count,int flags,int * rtvals)147ee4211bcSKonstantin Belousov vm_pager_put_pages(vm_object_t object, vm_page_t *m, int count, int flags,
148ee4211bcSKonstantin Belousov     int *rtvals)
149ee4211bcSKonstantin Belousov {
15089f6b863SAttilio Rao 	VM_OBJECT_ASSERT_WLOCKED(object);
151e4542174SMatthew Dillon 	(*pagertab[object->type]->pgo_putpages)
152e4542174SMatthew Dillon 	    (object, m, count, flags, rtvals);
1531c7c3c6aSMatthew Dillon }
1541c7c3c6aSMatthew Dillon 
15525db2c54SMatthew Dillon /*
15625db2c54SMatthew Dillon  *	vm_pager_haspage
15725db2c54SMatthew Dillon  *
15825db2c54SMatthew Dillon  *	Check to see if an object's pager has the requested page.  The
15925db2c54SMatthew Dillon  *	object's pager will also set before and after to give the caller
16025db2c54SMatthew Dillon  *	some idea of the number of pages before and after the requested
16125db2c54SMatthew Dillon  *	page can be I/O'd efficiently.
16225db2c54SMatthew Dillon  *
163cf51adc0SAlan Cox  *	The object must be locked.
16425db2c54SMatthew Dillon  */
1651c7c3c6aSMatthew Dillon static __inline boolean_t
vm_pager_has_page(vm_object_t object,vm_pindex_t offset,int * before,int * after)166ee4211bcSKonstantin Belousov vm_pager_has_page(vm_object_t object, vm_pindex_t offset, int *before,
167ee4211bcSKonstantin Belousov     int *after)
168ee4211bcSKonstantin Belousov {
16923955314SAlfred Perlstein 	boolean_t ret;
17023955314SAlfred Perlstein 
1714153054aSJeff Roberson 	VM_OBJECT_ASSERT_LOCKED(object);
17223955314SAlfred Perlstein 	ret = (*pagertab[object->type]->pgo_haspage)
17323955314SAlfred Perlstein 	    (object, offset, before, after);
17423955314SAlfred Perlstein 	return (ret);
1751c7c3c6aSMatthew Dillon }
1761c7c3c6aSMatthew Dillon 
177c42b43a0SKonstantin Belousov static __inline int
vm_pager_populate(vm_object_t object,vm_pindex_t pidx,int fault_type,vm_prot_t max_prot,vm_pindex_t * first,vm_pindex_t * last)178c42b43a0SKonstantin Belousov vm_pager_populate(vm_object_t object, vm_pindex_t pidx, int fault_type,
179c42b43a0SKonstantin Belousov     vm_prot_t max_prot, vm_pindex_t *first, vm_pindex_t *last)
180c42b43a0SKonstantin Belousov {
181c42b43a0SKonstantin Belousov 
182c42b43a0SKonstantin Belousov 	MPASS((object->flags & OBJ_POPULATE) != 0);
183c42b43a0SKonstantin Belousov 	MPASS(pidx < object->size);
184c99d0c58SMark Johnston 	MPASS(blockcount_read(&object->paging_in_progress) > 0);
185c42b43a0SKonstantin Belousov 	return ((*pagertab[object->type]->pgo_populate)(object, pidx,
186c42b43a0SKonstantin Belousov 	    fault_type, max_prot, first, last));
187c42b43a0SKonstantin Belousov }
188c42b43a0SKonstantin Belousov 
1891c7c3c6aSMatthew Dillon /*
1901c7c3c6aSMatthew Dillon  *      vm_pager_page_unswapped
1911c7c3c6aSMatthew Dillon  *
192cf51adc0SAlan Cox  *	Destroy swap associated with the page.
1931c7c3c6aSMatthew Dillon  *
194f976cfd9SPoul-Henning Kamp  *	XXX: A much better name would be "vm_pager_page_dirtied()"
195f976cfd9SPoul-Henning Kamp  *	XXX: It is not obvious if this could be profitably used by any
196f976cfd9SPoul-Henning Kamp  *	XXX: pagers besides the swap_pager or if it should even be a
197f976cfd9SPoul-Henning Kamp  *	XXX: generic pager_op in the first place.
1981c7c3c6aSMatthew Dillon  */
1991c7c3c6aSMatthew Dillon static __inline void
vm_pager_page_unswapped(vm_page_t m)2001c7c3c6aSMatthew Dillon vm_pager_page_unswapped(vm_page_t m)
2011c7c3c6aSMatthew Dillon {
202ee4211bcSKonstantin Belousov 	pgo_pageunswapped_t *method;
2032e3b314dSAlan Cox 
204ee4211bcSKonstantin Belousov 	method = pagertab[m->object->type]->pgo_pageunswapped;
205ee4211bcSKonstantin Belousov 	if (method != NULL)
206ee4211bcSKonstantin Belousov 		method(m);
2071c7c3c6aSMatthew Dillon }
2081c7c3c6aSMatthew Dillon 
209fe7bcbafSKyle Evans static __inline void
vm_pager_update_writecount(vm_object_t object,vm_offset_t start,vm_offset_t end)210fe7bcbafSKyle Evans vm_pager_update_writecount(vm_object_t object, vm_offset_t start,
211fe7bcbafSKyle Evans     vm_offset_t end)
212fe7bcbafSKyle Evans {
213ee4211bcSKonstantin Belousov 	pgo_writecount_t *method;
214fe7bcbafSKyle Evans 
215ee4211bcSKonstantin Belousov 	method = pagertab[object->type]->pgo_update_writecount;
216ee4211bcSKonstantin Belousov 	if (method != NULL)
217ee4211bcSKonstantin Belousov 		method(object, start, end);
218fe7bcbafSKyle Evans }
219fe7bcbafSKyle Evans 
220fe7bcbafSKyle Evans static __inline void
vm_pager_release_writecount(vm_object_t object,vm_offset_t start,vm_offset_t end)221fe7bcbafSKyle Evans vm_pager_release_writecount(vm_object_t object, vm_offset_t start,
222fe7bcbafSKyle Evans     vm_offset_t end)
223fe7bcbafSKyle Evans {
224ee4211bcSKonstantin Belousov 	pgo_writecount_t *method;
225fe7bcbafSKyle Evans 
226ee4211bcSKonstantin Belousov 	method = pagertab[object->type]->pgo_release_writecount;
227ee4211bcSKonstantin Belousov 	if (method != NULL)
228ee4211bcSKonstantin Belousov 		method(object, start, end);
229fe7bcbafSKyle Evans }
230fe7bcbafSKyle Evans 
231192112b7SKonstantin Belousov static __inline void
vm_pager_getvp(vm_object_t object,struct vnode ** vpp,bool * vp_heldp)232192112b7SKonstantin Belousov vm_pager_getvp(vm_object_t object, struct vnode **vpp, bool *vp_heldp)
233192112b7SKonstantin Belousov {
234192112b7SKonstantin Belousov 	pgo_getvp_t *method;
235192112b7SKonstantin Belousov 
236192112b7SKonstantin Belousov 	*vpp = NULL;
237a7c198a2SKonstantin Belousov 	if (vp_heldp != NULL)
238192112b7SKonstantin Belousov 		*vp_heldp = false;
239192112b7SKonstantin Belousov 	method = pagertab[object->type]->pgo_getvp;
240a7c198a2SKonstantin Belousov 	if (method != NULL)
241192112b7SKonstantin Belousov 		method(object, vpp, vp_heldp);
242192112b7SKonstantin Belousov }
243192112b7SKonstantin Belousov 
2441390a5cbSKonstantin Belousov static __inline void
vm_pager_freespace(vm_object_t object,vm_pindex_t start,vm_size_t size)2451390a5cbSKonstantin Belousov vm_pager_freespace(vm_object_t object, vm_pindex_t start,
2461390a5cbSKonstantin Belousov     vm_size_t size)
2471390a5cbSKonstantin Belousov {
2481390a5cbSKonstantin Belousov 	pgo_freespace_t *method;
2491390a5cbSKonstantin Belousov 
2501390a5cbSKonstantin Belousov 	method = pagertab[object->type]->pgo_freespace;
2511390a5cbSKonstantin Belousov 	if (method != NULL)
2521390a5cbSKonstantin Belousov 		method(object, start, size);
2531390a5cbSKonstantin Belousov }
2541390a5cbSKonstantin Belousov 
255d537d1f1SKonstantin Belousov static __inline void
vm_pager_page_inserted(vm_object_t object,vm_page_t m)256d537d1f1SKonstantin Belousov vm_pager_page_inserted(vm_object_t object, vm_page_t m)
257d537d1f1SKonstantin Belousov {
258d537d1f1SKonstantin Belousov 	pgo_page_inserted_t *method;
259d537d1f1SKonstantin Belousov 
260d537d1f1SKonstantin Belousov 	method = pagertab[object->type]->pgo_page_inserted;
261d537d1f1SKonstantin Belousov 	if (method != NULL)
262d537d1f1SKonstantin Belousov 		method(object, m);
263d537d1f1SKonstantin Belousov }
264d537d1f1SKonstantin Belousov 
265d537d1f1SKonstantin Belousov static __inline void
vm_pager_page_removed(vm_object_t object,vm_page_t m)266d537d1f1SKonstantin Belousov vm_pager_page_removed(vm_object_t object, vm_page_t m)
267d537d1f1SKonstantin Belousov {
268d537d1f1SKonstantin Belousov 	pgo_page_removed_t *method;
269d537d1f1SKonstantin Belousov 
270d537d1f1SKonstantin Belousov 	method = pagertab[object->type]->pgo_page_removed;
271d537d1f1SKonstantin Belousov 	if (method != NULL)
272d537d1f1SKonstantin Belousov 		method(object, m);
273d537d1f1SKonstantin Belousov }
274d537d1f1SKonstantin Belousov 
275ec201dddSKonstantin Belousov static __inline bool
vm_pager_can_alloc_page(vm_object_t object,vm_pindex_t pindex)276ec201dddSKonstantin Belousov vm_pager_can_alloc_page(vm_object_t object, vm_pindex_t pindex)
277ec201dddSKonstantin Belousov {
278ec201dddSKonstantin Belousov 	pgo_can_alloc_page_t *method;
279ec201dddSKonstantin Belousov 
280ec201dddSKonstantin Belousov 	method = pagertab[object->type]->pgo_can_alloc_page;
281ec201dddSKonstantin Belousov 	return (method != NULL ? method(object, pindex) : true);
282ec201dddSKonstantin Belousov }
283ec201dddSKonstantin Belousov 
284b730fd30SKonstantin Belousov int vm_pager_alloc_dyn_type(struct pagerops *ops, int base_type);
285b730fd30SKonstantin Belousov void vm_pager_free_dyn_type(objtype_t type);
286b730fd30SKonstantin Belousov 
287286790a7SKonstantin Belousov struct cdev_pager_ops {
288286790a7SKonstantin Belousov 	int (*cdev_pg_fault)(vm_object_t vm_obj, vm_ooffset_t offset,
289286790a7SKonstantin Belousov 	    int prot, vm_page_t *mres);
290c42b43a0SKonstantin Belousov 	int (*cdev_pg_populate)(vm_object_t vm_obj, vm_pindex_t pidx,
291c42b43a0SKonstantin Belousov 	    int fault_type, vm_prot_t max_prot, vm_pindex_t *first,
292c42b43a0SKonstantin Belousov 	    vm_pindex_t *last);
293286790a7SKonstantin Belousov 	int (*cdev_pg_ctor)(void *handle, vm_ooffset_t size, vm_prot_t prot,
294286790a7SKonstantin Belousov 	    vm_ooffset_t foff, struct ucred *cred, u_short *color);
295286790a7SKonstantin Belousov 	void (*cdev_pg_dtor)(void *handle);
296286790a7SKonstantin Belousov };
297286790a7SKonstantin Belousov 
298286790a7SKonstantin Belousov vm_object_t cdev_pager_allocate(void *handle, enum obj_type tp,
299d474440aSKonstantin Belousov     const struct cdev_pager_ops *ops, vm_ooffset_t size, vm_prot_t prot,
300286790a7SKonstantin Belousov     vm_ooffset_t foff, struct ucred *cred);
301286790a7SKonstantin Belousov vm_object_t cdev_pager_lookup(void *handle);
302286790a7SKonstantin Belousov void cdev_pager_free_page(vm_object_t object, vm_page_t m);
303*d48524e2SDoug Moore void cdev_mgtdev_pager_free_page(vm_object_t object, vm_page_t m);
304286790a7SKonstantin Belousov 
305a720b31cSKonstantin Belousov struct phys_pager_ops {
306a720b31cSKonstantin Belousov 	int (*phys_pg_getpages)(vm_object_t vm_obj, vm_page_t *m, int count,
307a720b31cSKonstantin Belousov 	    int *rbehind, int *rahead);
308a720b31cSKonstantin Belousov 	int (*phys_pg_populate)(vm_object_t vm_obj, vm_pindex_t pidx,
309a720b31cSKonstantin Belousov 	    int fault_type, vm_prot_t max_prot, vm_pindex_t *first,
310a720b31cSKonstantin Belousov 	    vm_pindex_t *last);
311a720b31cSKonstantin Belousov 	boolean_t (*phys_pg_haspage)(vm_object_t obj,  vm_pindex_t pindex,
312a720b31cSKonstantin Belousov 	    int *before, int *after);
313a720b31cSKonstantin Belousov 	void (*phys_pg_ctor)(vm_object_t vm_obj, vm_prot_t prot,
314a720b31cSKonstantin Belousov 	    vm_ooffset_t foff, struct ucred *cred);
315a720b31cSKonstantin Belousov 	void (*phys_pg_dtor)(vm_object_t vm_obj);
316a720b31cSKonstantin Belousov };
317d474440aSKonstantin Belousov extern const struct phys_pager_ops default_phys_pg_ops;
318d474440aSKonstantin Belousov vm_object_t phys_pager_allocate(void *handle, const struct phys_pager_ops *ops,
319a720b31cSKonstantin Belousov     void *data, vm_ooffset_t size, vm_prot_t prot, vm_ooffset_t foff,
320a720b31cSKonstantin Belousov     struct ucred *cred);
321a720b31cSKonstantin Belousov 
322a1287949SEivind Eklund #endif				/* _KERNEL */
323df8bae1dSRodney W. Grimes #endif				/* _VM_PAGER_ */
324