165a1cfb1Smckusick /* 2d1a9b8adSmckusick * Copyright (c) 1982, 1986 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*4a9959f4Sbostic * @(#)param.h 7.7 (Berkeley) 02/16/89 765a1cfb1Smckusick */ 85db792e4Sbill 92a0e599eSmarc #define BSD 198810 /* system version (year & month) */ 101a9e6e3cSkarels #define BSD4_3 1 112867d692Sbloom 12*4a9959f4Sbostic #include <sys/syslimits.h> 13*4a9959f4Sbostic 145db792e4Sbill /* 15b481cdefSroot * Machine-independent constants 16b481cdefSroot */ 1774c6c69bSkarels #define NMOUNT 20 /* number of mountable file systems */ 18f0028148Skarels /* NMOUNT must be <= 255 unless c_mdev (cmap.h) is expanded */ 19818d21a2Skarels #define MSWAPX NMOUNT /* pseudo mount table index for swapdev */ 20*4a9959f4Sbostic #define MAXUPRC CHILD_MAX /* max processes per user */ 21*4a9959f4Sbostic #define NOFILE OPEN_MAX /* max open files per process */ 225db792e4Sbill #define CANBSIZ 256 /* max size of typewriter line */ 23*4a9959f4Sbostic #define NCARGS ARG_MAX /* # characters in exec arglist */ 24aeeef3fcSbostic #define MAXINTERP 32 /* maximum interpreter file name length */ 25*4a9959f4Sbostic #define NGROUPS NGROUPS_MAX /* max number groups */ 26f520e942Skarels #define MAXHOSTNAMELEN 64 /* maximum hostname size */ 2745ac661dSwnj 28ebd4ffb8Skarels #define NOGROUP 65535 /* marker for empty group set member */ 29e74c57f3Ssam 305db792e4Sbill /* 31b481cdefSroot * Priorities 325db792e4Sbill */ 335db792e4Sbill #define PSWP 0 345db792e4Sbill #define PINOD 10 355db792e4Sbill #define PRIBIO 20 365db792e4Sbill #define PRIUBA 24 375db792e4Sbill #define PZERO 25 385db792e4Sbill #define PPIPE 26 395db792e4Sbill #define PWAIT 30 40bea46c20Ssam #define PLOCK 35 415db792e4Sbill #define PSLEP 40 425db792e4Sbill #define PUSER 50 435db792e4Sbill 4474c6c69bSkarels #define NZERO 0 455db792e4Sbill 46f520e942Skarels #ifndef KERNEL 47f520e942Skarels #include <sys/types.h> 48f520e942Skarels #else 49f520e942Skarels #ifndef LOCORE 50f520e942Skarels #include "types.h" 51f520e942Skarels #endif 52f520e942Skarels #endif 53f520e942Skarels 545db792e4Sbill /* 55b481cdefSroot * Signals 565db792e4Sbill */ 57586761c3Ssam #ifdef KERNEL 5864691dc4Sbloom #include "signal.h" 59586761c3Ssam #else 6046cc71adSbill #include <signal.h> 6146cc71adSbill #endif 62c6983186Sbill 63586761c3Ssam #define ISSIG(p) \ 64586761c3Ssam ((p)->p_sig && ((p)->p_flag&STRC || \ 65eb2beebeSroot ((p)->p_sig &~ ((p)->p_sigignore | (p)->p_sigmask))) && issig()) 6603c2128fSroot 67f520e942Skarels /* 68f520e942Skarels * Machine type dependent parameters. 69f520e942Skarels */ 70f520e942Skarels #ifdef KERNEL 71f520e942Skarels #include "../machine/machparam.h" 72f520e942Skarels #else 73f520e942Skarels #include <machine/machparam.h> 74f520e942Skarels #endif 75f520e942Skarels 765db792e4Sbill #define NBPW sizeof(int) /* number of bytes in an integer */ 775db792e4Sbill 785db792e4Sbill #define NULL 0 79f0028148Skarels #define CMASK 022 /* default mask for file creation */ 805db792e4Sbill #define NODEV (dev_t)(-1) 815db792e4Sbill 825db792e4Sbill /* 835db792e4Sbill * Clustering of hardware pages on machines with ridiculously small 845db792e4Sbill * page sizes is done here. The paging subsystem deals with units of 85f520e942Skarels * CLSIZE pte's describing NBPG (from machine/machparam.h) pages each. 865db792e4Sbill * 875db792e4Sbill * NOTE: SSIZE, SINCR and UPAGES must be multiples of CLSIZE 885db792e4Sbill */ 89248881f8Swnj #define CLBYTES (CLSIZE*NBPG) 90e163c03cSwnj #define CLOFSET (CLSIZE*NBPG-1) /* for clusters, like PGOFSET */ 91248881f8Swnj #define claligned(x) ((((int)(x))&CLOFSET)==0) 92248881f8Swnj #define CLOFF CLOFSET 93b481cdefSroot #define CLSHIFT (PGSHIFT+CLSIZELOG2) 945db792e4Sbill 95b481cdefSroot #if CLSIZE==1 96b481cdefSroot #define clbase(i) (i) 97b481cdefSroot #define clrnd(i) (i) 98b481cdefSroot #else 995db792e4Sbill /* give the base virtual address (first of CLSIZE) */ 1005db792e4Sbill #define clbase(i) ((i) &~ (CLSIZE-1)) 1015db792e4Sbill /* round a number of clicks up to a whole cluster */ 1025db792e4Sbill #define clrnd(i) (((i) + (CLSIZE-1)) &~ (CLSIZE-1)) 103b481cdefSroot #endif 1045db792e4Sbill 1054bda8b2fSkarels /* CBLOCK is the size of a clist block, must be power of 2 */ 1064bda8b2fSkarels #define CBLOCK 64 1072a0e599eSmarc #define CBQSIZE (CBLOCK/NBBY) /* quote bytes/cblock - can do better */ 1082a0e599eSmarc #define CBSIZE (CBLOCK - sizeof(struct cblock *) - CBQSIZE) /* data chars/clist */ 1094bda8b2fSkarels #define CROUND (CBLOCK - 1) /* clist rounding */ 1105db792e4Sbill 1115db792e4Sbill /* 112389af1dfSmckusic * File system parameters and macros. 113389af1dfSmckusic * 114389af1dfSmckusic * The file system is made out of blocks of at most MAXBSIZE units, 115389af1dfSmckusic * with smaller units (fragments) only in the last direct block. 116389af1dfSmckusic * MAXBSIZE primarily determines the size of buffers in the buffer 117389af1dfSmckusic * pool. It may be made larger without any effect on existing 118389af1dfSmckusic * file systems; however making it smaller make make some file 119389af1dfSmckusic * systems unmountable. 120389af1dfSmckusic * 121389af1dfSmckusic * Note that the blocked devices are assumed to have DEV_BSIZE 122389af1dfSmckusic * "sectors" and that fragments must be some multiple of this size. 12391d57239Smckusick * Block devices are read in BLKDEV_IOSIZE units. This number must 12491d57239Smckusick * be a power of two and in the range of 12591d57239Smckusick * DEV_BSIZE <= BLKDEV_IOSIZE <= MAXBSIZE 12691d57239Smckusick * This size has no effect upon the file system, but is usually set 12791d57239Smckusick * to the block size of the root file system, so as to maximize the 12891d57239Smckusick * speed of ``fsck''. 129389af1dfSmckusic */ 130389af1dfSmckusic #define MAXBSIZE 8192 131389af1dfSmckusic #define MAXFRAG 8 132389af1dfSmckusic 133edc472f6Skre /* 134389af1dfSmckusic * MAXPATHLEN defines the longest permissable path length 135389af1dfSmckusic * after expanding symbolic links. It is used to allocate 136389af1dfSmckusic * a temporary buffer from the buffer pool in which to do the 137389af1dfSmckusic * name expansion, hence should be a power of two, and must 138389af1dfSmckusic * be less than or equal to MAXBSIZE. 139389af1dfSmckusic * MAXSYMLINKS defines the maximum number of symbolic links 140389af1dfSmckusic * that may be expanded in a path name. It should be set high 141389af1dfSmckusic * enough to allow all legitimate uses, but halt infinite loops 142389af1dfSmckusic * reasonably quickly. 143389af1dfSmckusic */ 144*4a9959f4Sbostic #define MAXPATHLEN PATH_MAX 145389af1dfSmckusic #define MAXSYMLINKS 8 146389af1dfSmckusic 147389af1dfSmckusic /* 1482fe64d92Smckusick * Constants for setting the parameters of the kernel memory allocator. 1492fe64d92Smckusick * 1502fe64d92Smckusick * 2 ** MINBUCKET is the smallest unit of memory that will be 1512fe64d92Smckusick * allocated. It must be at least large enough to hold a pointer. 1522fe64d92Smckusick * 1532fe64d92Smckusick * Units of memory less or equal to MAXALLOCSAVE will permanently 1542fe64d92Smckusick * allocate physical memory; requests for these size pieces of 1552fe64d92Smckusick * memory are quite fast. Allocations greater than MAXALLOCSAVE must 1562fe64d92Smckusick * always allocate and free physical memory; requests for these 1572fe64d92Smckusick * size allocations should be done infrequently as they will be slow. 1582fe64d92Smckusick * Constraints: CLBYTES <= MAXALLOCSAVE <= 2 ** (MINBUCKET + 14) 1592fe64d92Smckusick * and MAXALLOCSIZE must be a power of two. 1602fe64d92Smckusick */ 1612fe64d92Smckusick #define MINBUCKET 4 /* 4 => min allocation of 16 bytes */ 1622fe64d92Smckusick #define MAXALLOCSAVE (2 * CLBYTES) 1632fe64d92Smckusick 1642fe64d92Smckusick /* 165389af1dfSmckusic * bit map related macros 166389af1dfSmckusic */ 167389af1dfSmckusic #define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY)) 168389af1dfSmckusic #define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY))) 169389af1dfSmckusic #define isset(a,i) ((a)[(i)/NBBY] & (1<<((i)%NBBY))) 170389af1dfSmckusic #define isclr(a,i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0) 171389af1dfSmckusic 172389af1dfSmckusic /* 173389af1dfSmckusic * Macros for fast min/max. 174389af1dfSmckusic */ 175389af1dfSmckusic #define MIN(a,b) (((a)<(b))?(a):(b)) 176389af1dfSmckusic #define MAX(a,b) (((a)>(b))?(a):(b)) 177389af1dfSmckusic 178389af1dfSmckusic /* 179389af1dfSmckusic * Macros for counting and rounding. 180389af1dfSmckusic */ 18183a906b7Skarels #ifndef howmany 182389af1dfSmckusic #define howmany(x, y) (((x)+((y)-1))/(y)) 18383a906b7Skarels #endif 184389af1dfSmckusic #define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) 1852fe64d92Smckusick #define powerof2(x) ((((x)-1)&(x))==0) 186