Home | History | Annotate | Line # | Download | only in uvm
uvm_param.h revision 1.12
      1 /*	$NetBSD: uvm_param.h,v 1.12 2001/08/05 03:33:16 matt Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1991, 1993
      5  *	The Regents of the University of California.  All rights reserved.
      6  *
      7  * This code is derived from software contributed to Berkeley by
      8  * The Mach Operating System project at Carnegie-Mellon University.
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  * 3. All advertising materials mentioning features or use of this software
     19  *    must display the following acknowledgement:
     20  *	This product includes software developed by the University of
     21  *	California, Berkeley and its contributors.
     22  * 4. Neither the name of the University nor the names of its contributors
     23  *    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_param.h	8.2 (Berkeley) 1/9/95
     39  *
     40  *
     41  * Copyright (c) 1987, 1990 Carnegie-Mellon University.
     42  * All rights reserved.
     43  *
     44  * Authors: Avadis Tevanian, Jr., Michael Wayne Young
     45  *
     46  * Permission to use, copy, modify and distribute this software and
     47  * its documentation is hereby granted, provided that both the copyright
     48  * notice and this permission notice appear in all copies of the
     49  * software, derivative works or modified versions, and any portions
     50  * thereof, and that both notices appear in supporting documentation.
     51  *
     52  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
     53  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
     54  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
     55  *
     56  * Carnegie Mellon requests users of this software to return to
     57  *
     58  *  Software Distribution Coordinator  or  Software.Distribution (at) CS.CMU.EDU
     59  *  School of Computer Science
     60  *  Carnegie Mellon University
     61  *  Pittsburgh PA 15213-3890
     62  *
     63  * any improvements or extensions that they make and grant Carnegie the
     64  * rights to redistribute these changes.
     65  */
     66 
     67 /*
     68  *	Machine independent virtual memory parameters.
     69  */
     70 
     71 #ifndef	_VM_PARAM_
     72 #define	_VM_PARAM_
     73 
     74 #ifdef _KERNEL
     75 #include <machine/vmparam.h>
     76 #endif
     77 
     78 /*
     79  * This belongs in types.h, but breaks too many existing programs.
     80  */
     81 typedef int	boolean_t;
     82 #ifndef TRUE
     83 #define	TRUE	1
     84 #endif
     85 #ifndef FALSE
     86 #define	FALSE	0
     87 #endif
     88 
     89 /*
     90  *	The machine independent pages are refered to as PAGES.  A page
     91  *	is some number of hardware pages, depending on the target machine.
     92  */
     93 #define	DEFAULT_PAGE_SIZE	4096
     94 
     95 #if defined(_KERNEL) && !defined(PAGE_SIZE)
     96 /*
     97  *	All references to the size of a page should be done with PAGE_SIZE
     98  *	or PAGE_SHIFT.  The fact they are variables is hidden here so that
     99  *	we can easily make them constant if we so desire.
    100  */
    101 #define	PAGE_SIZE	uvmexp.pagesize		/* size of page */
    102 #define	PAGE_MASK	uvmexp.pagemask		/* size of page - 1 */
    103 #define	PAGE_SHIFT	uvmexp.pageshift	/* bits to shift for pages */
    104 #endif /* _KERNEL */
    105 
    106 /*
    107  * CTL_VM identifiers
    108  */
    109 #define	VM_METER	1		/* struct vmmeter */
    110 #define	VM_LOADAVG	2		/* struct loadavg */
    111 #define	VM_UVMEXP	3		/* struct uvmexp */
    112 #define	VM_NKMEMPAGES	4		/* kmem_map pages */
    113 #define	VM_UVMEXP2	5		/* struct uvmexp_sysctl */
    114 #define	VM_ANONMIN	6
    115 #define	VM_VTEXTMIN	7
    116 #define	VM_VNODEMIN	8
    117 #define	VM_MAXSLP	9
    118 #define	VM_USPACE	10
    119 
    120 #define	VM_MAXID	11		/* number of valid vm ids */
    121 
    122 #define	CTL_VM_NAMES { \
    123 	{ 0, 0 }, \
    124 	{ "vmmeter", CTLTYPE_STRUCT }, \
    125 	{ "loadavg", CTLTYPE_STRUCT }, \
    126 	{ "uvmexp", CTLTYPE_STRUCT }, \
    127 	{ "nkmempages", CTLTYPE_INT }, \
    128 	{ "uvmexp2", CTLTYPE_STRUCT }, \
    129 	{ "anonmin", CTLTYPE_INT }, \
    130 	{ "vtextmin", CTLTYPE_INT }, \
    131 	{ "vnodemin", CTLTYPE_INT }, \
    132 	{ "maxslp", CTLTYPE_INT }, \
    133 	{ "uspace", CTLTYPE_INT }, \
    134 }
    135 
    136 #ifndef ASSEMBLER
    137 /*
    138  *	Convert addresses to pages and vice versa.
    139  *	No rounding is used.
    140  */
    141 #ifdef _KERNEL
    142 #define	atop(x)		(((paddr_t)(x)) >> PAGE_SHIFT)
    143 #define	ptoa(x)		((vaddr_t)((vaddr_t)(x) << PAGE_SHIFT))
    144 
    145 /*
    146  * Round off or truncate to the nearest page.  These will work
    147  * for either addresses or counts (i.e., 1 byte rounds to 1 page).
    148  */
    149 #define	round_page(x)	(((x) + PAGE_MASK) & ~PAGE_MASK)
    150 #define	trunc_page(x)	((x) & ~PAGE_MASK)
    151 
    152 extern psize_t		mem_size;	/* size of physical memory (bytes) */
    153 extern int		ubc_nwins;	/* number of UBC mapping windows */
    154 extern int		ubc_winshift;	/* shift for a UBC mapping window */
    155 
    156 #else
    157 /* out-of-kernel versions of round_page and trunc_page */
    158 #define	round_page(x) \
    159 	((((vaddr_t)(x) + (vm_page_size - 1)) / vm_page_size) * \
    160 	    vm_page_size)
    161 #define	trunc_page(x) \
    162 	((((vaddr_t)(x)) / vm_page_size) * vm_page_size)
    163 
    164 #endif /* _KERNEL */
    165 #endif /* ASSEMBLER */
    166 #endif /* _VM_PARAM_ */
    167