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*47539Skarels * @(#)param.h 7.20 (Berkeley) 03/17/91 723430Smckusick */ 863Sbill 944382Skarels #define BSD 199006 /* June, 1990 system version (year & month) */ 1025297Skarels #define BSD4_3 1 1140631Skarels #define BSD4_4 0.5 1224654Sbloom 1336805Sbostic #include <sys/syslimits.h> 1436805Sbostic 1563Sbill /* 168993Sroot * Machine-independent constants 178993Sroot */ 1840631Skarels #define MAXUPRC CHILD_MAX /* max processes per user */ 1940631Skarels #define NOFILE OPEN_MAX /* max open files per process */ 2040631Skarels #define NCARGS ARG_MAX /* # characters in exec arglist */ 2140631Skarels #define MAXINTERP 32 /* max interpreter file name length */ 2240631Skarels #define NGROUPS NGROUPS_MAX /* max number groups */ 2343890Skarels #define MAXHOSTNAMELEN 256 /* maximum hostname size */ 2443890Skarels #define MAXCOMLEN 16 /* maximum command name remembered */ 2543890Skarels /* MAXCOMLEN should be >= sizeof(ac_comm) (acct.h) */ 2643890Skarels #define MAXLOGNAME 12 /* maximum login name length */ 2743890Skarels /* MAXLOGNAME must be >= UT_NAMESIZE (<utmp.h>) */ 282751Swnj 2940631Skarels #define NOGROUP 65535 /* marker for empty group set member */ 3011808Ssam 3163Sbill /* 32*47539Skarels * Priorities. Note that with 32 run queues, 33*47539Skarels * differences less than 4 are insignificant. 3463Sbill */ 3563Sbill #define PSWP 0 36*47539Skarels #define PVM 4 37*47539Skarels #define PINOD 8 38*47539Skarels #define PRIBIO 16 39*47539Skarels #define PVFS 20 40*47539Skarels #define PSOCK 24 41*47539Skarels #define PZERO 25 /* No longer magic, shouldn't be here XXX */ 42*47539Skarels #define PWAIT 32 43*47539Skarels #define PLOCK 36 4440631Skarels #define PPAUSE 40 4563Sbill #define PUSER 50 46*47539Skarels #define MAXPRI 127 /* priorities range from 0 through MAXPRI */ 47*47539Skarels 4840631Skarels #define PRIMASK 0x0ff 4940631Skarels #define PCATCH 0x100 /* or'd with pri for tsleep to check signals */ 5063Sbill 51*47539Skarels #define NZERO 0 /* default "nice" */ 5263Sbill 5345793Sbostic #ifndef LOCORE 54*47539Skarels #include <sys/types.h> 5530406Skarels #endif 5630406Skarels 5763Sbill /* 58*47539Skarels * More types and definitions used throughout the kernel 59*47539Skarels */ 60*47539Skarels #ifdef KERNEL 61*47539Skarels #include <sys/cdefs.h> 62*47539Skarels #include <sys/errno.h> 63*47539Skarels #include <sys/time.h> 64*47539Skarels #include <sys/resource.h> 65*47539Skarels #include <sys/ucred.h> 66*47539Skarels #include <sys/uio.h> 67*47539Skarels #endif 68*47539Skarels 69*47539Skarels /* 708993Sroot * Signals 7163Sbill */ 7238783Skarels #include <sys/signal.h> 7363Sbill 7430406Skarels /* 7530406Skarels * Machine type dependent parameters. 7630406Skarels */ 7745793Sbostic #include <machine/param.h> 7845793Sbostic #include <machine/endian.h> 7945793Sbostic #include <machine/limits.h> 8030406Skarels 8112880Ssam #define NBPW sizeof(int) /* number of bytes in an integer */ 8263Sbill 8338783Skarels #ifndef NULL 8463Sbill #define NULL 0 8538783Skarels #endif 8616796Skarels #define CMASK 022 /* default mask for file creation */ 8763Sbill #define NODEV (dev_t)(-1) 8863Sbill 8963Sbill /* 9063Sbill * Clustering of hardware pages on machines with ridiculously small 9163Sbill * page sizes is done here. The paging subsystem deals with units of 9230406Skarels * CLSIZE pte's describing NBPG (from machine/machparam.h) pages each. 9363Sbill * 9463Sbill * NOTE: SSIZE, SINCR and UPAGES must be multiples of CLSIZE 9563Sbill */ 965080Swnj #define CLBYTES (CLSIZE*NBPG) 972637Swnj #define CLOFSET (CLSIZE*NBPG-1) /* for clusters, like PGOFSET */ 985080Swnj #define claligned(x) ((((int)(x))&CLOFSET)==0) 995080Swnj #define CLOFF CLOFSET 1008993Sroot #define CLSHIFT (PGSHIFT+CLSIZELOG2) 10163Sbill 1028993Sroot #if CLSIZE==1 1038993Sroot #define clbase(i) (i) 1048993Sroot #define clrnd(i) (i) 1058993Sroot #else 10663Sbill /* give the base virtual address (first of CLSIZE) */ 10763Sbill #define clbase(i) ((i) &~ (CLSIZE-1)) 10863Sbill /* round a number of clicks up to a whole cluster */ 10963Sbill #define clrnd(i) (((i) + (CLSIZE-1)) &~ (CLSIZE-1)) 1108993Sroot #endif 11163Sbill 11224930Skarels /* CBLOCK is the size of a clist block, must be power of 2 */ 11324930Skarels #define CBLOCK 64 11435813Smarc #define CBQSIZE (CBLOCK/NBBY) /* quote bytes/cblock - can do better */ 11535813Smarc #define CBSIZE (CBLOCK - sizeof(struct cblock *) - CBQSIZE) /* data chars/clist */ 11624930Skarels #define CROUND (CBLOCK - 1) /* clist rounding */ 11763Sbill 11863Sbill /* 1196564Smckusic * File system parameters and macros. 1206564Smckusic * 1216564Smckusic * The file system is made out of blocks of at most MAXBSIZE units, 1226564Smckusic * with smaller units (fragments) only in the last direct block. 1236564Smckusic * MAXBSIZE primarily determines the size of buffers in the buffer 1246564Smckusic * pool. It may be made larger without any effect on existing 1256564Smckusic * file systems; however making it smaller make make some file 1266564Smckusic * systems unmountable. 1273069Swnj */ 1286564Smckusic #define MAXBSIZE 8192 1296564Smckusic #define MAXFRAG 8 1306564Smckusic 1316564Smckusic /* 1326564Smckusic * MAXPATHLEN defines the longest permissable path length 1336564Smckusic * after expanding symbolic links. It is used to allocate 1346564Smckusic * a temporary buffer from the buffer pool in which to do the 1356564Smckusic * name expansion, hence should be a power of two, and must 1366564Smckusic * be less than or equal to MAXBSIZE. 1376564Smckusic * MAXSYMLINKS defines the maximum number of symbolic links 1386564Smckusic * that may be expanded in a path name. It should be set high 1396564Smckusic * enough to allow all legitimate uses, but halt infinite loops 1406564Smckusic * reasonably quickly. 1416564Smckusic */ 14236805Sbostic #define MAXPATHLEN PATH_MAX 1436564Smckusic #define MAXSYMLINKS 8 1446564Smckusic 1456564Smckusic /* 14640209Skarels * bit map related macros 14740209Skarels */ 14840209Skarels #define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY)) 14940209Skarels #define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY))) 15040209Skarels #define isset(a,i) ((a)[(i)/NBBY] & (1<<((i)%NBBY))) 15140209Skarels #define isclr(a,i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0) 15240209Skarels 15340209Skarels /* 15440209Skarels * Macros for counting and rounding. 15540209Skarels */ 15640209Skarels #ifndef howmany 15740209Skarels #define howmany(x, y) (((x)+((y)-1))/(y)) 15840209Skarels #endif 15940209Skarels #define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) 16040209Skarels #define powerof2(x) ((((x)-1)&(x))==0) 16140209Skarels 16240209Skarels /* 16340209Skarels * Macros for fast min/max: 16440209Skarels * with inline expansion, the "function" is faster. 16540209Skarels */ 16640209Skarels #ifdef KERNEL 16740209Skarels #define MIN(a,b) min((a), (b)) 16840209Skarels #define MAX(a,b) max((a), (b)) 16940209Skarels #else 17040209Skarels #define MIN(a,b) (((a)<(b))?(a):(b)) 17140209Skarels #define MAX(a,b) (((a)>(b))?(a):(b)) 17240209Skarels #endif 17340209Skarels 17440209Skarels /* 17531414Smckusick * Constants for setting the parameters of the kernel memory allocator. 17631414Smckusick * 17731414Smckusick * 2 ** MINBUCKET is the smallest unit of memory that will be 17831414Smckusick * allocated. It must be at least large enough to hold a pointer. 17931414Smckusick * 18031414Smckusick * Units of memory less or equal to MAXALLOCSAVE will permanently 18131414Smckusick * allocate physical memory; requests for these size pieces of 18231414Smckusick * memory are quite fast. Allocations greater than MAXALLOCSAVE must 18331414Smckusick * always allocate and free physical memory; requests for these 18431414Smckusick * size allocations should be done infrequently as they will be slow. 18531414Smckusick * Constraints: CLBYTES <= MAXALLOCSAVE <= 2 ** (MINBUCKET + 14) 18631414Smckusick * and MAXALLOCSIZE must be a power of two. 18731414Smckusick */ 18831414Smckusick #define MINBUCKET 4 /* 4 => min allocation of 16 bytes */ 18931414Smckusick #define MAXALLOCSAVE (2 * CLBYTES) 19031414Smckusick 19131414Smckusick /* 19238161Smckusick * Scale factor for scaled integers used to count %cpu time and load avgs. 19338161Smckusick * 19438161Smckusick * The number of CPU `tick's that map to a unique `%age' can be expressed 19538161Smckusick * by the formula (1 / (2 ^ (FSHIFT - 11))). The maximum load average that 19638161Smckusick * can be calculated (assuming 32 bits) can be closely approximated using 19738161Smckusick * the formula (2 ^ (2 * (16 - FSHIFT))) for (FSHIFT < 15). 19838161Smckusick * 19938161Smckusick * For the scheduler to maintain a 1:1 mapping of CPU `tick' to `%age', 20038161Smckusick * FSHIFT must be at least 11; this gives us a maximum load avg of ~1024. 20138161Smckusick */ 20238161Smckusick #define FSHIFT 11 /* bits to right of fixed binary point */ 20338161Smckusick #define FSCALE (1<<FSHIFT) 204