165a1cfb1Smckusick /* 20c67d176Skarels * Copyright (c) 1982, 1986, 1989 Regents of the University of California. 365a1cfb1Smckusick * All rights reserved. The Berkeley software License Agreement 465a1cfb1Smckusick * specifies the terms and conditions for redistribution. 565a1cfb1Smckusick * 6*1ba81c5bSkarels * @(#)param.h 7.21 (Berkeley) 04/20/91 765a1cfb1Smckusick */ 85db792e4Sbill 9*1ba81c5bSkarels #define BSD 199103 /* March, 1991 system version (year & month) */ 101a9e6e3cSkarels #define BSD4_3 1 1157ce53b7Skarels #define BSD4_4 0.5 122867d692Sbloom 134a9959f4Sbostic #include <sys/syslimits.h> 144a9959f4Sbostic 15*1ba81c5bSkarels #ifndef LOCORE 16*1ba81c5bSkarels #include <sys/types.h> 17*1ba81c5bSkarels #endif 18*1ba81c5bSkarels 195db792e4Sbill /* 20*1ba81c5bSkarels * Machine-independent constants (some used in following include files) 21b481cdefSroot */ 224a9959f4Sbostic #define MAXUPRC CHILD_MAX /* max processes per user */ 234a9959f4Sbostic #define NOFILE OPEN_MAX /* max open files per process */ 244a9959f4Sbostic #define NCARGS ARG_MAX /* # characters in exec arglist */ 2557ce53b7Skarels #define MAXINTERP 32 /* max interpreter file name length */ 264a9959f4Sbostic #define NGROUPS NGROUPS_MAX /* max number groups */ 2777caf3abSkarels #define MAXHOSTNAMELEN 256 /* maximum hostname size */ 2877caf3abSkarels #define MAXCOMLEN 16 /* maximum command name remembered */ 2977caf3abSkarels /* MAXCOMLEN should be >= sizeof(ac_comm) (acct.h) */ 3077caf3abSkarels #define MAXLOGNAME 12 /* maximum login name length */ 3177caf3abSkarels /* MAXLOGNAME must be >= UT_NAMESIZE (<utmp.h>) */ 3245ac661dSwnj 33ebd4ffb8Skarels #define NOGROUP 65535 /* marker for empty group set member */ 34e74c57f3Ssam 355db792e4Sbill /* 36f34b934bSkarels * More types and definitions used throughout the kernel 37f34b934bSkarels */ 38f34b934bSkarels #ifdef KERNEL 39f34b934bSkarels #include <sys/cdefs.h> 40f34b934bSkarels #include <sys/errno.h> 41f34b934bSkarels #include <sys/time.h> 42f34b934bSkarels #include <sys/resource.h> 43f34b934bSkarels #include <sys/ucred.h> 44f34b934bSkarels #include <sys/uio.h> 45f34b934bSkarels #endif 46f34b934bSkarels 47f34b934bSkarels /* 48b481cdefSroot * Signals 495db792e4Sbill */ 500c67d176Skarels #include <sys/signal.h> 5103c2128fSroot 52f520e942Skarels /* 53f520e942Skarels * Machine type dependent parameters. 54f520e942Skarels */ 5564716fc5Sbostic #include <machine/param.h> 5664716fc5Sbostic #include <machine/endian.h> 5764716fc5Sbostic #include <machine/limits.h> 58f520e942Skarels 59*1ba81c5bSkarels /* 60*1ba81c5bSkarels * Priorities. Note that with 32 run queues, 61*1ba81c5bSkarels * differences less than 4 are insignificant. 62*1ba81c5bSkarels */ 63*1ba81c5bSkarels #define PSWP 0 64*1ba81c5bSkarels #define PVM 4 65*1ba81c5bSkarels #define PINOD 8 66*1ba81c5bSkarels #define PRIBIO 16 67*1ba81c5bSkarels #define PVFS 20 68*1ba81c5bSkarels #define PSOCK 24 69*1ba81c5bSkarels #define PZERO 25 /* No longer magic, shouldn't be here XXX */ 70*1ba81c5bSkarels #define PWAIT 32 71*1ba81c5bSkarels #define PLOCK 36 72*1ba81c5bSkarels #define PPAUSE 40 73*1ba81c5bSkarels #define PUSER 50 74*1ba81c5bSkarels #define MAXPRI 127 /* priorities range from 0 through MAXPRI */ 75*1ba81c5bSkarels 76*1ba81c5bSkarels #define PRIMASK 0x0ff 77*1ba81c5bSkarels #define PCATCH 0x100 /* or'd with pri for tsleep to check signals */ 78*1ba81c5bSkarels 79*1ba81c5bSkarels #define NZERO 0 /* default "nice" */ 80*1ba81c5bSkarels 815db792e4Sbill #define NBPW sizeof(int) /* number of bytes in an integer */ 825db792e4Sbill 830c67d176Skarels #ifndef NULL 845db792e4Sbill #define NULL 0 850c67d176Skarels #endif 86f0028148Skarels #define CMASK 022 /* default mask for file creation */ 875db792e4Sbill #define NODEV (dev_t)(-1) 885db792e4Sbill 895db792e4Sbill /* 905db792e4Sbill * Clustering of hardware pages on machines with ridiculously small 915db792e4Sbill * page sizes is done here. The paging subsystem deals with units of 92f520e942Skarels * CLSIZE pte's describing NBPG (from machine/machparam.h) pages each. 935db792e4Sbill * 945db792e4Sbill * NOTE: SSIZE, SINCR and UPAGES must be multiples of CLSIZE 955db792e4Sbill */ 96248881f8Swnj #define CLBYTES (CLSIZE*NBPG) 97e163c03cSwnj #define CLOFSET (CLSIZE*NBPG-1) /* for clusters, like PGOFSET */ 98248881f8Swnj #define claligned(x) ((((int)(x))&CLOFSET)==0) 99248881f8Swnj #define CLOFF CLOFSET 100b481cdefSroot #define CLSHIFT (PGSHIFT+CLSIZELOG2) 1015db792e4Sbill 102b481cdefSroot #if CLSIZE==1 103b481cdefSroot #define clbase(i) (i) 104b481cdefSroot #define clrnd(i) (i) 105b481cdefSroot #else 1065db792e4Sbill /* give the base virtual address (first of CLSIZE) */ 1075db792e4Sbill #define clbase(i) ((i) &~ (CLSIZE-1)) 1085db792e4Sbill /* round a number of clicks up to a whole cluster */ 1095db792e4Sbill #define clrnd(i) (((i) + (CLSIZE-1)) &~ (CLSIZE-1)) 110b481cdefSroot #endif 1115db792e4Sbill 1124bda8b2fSkarels /* CBLOCK is the size of a clist block, must be power of 2 */ 1134bda8b2fSkarels #define CBLOCK 64 1142a0e599eSmarc #define CBQSIZE (CBLOCK/NBBY) /* quote bytes/cblock - can do better */ 1152a0e599eSmarc #define CBSIZE (CBLOCK - sizeof(struct cblock *) - CBQSIZE) /* data chars/clist */ 1164bda8b2fSkarels #define CROUND (CBLOCK - 1) /* clist rounding */ 1175db792e4Sbill 1185db792e4Sbill /* 119389af1dfSmckusic * File system parameters and macros. 120389af1dfSmckusic * 121389af1dfSmckusic * The file system is made out of blocks of at most MAXBSIZE units, 122389af1dfSmckusic * with smaller units (fragments) only in the last direct block. 123389af1dfSmckusic * MAXBSIZE primarily determines the size of buffers in the buffer 124389af1dfSmckusic * pool. It may be made larger without any effect on existing 125389af1dfSmckusic * file systems; however making it smaller make make some file 126389af1dfSmckusic * systems unmountable. 127389af1dfSmckusic */ 128389af1dfSmckusic #define MAXBSIZE 8192 129389af1dfSmckusic #define MAXFRAG 8 130389af1dfSmckusic 131edc472f6Skre /* 132389af1dfSmckusic * MAXPATHLEN defines the longest permissable path length 133389af1dfSmckusic * after expanding symbolic links. It is used to allocate 134389af1dfSmckusic * a temporary buffer from the buffer pool in which to do the 135389af1dfSmckusic * name expansion, hence should be a power of two, and must 136389af1dfSmckusic * be less than or equal to MAXBSIZE. 137389af1dfSmckusic * MAXSYMLINKS defines the maximum number of symbolic links 138389af1dfSmckusic * that may be expanded in a path name. It should be set high 139389af1dfSmckusic * enough to allow all legitimate uses, but halt infinite loops 140389af1dfSmckusic * reasonably quickly. 141389af1dfSmckusic */ 1424a9959f4Sbostic #define MAXPATHLEN PATH_MAX 143389af1dfSmckusic #define MAXSYMLINKS 8 144389af1dfSmckusic 145389af1dfSmckusic /* 146ab090aa7Skarels * bit map related macros 147ab090aa7Skarels */ 148ab090aa7Skarels #define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY)) 149ab090aa7Skarels #define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY))) 150ab090aa7Skarels #define isset(a,i) ((a)[(i)/NBBY] & (1<<((i)%NBBY))) 151ab090aa7Skarels #define isclr(a,i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0) 152ab090aa7Skarels 153ab090aa7Skarels /* 154ab090aa7Skarels * Macros for counting and rounding. 155ab090aa7Skarels */ 156ab090aa7Skarels #ifndef howmany 157ab090aa7Skarels #define howmany(x, y) (((x)+((y)-1))/(y)) 158ab090aa7Skarels #endif 159ab090aa7Skarels #define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) 160ab090aa7Skarels #define powerof2(x) ((((x)-1)&(x))==0) 161ab090aa7Skarels 162ab090aa7Skarels /* 163ab090aa7Skarels * Macros for fast min/max: 164ab090aa7Skarels * with inline expansion, the "function" is faster. 165ab090aa7Skarels */ 166ab090aa7Skarels #ifdef KERNEL 167ab090aa7Skarels #define MIN(a,b) min((a), (b)) 168ab090aa7Skarels #define MAX(a,b) max((a), (b)) 169ab090aa7Skarels #else 170ab090aa7Skarels #define MIN(a,b) (((a)<(b))?(a):(b)) 171ab090aa7Skarels #define MAX(a,b) (((a)>(b))?(a):(b)) 172ab090aa7Skarels #endif 173ab090aa7Skarels 174ab090aa7Skarels /* 1752fe64d92Smckusick * Constants for setting the parameters of the kernel memory allocator. 1762fe64d92Smckusick * 1772fe64d92Smckusick * 2 ** MINBUCKET is the smallest unit of memory that will be 1782fe64d92Smckusick * allocated. It must be at least large enough to hold a pointer. 1792fe64d92Smckusick * 1802fe64d92Smckusick * Units of memory less or equal to MAXALLOCSAVE will permanently 1812fe64d92Smckusick * allocate physical memory; requests for these size pieces of 1822fe64d92Smckusick * memory are quite fast. Allocations greater than MAXALLOCSAVE must 1832fe64d92Smckusick * always allocate and free physical memory; requests for these 1842fe64d92Smckusick * size allocations should be done infrequently as they will be slow. 1852fe64d92Smckusick * Constraints: CLBYTES <= MAXALLOCSAVE <= 2 ** (MINBUCKET + 14) 1862fe64d92Smckusick * and MAXALLOCSIZE must be a power of two. 1872fe64d92Smckusick */ 1882fe64d92Smckusick #define MINBUCKET 4 /* 4 => min allocation of 16 bytes */ 1892fe64d92Smckusick #define MAXALLOCSAVE (2 * CLBYTES) 1902fe64d92Smckusick 1912fe64d92Smckusick /* 1924233ee38Smckusick * Scale factor for scaled integers used to count %cpu time and load avgs. 1934233ee38Smckusick * 1944233ee38Smckusick * The number of CPU `tick's that map to a unique `%age' can be expressed 1954233ee38Smckusick * by the formula (1 / (2 ^ (FSHIFT - 11))). The maximum load average that 1964233ee38Smckusick * can be calculated (assuming 32 bits) can be closely approximated using 1974233ee38Smckusick * the formula (2 ^ (2 * (16 - FSHIFT))) for (FSHIFT < 15). 1984233ee38Smckusick * 1994233ee38Smckusick * For the scheduler to maintain a 1:1 mapping of CPU `tick' to `%age', 2004233ee38Smckusick * FSHIFT must be at least 11; this gives us a maximum load avg of ~1024. 2014233ee38Smckusick */ 2024233ee38Smckusick #define FSHIFT 11 /* bits to right of fixed binary point */ 2034233ee38Smckusick #define FSCALE (1<<FSHIFT) 204