1 /* $NetBSD: uvm_param.h,v 1.1 2000/06/26 14:59:04 mrg 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_MAXID 5 /* number of valid vm ids */ 112 113 #define CTL_VM_NAMES { \ 114 { 0, 0 }, \ 115 { "vmmeter", CTLTYPE_STRUCT }, \ 116 { "loadavg", CTLTYPE_STRUCT }, \ 117 { "uvmexp", CTLTYPE_STRUCT }, \ 118 { "nkmempages", CTLTYPE_INT }, \ 119 } 120 121 122 /* 123 * Return values from the VM routines. 124 */ 125 #define KERN_SUCCESS 0 126 #define KERN_INVALID_ADDRESS 1 127 #define KERN_PROTECTION_FAILURE 2 128 #define KERN_NO_SPACE 3 129 #define KERN_INVALID_ARGUMENT 4 130 #define KERN_FAILURE 5 131 #define KERN_RESOURCE_SHORTAGE 6 132 #define KERN_NOT_RECEIVER 7 133 #define KERN_NO_ACCESS 8 134 #define KERN_PAGES_LOCKED 9 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) (((unsigned long)(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 154 #else 155 /* out-of-kernel versions of round_page and trunc_page */ 156 #define round_page(x) \ 157 ((((vaddr_t)(x) + (vm_page_size - 1)) / vm_page_size) * \ 158 vm_page_size) 159 #define trunc_page(x) \ 160 ((((vaddr_t)(x)) / vm_page_size) * vm_page_size) 161 162 #endif /* _KERNEL */ 163 #endif /* ASSEMBLER */ 164 #endif /* _VM_PARAM_ */ 165