Home | History | Annotate | Line # | Download | only in uvm
uvm_pager.h revision 1.7.2.2
      1 /*	$NetBSD: uvm_pager.h,v 1.7.2.2 1999/02/25 04:25:05 chs Exp $	*/
      2 
      3 /*
      4  * XXXCDC: "ROUGH DRAFT" QUALITY UVM PRE-RELEASE FILE!
      5  *	   >>>USE AT YOUR OWN RISK, WORK IS NOT FINISHED<<<
      6  */
      7 /*
      8  *
      9  * Copyright (c) 1997 Charles D. Cranor and Washington University.
     10  * All rights reserved.
     11  *
     12  * Redistribution and use in source and binary forms, with or without
     13  * modification, are permitted provided that the following conditions
     14  * are met:
     15  * 1. Redistributions of source code must retain the above copyright
     16  *    notice, this list of conditions and the following disclaimer.
     17  * 2. Redistributions in binary form must reproduce the above copyright
     18  *    notice, this list of conditions and the following disclaimer in the
     19  *    documentation and/or other materials provided with the distribution.
     20  * 3. All advertising materials mentioning features or use of this software
     21  *    must display the following acknowledgement:
     22  *      This product includes software developed by Charles D. Cranor and
     23  *      Washington University.
     24  * 4. The name of the author may not be used to endorse or promote products
     25  *    derived from this software without specific prior written permission.
     26  *
     27  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     28  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     29  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     30  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     31  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     32  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     33  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     34  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     35  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     36  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     37  *
     38  * from: Id: uvm_pager.h,v 1.1.2.14 1998/01/13 19:00:50 chuck Exp
     39  */
     40 
     41 #ifndef _UVM_UVM_PAGER_H_
     42 #define _UVM_UVM_PAGER_H_
     43 
     44 #include <sys/buf.h>
     45 
     46 /*
     47  * uvm_pager.h
     48  */
     49 
     50 /*
     51  * async pager i/o descriptor structure
     52  */
     53 
     54 TAILQ_HEAD(uvm_aiohead, uvm_aiodesc);
     55 
     56 struct uvm_aiodesc {
     57 	void (*aiodone) __P((struct uvm_aiodesc *));
     58 						/* aio done function */
     59 	vaddr_t kva;				/* KVA of mapped page(s) */
     60 	int npages;				/* # of pages in I/O req */
     61 	void *pd_ptr;				/* pager-dependent pointer */
     62 	TAILQ_ENTRY(uvm_aiodesc) aioq;		/* linked list of aio's */
     63 };
     64 
     65 struct uvm_aiobuf {
     66 	struct buf buf;
     67 	struct uvm_aiodesc aio;
     68 };
     69 
     70 /*
     71  * pager ops
     72  */
     73 
     74 struct uvm_pagerops {
     75 	void		(*pgo_init) __P((void));/* init pager */
     76 	struct uvm_object * (*pgo_attach)	/* get uvm_object */
     77 			__P((void *, vm_prot_t));
     78 	void		(*pgo_reference)	/* add reference to obj */
     79 			 __P((struct uvm_object *));
     80 	void			(*pgo_detach)	/* drop reference to obj */
     81 			 __P((struct uvm_object *));
     82 	int			(*pgo_fault)	/* special nonstd fault fn */
     83 			 __P((struct uvm_faultinfo *, vaddr_t,
     84 				 vm_page_t *, int, int, vm_fault_t,
     85 				 vm_prot_t, int));
     86 	boolean_t		(*pgo_flush)	/* flush pages out of obj */
     87 			 __P((struct uvm_object *, vaddr_t,
     88 				vaddr_t, int));
     89 	int			(*pgo_get)	/* get/read page */
     90 			 __P((struct uvm_object *, vaddr_t,
     91 				 vm_page_t *, int *, int, vm_prot_t, int, int));
     92 	int			(*pgo_asyncget)	/* start async get */
     93 			 __P((struct uvm_object *, vaddr_t, int));
     94 	int			(*pgo_put)	/* put/write page */
     95 			 __P((struct uvm_object *, vm_page_t *,
     96 				 int, boolean_t));
     97 	void			(*pgo_cluster)	/* return range of cluster */
     98 			__P((struct uvm_object *, vaddr_t, vaddr_t *,
     99 				vaddr_t *));
    100 	struct vm_page **	(*pgo_mk_pcluster)	/* make "put" cluster */
    101 			 __P((struct uvm_object *, struct vm_page **,
    102 				 int *, struct vm_page *, int, vaddr_t,
    103 				 vaddr_t));
    104 	void			(*pgo_shareprot)	/* share protect */
    105 			 __P((vm_map_entry_t, vm_prot_t));
    106 	void			(*pgo_aiodone)		/* async iodone */
    107 			 __P((struct uvm_aiodesc *));
    108 	boolean_t		(*pgo_releasepg)	/* release page */
    109 			 __P((struct vm_page *, struct vm_page **));
    110 };
    111 
    112 /* pager flags [mostly for flush] */
    113 
    114 #define PGO_CLEANIT	0x001	/* write dirty pages to backing store */
    115 #define PGO_SYNCIO	0x002	/* if PGO_CLEAN: use sync I/O? */
    116 /*
    117  * obviously if neither PGO_INVALIDATE or PGO_FREE are set then the pages
    118  * stay where they are.
    119  */
    120 #define PGO_DEACTIVATE	0x004	/* deactivate flushed pages */
    121 #define PGO_FREE	0x008	/* free flushed pages */
    122 
    123 #define PGO_ALLPAGES	0x010	/* flush whole object/get all pages */
    124 #define PGO_DOACTCLUST	0x020	/* flag to mk_pcluster to include active */
    125 #define PGO_LOCKED	0x040	/* fault data structures are locked [get] */
    126 #define PGO_PDFREECLUST	0x080	/* daemon's free cluster flag [uvm_pager_put] */
    127 #define PGO_REALLOCSWAP	0x100	/* reallocate swap area [pager_dropcluster] */
    128 
    129 #define PGO_OVERWRITE	0x200	/* page will be overwritten immediately */
    130 
    131 /* page we are not interested in getting */
    132 #define PGO_DONTCARE ((struct vm_page *) -1)	/* [get only] */
    133 
    134 /*
    135  * handle inline options
    136  */
    137 
    138 #ifdef UVM_PAGER_INLINE
    139 #define PAGER_INLINE static __inline
    140 #else
    141 #define PAGER_INLINE /* nothing */
    142 #endif /* UVM_PAGER_INLINE */
    143 
    144 /*
    145  * prototypes
    146  */
    147 
    148 void		uvm_pager_dropcluster __P((struct uvm_object *,
    149 					struct vm_page *, struct vm_page **,
    150 					int *, int, int));
    151 void		uvm_pager_init __P((void));
    152 int		uvm_pager_put __P((struct uvm_object *, struct vm_page *,
    153 				   struct vm_page ***, int *, int,
    154 				   vaddr_t, vaddr_t));
    155 
    156 PAGER_INLINE struct vm_page *uvm_pageratop __P((vaddr_t));
    157 
    158 vaddr_t	uvm_pagermapin __P((struct vm_page **, int,
    159 				    struct uvm_aiodesc **, int));
    160 void		uvm_pagermapout __P((vaddr_t, int));
    161 struct vm_page **uvm_mk_pcluster  __P((struct uvm_object *, struct vm_page **,
    162 				       int *, struct vm_page *, int,
    163 				       vaddr_t, vaddr_t));
    164 void		uvm_shareprot __P((vm_map_entry_t, vm_prot_t));
    165 
    166 
    167 #endif /* _UVM_UVM_PAGER_H_ */
    168