Home | History | Annotate | Line # | Download | only in uvm
uvm_pager.h revision 1.10.2.1
      1  1.10.2.1   bouyer /*	$NetBSD: uvm_pager.h,v 1.10.2.1 2000/11/20 18:12:04 bouyer Exp $	*/
      2       1.1      mrg 
      3       1.1      mrg /*
      4       1.1      mrg  *
      5       1.1      mrg  * Copyright (c) 1997 Charles D. Cranor and Washington University.
      6       1.1      mrg  * All rights reserved.
      7       1.1      mrg  *
      8       1.1      mrg  * Redistribution and use in source and binary forms, with or without
      9       1.1      mrg  * modification, are permitted provided that the following conditions
     10       1.1      mrg  * are met:
     11       1.1      mrg  * 1. Redistributions of source code must retain the above copyright
     12       1.1      mrg  *    notice, this list of conditions and the following disclaimer.
     13       1.1      mrg  * 2. Redistributions in binary form must reproduce the above copyright
     14       1.1      mrg  *    notice, this list of conditions and the following disclaimer in the
     15       1.1      mrg  *    documentation and/or other materials provided with the distribution.
     16       1.1      mrg  * 3. All advertising materials mentioning features or use of this software
     17       1.1      mrg  *    must display the following acknowledgement:
     18       1.1      mrg  *      This product includes software developed by Charles D. Cranor and
     19       1.1      mrg  *      Washington University.
     20       1.1      mrg  * 4. The name of the author may not be used to endorse or promote products
     21       1.1      mrg  *    derived from this software without specific prior written permission.
     22       1.1      mrg  *
     23       1.1      mrg  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     24       1.1      mrg  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     25       1.1      mrg  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     26       1.1      mrg  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     27       1.1      mrg  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     28       1.1      mrg  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     29       1.1      mrg  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     30       1.1      mrg  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     31       1.1      mrg  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     32       1.1      mrg  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     33       1.3      mrg  *
     34       1.3      mrg  * from: Id: uvm_pager.h,v 1.1.2.14 1998/01/13 19:00:50 chuck Exp
     35       1.1      mrg  */
     36       1.1      mrg 
     37  1.10.2.1   bouyer /*
     38  1.10.2.1   bouyer  * Copyright (c) 1990 University of Utah.
     39  1.10.2.1   bouyer  * Copyright (c) 1991, 1993
     40  1.10.2.1   bouyer  *	The Regents of the University of California.  All rights reserved.
     41  1.10.2.1   bouyer  *
     42  1.10.2.1   bouyer  * This code is derived from software contributed to Berkeley by
     43  1.10.2.1   bouyer  * the Systems Programming Group of the University of Utah Computer
     44  1.10.2.1   bouyer  * Science Department.
     45  1.10.2.1   bouyer  *
     46  1.10.2.1   bouyer  * Redistribution and use in source and binary forms, with or without
     47  1.10.2.1   bouyer  * modification, are permitted provided that the following conditions
     48  1.10.2.1   bouyer  * are met:
     49  1.10.2.1   bouyer  * 1. Redistributions of source code must retain the above copyright
     50  1.10.2.1   bouyer  *    notice, this list of conditions and the following disclaimer.
     51  1.10.2.1   bouyer  * 2. Redistributions in binary form must reproduce the above copyright
     52  1.10.2.1   bouyer  *    notice, this list of conditions and the following disclaimer in the
     53  1.10.2.1   bouyer  *    documentation and/or other materials provided with the distribution.
     54  1.10.2.1   bouyer  * 3. All advertising materials mentioning features or use of this software
     55  1.10.2.1   bouyer  *    must display the following acknowledgement:
     56  1.10.2.1   bouyer  *	This product includes software developed by the University of
     57  1.10.2.1   bouyer  *	California, Berkeley and its contributors.
     58  1.10.2.1   bouyer  * 4. Neither the name of the University nor the names of its contributors
     59  1.10.2.1   bouyer  *    may be used to endorse or promote products derived from this software
     60  1.10.2.1   bouyer  *    without specific prior written permission.
     61  1.10.2.1   bouyer  *
     62  1.10.2.1   bouyer  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     63  1.10.2.1   bouyer  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     64  1.10.2.1   bouyer  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     65  1.10.2.1   bouyer  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     66  1.10.2.1   bouyer  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     67  1.10.2.1   bouyer  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     68  1.10.2.1   bouyer  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     69  1.10.2.1   bouyer  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     70  1.10.2.1   bouyer  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     71  1.10.2.1   bouyer  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     72  1.10.2.1   bouyer  * SUCH DAMAGE.
     73  1.10.2.1   bouyer  *
     74  1.10.2.1   bouyer  *	@(#)vm_pager.h	8.5 (Berkeley) 7/7/94
     75  1.10.2.1   bouyer  */
     76  1.10.2.1   bouyer 
     77       1.4    perry #ifndef _UVM_UVM_PAGER_H_
     78       1.4    perry #define _UVM_UVM_PAGER_H_
     79       1.4    perry 
     80       1.1      mrg /*
     81       1.1      mrg  * uvm_pager.h
     82       1.1      mrg  */
     83       1.1      mrg 
     84       1.1      mrg /*
     85       1.1      mrg  * async pager i/o descriptor structure
     86       1.1      mrg  */
     87       1.1      mrg 
     88       1.1      mrg TAILQ_HEAD(uvm_aiohead, uvm_aiodesc);
     89       1.1      mrg 
     90       1.1      mrg struct uvm_aiodesc {
     91       1.6      mrg 	void (*aiodone) __P((struct uvm_aiodesc *));
     92       1.6      mrg 						/* aio done function */
     93       1.7      eeh 	vaddr_t kva;			/* KVA of mapped page(s) */
     94       1.6      mrg 	int npages;				/* # of pages in I/O req */
     95       1.6      mrg 	void *pd_ptr;				/* pager-dependent pointer */
     96       1.6      mrg 	TAILQ_ENTRY(uvm_aiodesc) aioq;		/* linked list of aio's */
     97       1.1      mrg };
     98       1.1      mrg 
     99       1.1      mrg /*
    100       1.1      mrg  * pager ops
    101       1.1      mrg  */
    102       1.1      mrg 
    103       1.1      mrg struct uvm_pagerops {
    104       1.6      mrg 	void		(*pgo_init) __P((void));/* init pager */
    105       1.6      mrg 	void		(*pgo_reference)	/* add reference to obj */
    106       1.6      mrg 			 __P((struct uvm_object *));
    107       1.6      mrg 	void			(*pgo_detach)	/* drop reference to obj */
    108       1.6      mrg 			 __P((struct uvm_object *));
    109       1.6      mrg 	int			(*pgo_fault)	/* special nonstd fault fn */
    110       1.7      eeh 			 __P((struct uvm_faultinfo *, vaddr_t,
    111       1.1      mrg 				 vm_page_t *, int, int, vm_fault_t,
    112       1.1      mrg 				 vm_prot_t, int));
    113       1.6      mrg 	boolean_t		(*pgo_flush)	/* flush pages out of obj */
    114  1.10.2.1   bouyer 			 __P((struct uvm_object *, voff_t, voff_t, int));
    115       1.6      mrg 	int			(*pgo_get)	/* get/read page */
    116  1.10.2.1   bouyer 			 __P((struct uvm_object *, voff_t,
    117       1.1      mrg 				 vm_page_t *, int *, int, vm_prot_t, int, int));
    118       1.6      mrg 	int			(*pgo_asyncget)	/* start async get */
    119  1.10.2.1   bouyer 			 __P((struct uvm_object *, voff_t, int));
    120       1.6      mrg 	int			(*pgo_put)	/* put/write page */
    121       1.6      mrg 			 __P((struct uvm_object *, vm_page_t *,
    122       1.1      mrg 				 int, boolean_t));
    123       1.6      mrg 	void			(*pgo_cluster)	/* return range of cluster */
    124  1.10.2.1   bouyer 			__P((struct uvm_object *, voff_t, voff_t *,
    125  1.10.2.1   bouyer 				voff_t *));
    126       1.6      mrg 	struct vm_page **	(*pgo_mk_pcluster)	/* make "put" cluster */
    127       1.6      mrg 			 __P((struct uvm_object *, struct vm_page **,
    128  1.10.2.1   bouyer 				 int *, struct vm_page *, int, voff_t,
    129  1.10.2.1   bouyer 				 voff_t));
    130       1.6      mrg 	void			(*pgo_aiodone)		/* async iodone */
    131       1.6      mrg 			 __P((struct uvm_aiodesc *));
    132       1.6      mrg 	boolean_t		(*pgo_releasepg)	/* release page */
    133       1.6      mrg 			 __P((struct vm_page *, struct vm_page **));
    134       1.1      mrg };
    135       1.1      mrg 
    136       1.1      mrg /* pager flags [mostly for flush] */
    137       1.1      mrg 
    138       1.1      mrg #define PGO_CLEANIT	0x001	/* write dirty pages to backing store */
    139       1.1      mrg #define PGO_SYNCIO	0x002	/* if PGO_CLEAN: use sync I/O? */
    140       1.1      mrg /*
    141       1.1      mrg  * obviously if neither PGO_INVALIDATE or PGO_FREE are set then the pages
    142       1.1      mrg  * stay where they are.
    143       1.1      mrg  */
    144       1.1      mrg #define PGO_DEACTIVATE	0x004	/* deactivate flushed pages */
    145       1.1      mrg #define PGO_FREE	0x008	/* free flushed pages */
    146       1.1      mrg 
    147       1.1      mrg #define PGO_ALLPAGES	0x010	/* flush whole object/get all pages */
    148       1.1      mrg #define PGO_DOACTCLUST	0x020	/* flag to mk_pcluster to include active */
    149       1.1      mrg #define PGO_LOCKED	0x040	/* fault data structures are locked [get] */
    150       1.1      mrg #define PGO_PDFREECLUST	0x080	/* daemon's free cluster flag [uvm_pager_put] */
    151       1.1      mrg #define PGO_REALLOCSWAP	0x100	/* reallocate swap area [pager_dropcluster] */
    152       1.1      mrg 
    153       1.1      mrg /* page we are not interested in getting */
    154       1.1      mrg #define PGO_DONTCARE ((struct vm_page *) -1)	/* [get only] */
    155       1.1      mrg 
    156      1.10  thorpej #ifdef _KERNEL
    157      1.10  thorpej 
    158       1.1      mrg /*
    159       1.1      mrg  * handle inline options
    160       1.1      mrg  */
    161       1.1      mrg 
    162       1.1      mrg #ifdef UVM_PAGER_INLINE
    163       1.1      mrg #define PAGER_INLINE static __inline
    164       1.1      mrg #else
    165       1.1      mrg #define PAGER_INLINE /* nothing */
    166       1.1      mrg #endif /* UVM_PAGER_INLINE */
    167       1.1      mrg 
    168       1.1      mrg /*
    169       1.1      mrg  * prototypes
    170       1.1      mrg  */
    171       1.1      mrg 
    172       1.1      mrg void		uvm_pager_dropcluster __P((struct uvm_object *,
    173       1.1      mrg 					struct vm_page *, struct vm_page **,
    174  1.10.2.1   bouyer 					int *, int));
    175       1.1      mrg void		uvm_pager_init __P((void));
    176       1.1      mrg int		uvm_pager_put __P((struct uvm_object *, struct vm_page *,
    177       1.1      mrg 				   struct vm_page ***, int *, int,
    178  1.10.2.1   bouyer 				   voff_t, voff_t));
    179       1.1      mrg 
    180       1.7      eeh PAGER_INLINE struct vm_page *uvm_pageratop __P((vaddr_t));
    181       1.1      mrg 
    182       1.7      eeh vaddr_t	uvm_pagermapin __P((struct vm_page **, int,
    183       1.1      mrg 				    struct uvm_aiodesc **, int));
    184       1.7      eeh void		uvm_pagermapout __P((vaddr_t, int));
    185       1.1      mrg struct vm_page **uvm_mk_pcluster  __P((struct uvm_object *, struct vm_page **,
    186       1.1      mrg 				       int *, struct vm_page *, int,
    187  1.10.2.1   bouyer 				       voff_t, voff_t));
    188  1.10.2.1   bouyer 
    189  1.10.2.1   bouyer /* Flags to uvm_pagermapin() */
    190  1.10.2.1   bouyer #define	UVMPAGER_MAPIN_WAITOK	0x01	/* it's okay to wait */
    191  1.10.2.1   bouyer #define	UVMPAGER_MAPIN_READ	0x02	/* host <- device */
    192  1.10.2.1   bouyer #define	UVMPAGER_MAPIN_WRITE	0x00	/* device -> host (pseudo flag) */
    193  1.10.2.1   bouyer 
    194  1.10.2.1   bouyer /*
    195  1.10.2.1   bouyer  * get/put return values
    196  1.10.2.1   bouyer  * OK	   operation was successful
    197  1.10.2.1   bouyer  * BAD	   specified data was out of the accepted range
    198  1.10.2.1   bouyer  * FAIL	   specified data was in range, but doesn't exist
    199  1.10.2.1   bouyer  * PEND	   operations was initiated but not completed
    200  1.10.2.1   bouyer  * ERROR   error while accessing data that is in range and exists
    201  1.10.2.1   bouyer  * AGAIN   temporary resource shortage prevented operation from happening
    202  1.10.2.1   bouyer  * UNLOCK  unlock the map and try again
    203  1.10.2.1   bouyer  * REFAULT [uvm_fault internal use only!] unable to relock data structures,
    204  1.10.2.1   bouyer  *         thus the mapping needs to be reverified before we can procede
    205  1.10.2.1   bouyer  */
    206  1.10.2.1   bouyer #define	VM_PAGER_OK		0
    207  1.10.2.1   bouyer #define	VM_PAGER_BAD		1
    208  1.10.2.1   bouyer #define	VM_PAGER_FAIL		2
    209  1.10.2.1   bouyer #define	VM_PAGER_PEND		3
    210  1.10.2.1   bouyer #define	VM_PAGER_ERROR		4
    211  1.10.2.1   bouyer #define VM_PAGER_AGAIN		5
    212  1.10.2.1   bouyer #define VM_PAGER_UNLOCK		6
    213  1.10.2.1   bouyer #define VM_PAGER_REFAULT	7
    214       1.1      mrg 
    215      1.10  thorpej #endif /* _KERNEL */
    216       1.4    perry 
    217       1.4    perry #endif /* _UVM_UVM_PAGER_H_ */
    218