1 /* $NetBSD: uvm_param.h,v 1.4 2001/01/09 13:55:20 pk 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@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 #include <machine/vmparam.h> 75 76 /* 77 * This belongs in types.h, but breaks too many existing programs. 78 */ 79 typedef int boolean_t; 80 #ifndef TRUE 81 #define TRUE 1 82 #endif 83 #ifndef FALSE 84 #define FALSE 0 85 #endif 86 87 /* 88 * The machine independent pages are refered to as PAGES. A page 89 * is some number of hardware pages, depending on the target machine. 90 */ 91 #define DEFAULT_PAGE_SIZE 4096 92 93 #if defined(_KERNEL) && !defined(PAGE_SIZE) 94 /* 95 * All references to the size of a page should be done with PAGE_SIZE 96 * or PAGE_SHIFT. The fact they are variables is hidden here so that 97 * we can easily make them constant if we so desire. 98 */ 99 #define PAGE_SIZE uvmexp.pagesize /* size of page */ 100 #define PAGE_MASK uvmexp.pagemask /* size of page - 1 */ 101 #define PAGE_SHIFT uvmexp.pageshift /* bits to shift for pages */ 102 #endif /* _KERNEL */ 103 104 /* 105 * CTL_VM identifiers 106 */ 107 #define VM_METER 1 /* struct vmmeter */ 108 #define VM_LOADAVG 2 /* struct loadavg */ 109 #define VM_UVMEXP 3 /* struct uvmexp */ 110 #define VM_NKMEMPAGES 4 /* kmem_map pages */ 111 #define VM_UVMEXP2 5 /* struct uvmexp_sysctl */ 112 #define VM_MAXID 6 /* number of valid vm ids */ 113 114 #define CTL_VM_NAMES { \ 115 { 0, 0 }, \ 116 { "vmmeter", CTLTYPE_STRUCT }, \ 117 { "loadavg", CTLTYPE_STRUCT }, \ 118 { "uvmexp", CTLTYPE_STRUCT }, \ 119 { "nkmempages", CTLTYPE_INT }, \ 120 { "uvmexp2", CTLTYPE_STRUCT }, \ 121 } 122 123 124 /* 125 * Return values from the VM routines. 126 */ 127 #define KERN_SUCCESS 0 128 #define KERN_INVALID_ADDRESS 1 129 #define KERN_PROTECTION_FAILURE 2 130 #define KERN_NO_SPACE 3 131 #define KERN_INVALID_ARGUMENT 4 132 #define KERN_FAILURE 5 133 #define KERN_RESOURCE_SHORTAGE 6 134 #define KERN_NOT_RECEIVER 7 135 #define KERN_NO_ACCESS 8 136 #define KERN_PAGES_LOCKED 9 137 138 #ifndef ASSEMBLER 139 /* 140 * Convert addresses to pages and vice versa. 141 * No rounding is used. 142 */ 143 #ifdef _KERNEL 144 #define atop(x) (((paddr_t)(x)) >> PAGE_SHIFT) 145 #define ptoa(x) ((vaddr_t)((vaddr_t)(x) << PAGE_SHIFT)) 146 147 /* 148 * Round off or truncate to the nearest page. These will work 149 * for either addresses or counts (i.e., 1 byte rounds to 1 page). 150 */ 151 #define round_page(x) (((x) + PAGE_MASK) & ~PAGE_MASK) 152 #define trunc_page(x) ((x) & ~PAGE_MASK) 153 154 extern psize_t mem_size; /* size of physical memory (bytes) */ 155 extern int ubc_nwins; /* number of UBC mapping windows */ 156 extern int ubc_winsize; /* size of a UBC mapping window */ 157 158 #else 159 /* out-of-kernel versions of round_page and trunc_page */ 160 #define round_page(x) \ 161 ((((vaddr_t)(x) + (vm_page_size - 1)) / vm_page_size) * \ 162 vm_page_size) 163 #define trunc_page(x) \ 164 ((((vaddr_t)(x)) / vm_page_size) * vm_page_size) 165 166 #endif /* _KERNEL */ 167 #endif /* ASSEMBLER */ 168 #endif /* _VM_PARAM_ */ 169