Home | History | Annotate | Line # | Download | only in uvm
uvm.h revision 1.7
      1 /*	$NetBSD: uvm.h,v 1.7 1998/05/18 15:00:50 pk 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  *
     10  * Copyright (c) 1997 Charles D. Cranor and Washington University.
     11  * All rights reserved.
     12  *
     13  * Redistribution and use in source and binary forms, with or without
     14  * modification, are permitted provided that the following conditions
     15  * are met:
     16  * 1. Redistributions of source code must retain the above copyright
     17  *    notice, this list of conditions and the following disclaimer.
     18  * 2. Redistributions in binary form must reproduce the above copyright
     19  *    notice, this list of conditions and the following disclaimer in the
     20  *    documentation and/or other materials provided with the distribution.
     21  * 3. All advertising materials mentioning features or use of this software
     22  *    must display the following acknowledgement:
     23  *      This product includes software developed by Charles D. Cranor and
     24  *      Washington University.
     25  * 4. The name of the author may not be used to endorse or promote products
     26  *    derived from this software without specific prior written permission.
     27  *
     28  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     29  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     30  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     31  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     32  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     33  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     34  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     35  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     36  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     37  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     38  *
     39  * from: Id: uvm.h,v 1.1.2.14 1998/02/02 20:07:19 chuck Exp
     40  */
     41 
     42 #ifndef _UVM_UVM_H_
     43 #define _UVM_UVM_H_
     44 
     45 #include "opt_uvmhist.h"
     46 
     47 #include <uvm/uvm_extern.h>
     48 
     49 #include <uvm/uvm_stat.h>
     50 
     51 /*
     52  * pull in prototypes
     53  */
     54 
     55 #include <uvm/uvm_amap.h>
     56 #include <uvm/uvm_aobj.h>
     57 #include <uvm/uvm_fault.h>
     58 #include <uvm/uvm_glue.h>
     59 #include <uvm/uvm_km.h>
     60 #include <uvm/uvm_loan.h>
     61 #include <uvm/uvm_map.h>
     62 #include <uvm/uvm_object.h>
     63 #include <uvm/uvm_page.h>
     64 #include <uvm/uvm_pager.h>
     65 #include <uvm/uvm_pdaemon.h>
     66 #include <uvm/uvm_swap.h>
     67 
     68 /*
     69  * uvm structure (vm global state: collected in one structure for ease
     70  * of reference...)
     71  */
     72 
     73 struct uvm {
     74 	/* vm_page related parameters */
     75 		/* vm_page queues */
     76 	struct pglist page_free;	/* unallocated pages */
     77 	struct pglist page_active;	/* allocated pages, in use */
     78 	struct pglist page_inactive_swp;/* pages inactive (reclaim or free) */
     79 	struct pglist page_inactive_obj;/* pages inactive (reclaim or free) */
     80 	simple_lock_data_t pageqlock;	/* lock for active/inactive page q */
     81 	simple_lock_data_t fpageqlock;	/* lock for free page q */
     82 		/* page daemon trigger */
     83 	int pagedaemon;			/* daemon sleeps on this */
     84 	struct proc *pagedaemon_proc;	/* daemon's pid */
     85 	simple_lock_data_t pagedaemon_lock;
     86 		/* page hash */
     87 	struct pglist *page_hash;	/* page hash table (vp/off->page) */
     88 	int page_nhash;			/* number of buckets */
     89 	int page_hashmask;		/* hash mask */
     90 	simple_lock_data_t hashlock;	/* lock on page_hash array */
     91 	/* anon stuff */
     92 	struct vm_anon *afree;		/* anon free list */
     93 	simple_lock_data_t afreelock; 	/* lock on anon free list */
     94 
     95 	/* static kernel map entry pool */
     96 	vm_map_entry_t kentry_free;	/* free page pool */
     97 	simple_lock_data_t kentry_lock;
     98 
     99 	/* aio_done is locked by uvm.pagedaemon_lock and splbio! */
    100 	struct uvm_aiohead aio_done;	/* done async i/o reqs */
    101 
    102 	/* pager VM area bounds */
    103 	vm_offset_t pager_sva;		/* start of pager VA area */
    104 	vm_offset_t pager_eva;		/* end of pager VA area */
    105 
    106 	/* kernel object: to support anonymous pageable kernel memory */
    107 	struct uvm_object *kernel_object;
    108 };
    109 
    110 extern struct uvm uvm;
    111 
    112 /*
    113  * historys
    114  */
    115 
    116 UVMHIST_DECL(maphist);
    117 UVMHIST_DECL(pdhist);
    118 
    119 /*
    120  * vm_map_entry etype bits:
    121  */
    122 
    123 #define UVM_ET_OBJ		0x01	/* it is a uvm_object */
    124 #define UVM_ET_MAP		0x02	/* it is a vm_map */
    125 #define UVM_ET_SUBMAP		0x04	/* it is a submap (MAP must be 1 too) */
    126 #define UVM_ET_COPYONWRITE 	0x08	/* copy_on_write */
    127 #define UVM_ET_NEEDSCOPY	0x10	/* needs_copy */
    128 
    129 #define UVM_ET_ISOBJ(E)		(((E)->etype & UVM_ET_OBJ) != 0)
    130 #define UVM_ET_ISMAP(E)		(((E)->etype & UVM_ET_MAP) != 0)
    131 #define UVM_ET_ISSUBMAP(E)	(((E)->etype & UVM_ET_SUBMAP) != 0)
    132 #define UVM_ET_ISCOPYONWRITE(E)	(((E)->etype & UVM_ET_COPYONWRITE) != 0)
    133 #define UVM_ET_ISNEEDSCOPY(E)	(((E)->etype & UVM_ET_NEEDSCOPY) != 0)
    134 
    135 /*
    136  * macros
    137  */
    138 
    139 /*
    140  * UVM_UNLOCK_AND_WAIT: atomic unlock+wait... front end for the
    141  * (poorly named) thread_sleep_msg function.
    142  */
    143 
    144 #if NCPU > 1 || defined(LOCKDEBUG)
    145 
    146 #define UVM_UNLOCK_AND_WAIT(event,lock,intr,msg, timo) \
    147 	thread_sleep_msg(event,lock,intr,msg, timo)
    148 
    149 #else
    150 
    151 #define UVM_UNLOCK_AND_WAIT(event,lock,intr,msg, timo) \
    152 	thread_sleep_msg(event,NULL,intr,msg, timo)
    153 
    154 #endif
    155 
    156 /*
    157  * UVM_PAGE_OWN: track page ownership (only if UVM_PAGE_TRKOWN)
    158  */
    159 
    160 #if defined(UVM_PAGE_TRKOWN)
    161 
    162 #define UVM_PAGE_OWN(PG, TAG) uvm_page_own(PG, TAG)
    163 
    164 #else /* UVM_PAGE_TRKOWN */
    165 
    166 #define UVM_PAGE_OWN(PG, TAG) /* nothing */
    167 
    168 #endif /* UVM_PAGE_TRKOWN */
    169 
    170 /*
    171  * pull in inlines
    172  */
    173 
    174 #include <uvm/uvm_amap_i.h>
    175 #include <uvm/uvm_fault_i.h>
    176 #include <uvm/uvm_map_i.h>
    177 #include <uvm/uvm_page_i.h>
    178 #include <uvm/uvm_pager_i.h>
    179 
    180 #endif /* _UVM_UVM_H_ */
    181