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