xref: /csrg-svn/sys/sys/param.h (revision 7442)
16564Smckusic /* "@(#)param.h 2.1 3/25/82" */
263Sbill 
3*7442Skre /*	param.h	4.19	82/07/15	*/
46564Smckusic 
563Sbill /*
62751Swnj  * Tunable variables which do not usually vary per system.
763Sbill  *
82751Swnj  * The sizes of most system tables are configured
92751Swnj  * into each system description.  The file system buffer
102751Swnj  * cache size is assigned based on available memory.
112751Swnj  * The tables whose sizes don't vary often are given here.
1263Sbill  */
1363Sbill 
14356Sbill #define	NMOUNT	15		/* number of mountable file systems */
15356Sbill #define	MSWAPX	15		/* pseudo mount table index for swapdev */
1663Sbill #define	MAXUPRC	25		/* max processes per user */
1763Sbill #define	SSIZE	4		/* initial stack size (*512 bytes) */
1863Sbill #define	SINCR	4		/* increment of stack (*512 bytes) */
1963Sbill #define	NOFILE	20		/* max open files per process */
202751Swnj /* NOFILE MUST NOT BE >= 31; SEE pte.h */
2163Sbill #define	CANBSIZ	256		/* max size of typewriter line */
22874Sbill #define	NCARGS	10240		/* # characters in exec arglist */
232751Swnj 
2463Sbill /*
2563Sbill  * priorities
2663Sbill  * probably should not be
2763Sbill  * altered too much
2863Sbill  */
2963Sbill 
3063Sbill #define	PSWP	0
3163Sbill #define	PINOD	10
3263Sbill #define	PRIBIO	20
3363Sbill #define	PRIUBA	24
3463Sbill #define	PZERO	25
3563Sbill #define	PPIPE	26
3663Sbill #define	PWAIT	30
3763Sbill #define	PSLEP	40
3863Sbill #define	PUSER	50
3963Sbill 
4063Sbill #define	NZERO	20
4163Sbill 
4263Sbill /*
4363Sbill  * signals
4463Sbill  * dont change
4563Sbill  */
4663Sbill 
47176Sbill #ifndef	NSIG
48176Sbill #include <signal.h>
49176Sbill #endif
5063Sbill 
5163Sbill /*
5297Sbill  * Return values from tsleep().
5397Sbill  */
5497Sbill #define	TS_OK	0	/* normal wakeup */
5597Sbill #define	TS_TIME	1	/* timed-out wakeup */
5697Sbill #define	TS_SIG	2	/* asynchronous signal wakeup */
5797Sbill 
5897Sbill /*
5963Sbill  * fundamental constants of the implementation--
6063Sbill  * cannot be changed easily.
6163Sbill  */
6263Sbill 
632637Swnj #define	NBBY		8		/* number of bits in a byte */
642637Swnj #define	NBPW		sizeof(int)	/* number of bytes in an integer */
652637Swnj #define	NBPG		512
662637Swnj #define	PGOFSET		(NBPG-1)	/* byte offset into page */
672637Swnj #define	PGSHIFT		9		/* LOG2(NBPG) */
6863Sbill 
692637Swnj #define	UPAGES	8		/* pages of u-area */
7063Sbill #define	NULL	0
7163Sbill #define	CMASK	0		/* default mask for file creation */
7263Sbill #define	NODEV	(dev_t)(-1)
735857Swnj #define	NGRPS	256		/* max number groups */
7463Sbill 
7563Sbill /*
7663Sbill  * Clustering of hardware pages on machines with ridiculously small
7763Sbill  * page sizes is done here.  The paging subsystem deals with units of
7863Sbill  * CLSIZE pte's describing NBPG (from vm.h) pages each... BSIZE must
7963Sbill  * be CLSIZE*NBPG in the current implementation, that is the paging subsystem
8063Sbill  * deals with the same size blocks that the file system uses.
8163Sbill  *
8263Sbill  * NOTE: SSIZE, SINCR and UPAGES must be multiples of CLSIZE
8363Sbill  */
845080Swnj #define	CLSIZE		2
855080Swnj #define	CLBYTES		(CLSIZE*NBPG)
862637Swnj #define	CLOFSET		(CLSIZE*NBPG-1)	/* for clusters, like PGOFSET */
875080Swnj #define	claligned(x)	((((int)(x))&CLOFSET)==0)
885080Swnj #define	CLOFF		CLOFSET
895080Swnj #define	CLSHIFT		(PGSHIFT+1)
9063Sbill 
9163Sbill /* give the base virtual address (first of CLSIZE) */
9263Sbill #define	clbase(i)	((i) &~ (CLSIZE-1))
9363Sbill 
9463Sbill /* round a number of clicks up to a whole cluster */
9563Sbill #define	clrnd(i)	(((i) + (CLSIZE-1)) &~ (CLSIZE-1))
9663Sbill 
9763Sbill #ifndef INTRLVE
9863Sbill /* macros replacing interleaving functions */
9963Sbill #define	dkblock(bp)	((bp)->b_blkno)
10063Sbill #define	dkunit(bp)	(minor((bp)->b_dev) >> 3)
10163Sbill #endif
10263Sbill 
10363Sbill #define	CBSIZE	28		/* number of chars in a clist block */
10463Sbill #define	CROUND	0x1F		/* clist rounding; sizeof(int *) + CBSIZE -1*/
10563Sbill 
10663Sbill /*
10763Sbill  * Some macros for units conversion
10863Sbill  */
10963Sbill /* Core clicks (512 bytes) to segments and vice versa */
11063Sbill #define	ctos(x)	(x)
11163Sbill #define	stoc(x)	(x)
11263Sbill 
11363Sbill /* Core clicks (512 bytes) to disk blocks */
11463Sbill #define	ctod(x)	(x)
11563Sbill 
11663Sbill /* clicks to bytes */
11763Sbill #define	ctob(x)	((x)<<9)
11863Sbill 
11963Sbill /* bytes to clicks */
12063Sbill #define	btoc(x)	((((unsigned)(x)+511)>>9))
12163Sbill 
1223069Swnj #ifndef KERNEL
1233069Swnj #include	<sys/types.h>
1243069Swnj #else
1253069Swnj #include	"../h/types.h"
1263069Swnj #endif
12763Sbill 
12863Sbill /*
12963Sbill  * Machine-dependent bits and macros
13063Sbill  */
13163Sbill #define	UMODE	PSL_CURMOD		/* usermode bits */
13263Sbill #define	USERMODE(ps)	(((ps) & UMODE) == UMODE)
13363Sbill 
13463Sbill #define	BASEPRI(ps)	(((ps) & PSL_IPL) != 0)
1353069Swnj 
1363069Swnj /*
1376564Smckusic  * File system parameters and macros.
1386564Smckusic  *
1396564Smckusic  * The file system is made out of blocks of at most MAXBSIZE units,
1406564Smckusic  * with smaller units (fragments) only in the last direct block.
1416564Smckusic  * MAXBSIZE primarily determines the size of buffers in the buffer
1426564Smckusic  * pool. It may be made larger without any effect on existing
1436564Smckusic  * file systems; however making it smaller make make some file
1446564Smckusic  * systems unmountable.
1456564Smckusic  *
1466564Smckusic  * Note that the blocked devices are assumed to have DEV_BSIZE
1476564Smckusic  * "sectors" and that fragments must be some multiple of this size.
1487147Smckusick  * Block devices are read in BLKDEV_IOSIZE units. This number must
1497147Smckusick  * be a power of two and in the range of
1507147Smckusick  *	DEV_BSIZE <= BLKDEV_IOSIZE <= MAXBSIZE
1517147Smckusick  * This size has no effect upon the file system, but is usually set
1527147Smckusick  * to the block size of the root file system, so as to maximize the
1537147Smckusick  * speed of ``fsck''.
1543069Swnj  */
1556564Smckusic #define	MAXBSIZE	8192
1566564Smckusic #define	DEV_BSIZE	512
1577147Smckusick #define BLKDEV_IOSIZE	4096
1586564Smckusic #define MAXFRAG 	8
1596564Smckusic 
1606564Smckusic /*
161*7442Skre  * Map a ``block device block'' to a file system block.
162*7442Skre  * This should be device dependent, and will be after we
163*7442Skre  * add an entry to cdevsw for that purpose.  For now though
164*7442Skre  * just use DEV_BSIZE.
165*7442Skre  */
166*7442Skre #define	bdbtofsb(bn)	((bn) / CLSIZE)
167*7442Skre 
168*7442Skre /*
1696564Smckusic  * MAXPATHLEN defines the longest permissable path length
1706564Smckusic  * after expanding symbolic links. It is used to allocate
1716564Smckusic  * a temporary buffer from the buffer pool in which to do the
1726564Smckusic  * name expansion, hence should be a power of two, and must
1736564Smckusic  * be less than or equal to MAXBSIZE.
1746564Smckusic  * MAXSYMLINKS defines the maximum number of symbolic links
1756564Smckusic  * that may be expanded in a path name. It should be set high
1766564Smckusic  * enough to allow all legitimate uses, but halt infinite loops
1776564Smckusic  * reasonably quickly.
1786564Smckusic  */
1796564Smckusic #define MAXPATHLEN	1024
1806564Smckusic #define MAXSYMLINKS	8
1816564Smckusic 
1826564Smckusic /*
1836564Smckusic  * bit map related macros
1846564Smckusic  */
1856564Smckusic #define	setbit(a,i)	((a)[(i)/NBBY] |= 1<<((i)%NBBY))
1866564Smckusic #define	clrbit(a,i)	((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
1876564Smckusic #define	isset(a,i)	((a)[(i)/NBBY] & (1<<((i)%NBBY)))
1886564Smckusic #define	isclr(a,i)	(((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
1896564Smckusic 
1906564Smckusic /*
1916564Smckusic  * Macros for fast min/max.
1926564Smckusic  */
1936564Smckusic #define	MIN(a,b) (((a)<(b))?(a):(b))
1946564Smckusic #define	MAX(a,b) (((a)>(b))?(a):(b))
1956564Smckusic 
1966564Smckusic /*
1976564Smckusic  * Macros for counting and rounding.
1986564Smckusic  */
1996564Smckusic #define	howmany(x, y)	(((x)+((y)-1))/(y))
2006564Smckusic #define	roundup(x, y)	((((x)+((y)-1))/(y))*(y))
2016564Smckusic 
2026564Smckusic /*
2036564Smckusic  * Provide about n microseconds of delay.
2046564Smckusic  */
2053069Swnj #define	DELAY(n)	{ register int N = (n); while (--N > 0); }
206