vm_pager.h revision 34206
191100Sdes/*
291100Sdes * Copyright (c) 1990 University of Utah.
392289Sdes * Copyright (c) 1991, 1993
491100Sdes *	The Regents of the University of California.  All rights reserved.
591100Sdes *
691100Sdes * This code is derived from software contributed to Berkeley by
799158Sdes * the Systems Programming Group of the University of Utah Computer
899158Sdes * Science Department.
999158Sdes *
1091100Sdes * Redistribution and use in source and binary forms, with or without
1191100Sdes * modification, are permitted provided that the following conditions
1291100Sdes * are met:
1391100Sdes * 1. Redistributions of source code must retain the above copyright
1491100Sdes *    notice, this list of conditions and the following disclaimer.
1591100Sdes * 2. Redistributions in binary form must reproduce the above copyright
1691100Sdes *    notice, this list of conditions and the following disclaimer in the
1791100Sdes *    documentation and/or other materials provided with the distribution.
1891100Sdes * 3. All advertising materials mentioning features or use of this software
1991100Sdes *    must display the following acknowledgement:
2091100Sdes *	This product includes software developed by the University of
2191100Sdes *	California, Berkeley and its contributors.
2291100Sdes * 4. Neither the name of the University nor the names of its contributors
2391100Sdes *    may be used to endorse or promote products derived from this software
2491100Sdes *    without specific prior written permission.
2591100Sdes *
2691100Sdes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2791100Sdes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2891100Sdes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2991100Sdes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
3091100Sdes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3191100Sdes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3291100Sdes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3391100Sdes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3491100Sdes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35108794Sdes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3691100Sdes * SUCH DAMAGE.
3791100Sdes *
3891100Sdes *	@(#)vm_pager.h	8.4 (Berkeley) 1/12/94
3991100Sdes * $Id: vm_pager.h,v 1.15 1998/02/03 22:19:35 bde Exp $
4099158Sdes */
4191100Sdes
4291100Sdes/*
4391100Sdes * Pager routine interface definition.
4499158Sdes */
4599158Sdes
4699158Sdes#ifndef	_VM_PAGER_
4799158Sdes#define	_VM_PAGER_
4899158Sdes
4999158Sdes#include <sys/queue.h>
5099158Sdes
5199158SdesTAILQ_HEAD(pagerlst, vm_object);
5299158Sdes
5399158Sdesstruct pagerops {
5499158Sdes	void (*pgo_init) __P((void));		/* Initialize pager. */
5599158Sdes	vm_object_t (*pgo_alloc) __P((void *, vm_size_t, vm_prot_t, vm_ooffset_t));	/* Allocate pager. */
5699158Sdes	void (*pgo_dealloc) __P((vm_object_t));	/* Disassociate. */
5799158Sdes	int (*pgo_getpages) __P((vm_object_t, vm_page_t *, int, int));	/* Get (read) page. */
5899158Sdes	int (*pgo_putpages) __P((vm_object_t, vm_page_t *, int, int, int *)); /* Put (write) page. */
5999158Sdes	boolean_t (*pgo_haspage) __P((vm_object_t, vm_pindex_t, int *, int *)); /* Does pager have page? */
6099158Sdes	void (*pgo_sync) __P((void));
6199158Sdes};
6299158Sdes
6399158Sdes/*
6499158Sdes * get/put return values
6599158Sdes * OK	 operation was successful
6699158Sdes * BAD	 specified data was out of the accepted range
6799158Sdes * FAIL	 specified data was in range, but doesn't exist
6899158Sdes * PEND	 operations was initiated but not completed
6999158Sdes * ERROR error while accessing data that is in range and exists
7099158Sdes * AGAIN temporary resource shortage prevented operation from happening
7199158Sdes */
7299158Sdes#define	VM_PAGER_OK	0
7399158Sdes#define	VM_PAGER_BAD	1
7499158Sdes#define	VM_PAGER_FAIL	2
7599158Sdes#define	VM_PAGER_PEND	3
7699158Sdes#define	VM_PAGER_ERROR	4
7799158Sdes#define VM_PAGER_AGAIN	5
7899158Sdes
7999158Sdes#define	VM_PAGER_PUT_SYNC	0x1
8091100Sdes#define	VM_PAGER_PUT_INVAL	0x2
8191100Sdes
8291100Sdes#ifdef KERNEL
8391100Sdes
8491100Sdes#ifdef MALLOC_DECLARE
8591100SdesMALLOC_DECLARE(M_VMPGDATA);
8691100Sdes#endif
8791100Sdes
8891100Sdesextern vm_map_t pager_map;
8991100Sdesextern int pager_map_size;
9091100Sdes
9191100Sdesvm_object_t vm_pager_allocate __P((objtype_t, void *, vm_size_t, vm_prot_t, vm_ooffset_t));
9291100Sdesvoid vm_pager_bufferinit __P((void));
9391100Sdesvoid vm_pager_deallocate __P((vm_object_t));
9491100Sdesint vm_pager_get_pages __P((vm_object_t, vm_page_t *, int, int));
9591100Sdesboolean_t vm_pager_has_page __P((vm_object_t, vm_pindex_t, int *, int *));
9691100Sdesvoid vm_pager_init __P((void));
9791100Sdesvm_object_t vm_pager_object_lookup __P((struct pagerlst *, void *));
9891100Sdesvm_offset_t vm_pager_map_pages __P((vm_page_t *, int, boolean_t));
9991100Sdesvm_offset_t vm_pager_map_page __P((vm_page_t));
10091100Sdesint vm_pager_put_pages __P((vm_object_t, vm_page_t *, int, boolean_t, int *));
10191100Sdesvoid vm_pager_sync __P((void));
10291100Sdesvoid vm_pager_unmap_pages __P((vm_offset_t, int));
10391100Sdesvoid vm_pager_unmap_page __P((vm_offset_t));
10491100Sdes#endif
10591100Sdes
10691100Sdes#endif				/* _VM_PAGER_ */
10791100Sdes