Home | History | Annotate | Line # | Download | only in uvm
uvm_param.h revision 1.2
      1  1.2  simonb /*	$NetBSD: uvm_param.h,v 1.2 2000/11/29 09:52:19 simonb Exp $	*/
      2  1.1     mrg 
      3  1.1     mrg /*
      4  1.1     mrg  * Copyright (c) 1991, 1993
      5  1.1     mrg  *	The Regents of the University of California.  All rights reserved.
      6  1.1     mrg  *
      7  1.1     mrg  * This code is derived from software contributed to Berkeley by
      8  1.1     mrg  * The Mach Operating System project at Carnegie-Mellon University.
      9  1.1     mrg  *
     10  1.1     mrg  * Redistribution and use in source and binary forms, with or without
     11  1.1     mrg  * modification, are permitted provided that the following conditions
     12  1.1     mrg  * are met:
     13  1.1     mrg  * 1. Redistributions of source code must retain the above copyright
     14  1.1     mrg  *    notice, this list of conditions and the following disclaimer.
     15  1.1     mrg  * 2. Redistributions in binary form must reproduce the above copyright
     16  1.1     mrg  *    notice, this list of conditions and the following disclaimer in the
     17  1.1     mrg  *    documentation and/or other materials provided with the distribution.
     18  1.1     mrg  * 3. All advertising materials mentioning features or use of this software
     19  1.1     mrg  *    must display the following acknowledgement:
     20  1.1     mrg  *	This product includes software developed by the University of
     21  1.1     mrg  *	California, Berkeley and its contributors.
     22  1.1     mrg  * 4. Neither the name of the University nor the names of its contributors
     23  1.1     mrg  *    may be used to endorse or promote products derived from this software
     24  1.1     mrg  *    without specific prior written permission.
     25  1.1     mrg  *
     26  1.1     mrg  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     27  1.1     mrg  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     28  1.1     mrg  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     29  1.1     mrg  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     30  1.1     mrg  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     31  1.1     mrg  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     32  1.1     mrg  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     33  1.1     mrg  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     34  1.1     mrg  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     35  1.1     mrg  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     36  1.1     mrg  * SUCH DAMAGE.
     37  1.1     mrg  *
     38  1.1     mrg  *	@(#)vm_param.h	8.2 (Berkeley) 1/9/95
     39  1.1     mrg  *
     40  1.1     mrg  *
     41  1.1     mrg  * Copyright (c) 1987, 1990 Carnegie-Mellon University.
     42  1.1     mrg  * All rights reserved.
     43  1.1     mrg  *
     44  1.1     mrg  * Authors: Avadis Tevanian, Jr., Michael Wayne Young
     45  1.1     mrg  *
     46  1.1     mrg  * Permission to use, copy, modify and distribute this software and
     47  1.1     mrg  * its documentation is hereby granted, provided that both the copyright
     48  1.1     mrg  * notice and this permission notice appear in all copies of the
     49  1.1     mrg  * software, derivative works or modified versions, and any portions
     50  1.1     mrg  * thereof, and that both notices appear in supporting documentation.
     51  1.1     mrg  *
     52  1.1     mrg  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
     53  1.1     mrg  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
     54  1.1     mrg  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
     55  1.1     mrg  *
     56  1.1     mrg  * Carnegie Mellon requests users of this software to return to
     57  1.1     mrg  *
     58  1.1     mrg  *  Software Distribution Coordinator  or  Software.Distribution (at) CS.CMU.EDU
     59  1.1     mrg  *  School of Computer Science
     60  1.1     mrg  *  Carnegie Mellon University
     61  1.1     mrg  *  Pittsburgh PA 15213-3890
     62  1.1     mrg  *
     63  1.1     mrg  * any improvements or extensions that they make and grant Carnegie the
     64  1.1     mrg  * rights to redistribute these changes.
     65  1.1     mrg  */
     66  1.1     mrg 
     67  1.1     mrg /*
     68  1.1     mrg  *	Machine independent virtual memory parameters.
     69  1.1     mrg  */
     70  1.1     mrg 
     71  1.1     mrg #ifndef	_VM_PARAM_
     72  1.1     mrg #define	_VM_PARAM_
     73  1.1     mrg 
     74  1.1     mrg #include <machine/vmparam.h>
     75  1.1     mrg 
     76  1.1     mrg /*
     77  1.1     mrg  * This belongs in types.h, but breaks too many existing programs.
     78  1.1     mrg  */
     79  1.1     mrg typedef int	boolean_t;
     80  1.1     mrg #ifndef TRUE
     81  1.1     mrg #define	TRUE	1
     82  1.1     mrg #endif
     83  1.1     mrg #ifndef FALSE
     84  1.1     mrg #define	FALSE	0
     85  1.1     mrg #endif
     86  1.1     mrg 
     87  1.1     mrg /*
     88  1.1     mrg  *	The machine independent pages are refered to as PAGES.  A page
     89  1.1     mrg  *	is some number of hardware pages, depending on the target machine.
     90  1.1     mrg  */
     91  1.1     mrg #define	DEFAULT_PAGE_SIZE	4096
     92  1.1     mrg 
     93  1.1     mrg #if defined(_KERNEL) && !defined(PAGE_SIZE)
     94  1.1     mrg /*
     95  1.1     mrg  *	All references to the size of a page should be done with PAGE_SIZE
     96  1.1     mrg  *	or PAGE_SHIFT.  The fact they are variables is hidden here so that
     97  1.1     mrg  *	we can easily make them constant if we so desire.
     98  1.1     mrg  */
     99  1.1     mrg #define	PAGE_SIZE	uvmexp.pagesize		/* size of page */
    100  1.1     mrg #define	PAGE_MASK	uvmexp.pagemask		/* size of page - 1 */
    101  1.1     mrg #define	PAGE_SHIFT	uvmexp.pageshift	/* bits to shift for pages */
    102  1.1     mrg #endif /* _KERNEL */
    103  1.1     mrg 
    104  1.1     mrg /*
    105  1.1     mrg  * CTL_VM identifiers
    106  1.1     mrg  */
    107  1.1     mrg #define	VM_METER	1		/* struct vmmeter */
    108  1.1     mrg #define	VM_LOADAVG	2		/* struct loadavg */
    109  1.2  simonb #define	VM_UVMEXP	3		/* struct uvmexp */
    110  1.1     mrg #define	VM_NKMEMPAGES	4		/* kmem_map pages */
    111  1.2  simonb #define	VM_UVMEXP2	5		/* struct uvmexp_sysctl */
    112  1.2  simonb #define	VM_MAXID	6		/* number of valid vm ids */
    113  1.1     mrg 
    114  1.1     mrg #define	CTL_VM_NAMES { \
    115  1.1     mrg 	{ 0, 0 }, \
    116  1.1     mrg 	{ "vmmeter", CTLTYPE_STRUCT }, \
    117  1.1     mrg 	{ "loadavg", CTLTYPE_STRUCT }, \
    118  1.1     mrg 	{ "uvmexp", CTLTYPE_STRUCT }, \
    119  1.1     mrg 	{ "nkmempages", CTLTYPE_INT }, \
    120  1.2  simonb 	{ "uvmexp2", CTLTYPE_STRUCT }, \
    121  1.1     mrg }
    122  1.1     mrg 
    123  1.1     mrg 
    124  1.1     mrg /*
    125  1.1     mrg  *	Return values from the VM routines.
    126  1.1     mrg  */
    127  1.1     mrg #define	KERN_SUCCESS		0
    128  1.1     mrg #define	KERN_INVALID_ADDRESS	1
    129  1.1     mrg #define	KERN_PROTECTION_FAILURE	2
    130  1.1     mrg #define	KERN_NO_SPACE		3
    131  1.1     mrg #define	KERN_INVALID_ARGUMENT	4
    132  1.1     mrg #define	KERN_FAILURE		5
    133  1.1     mrg #define	KERN_RESOURCE_SHORTAGE	6
    134  1.1     mrg #define	KERN_NOT_RECEIVER	7
    135  1.1     mrg #define	KERN_NO_ACCESS		8
    136  1.1     mrg #define	KERN_PAGES_LOCKED	9
    137  1.1     mrg 
    138  1.1     mrg #ifndef ASSEMBLER
    139  1.1     mrg /*
    140  1.1     mrg  *	Convert addresses to pages and vice versa.
    141  1.1     mrg  *	No rounding is used.
    142  1.1     mrg  */
    143  1.1     mrg #ifdef _KERNEL
    144  1.1     mrg #define	atop(x)		(((unsigned long)(x)) >> PAGE_SHIFT)
    145  1.1     mrg #define	ptoa(x)		((vaddr_t)((vaddr_t)(x) << PAGE_SHIFT))
    146  1.1     mrg 
    147  1.1     mrg /*
    148  1.1     mrg  * Round off or truncate to the nearest page.  These will work
    149  1.1     mrg  * for either addresses or counts (i.e., 1 byte rounds to 1 page).
    150  1.1     mrg  */
    151  1.1     mrg #define	round_page(x)	(((x) + PAGE_MASK) & ~PAGE_MASK)
    152  1.1     mrg #define	trunc_page(x)	((x) & ~PAGE_MASK)
    153  1.1     mrg 
    154  1.1     mrg extern psize_t		mem_size;	/* size of physical memory (bytes) */
    155  1.1     mrg 
    156  1.1     mrg #else
    157  1.1     mrg /* out-of-kernel versions of round_page and trunc_page */
    158  1.1     mrg #define	round_page(x) \
    159  1.1     mrg 	((((vaddr_t)(x) + (vm_page_size - 1)) / vm_page_size) * \
    160  1.1     mrg 	    vm_page_size)
    161  1.1     mrg #define	trunc_page(x) \
    162  1.1     mrg 	((((vaddr_t)(x)) / vm_page_size) * vm_page_size)
    163  1.1     mrg 
    164  1.1     mrg #endif /* _KERNEL */
    165  1.1     mrg #endif /* ASSEMBLER */
    166  1.1     mrg #endif /* _VM_PARAM_ */
    167