1 /* $NetBSD: param.h,v 1.140 2002/05/22 03:29:09 tv Exp $ */ 2 3 /*- 4 * Copyright (c) 1982, 1986, 1989, 1993 5 * The Regents of the University of California. All rights reserved. 6 * (c) UNIX System Laboratories, Inc. 7 * All or some portions of this file are derived from material licensed 8 * to the University of California by American Telephone and Telegraph 9 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 10 * the permission of UNIX System Laboratories, Inc. 11 * 12 * Redistribution and use in source and binary forms, with or without 13 * modification, are permitted provided that the following conditions 14 * are met: 15 * 1. Redistributions of source code must retain the above copyright 16 * notice, this list of conditions and the following disclaimer. 17 * 2. Redistributions in binary form must reproduce the above copyright 18 * notice, this list of conditions and the following disclaimer in the 19 * documentation and/or other materials provided with the distribution. 20 * 3. All advertising materials mentioning features or use of this software 21 * must display the following acknowledgement: 22 * This product includes software developed by the University of 23 * California, Berkeley and its contributors. 24 * 4. Neither the name of the University nor the names of its contributors 25 * may be used to endorse or promote products derived from this software 26 * without specific prior written permission. 27 * 28 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 29 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 30 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 31 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 32 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 36 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 37 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 38 * SUCH DAMAGE. 39 * 40 * @(#)param.h 8.3 (Berkeley) 4/4/95 41 */ 42 43 #ifndef _SYS_PARAM_H_ 44 #define _SYS_PARAM_H_ 45 46 /* 47 * Historic BSD #defines -- probably will remain untouched for all time. 48 */ 49 #define BSD 199506 /* System version (year & month). */ 50 #define BSD4_3 1 51 #define BSD4_4 1 52 53 /* 54 * #define __NetBSD_Version__ MMmmrrpp00 55 * 56 * M = major version 57 * m = minor version 58 * r = release ["",A-Z,Z[A-Z] but numeric] 59 * p = patchlevel 60 * 61 * So: 62 * NetBSD-1.2D = 102040000 63 * And: 64 * NetBSD-1.2.1 = 102000100 65 * 66 * 67 * Don't forget to change conf/osrelease.sh too. 68 */ 69 70 #define __NetBSD_Version__ 106010000 /* NetBSD 1.6A */ 71 72 /* 73 * Historical NetBSD #define 74 * 75 * NetBSD 1.4 was the last release for which this value was incremented. 76 * The value is now permanently fixed at 199905. It will never be 77 * changed again. 78 * 79 * New code must use __NetBSD_Version__ instead, and should not even 80 * count on NetBSD being defined. 81 * 82 */ 83 84 #define NetBSD 199905 /* NetBSD version (year & month). */ 85 86 #include <sys/null.h> 87 88 #ifndef _LOCORE 89 #include <sys/inttypes.h> 90 #include <sys/types.h> 91 #endif 92 93 /* 94 * Machine-independent constants (some used in following include files). 95 * Redefined constants are from POSIX 1003.1 limits file. 96 * 97 * MAXCOMLEN should be >= sizeof(ac_comm) (see <acct.h>) 98 * MAXLOGNAME should be >= UT_NAMESIZE (see <utmp.h>) 99 */ 100 #include <sys/syslimits.h> 101 102 #define MAXCOMLEN 16 /* max command name remembered */ 103 #define MAXINTERP 64 /* max interpreter file name length */ 104 /* DEPRECATED: use LOGIN_NAME_MAX instead. */ 105 #define MAXLOGNAME (LOGIN_NAME_MAX - 1) /* max login name length */ 106 #define NCARGS ARG_MAX /* max bytes for an exec function */ 107 #define NGROUPS NGROUPS_MAX /* max number groups */ 108 #define NOFILE OPEN_MAX /* max open files per process */ 109 #define NOGROUP 65535 /* marker for empty group set member */ 110 #define MAXHOSTNAMELEN 256 /* max hostname size */ 111 112 #ifndef MAXUPRC /* max simultaneous processes */ 113 #define MAXUPRC CHILD_MAX /* POSIX 1003.1-compliant default */ 114 #else 115 #if (MAXUPRC - 0) < CHILD_MAX 116 #error MAXUPRC less than CHILD_MAX. See options(4) for details. 117 #endif /* (MAXUPRC - 0) < CHILD_MAX */ 118 #endif /* !defined(MAXUPRC) */ 119 120 /* More types and definitions used throughout the kernel. */ 121 #ifdef _KERNEL 122 #include <sys/cdefs.h> 123 #include <sys/errno.h> 124 #include <sys/time.h> 125 #include <sys/resource.h> 126 #include <sys/ucred.h> 127 #include <sys/uio.h> 128 #ifndef NPROC 129 #define NPROC (20 + 16 * MAXUSERS) 130 #endif 131 #ifndef NTEXT 132 #define NTEXT (80 + NPROC / 8) /* actually the object cache */ 133 #endif 134 #ifndef NVNODE 135 #define NVNODE (NPROC + NTEXT + 100) 136 #define NVNODE_IMPLICIT 137 #endif 138 #endif /* _KERNEL */ 139 140 /* Signals. */ 141 #include <sys/signal.h> 142 143 /* Machine type dependent parameters. */ 144 #include <machine/param.h> 145 #include <machine/limits.h> 146 147 /* 148 * Priorities. Note that with 32 run queues, differences less than 4 are 149 * insignificant. 150 */ 151 #define PSWP 0 152 #define PVM 4 153 #define PINOD 8 154 #define PRIBIO 16 155 #define PVFS 20 156 #define PZERO 22 /* No longer magic, shouldn't be here. XXX */ 157 #define PSOCK 24 158 #define PWAIT 32 159 #define PLOCK 36 160 #define PPAUSE 40 161 #define PUSER 50 162 #define MAXPRI 127 /* Priorities range from 0 through MAXPRI. */ 163 164 #define PRIMASK 0x0ff 165 #define PCATCH 0x100 /* OR'd with pri for tsleep to check signals */ 166 #define PNORELOCK 0x200 /* OR'd with pri for cond_wait() to not relock 167 the interlock */ 168 169 #define NBPW sizeof(int) /* number of bytes per word (integer) */ 170 171 #define CMASK 022 /* default file mask: S_IWGRP|S_IWOTH */ 172 #define NODEV (dev_t)(-1) /* non-existent device */ 173 174 #define CBLOCK 64 /* Clist block size, must be a power of 2. */ 175 #define CBQSIZE (CBLOCK/NBBY) /* Quote bytes/cblock - can do better. */ 176 /* Data chars/clist. */ 177 #define CBSIZE (CBLOCK - sizeof(struct cblock *) - CBQSIZE) 178 #define CROUND (CBLOCK - 1) /* Clist rounding. */ 179 180 /* 181 * File system parameters and macros. 182 * 183 * The file system is made out of blocks of at most MAXBSIZE units, with 184 * smaller units (fragments) only in the last direct block. MAXBSIZE 185 * primarily determines the size of buffers in the buffer pool. It may be 186 * made larger without any effect on existing file systems; however making 187 * it smaller may make some file systems unmountable. 188 */ 189 #ifndef MAXBSIZE /* XXX */ 190 #define MAXBSIZE MAXPHYS 191 #endif 192 #define MAXFRAG 8 193 194 /* 195 * MAXPATHLEN defines the longest permissible path length after expanding 196 * symbolic links. It is used to allocate a temporary buffer from the buffer 197 * pool in which to do the name expansion, hence should be a power of two, 198 * and must be less than or equal to MAXBSIZE. MAXSYMLINKS defines the 199 * maximum number of symbolic links that may be expanded in a path name. 200 * It should be set high enough to allow all legitimate uses, but halt 201 * infinite loops reasonably quickly. 202 */ 203 #define MAXPATHLEN PATH_MAX 204 #define MAXSYMLINKS 32 205 206 /* Bit map related macros. */ 207 #define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY)) 208 #define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY))) 209 #define isset(a,i) ((a)[(i)/NBBY] & (1<<((i)%NBBY))) 210 #define isclr(a,i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0) 211 212 /* Macros for counting and rounding. */ 213 #ifndef howmany 214 #define howmany(x, y) (((x)+((y)-1))/(y)) 215 #endif 216 #define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) 217 #define powerof2(x) ((((x)-1)&(x))==0) 218 219 /* Macros for min/max. */ 220 #define MIN(a,b) (((a)<(b))?(a):(b)) 221 #define MAX(a,b) (((a)>(b))?(a):(b)) 222 223 /* 224 * Constants for setting the parameters of the kernel memory allocator. 225 * 226 * 2 ** MINBUCKET is the smallest unit of memory that will be 227 * allocated. It must be at least large enough to hold a pointer. 228 * 229 * Units of memory less or equal to MAXALLOCSAVE will permanently 230 * allocate physical memory; requests for these size pieces of 231 * memory are quite fast. Allocations greater than MAXALLOCSAVE must 232 * always allocate and free physical memory; requests for these 233 * size allocations should be done infrequently as they will be slow. 234 * 235 * Constraints: NBPG <= MAXALLOCSAVE <= 2 ** (MINBUCKET + 14), and 236 * MAXALLOCSAVE must be a power of two. 237 */ 238 #define MINBUCKET 4 /* 4 => min allocation of 16 bytes */ 239 #define MAXALLOCSAVE (2 * NBPG) 240 241 /* 242 * Scale factor for scaled integers used to count %cpu time and load avgs. 243 * 244 * The number of CPU `tick's that map to a unique `%age' can be expressed 245 * by the formula (1 / (2 ^ (FSHIFT - 11))). The maximum load average that 246 * can be calculated (assuming 32 bits) can be closely approximated using 247 * the formula (2 ^ (2 * (16 - FSHIFT))) for (FSHIFT < 15). 248 * 249 * For the scheduler to maintain a 1:1 mapping of CPU `tick' to `%age', 250 * FSHIFT must be at least 11; this gives us a maximum load avg of ~1024. 251 */ 252 #define FSHIFT 11 /* bits to right of fixed binary point */ 253 #define FSCALE (1<<FSHIFT) 254 255 /* 256 * The time for a process to be blocked before being very swappable. 257 * This is a number of seconds which the system takes as being a non-trivial 258 * amount of real time. You probably shouldn't change this; 259 * it is used in subtle ways (fractions and multiples of it are, that is, like 260 * half of a ``long time'', almost a long time, etc.) 261 * It is related to human patience and other factors which don't really 262 * change over time. 263 */ 264 #define MAXSLP 20 265 266 /* 267 * Defaults for Unified Buffer Cache parameters. 268 * These may be overridden in <machine/param.h>. 269 */ 270 271 #ifndef UBC_WINSHIFT 272 #define UBC_WINSHIFT 13 273 #endif 274 #ifndef UBC_NWINS 275 #define UBC_NWINS 1024 276 #endif 277 278 #ifdef _KERNEL 279 /* 280 * macro to convert from milliseconds to hz without integer overflow 281 * Default version using only 32bits arithmetics. 282 * 64bit port can define 64bit version in their <machine/param.h> 283 * 0x20000 is safe for hz < 20000 284 */ 285 #ifndef mstohz 286 #define mstohz(ms) \ 287 (__predict_false((ms) >= 0x20000) ? \ 288 ((ms +0u) / 1000u) * hz : \ 289 ((ms +0u) * hz) / 1000u) 290 #endif 291 #endif /* _KERNEL */ 292 293 #endif /* !_SYS_PARAM_H_ */ 294