148799Sbostic /*- 261064Sbostic * Copyright (c) 1982, 1986, 1989, 1993 361064Sbostic * The Regents of the University of California. All rights reserved. 465772Sbostic * (c) UNIX System Laboratories, Inc. 565772Sbostic * All or some portions of this file are derived from material licensed 665772Sbostic * to the University of California by American Telephone and Telegraph 765772Sbostic * Co. or Unix System Laboratories, Inc. and are reproduced herein with 865772Sbostic * the permission of UNIX System Laboratories, Inc. 923430Smckusick * 1048799Sbostic * %sccs.include.redist.c% 1148799Sbostic * 12*68733Smckusick * @(#)param.h 8.3 (Berkeley) 04/04/95 1323430Smckusick */ 1463Sbill 15*68733Smckusick #define BSD 199506 /* System version (year & month). */ 1625297Skarels #define BSD4_3 1 1759536Sbostic #define BSD4_4 1 1824654Sbloom 1948799Sbostic #ifndef NULL 2048799Sbostic #define NULL 0 2148799Sbostic #endif 2236805Sbostic 2348389Skarels #ifndef LOCORE 2448389Skarels #include <sys/types.h> 2548389Skarels #endif 2648389Skarels 2763Sbill /* 2848799Sbostic * Machine-independent constants (some used in following include files). 2948799Sbostic * Redefined constants are from POSIX 1003.1 limits file. 3048799Sbostic * 3148799Sbostic * MAXCOMLEN should be >= sizeof(ac_comm) (see <acct.h>) 3248799Sbostic * MAXLOGNAME should be >= UT_NAMESIZE (see <utmp.h>) 338993Sroot */ 3448799Sbostic #include <sys/syslimits.h> 3548799Sbostic 3648799Sbostic #define MAXCOMLEN 16 /* max command name remembered */ 3740631Skarels #define MAXINTERP 32 /* max interpreter file name length */ 3848799Sbostic #define MAXLOGNAME 12 /* max login name length */ 3948799Sbostic #define MAXUPRC CHILD_MAX /* max simultaneous processes */ 4048799Sbostic #define NCARGS ARG_MAX /* max bytes for an exec function */ 4140631Skarels #define NGROUPS NGROUPS_MAX /* max number groups */ 4248799Sbostic #define NOFILE OPEN_MAX /* max open files per process */ 4340631Skarels #define NOGROUP 65535 /* marker for empty group set member */ 4448799Sbostic #define MAXHOSTNAMELEN 256 /* max hostname size */ 4511808Ssam 4648799Sbostic /* More types and definitions used throughout the kernel. */ 4747539Skarels #ifdef KERNEL 4847539Skarels #include <sys/cdefs.h> 4947539Skarels #include <sys/errno.h> 5047539Skarels #include <sys/time.h> 5147539Skarels #include <sys/resource.h> 5247539Skarels #include <sys/ucred.h> 5347539Skarels #include <sys/uio.h> 5447539Skarels #endif 5547539Skarels 5648799Sbostic /* Signals. */ 5738783Skarels #include <sys/signal.h> 5863Sbill 5948799Sbostic /* Machine type dependent parameters. */ 6045793Sbostic #include <machine/param.h> 6145793Sbostic #include <machine/limits.h> 6230406Skarels 6348389Skarels /* 6448799Sbostic * Priorities. Note that with 32 run queues, differences less than 4 are 6548799Sbostic * insignificant. 6648389Skarels */ 6748389Skarels #define PSWP 0 6848389Skarels #define PVM 4 6948389Skarels #define PINOD 8 7048389Skarels #define PRIBIO 16 7148389Skarels #define PVFS 20 7249237Skarels #define PZERO 22 /* No longer magic, shouldn't be here. XXX */ 7348389Skarels #define PSOCK 24 7448389Skarels #define PWAIT 32 7548389Skarels #define PLOCK 36 7648389Skarels #define PPAUSE 40 7748389Skarels #define PUSER 50 7848799Sbostic #define MAXPRI 127 /* Priorities range from 0 through MAXPRI. */ 7948389Skarels 8048389Skarels #define PRIMASK 0x0ff 8148799Sbostic #define PCATCH 0x100 /* OR'd with pri for tsleep to check signals */ 8248389Skarels 8348389Skarels #define NZERO 0 /* default "nice" */ 8448389Skarels 8548799Sbostic #define NBPW sizeof(int) /* number of bytes per word (integer) */ 8663Sbill 8748799Sbostic #define CMASK 022 /* default file mask: S_IWGRP|S_IWOTH */ 8848799Sbostic #define NODEV (dev_t)(-1) /* non-existent device */ 8963Sbill 9063Sbill /* 9163Sbill * Clustering of hardware pages on machines with ridiculously small 9263Sbill * page sizes is done here. The paging subsystem deals with units of 9330406Skarels * CLSIZE pte's describing NBPG (from machine/machparam.h) pages each. 9463Sbill */ 955080Swnj #define CLBYTES (CLSIZE*NBPG) 962637Swnj #define CLOFSET (CLSIZE*NBPG-1) /* for clusters, like PGOFSET */ 975080Swnj #define claligned(x) ((((int)(x))&CLOFSET)==0) 985080Swnj #define CLOFF CLOFSET 998993Sroot #define CLSHIFT (PGSHIFT+CLSIZELOG2) 10063Sbill 1018993Sroot #if CLSIZE==1 1028993Sroot #define clbase(i) (i) 1038993Sroot #define clrnd(i) (i) 1048993Sroot #else 10548799Sbostic /* Give the base virtual address (first of CLSIZE). */ 10663Sbill #define clbase(i) ((i) &~ (CLSIZE-1)) 10748799Sbostic /* Round a number of clicks up to a whole cluster. */ 10863Sbill #define clrnd(i) (((i) + (CLSIZE-1)) &~ (CLSIZE-1)) 1098993Sroot #endif 11063Sbill 11148799Sbostic #define CBLOCK 64 /* Clist block size, must be a power of 2. */ 11248799Sbostic #define CBQSIZE (CBLOCK/NBBY) /* Quote bytes/cblock - can do better. */ 11348799Sbostic /* Data chars/clist. */ 11448799Sbostic #define CBSIZE (CBLOCK - sizeof(struct cblock *) - CBQSIZE) 11548799Sbostic #define CROUND (CBLOCK - 1) /* Clist rounding. */ 11663Sbill 11763Sbill /* 1186564Smckusic * File system parameters and macros. 1196564Smckusic * 12048799Sbostic * The file system is made out of blocks of at most MAXBSIZE units, with 12148799Sbostic * smaller units (fragments) only in the last direct block. MAXBSIZE 12248799Sbostic * primarily determines the size of buffers in the buffer pool. It may be 12348799Sbostic * made larger without any effect on existing file systems; however making 12448799Sbostic * it smaller make make some file systems unmountable. 1253069Swnj */ 12657034Smargo #define MAXBSIZE MAXPHYS 1276564Smckusic #define MAXFRAG 8 1286564Smckusic 1296564Smckusic /* 13048799Sbostic * MAXPATHLEN defines the longest permissable path length after expanding 13148799Sbostic * symbolic links. It is used to allocate a temporary buffer from the buffer 13248799Sbostic * pool in which to do the name expansion, hence should be a power of two, 13348799Sbostic * and must be less than or equal to MAXBSIZE. MAXSYMLINKS defines the 13448799Sbostic * maximum number of symbolic links that may be expanded in a path name. 13548799Sbostic * It should be set high enough to allow all legitimate uses, but halt 13648799Sbostic * infinite loops reasonably quickly. 1376564Smckusic */ 13836805Sbostic #define MAXPATHLEN PATH_MAX 1396564Smckusic #define MAXSYMLINKS 8 1406564Smckusic 14148799Sbostic /* Bit map related macros. */ 14240209Skarels #define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY)) 14340209Skarels #define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY))) 14440209Skarels #define isset(a,i) ((a)[(i)/NBBY] & (1<<((i)%NBBY))) 14540209Skarels #define isclr(a,i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0) 14640209Skarels 14748799Sbostic /* Macros for counting and rounding. */ 14840209Skarels #ifndef howmany 14940209Skarels #define howmany(x, y) (((x)+((y)-1))/(y)) 15040209Skarels #endif 15140209Skarels #define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) 15240209Skarels #define powerof2(x) ((((x)-1)&(x))==0) 15340209Skarels 15455075Sbostic /* Macros for min/max. */ 15555075Sbostic #ifndef KERNEL 15640209Skarels #define MIN(a,b) (((a)<(b))?(a):(b)) 15740209Skarels #define MAX(a,b) (((a)>(b))?(a):(b)) 15840209Skarels #endif 15940209Skarels 16040209Skarels /* 16131414Smckusick * Constants for setting the parameters of the kernel memory allocator. 16231414Smckusick * 16331414Smckusick * 2 ** MINBUCKET is the smallest unit of memory that will be 16431414Smckusick * allocated. It must be at least large enough to hold a pointer. 16531414Smckusick * 16631414Smckusick * Units of memory less or equal to MAXALLOCSAVE will permanently 16731414Smckusick * allocate physical memory; requests for these size pieces of 16831414Smckusick * memory are quite fast. Allocations greater than MAXALLOCSAVE must 16931414Smckusick * always allocate and free physical memory; requests for these 17031414Smckusick * size allocations should be done infrequently as they will be slow. 17148799Sbostic * 17248799Sbostic * Constraints: CLBYTES <= MAXALLOCSAVE <= 2 ** (MINBUCKET + 14), and 17348799Sbostic * MAXALLOCSIZE must be a power of two. 17431414Smckusick */ 17531414Smckusick #define MINBUCKET 4 /* 4 => min allocation of 16 bytes */ 17631414Smckusick #define MAXALLOCSAVE (2 * CLBYTES) 17731414Smckusick 17831414Smckusick /* 17938161Smckusick * Scale factor for scaled integers used to count %cpu time and load avgs. 18038161Smckusick * 18138161Smckusick * The number of CPU `tick's that map to a unique `%age' can be expressed 18238161Smckusick * by the formula (1 / (2 ^ (FSHIFT - 11))). The maximum load average that 18338161Smckusick * can be calculated (assuming 32 bits) can be closely approximated using 18438161Smckusick * the formula (2 ^ (2 * (16 - FSHIFT))) for (FSHIFT < 15). 18538161Smckusick * 18638161Smckusick * For the scheduler to maintain a 1:1 mapping of CPU `tick' to `%age', 18738161Smckusick * FSHIFT must be at least 11; this gives us a maximum load avg of ~1024. 18838161Smckusick */ 18938161Smckusick #define FSHIFT 11 /* bits to right of fixed binary point */ 19038161Smckusick #define FSCALE (1<<FSHIFT) 191