1 /** $MirOS: src/sys/sys/param.h,v 1.98 2014/02/20 01:01:00 tg Exp $ */ 2 /* $OpenBSD: param.h,v 1.54 2004/02/27 18:06:55 deraadt Exp $ */ 3 /* $NetBSD: param.h,v 1.23 1996/03/17 01:02:29 thorpej Exp $ */ 4 5 /*- 6 * Copyright (c) 2003, 2004, 2005, 2006, 2009, 2011, 2012, 2013, 2014 7 * The MirOS Project. All rights reserved. 8 * Copyright (c) 2002, 2003, 2007, 2008 9 * Thorsten “mirabilos” Glaser <tg@mirbsd.org> 10 * Copyright (c) 1982, 1986, 1989, 1993 11 * The Regents of the University of California. All rights reserved. 12 * (c) UNIX System Laboratories, Inc. 13 * All or some portions of this file are derived from material licensed 14 * to the University of California by American Telephone and Telegraph 15 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 16 * the permission of UNIX System Laboratories, Inc. 17 * 18 * Redistribution and use in source and binary forms, with or without 19 * modification, are permitted provided that the following conditions 20 * are met: 21 * 1. Redistributions of source code must retain the above copyright 22 * notice, this list of conditions and the following disclaimer. 23 * 2. Redistributions in binary form must reproduce the above copyright 24 * notice, this list of conditions and the following disclaimer in the 25 * documentation and/or other materials provided with the distribution. 26 * 3. Neither the name of the University nor the names of its contributors 27 * may be used to endorse or promote products derived from this software 28 * without specific prior written permission. 29 * 30 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 31 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 32 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 33 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 34 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 35 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 36 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 37 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 38 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 39 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 40 * SUCH DAMAGE. 41 * 42 * @(#)param.h 8.2 (Berkeley) 1/21/94 43 */ 44 45 #ifndef _SYS_PARAM_H 46 #define _SYS_PARAM_H 47 48 #define BSD 199306 /* System version (year & month). */ 49 #define BSD4_3 1 50 #define BSD4_4 1 51 #define MirBSD 0x0AB5 /* minor 10-7F=prerelease; 80=release 52 * minor 81-9F=stable; A0-FF=unlocked 53 */ 54 #ifndef _LOCORE 55 #include <sys/types.h> 56 #include <sys/simplelock.h> 57 #endif 58 59 #ifndef NULL 60 #ifdef __GNUG__ 61 #define NULL __null 62 #elif defined(lint) 63 #define NULL 0 64 #else 65 #define NULL ((void *)((__PTRDIFF_TYPE__)0UL)) 66 #endif 67 #endif 68 69 /* 70 * Machine-independent constants (some used in following include files). 71 * Redefined constants are from POSIX 1003.1 limits file. 72 * 73 * MAXCOMLEN should be >= sizeof(ac_comm) (see <acct.h>) 74 * MAXLOGNAME should be >= UT_NAMESIZE (see <utmp.h>) 75 */ 76 #include <sys/syslimits.h> 77 78 #define MAXCOMLEN 16 /* max command name remembered */ 79 #define MAXINTERP 64 /* max interpreter file name length */ 80 #define MAXLOGNAME 32 /* max login name length */ 81 #define MAXUPRC CHILD_MAX /* max simultaneous processes */ 82 #define NCARGS ARG_MAX /* max bytes for an exec function */ 83 #define NGROUPS NGROUPS_MAX /* max number groups */ 84 #define NOFILE OPEN_MAX /* max open files per process (soft) */ 85 #define NOFILE_MAX 1024 /* max open files per process (hard) */ 86 #define NOGROUP 65535 /* marker for empty group set member */ 87 #define MAXHOSTNAMELEN 256 /* max hostname size */ 88 89 /* More types and definitions used throughout the kernel. */ 90 #ifdef _KERNEL 91 #include <sys/cdefs.h> 92 #include <sys/errno.h> 93 #include <sys/time.h> 94 #include <sys/resource.h> 95 #include <sys/ucred.h> 96 #include <sys/uio.h> 97 #endif 98 99 /* Signals. */ 100 #include <sys/signal.h> 101 102 /* Machine type dependent parameters. */ 103 #include <sys/limits.h> 104 #include <machine/param.h> 105 106 /* 107 * Priorities. Note that with 32 run queues, differences less than 4 are 108 * insignificant. 109 */ 110 #define PSWP 0 111 #define PVM 4 112 #define PINOD 8 113 #define PRIBIO 16 114 #define PVFS 20 115 #define PZERO 22 /* No longer magic, shouldn't be here. XXX */ 116 #define PSOCK 24 117 #define PWAIT 32 118 #define PLOCK 36 119 #define PPAUSE 40 120 #define PUSER 50 121 #define MAXPRI 127 /* Priorities range from 0 through MAXPRI. */ 122 123 #define PRIMASK 0x0ff 124 #define PCATCH 0x100 /* OR'd with pri for tsleep to check signals */ 125 #define PNORELOCK 0x200 /* OR'd with pri for ltsleep to not relock 126 the interlock */ 127 128 #define NBPW sizeof(int) /* number of bytes per word (integer) */ 129 130 #define CMASK 022 /* default file mask: S_IWGRP|S_IWOTH */ 131 #define NODEV (dev_t)(-1) /* non-existent device */ 132 #define NETDEV (dev_t)(-2) /* network device (for nfs swap) */ 133 134 #define CBLOCK 64 /* Clist block size, must be a power of 2. */ 135 #define CBQSIZE (CBLOCK/NBBY) /* Quote bytes/cblock - can do better. */ 136 /* Data chars/clist. */ 137 #define CBSIZE (CBLOCK - sizeof(struct cblock *) - CBQSIZE) 138 #define CROUND (CBLOCK - 1) /* Clist rounding. */ 139 140 /* 141 * File system parameters and macros. 142 * 143 * The file system is made out of blocks of at most MAXBSIZE units, with 144 * smaller units (fragments) only in the last direct block. MAXBSIZE 145 * primarily determines the size of buffers in the buffer pool. It may be 146 * made larger without any effect on existing file systems; however making 147 * it smaller makes some file systems unmountable. 148 */ 149 #ifndef MAXBSIZE /* XXX temp until sun3 DMA chaining */ 150 #define MAXBSIZE MAXPHYS 151 #endif 152 #define MAXFRAG 8 153 154 /* 155 * MAXPATHLEN defines the longest permissable path length after expanding 156 * symbolic links. It is used to allocate a temporary buffer from the buffer 157 * pool in which to do the name expansion, hence should be a power of two, 158 * and must be less than or equal to MAXBSIZE. MAXSYMLINKS defines the 159 * maximum number of symbolic links that may be expanded in a path name. 160 * It should be set high enough to allow all legitimate uses, but halt 161 * infinite loops reasonably quickly. 162 */ 163 #define MAXPATHLEN PATH_MAX 164 #define MAXSYMLINKS 32 165 166 /* Macros to set/clear/test flags. */ 167 #ifdef _KERNEL 168 #define SET(t, f) ((t) |= (f)) 169 #define CLR(t, f) ((t) &= ~(f)) 170 #define ISSET(t, f) ((t) & (f)) 171 #endif 172 173 /* Bit map related macros. */ 174 #define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY)) 175 #define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY))) 176 #define isset(a,i) ((a)[(i)/NBBY] & (1<<((i)%NBBY))) 177 #define isclr(a,i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0) 178 179 /* Macros for counting, rounding and bounding */ 180 #ifndef howmany 181 #define howmany(x, y) (((x)+((y)-1))/(y)) 182 #endif 183 #define roundup(x,y) (howmany((x), (y)) * (y)) 184 #define powerof2(x) ((((x)-1)&(x))==0) 185 #define MIN(a,b) (((a)<(b))?(a):(b)) 186 #define MAX(a,b) (((a)>(b))?(a):(b)) 187 188 #define __BOUNDINT(minv,maxv,v) \ 189 ( ((v) < (minv)) ? (minv) : ( ((v) > (maxv)) ? (maxv) : (v) ) ) 190 #define __BOUNDINT0(maxv,x) __BOUNDINT(0,(maxv),(x)) 191 #define __BOUNDINTU(maxv,x) MIN((maxv),(x)) 192 193 /* Macros for calculating the offset of a field */ 194 #if !defined(offsetof) && (defined(_KERNEL) || defined(_STANDALONE)) 195 #define offsetof(s, e) ((size_t)&((s *)0)->e) 196 #endif 197 198 /* 199 * Constants for setting the parameters of the kernel memory allocator. 200 * 201 * 2 ** MINBUCKET is the smallest unit of memory that will be 202 * allocated. It must be at least large enough to hold a pointer. 203 * 204 * Units of memory less or equal to MAXALLOCSAVE will permanently 205 * allocate physical memory; requests for these size pieces of 206 * memory are quite fast. Allocations greater than MAXALLOCSAVE must 207 * always allocate and free physical memory; requests for these 208 * size allocations should be done infrequently as they will be slow. 209 * 210 * Constraints: PAGE_SIZE <= MAXALLOCSAVE <= 2 ** (MINBUCKET + 14), and 211 * MAXALLOCSIZE must be a power of two. 212 */ 213 #define MINBUCKET 4 /* 4 => min allocation of 16 bytes */ 214 #define MAXALLOCSAVE (2 * PAGE_SIZE) 215 216 /* 217 * Scale factor for scaled integers used to count %cpu time and load avgs. 218 * 219 * The number of CPU 'tick's that map to a unique '%age' can be expressed 220 * by the formula (1 / (2 ^ (FSHIFT - 11))). The maximum load average that 221 * can be calculated (assuming 32 bits) can be closely approximated using 222 * the formula (2 ^ (2 * (16 - FSHIFT))) for (FSHIFT < 15). 223 * 224 * For the scheduler to maintain a 1:1 mapping of CPU 'tick' to '%age', 225 * FSHIFT must be at least 11; this gives us a maximum load avg of ~1024. 226 */ 227 #define FSHIFT 11 /* bits to right of fixed binary point */ 228 #define FSCALE (1<<FSHIFT) 229 230 /* 231 * rfork() options. 232 * 233 * XXX currently, operations without RFPROC set are not supported. 234 */ 235 #define RFNAMEG (1<<0) /* UNIMPL new plan9 'name space' */ 236 #define RFENVG (1<<1) /* UNIMPL copy plan9 'env space' */ 237 #define RFFDG (1<<2) /* copy fd table */ 238 #define RFNOTEG (1<<3) /* UNIMPL create new plan9 'note group' */ 239 #define RFPROC (1<<4) /* change child (else changes curproc) */ 240 #define RFMEM (1<<5) /* share 'address space' */ 241 #define RFNOWAIT (1<<6) /* parent need not wait() on child */ 242 #define RFCNAMEG (1<<10) /* UNIMPL zero plan9 'name space' */ 243 #define RFCENVG (1<<11) /* UNIMPL zero plan9 'env space' */ 244 #define RFCFDG (1<<12) /* zero fd table */ 245 246 #endif /* ndef _SYS_PARAM_H */ 247