19ae9ad29Sbostic /*- 29ae9ad29Sbostic * Copyright (c) 1982, 1986, 1989 The Regents of the University of California. 39ae9ad29Sbostic * All rights reserved. 465a1cfb1Smckusick * 59ae9ad29Sbostic * %sccs.include.redist.c% 69ae9ad29Sbostic * 7*50ed812dSbostic * @(#)param.h 7.28 (Berkeley) 04/29/93 865a1cfb1Smckusick */ 95db792e4Sbill 10*50ed812dSbostic #define BSD 199306 /* System version (year & month). */ 111a9e6e3cSkarels #define BSD4_3 1 12*50ed812dSbostic #define BSD4_4 1 132867d692Sbloom 149ae9ad29Sbostic #ifndef NULL 159ae9ad29Sbostic #define NULL 0 169ae9ad29Sbostic #endif 174a9959f4Sbostic 181ba81c5bSkarels #ifndef LOCORE 191ba81c5bSkarels #include <sys/types.h> 201ba81c5bSkarels #endif 211ba81c5bSkarels 225db792e4Sbill /* 239ae9ad29Sbostic * Machine-independent constants (some used in following include files). 249ae9ad29Sbostic * Redefined constants are from POSIX 1003.1 limits file. 259ae9ad29Sbostic * 269ae9ad29Sbostic * MAXCOMLEN should be >= sizeof(ac_comm) (see <acct.h>) 279ae9ad29Sbostic * MAXLOGNAME should be >= UT_NAMESIZE (see <utmp.h>) 28b481cdefSroot */ 299ae9ad29Sbostic #include <sys/syslimits.h> 309ae9ad29Sbostic 319ae9ad29Sbostic #define MAXCOMLEN 16 /* max command name remembered */ 3257ce53b7Skarels #define MAXINTERP 32 /* max interpreter file name length */ 339ae9ad29Sbostic #define MAXLOGNAME 12 /* max login name length */ 349ae9ad29Sbostic #define MAXUPRC CHILD_MAX /* max simultaneous processes */ 359ae9ad29Sbostic #define NCARGS ARG_MAX /* max bytes for an exec function */ 364a9959f4Sbostic #define NGROUPS NGROUPS_MAX /* max number groups */ 379ae9ad29Sbostic #define NOFILE OPEN_MAX /* max open files per process */ 38ebd4ffb8Skarels #define NOGROUP 65535 /* marker for empty group set member */ 399ae9ad29Sbostic #define MAXHOSTNAMELEN 256 /* max hostname size */ 40e74c57f3Ssam 419ae9ad29Sbostic /* More types and definitions used throughout the kernel. */ 42f34b934bSkarels #ifdef KERNEL 43f34b934bSkarels #include <sys/cdefs.h> 44f34b934bSkarels #include <sys/errno.h> 45f34b934bSkarels #include <sys/time.h> 46f34b934bSkarels #include <sys/resource.h> 47f34b934bSkarels #include <sys/ucred.h> 48f34b934bSkarels #include <sys/uio.h> 49f34b934bSkarels #endif 50f34b934bSkarels 519ae9ad29Sbostic /* Signals. */ 520c67d176Skarels #include <sys/signal.h> 5303c2128fSroot 549ae9ad29Sbostic /* Machine type dependent parameters. */ 5564716fc5Sbostic #include <machine/param.h> 5664716fc5Sbostic #include <machine/limits.h> 57f520e942Skarels 581ba81c5bSkarels /* 599ae9ad29Sbostic * Priorities. Note that with 32 run queues, differences less than 4 are 609ae9ad29Sbostic * insignificant. 611ba81c5bSkarels */ 621ba81c5bSkarels #define PSWP 0 631ba81c5bSkarels #define PVM 4 641ba81c5bSkarels #define PINOD 8 651ba81c5bSkarels #define PRIBIO 16 661ba81c5bSkarels #define PVFS 20 671041662dSkarels #define PZERO 22 /* No longer magic, shouldn't be here. XXX */ 681ba81c5bSkarels #define PSOCK 24 691ba81c5bSkarels #define PWAIT 32 701ba81c5bSkarels #define PLOCK 36 711ba81c5bSkarels #define PPAUSE 40 721ba81c5bSkarels #define PUSER 50 739ae9ad29Sbostic #define MAXPRI 127 /* Priorities range from 0 through MAXPRI. */ 741ba81c5bSkarels 751ba81c5bSkarels #define PRIMASK 0x0ff 769ae9ad29Sbostic #define PCATCH 0x100 /* OR'd with pri for tsleep to check signals */ 771ba81c5bSkarels 781ba81c5bSkarels #define NZERO 0 /* default "nice" */ 791ba81c5bSkarels 809ae9ad29Sbostic #define NBPW sizeof(int) /* number of bytes per word (integer) */ 815db792e4Sbill 829ae9ad29Sbostic #define CMASK 022 /* default file mask: S_IWGRP|S_IWOTH */ 839ae9ad29Sbostic #define NODEV (dev_t)(-1) /* non-existent device */ 845db792e4Sbill 855db792e4Sbill /* 865db792e4Sbill * Clustering of hardware pages on machines with ridiculously small 875db792e4Sbill * page sizes is done here. The paging subsystem deals with units of 88f520e942Skarels * CLSIZE pte's describing NBPG (from machine/machparam.h) pages each. 895db792e4Sbill */ 90248881f8Swnj #define CLBYTES (CLSIZE*NBPG) 91e163c03cSwnj #define CLOFSET (CLSIZE*NBPG-1) /* for clusters, like PGOFSET */ 92248881f8Swnj #define claligned(x) ((((int)(x))&CLOFSET)==0) 93248881f8Swnj #define CLOFF CLOFSET 94b481cdefSroot #define CLSHIFT (PGSHIFT+CLSIZELOG2) 955db792e4Sbill 96b481cdefSroot #if CLSIZE==1 97b481cdefSroot #define clbase(i) (i) 98b481cdefSroot #define clrnd(i) (i) 99b481cdefSroot #else 1009ae9ad29Sbostic /* Give the base virtual address (first of CLSIZE). */ 1015db792e4Sbill #define clbase(i) ((i) &~ (CLSIZE-1)) 1029ae9ad29Sbostic /* Round a number of clicks up to a whole cluster. */ 1035db792e4Sbill #define clrnd(i) (((i) + (CLSIZE-1)) &~ (CLSIZE-1)) 104b481cdefSroot #endif 1055db792e4Sbill 1069ae9ad29Sbostic #define CBLOCK 64 /* Clist block size, must be a power of 2. */ 1079ae9ad29Sbostic #define CBQSIZE (CBLOCK/NBBY) /* Quote bytes/cblock - can do better. */ 1089ae9ad29Sbostic /* Data chars/clist. */ 1099ae9ad29Sbostic #define CBSIZE (CBLOCK - sizeof(struct cblock *) - CBQSIZE) 1109ae9ad29Sbostic #define CROUND (CBLOCK - 1) /* Clist rounding. */ 1115db792e4Sbill 1125db792e4Sbill /* 113389af1dfSmckusic * File system parameters and macros. 114389af1dfSmckusic * 1159ae9ad29Sbostic * The file system is made out of blocks of at most MAXBSIZE units, with 1169ae9ad29Sbostic * smaller units (fragments) only in the last direct block. MAXBSIZE 1179ae9ad29Sbostic * primarily determines the size of buffers in the buffer pool. It may be 1189ae9ad29Sbostic * made larger without any effect on existing file systems; however making 1199ae9ad29Sbostic * it smaller make make some file systems unmountable. 120389af1dfSmckusic */ 1219433929dSmargo #define MAXBSIZE MAXPHYS 122389af1dfSmckusic #define MAXFRAG 8 123389af1dfSmckusic 124edc472f6Skre /* 1259ae9ad29Sbostic * MAXPATHLEN defines the longest permissable path length after expanding 1269ae9ad29Sbostic * symbolic links. It is used to allocate a temporary buffer from the buffer 1279ae9ad29Sbostic * pool in which to do the name expansion, hence should be a power of two, 1289ae9ad29Sbostic * and must be less than or equal to MAXBSIZE. MAXSYMLINKS defines the 1299ae9ad29Sbostic * maximum number of symbolic links that may be expanded in a path name. 1309ae9ad29Sbostic * It should be set high enough to allow all legitimate uses, but halt 1319ae9ad29Sbostic * infinite loops reasonably quickly. 132389af1dfSmckusic */ 1334a9959f4Sbostic #define MAXPATHLEN PATH_MAX 134389af1dfSmckusic #define MAXSYMLINKS 8 135389af1dfSmckusic 1369ae9ad29Sbostic /* Bit map related macros. */ 137ab090aa7Skarels #define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY)) 138ab090aa7Skarels #define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY))) 139ab090aa7Skarels #define isset(a,i) ((a)[(i)/NBBY] & (1<<((i)%NBBY))) 140ab090aa7Skarels #define isclr(a,i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0) 141ab090aa7Skarels 1429ae9ad29Sbostic /* Macros for counting and rounding. */ 143ab090aa7Skarels #ifndef howmany 144ab090aa7Skarels #define howmany(x, y) (((x)+((y)-1))/(y)) 145ab090aa7Skarels #endif 146ab090aa7Skarels #define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) 147ab090aa7Skarels #define powerof2(x) ((((x)-1)&(x))==0) 148ab090aa7Skarels 14903a7e507Sbostic /* Macros for min/max. */ 15003a7e507Sbostic #ifndef KERNEL 151ab090aa7Skarels #define MIN(a,b) (((a)<(b))?(a):(b)) 152ab090aa7Skarels #define MAX(a,b) (((a)>(b))?(a):(b)) 153ab090aa7Skarels #endif 154ab090aa7Skarels 155ab090aa7Skarels /* 1562fe64d92Smckusick * Constants for setting the parameters of the kernel memory allocator. 1572fe64d92Smckusick * 1582fe64d92Smckusick * 2 ** MINBUCKET is the smallest unit of memory that will be 1592fe64d92Smckusick * allocated. It must be at least large enough to hold a pointer. 1602fe64d92Smckusick * 1612fe64d92Smckusick * Units of memory less or equal to MAXALLOCSAVE will permanently 1622fe64d92Smckusick * allocate physical memory; requests for these size pieces of 1632fe64d92Smckusick * memory are quite fast. Allocations greater than MAXALLOCSAVE must 1642fe64d92Smckusick * always allocate and free physical memory; requests for these 1652fe64d92Smckusick * size allocations should be done infrequently as they will be slow. 1669ae9ad29Sbostic * 1679ae9ad29Sbostic * Constraints: CLBYTES <= MAXALLOCSAVE <= 2 ** (MINBUCKET + 14), and 1689ae9ad29Sbostic * MAXALLOCSIZE must be a power of two. 1692fe64d92Smckusick */ 1702fe64d92Smckusick #define MINBUCKET 4 /* 4 => min allocation of 16 bytes */ 1712fe64d92Smckusick #define MAXALLOCSAVE (2 * CLBYTES) 1722fe64d92Smckusick 1732fe64d92Smckusick /* 1744233ee38Smckusick * Scale factor for scaled integers used to count %cpu time and load avgs. 1754233ee38Smckusick * 1764233ee38Smckusick * The number of CPU `tick's that map to a unique `%age' can be expressed 1774233ee38Smckusick * by the formula (1 / (2 ^ (FSHIFT - 11))). The maximum load average that 1784233ee38Smckusick * can be calculated (assuming 32 bits) can be closely approximated using 1794233ee38Smckusick * the formula (2 ^ (2 * (16 - FSHIFT))) for (FSHIFT < 15). 1804233ee38Smckusick * 1814233ee38Smckusick * For the scheduler to maintain a 1:1 mapping of CPU `tick' to `%age', 1824233ee38Smckusick * FSHIFT must be at least 11; this gives us a maximum load avg of ~1024. 1834233ee38Smckusick */ 1844233ee38Smckusick #define FSHIFT 11 /* bits to right of fixed binary point */ 1854233ee38Smckusick #define FSCALE (1<<FSHIFT) 186