vm_pager.h revision 34206
180588Sobrien/*
280588Sobrien * Copyright (c) 1990 University of Utah.
3330569Sgordon * Copyright (c) 1991, 1993
480588Sobrien *	The Regents of the University of California.  All rights reserved.
580588Sobrien *
6330569Sgordon * This code is derived from software contributed to Berkeley by
780588Sobrien * the Systems Programming Group of the University of Utah Computer
880588Sobrien * Science Department.
980588Sobrien *
10186690Sobrien * Redistribution and use in source and binary forms, with or without
11186690Sobrien * modification, are permitted provided that the following conditions
1280588Sobrien * are met:
1380588Sobrien * 1. Redistributions of source code must retain the above copyright
1480588Sobrien *    notice, this list of conditions and the following disclaimer.
1580588Sobrien * 2. Redistributions in binary form must reproduce the above copyright
16186690Sobrien *    notice, this list of conditions and the following disclaimer in the
17186690Sobrien *    documentation and/or other materials provided with the distribution.
1880588Sobrien * 3. All advertising materials mentioning features or use of this software
1980588Sobrien *    must display the following acknowledgement:
2080588Sobrien *	This product includes software developed by the University of
2180588Sobrien *	California, Berkeley and its contributors.
22267843Sdelphij * 4. Neither the name of the University nor the names of its contributors
2380588Sobrien *    may be used to endorse or promote products derived from this software
24 *    without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 *
38 *	@(#)vm_pager.h	8.4 (Berkeley) 1/12/94
39 * $Id: vm_pager.h,v 1.15 1998/02/03 22:19:35 bde Exp $
40 */
41
42/*
43 * Pager routine interface definition.
44 */
45
46#ifndef	_VM_PAGER_
47#define	_VM_PAGER_
48
49#include <sys/queue.h>
50
51TAILQ_HEAD(pagerlst, vm_object);
52
53struct pagerops {
54	void (*pgo_init) __P((void));		/* Initialize pager. */
55	vm_object_t (*pgo_alloc) __P((void *, vm_size_t, vm_prot_t, vm_ooffset_t));	/* Allocate pager. */
56	void (*pgo_dealloc) __P((vm_object_t));	/* Disassociate. */
57	int (*pgo_getpages) __P((vm_object_t, vm_page_t *, int, int));	/* Get (read) page. */
58	int (*pgo_putpages) __P((vm_object_t, vm_page_t *, int, int, int *)); /* Put (write) page. */
59	boolean_t (*pgo_haspage) __P((vm_object_t, vm_pindex_t, int *, int *)); /* Does pager have page? */
60	void (*pgo_sync) __P((void));
61};
62
63/*
64 * get/put return values
65 * OK	 operation was successful
66 * BAD	 specified data was out of the accepted range
67 * FAIL	 specified data was in range, but doesn't exist
68 * PEND	 operations was initiated but not completed
69 * ERROR error while accessing data that is in range and exists
70 * AGAIN temporary resource shortage prevented operation from happening
71 */
72#define	VM_PAGER_OK	0
73#define	VM_PAGER_BAD	1
74#define	VM_PAGER_FAIL	2
75#define	VM_PAGER_PEND	3
76#define	VM_PAGER_ERROR	4
77#define VM_PAGER_AGAIN	5
78
79#define	VM_PAGER_PUT_SYNC	0x1
80#define	VM_PAGER_PUT_INVAL	0x2
81
82#ifdef KERNEL
83
84#ifdef MALLOC_DECLARE
85MALLOC_DECLARE(M_VMPGDATA);
86#endif
87
88extern vm_map_t pager_map;
89extern int pager_map_size;
90
91vm_object_t vm_pager_allocate __P((objtype_t, void *, vm_size_t, vm_prot_t, vm_ooffset_t));
92void vm_pager_bufferinit __P((void));
93void vm_pager_deallocate __P((vm_object_t));
94int vm_pager_get_pages __P((vm_object_t, vm_page_t *, int, int));
95boolean_t vm_pager_has_page __P((vm_object_t, vm_pindex_t, int *, int *));
96void vm_pager_init __P((void));
97vm_object_t vm_pager_object_lookup __P((struct pagerlst *, void *));
98vm_offset_t vm_pager_map_pages __P((vm_page_t *, int, boolean_t));
99vm_offset_t vm_pager_map_page __P((vm_page_t));
100int vm_pager_put_pages __P((vm_object_t, vm_page_t *, int, boolean_t, int *));
101void vm_pager_sync __P((void));
102void vm_pager_unmap_pages __P((vm_offset_t, int));
103void vm_pager_unmap_page __P((vm_offset_t));
104#endif
105
106#endif				/* _VM_PAGER_ */
107