xref: /netbsd-src/sys/uvm/uvm_pager.h (revision 812b46df753f8a23d5bd1349b849f13624ab20e0)
1*812b46dfSad /*	$NetBSD: uvm_pager.h,v 1.49 2020/05/19 22:22:15 ad Exp $	*/
2f2caacc7Smrg 
3f2caacc7Smrg /*
4f2caacc7Smrg  * Copyright (c) 1997 Charles D. Cranor and Washington University.
5f2caacc7Smrg  * All rights reserved.
6f2caacc7Smrg  *
7f2caacc7Smrg  * Redistribution and use in source and binary forms, with or without
8f2caacc7Smrg  * modification, are permitted provided that the following conditions
9f2caacc7Smrg  * are met:
10f2caacc7Smrg  * 1. Redistributions of source code must retain the above copyright
11f2caacc7Smrg  *    notice, this list of conditions and the following disclaimer.
12f2caacc7Smrg  * 2. Redistributions in binary form must reproduce the above copyright
13f2caacc7Smrg  *    notice, this list of conditions and the following disclaimer in the
14f2caacc7Smrg  *    documentation and/or other materials provided with the distribution.
15f2caacc7Smrg  *
16f2caacc7Smrg  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17f2caacc7Smrg  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18f2caacc7Smrg  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19f2caacc7Smrg  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20f2caacc7Smrg  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21f2caacc7Smrg  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22f2caacc7Smrg  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23f2caacc7Smrg  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24f2caacc7Smrg  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25f2caacc7Smrg  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
261f6b921cSmrg  *
271f6b921cSmrg  * from: Id: uvm_pager.h,v 1.1.2.14 1998/01/13 19:00:50 chuck Exp
28f2caacc7Smrg  */
29f2caacc7Smrg 
302f159a1bSmrg /*
312f159a1bSmrg  * Copyright (c) 1991, 1993
322f159a1bSmrg  *	The Regents of the University of California.  All rights reserved.
332f159a1bSmrg  *
342f159a1bSmrg  * This code is derived from software contributed to Berkeley by
352f159a1bSmrg  * the Systems Programming Group of the University of Utah Computer
362f159a1bSmrg  * Science Department.
372f159a1bSmrg  *
382f159a1bSmrg  * Redistribution and use in source and binary forms, with or without
392f159a1bSmrg  * modification, are permitted provided that the following conditions
402f159a1bSmrg  * are met:
412f159a1bSmrg  * 1. Redistributions of source code must retain the above copyright
422f159a1bSmrg  *    notice, this list of conditions and the following disclaimer.
432f159a1bSmrg  * 2. Redistributions in binary form must reproduce the above copyright
442f159a1bSmrg  *    notice, this list of conditions and the following disclaimer in the
452f159a1bSmrg  *    documentation and/or other materials provided with the distribution.
46aad01611Sagc  * 3. Neither the name of the University nor the names of its contributors
47aad01611Sagc  *    may be used to endorse or promote products derived from this software
48aad01611Sagc  *    without specific prior written permission.
49aad01611Sagc  *
50aad01611Sagc  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
51aad01611Sagc  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
52aad01611Sagc  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
53aad01611Sagc  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
54aad01611Sagc  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
55aad01611Sagc  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
56aad01611Sagc  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
57aad01611Sagc  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
58aad01611Sagc  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
59aad01611Sagc  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
60aad01611Sagc  * SUCH DAMAGE.
61aad01611Sagc  *
62aad01611Sagc  *	@(#)vm_pager.h	8.5 (Berkeley) 7/7/94
63aad01611Sagc  */
64aad01611Sagc 
65aad01611Sagc /*
66aad01611Sagc  * Copyright (c) 1990 University of Utah.
67aad01611Sagc  *
68aad01611Sagc  * This code is derived from software contributed to Berkeley by
69aad01611Sagc  * the Systems Programming Group of the University of Utah Computer
70aad01611Sagc  * Science Department.
71aad01611Sagc  *
72aad01611Sagc  * Redistribution and use in source and binary forms, with or without
73aad01611Sagc  * modification, are permitted provided that the following conditions
74aad01611Sagc  * are met:
75aad01611Sagc  * 1. Redistributions of source code must retain the above copyright
76aad01611Sagc  *    notice, this list of conditions and the following disclaimer.
77aad01611Sagc  * 2. Redistributions in binary form must reproduce the above copyright
78aad01611Sagc  *    notice, this list of conditions and the following disclaimer in the
79aad01611Sagc  *    documentation and/or other materials provided with the distribution.
80afca0358Schuck  * 3. Neither the name of the University nor the names of its contributors
812f159a1bSmrg  *    may be used to endorse or promote products derived from this software
822f159a1bSmrg  *    without specific prior written permission.
832f159a1bSmrg  *
842f159a1bSmrg  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
852f159a1bSmrg  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
862f159a1bSmrg  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
872f159a1bSmrg  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
882f159a1bSmrg  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
892f159a1bSmrg  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
902f159a1bSmrg  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
912f159a1bSmrg  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
922f159a1bSmrg  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
932f159a1bSmrg  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
942f159a1bSmrg  * SUCH DAMAGE.
952f159a1bSmrg  *
962f159a1bSmrg  *	@(#)vm_pager.h	8.5 (Berkeley) 7/7/94
972f159a1bSmrg  */
982f159a1bSmrg 
99021fdb64Sperry #ifndef _UVM_UVM_PAGER_H_
100021fdb64Sperry #define _UVM_UVM_PAGER_H_
101021fdb64Sperry 
102f2caacc7Smrg /*
103f2caacc7Smrg  * uvm_pager.h
104f2caacc7Smrg  */
105f2caacc7Smrg 
106f2caacc7Smrg /*
10764c6d1d2Schs  * forward structure declarations
10864c6d1d2Schs  */
10964c6d1d2Schs 
11064c6d1d2Schs struct uvm_faultinfo;
111b77712ddSchristos struct uvm_object;
11264c6d1d2Schs 
11364c6d1d2Schs /*
114f2caacc7Smrg  * pager ops
115f2caacc7Smrg  */
116f2caacc7Smrg 
117f2caacc7Smrg struct uvm_pagerops {
11864c6d1d2Schs 
11964c6d1d2Schs 	/* init pager */
120325f5482Sjunyoung 	void	(*pgo_init)(void);
12164c6d1d2Schs 
12264c6d1d2Schs 	/* add reference to obj */
12364c6d1d2Schs 	void	(*pgo_reference)(struct uvm_object *);
12464c6d1d2Schs 
12564c6d1d2Schs 	/* drop reference to obj */
12664c6d1d2Schs 	void	(*pgo_detach)(struct uvm_object *);
12764c6d1d2Schs 
12864c6d1d2Schs 	/* special non-standard fault processing */
12964c6d1d2Schs 	int	(*pgo_fault)(struct uvm_faultinfo *, vaddr_t, struct vm_page **,
1302d1a0b57Sdrochner 			     int, int, vm_prot_t, int);
13164c6d1d2Schs 
13264c6d1d2Schs 	/* get/read pages */
13364c6d1d2Schs 	int	(*pgo_get)(struct uvm_object *, voff_t, struct vm_page **,
13464c6d1d2Schs 			   int *, int, vm_prot_t, int, int);
13564c6d1d2Schs 
13664c6d1d2Schs 	/* put/write pages */
13764c6d1d2Schs 	int	(*pgo_put)(struct uvm_object *, voff_t, voff_t, int);
138da3ef92bSad 
139da3ef92bSad 	/* mark object dirty */
140da3ef92bSad 	void	(*pgo_markdirty)(struct uvm_object *);
141f2caacc7Smrg };
142f2caacc7Smrg 
143f2caacc7Smrg /* pager flags [mostly for flush] */
144f2caacc7Smrg 
145f2caacc7Smrg #define PGO_CLEANIT	0x001	/* write dirty pages to backing store */
146c65d708aSpooka #define PGO_SYNCIO	0x002	/* use sync I/O */
147f2caacc7Smrg #define PGO_DEACTIVATE	0x004	/* deactivate flushed pages */
148f2caacc7Smrg #define PGO_FREE	0x008	/* free flushed pages */
149aeda8d3bSchs /* if PGO_FREE is not set then the pages stay where they are. */
150f2caacc7Smrg 
151*812b46dfSad #define PGO_ALLPAGES	0x010	/* flush whole object [put] */
1522241f551Sjdolecek #define PGO_JOURNALLOCKED 0x020	/* journal is already locked [get/put] */
153f2caacc7Smrg #define PGO_LOCKED	0x040	/* fault data structures are locked [get] */
154b397c875Sperseant #define PGO_BUSYFAIL	0x080	/* fail if a page is busy [put] */
155aeda8d3bSchs #define PGO_OVERWRITE	0x200	/* pages will be overwritten before unlocked */
156f80ed589Schs #define PGO_PASTEOF	0x400	/* allow allocation of pages past EOF */
1572a6dc9d0Syamt #define PGO_NOBLOCKALLOC 0x800	/* backing block allocation is not needed */
158b7bfe828Syamt #define PGO_NOTIMESTAMP 0x1000	/* don't mark object accessed/modified */
159aba740b2Schs #define PGO_RECLAIM	0x2000	/* object is being reclaimed */
160fca58884Schs #define PGO_GLOCKHELD	0x4000	/* genfs_node's lock is already held */
1618306a9edSchs #define PGO_LAZY	0x8000	/* equivalent of MNT_LAZY / FSYNC_LAZY */
162f2caacc7Smrg 
163f2caacc7Smrg /* page we are not interested in getting */
164aeda8d3bSchs #define PGO_DONTCARE ((struct vm_page *) -1L)	/* [get only] */
165f2caacc7Smrg 
166abb48c5bSthorpej #ifdef _KERNEL
167abb48c5bSthorpej 
168f2caacc7Smrg /*
169f2caacc7Smrg  * prototypes
170f2caacc7Smrg  */
171f2caacc7Smrg 
172325f5482Sjunyoung void	uvm_pager_init(void);
173d289edb2Smatt void	uvm_pager_realloc_emerg(void);
174a3af4c15Syamt struct vm_page *uvm_pageratop(vaddr_t);
175325f5482Sjunyoung vaddr_t	uvm_pagermapin(struct vm_page **, int, int);
176325f5482Sjunyoung void	uvm_pagermapout(vaddr_t, int);
177f2caacc7Smrg 
17823005df1Syamt extern size_t pager_map_size;
17923005df1Syamt 
180655b21e1Sthorpej /* Flags to uvm_pagermapin() */
181655b21e1Sthorpej #define	UVMPAGER_MAPIN_WAITOK	0x01	/* it's okay to wait */
18264c6d1d2Schs #define	UVMPAGER_MAPIN_READ	0x02	/* device -> host */
18364c6d1d2Schs #define	UVMPAGER_MAPIN_WRITE	0x00	/* host -> device (pseudo flag) */
184655b21e1Sthorpej 
185abb48c5bSthorpej #endif /* _KERNEL */
186021fdb64Sperry 
187021fdb64Sperry #endif /* _UVM_UVM_PAGER_H_ */
188