123430Smckusick /* 238783Skarels * Copyright (c) 1982, 1986, 1989 Regents of the University of California. 323430Smckusick * All rights reserved. The Berkeley software License Agreement 423430Smckusick * specifies the terms and conditions for redistribution. 523430Smckusick * 6*40631Skarels * @(#)param.h 7.13 (Berkeley) 03/25/90 723430Smckusick */ 863Sbill 9*40631Skarels #define BSD 199003 /* system version (year & month) */ 1025297Skarels #define BSD4_3 1 11*40631Skarels #define BSD4_4 0.5 1224654Sbloom 1336805Sbostic #include <sys/syslimits.h> 1436805Sbostic 1563Sbill /* 168993Sroot * Machine-independent constants 178993Sroot */ 18*40631Skarels #define NMOUNT 30 /* number of mountable file systems */ 1916796Skarels /* NMOUNT must be <= 255 unless c_mdev (cmap.h) is expanded */ 20*40631Skarels #define MSWAPX NMOUNT /* pseudo mount index for swapdev */ 21*40631Skarels #define MAXUPRC CHILD_MAX /* max processes per user */ 22*40631Skarels #define NOFILE OPEN_MAX /* max open files per process */ 23*40631Skarels #define CANBSIZ 256 /* max size of tty input line */ 24*40631Skarels #define NCARGS ARG_MAX /* # characters in exec arglist */ 25*40631Skarels #define MAXINTERP 32 /* max interpreter file name length */ 26*40631Skarels #define NGROUPS NGROUPS_MAX /* max number groups */ 27*40631Skarels #define MAXHOSTNAMELEN 64 /* maximum hostname size */ 282751Swnj 29*40631Skarels #define NOGROUP 65535 /* marker for empty group set member */ 3011808Ssam 3163Sbill /* 328993Sroot * Priorities 3363Sbill */ 3463Sbill #define PSWP 0 3563Sbill #define PINOD 10 3663Sbill #define PRIBIO 20 3737717Smckusick #define PVFS 22 3863Sbill #define PZERO 25 39*40631Skarels #define PSOCK 26 4063Sbill #define PWAIT 30 417688Ssam #define PLOCK 35 42*40631Skarels #define PPAUSE 40 4363Sbill #define PUSER 50 44*40631Skarels #define PRIMASK 0x0ff 45*40631Skarels #define PCATCH 0x100 /* or'd with pri for tsleep to check signals */ 46*40631Skarels #define PABORT 0x200 /* or'd with pri for tsleep to longjmp XXX */ 4763Sbill 4817556Skarels #define NZERO 0 4963Sbill 5030406Skarels #ifndef KERNEL 5130406Skarels #include <sys/types.h> 5230406Skarels #else 5330406Skarels #ifndef LOCORE 5430406Skarels #include "types.h" 5530406Skarels #endif 5630406Skarels #endif 5730406Skarels 5863Sbill /* 598993Sroot * Signals 6063Sbill */ 6112880Ssam #ifdef KERNEL 6217033Sbloom #include "signal.h" 6312880Ssam #else 6438783Skarels #include <sys/signal.h> 65176Sbill #endif 6663Sbill 6730406Skarels /* 6830406Skarels * Machine type dependent parameters. 6930406Skarels */ 7030406Skarels #ifdef KERNEL 7137497Smckusick #include "machine/machparam.h" 7230406Skarels #else 7330406Skarels #include <machine/machparam.h> 7430406Skarels #endif 7530406Skarels 7612880Ssam #define NBPW sizeof(int) /* number of bytes in an integer */ 7763Sbill 7838783Skarels #ifndef NULL 7963Sbill #define NULL 0 8038783Skarels #endif 8116796Skarels #define CMASK 022 /* default mask for file creation */ 8263Sbill #define NODEV (dev_t)(-1) 8363Sbill 8463Sbill /* 8563Sbill * Clustering of hardware pages on machines with ridiculously small 8663Sbill * page sizes is done here. The paging subsystem deals with units of 8730406Skarels * CLSIZE pte's describing NBPG (from machine/machparam.h) pages each. 8863Sbill * 8963Sbill * NOTE: SSIZE, SINCR and UPAGES must be multiples of CLSIZE 9063Sbill */ 915080Swnj #define CLBYTES (CLSIZE*NBPG) 922637Swnj #define CLOFSET (CLSIZE*NBPG-1) /* for clusters, like PGOFSET */ 935080Swnj #define claligned(x) ((((int)(x))&CLOFSET)==0) 945080Swnj #define CLOFF CLOFSET 958993Sroot #define CLSHIFT (PGSHIFT+CLSIZELOG2) 9663Sbill 978993Sroot #if CLSIZE==1 988993Sroot #define clbase(i) (i) 998993Sroot #define clrnd(i) (i) 1008993Sroot #else 10163Sbill /* give the base virtual address (first of CLSIZE) */ 10263Sbill #define clbase(i) ((i) &~ (CLSIZE-1)) 10363Sbill /* round a number of clicks up to a whole cluster */ 10463Sbill #define clrnd(i) (((i) + (CLSIZE-1)) &~ (CLSIZE-1)) 1058993Sroot #endif 10663Sbill 10724930Skarels /* CBLOCK is the size of a clist block, must be power of 2 */ 10824930Skarels #define CBLOCK 64 10935813Smarc #define CBQSIZE (CBLOCK/NBBY) /* quote bytes/cblock - can do better */ 11035813Smarc #define CBSIZE (CBLOCK - sizeof(struct cblock *) - CBQSIZE) /* data chars/clist */ 11124930Skarels #define CROUND (CBLOCK - 1) /* clist rounding */ 11263Sbill 11363Sbill /* 1146564Smckusic * File system parameters and macros. 1156564Smckusic * 1166564Smckusic * The file system is made out of blocks of at most MAXBSIZE units, 1176564Smckusic * with smaller units (fragments) only in the last direct block. 1186564Smckusic * MAXBSIZE primarily determines the size of buffers in the buffer 1196564Smckusic * pool. It may be made larger without any effect on existing 1206564Smckusic * file systems; however making it smaller make make some file 1216564Smckusic * systems unmountable. 1223069Swnj */ 1236564Smckusic #define MAXBSIZE 8192 1246564Smckusic #define MAXFRAG 8 1256564Smckusic 1266564Smckusic /* 1276564Smckusic * MAXPATHLEN defines the longest permissable path length 1286564Smckusic * after expanding symbolic links. It is used to allocate 1296564Smckusic * a temporary buffer from the buffer pool in which to do the 1306564Smckusic * name expansion, hence should be a power of two, and must 1316564Smckusic * be less than or equal to MAXBSIZE. 1326564Smckusic * MAXSYMLINKS defines the maximum number of symbolic links 1336564Smckusic * that may be expanded in a path name. It should be set high 1346564Smckusic * enough to allow all legitimate uses, but halt infinite loops 1356564Smckusic * reasonably quickly. 1366564Smckusic */ 13736805Sbostic #define MAXPATHLEN PATH_MAX 1386564Smckusic #define MAXSYMLINKS 8 1396564Smckusic 1406564Smckusic /* 14140209Skarels * bit map related macros 14240209Skarels */ 14340209Skarels #define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY)) 14440209Skarels #define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY))) 14540209Skarels #define isset(a,i) ((a)[(i)/NBBY] & (1<<((i)%NBBY))) 14640209Skarels #define isclr(a,i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0) 14740209Skarels 14840209Skarels /* 14940209Skarels * Macros for counting and rounding. 15040209Skarels */ 15140209Skarels #ifndef howmany 15240209Skarels #define howmany(x, y) (((x)+((y)-1))/(y)) 15340209Skarels #endif 15440209Skarels #define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) 15540209Skarels #define powerof2(x) ((((x)-1)&(x))==0) 15640209Skarels 15740209Skarels /* 15840209Skarels * Macros for fast min/max: 15940209Skarels * with inline expansion, the "function" is faster. 16040209Skarels */ 16140209Skarels #ifdef KERNEL 16240209Skarels #define MIN(a,b) min((a), (b)) 16340209Skarels #define MAX(a,b) max((a), (b)) 16440209Skarels #else 16540209Skarels #define MIN(a,b) (((a)<(b))?(a):(b)) 16640209Skarels #define MAX(a,b) (((a)>(b))?(a):(b)) 16740209Skarels #endif 16840209Skarels 16940209Skarels /* 17031414Smckusick * Constants for setting the parameters of the kernel memory allocator. 17131414Smckusick * 17231414Smckusick * 2 ** MINBUCKET is the smallest unit of memory that will be 17331414Smckusick * allocated. It must be at least large enough to hold a pointer. 17431414Smckusick * 17531414Smckusick * Units of memory less or equal to MAXALLOCSAVE will permanently 17631414Smckusick * allocate physical memory; requests for these size pieces of 17731414Smckusick * memory are quite fast. Allocations greater than MAXALLOCSAVE must 17831414Smckusick * always allocate and free physical memory; requests for these 17931414Smckusick * size allocations should be done infrequently as they will be slow. 18031414Smckusick * Constraints: CLBYTES <= MAXALLOCSAVE <= 2 ** (MINBUCKET + 14) 18131414Smckusick * and MAXALLOCSIZE must be a power of two. 18231414Smckusick */ 18331414Smckusick #define MINBUCKET 4 /* 4 => min allocation of 16 bytes */ 18431414Smckusick #define MAXALLOCSAVE (2 * CLBYTES) 18531414Smckusick 18631414Smckusick /* 18738161Smckusick * Scale factor for scaled integers used to count %cpu time and load avgs. 18838161Smckusick * 18938161Smckusick * The number of CPU `tick's that map to a unique `%age' can be expressed 19038161Smckusick * by the formula (1 / (2 ^ (FSHIFT - 11))). The maximum load average that 19138161Smckusick * can be calculated (assuming 32 bits) can be closely approximated using 19238161Smckusick * the formula (2 ^ (2 * (16 - FSHIFT))) for (FSHIFT < 15). 19338161Smckusick * 19438161Smckusick * For the scheduler to maintain a 1:1 mapping of CPU `tick' to `%age', 19538161Smckusick * FSHIFT must be at least 11; this gives us a maximum load avg of ~1024. 19638161Smckusick */ 19738161Smckusick #define FSHIFT 11 /* bits to right of fixed binary point */ 19838161Smckusick #define FSCALE (1<<FSHIFT) 199