xref: /original-bsd/sys/sys/param.h (revision edc472f6)
1389af1dfSmckusic /* "@(#)param.h 2.1 3/25/82" */
2389af1dfSmckusic 
3*edc472f6Skre /*	param.h	4.19	82/07/15	*/
45db792e4Sbill 
55db792e4Sbill /*
645ac661dSwnj  * Tunable variables which do not usually vary per system.
75db792e4Sbill  *
845ac661dSwnj  * The sizes of most system tables are configured
945ac661dSwnj  * into each system description.  The file system buffer
1045ac661dSwnj  * cache size is assigned based on available memory.
1145ac661dSwnj  * The tables whose sizes don't vary often are given here.
125db792e4Sbill  */
135db792e4Sbill 
1416850871Sbill #define	NMOUNT	15		/* number of mountable file systems */
1516850871Sbill #define	MSWAPX	15		/* pseudo mount table index for swapdev */
165db792e4Sbill #define	MAXUPRC	25		/* max processes per user */
175db792e4Sbill #define	SSIZE	4		/* initial stack size (*512 bytes) */
185db792e4Sbill #define	SINCR	4		/* increment of stack (*512 bytes) */
195db792e4Sbill #define	NOFILE	20		/* max open files per process */
2045ac661dSwnj /* NOFILE MUST NOT BE >= 31; SEE pte.h */
215db792e4Sbill #define	CANBSIZ	256		/* max size of typewriter line */
225eb5d423Sbill #define	NCARGS	10240		/* # characters in exec arglist */
2345ac661dSwnj 
245db792e4Sbill /*
255db792e4Sbill  * priorities
265db792e4Sbill  * probably should not be
275db792e4Sbill  * altered too much
285db792e4Sbill  */
295db792e4Sbill 
305db792e4Sbill #define	PSWP	0
315db792e4Sbill #define	PINOD	10
325db792e4Sbill #define	PRIBIO	20
335db792e4Sbill #define	PRIUBA	24
345db792e4Sbill #define	PZERO	25
355db792e4Sbill #define	PPIPE	26
365db792e4Sbill #define	PWAIT	30
375db792e4Sbill #define	PSLEP	40
385db792e4Sbill #define	PUSER	50
395db792e4Sbill 
405db792e4Sbill #define	NZERO	20
415db792e4Sbill 
425db792e4Sbill /*
435db792e4Sbill  * signals
445db792e4Sbill  * dont change
455db792e4Sbill  */
465db792e4Sbill 
4746cc71adSbill #ifndef	NSIG
4846cc71adSbill #include <signal.h>
4946cc71adSbill #endif
50c6983186Sbill 
51c6983186Sbill /*
52c6983186Sbill  * Return values from tsleep().
53c6983186Sbill  */
54c6983186Sbill #define	TS_OK	0	/* normal wakeup */
55c6983186Sbill #define	TS_TIME	1	/* timed-out wakeup */
56c6983186Sbill #define	TS_SIG	2	/* asynchronous signal wakeup */
575db792e4Sbill 
585db792e4Sbill /*
595db792e4Sbill  * fundamental constants of the implementation--
605db792e4Sbill  * cannot be changed easily.
615db792e4Sbill  */
625db792e4Sbill 
63e163c03cSwnj #define	NBBY		8		/* number of bits in a byte */
645db792e4Sbill #define	NBPW		sizeof(int)	/* number of bytes in an integer */
65e163c03cSwnj #define	NBPG		512
66e163c03cSwnj #define	PGOFSET		(NBPG-1)	/* byte offset into page */
67e163c03cSwnj #define	PGSHIFT		9		/* LOG2(NBPG) */
685db792e4Sbill 
69e163c03cSwnj #define	UPAGES	8		/* pages of u-area */
705db792e4Sbill #define	NULL	0
715db792e4Sbill #define	CMASK	0		/* default mask for file creation */
725db792e4Sbill #define	NODEV	(dev_t)(-1)
7341fc41bdSwnj #define	NGRPS	256		/* max number groups */
745db792e4Sbill 
755db792e4Sbill /*
765db792e4Sbill  * Clustering of hardware pages on machines with ridiculously small
775db792e4Sbill  * page sizes is done here.  The paging subsystem deals with units of
785db792e4Sbill  * CLSIZE pte's describing NBPG (from vm.h) pages each... BSIZE must
795db792e4Sbill  * be CLSIZE*NBPG in the current implementation, that is the paging subsystem
805db792e4Sbill  * deals with the same size blocks that the file system uses.
815db792e4Sbill  *
825db792e4Sbill  * NOTE: SSIZE, SINCR and UPAGES must be multiples of CLSIZE
835db792e4Sbill  */
845db792e4Sbill #define	CLSIZE		2
85248881f8Swnj #define	CLBYTES		(CLSIZE*NBPG)
86e163c03cSwnj #define	CLOFSET		(CLSIZE*NBPG-1)	/* for clusters, like PGOFSET */
87248881f8Swnj #define	claligned(x)	((((int)(x))&CLOFSET)==0)
88248881f8Swnj #define	CLOFF		CLOFSET
89248881f8Swnj #define	CLSHIFT		(PGSHIFT+1)
905db792e4Sbill 
915db792e4Sbill /* give the base virtual address (first of CLSIZE) */
925db792e4Sbill #define	clbase(i)	((i) &~ (CLSIZE-1))
935db792e4Sbill 
945db792e4Sbill /* round a number of clicks up to a whole cluster */
955db792e4Sbill #define	clrnd(i)	(((i) + (CLSIZE-1)) &~ (CLSIZE-1))
965db792e4Sbill 
975db792e4Sbill #ifndef INTRLVE
985db792e4Sbill /* macros replacing interleaving functions */
995db792e4Sbill #define	dkblock(bp)	((bp)->b_blkno)
1005db792e4Sbill #define	dkunit(bp)	(minor((bp)->b_dev) >> 3)
1015db792e4Sbill #endif
1025db792e4Sbill 
1035db792e4Sbill #define	CBSIZE	28		/* number of chars in a clist block */
1045db792e4Sbill #define	CROUND	0x1F		/* clist rounding; sizeof(int *) + CBSIZE -1*/
1055db792e4Sbill 
1065db792e4Sbill /*
1075db792e4Sbill  * Some macros for units conversion
1085db792e4Sbill  */
1095db792e4Sbill /* Core clicks (512 bytes) to segments and vice versa */
1105db792e4Sbill #define	ctos(x)	(x)
1115db792e4Sbill #define	stoc(x)	(x)
1125db792e4Sbill 
1135db792e4Sbill /* Core clicks (512 bytes) to disk blocks */
1145db792e4Sbill #define	ctod(x)	(x)
1155db792e4Sbill 
1165db792e4Sbill /* clicks to bytes */
1175db792e4Sbill #define	ctob(x)	((x)<<9)
1185db792e4Sbill 
1195db792e4Sbill /* bytes to clicks */
1205db792e4Sbill #define	btoc(x)	((((unsigned)(x)+511)>>9))
1215db792e4Sbill 
122e0ff83f9Swnj #ifndef KERNEL
123e0ff83f9Swnj #include	<sys/types.h>
124e0ff83f9Swnj #else
125e0ff83f9Swnj #include	"../h/types.h"
126e0ff83f9Swnj #endif
12776379a38Sbill 
1285db792e4Sbill /*
1295db792e4Sbill  * Machine-dependent bits and macros
1305db792e4Sbill  */
1315db792e4Sbill #define	UMODE	PSL_CURMOD		/* usermode bits */
1325db792e4Sbill #define	USERMODE(ps)	(((ps) & UMODE) == UMODE)
1335db792e4Sbill 
1345db792e4Sbill #define	BASEPRI(ps)	(((ps) & PSL_IPL) != 0)
135e0ff83f9Swnj 
136e0ff83f9Swnj /*
137389af1dfSmckusic  * File system parameters and macros.
138389af1dfSmckusic  *
139389af1dfSmckusic  * The file system is made out of blocks of at most MAXBSIZE units,
140389af1dfSmckusic  * with smaller units (fragments) only in the last direct block.
141389af1dfSmckusic  * MAXBSIZE primarily determines the size of buffers in the buffer
142389af1dfSmckusic  * pool. It may be made larger without any effect on existing
143389af1dfSmckusic  * file systems; however making it smaller make make some file
144389af1dfSmckusic  * systems unmountable.
145389af1dfSmckusic  *
146389af1dfSmckusic  * Note that the blocked devices are assumed to have DEV_BSIZE
147389af1dfSmckusic  * "sectors" and that fragments must be some multiple of this size.
14891d57239Smckusick  * Block devices are read in BLKDEV_IOSIZE units. This number must
14991d57239Smckusick  * be a power of two and in the range of
15091d57239Smckusick  *	DEV_BSIZE <= BLKDEV_IOSIZE <= MAXBSIZE
15191d57239Smckusick  * This size has no effect upon the file system, but is usually set
15291d57239Smckusick  * to the block size of the root file system, so as to maximize the
15391d57239Smckusick  * speed of ``fsck''.
154389af1dfSmckusic  */
155389af1dfSmckusic #define	MAXBSIZE	8192
156389af1dfSmckusic #define	DEV_BSIZE	512
15791d57239Smckusick #define BLKDEV_IOSIZE	4096
158389af1dfSmckusic #define MAXFRAG 	8
159389af1dfSmckusic 
160389af1dfSmckusic /*
161*edc472f6Skre  * Map a ``block device block'' to a file system block.
162*edc472f6Skre  * This should be device dependent, and will be after we
163*edc472f6Skre  * add an entry to cdevsw for that purpose.  For now though
164*edc472f6Skre  * just use DEV_BSIZE.
165*edc472f6Skre  */
166*edc472f6Skre #define	bdbtofsb(bn)	((bn) / CLSIZE)
167*edc472f6Skre 
168*edc472f6Skre /*
169389af1dfSmckusic  * MAXPATHLEN defines the longest permissable path length
170389af1dfSmckusic  * after expanding symbolic links. It is used to allocate
171389af1dfSmckusic  * a temporary buffer from the buffer pool in which to do the
172389af1dfSmckusic  * name expansion, hence should be a power of two, and must
173389af1dfSmckusic  * be less than or equal to MAXBSIZE.
174389af1dfSmckusic  * MAXSYMLINKS defines the maximum number of symbolic links
175389af1dfSmckusic  * that may be expanded in a path name. It should be set high
176389af1dfSmckusic  * enough to allow all legitimate uses, but halt infinite loops
177389af1dfSmckusic  * reasonably quickly.
178389af1dfSmckusic  */
179389af1dfSmckusic #define MAXPATHLEN	1024
180389af1dfSmckusic #define MAXSYMLINKS	8
181389af1dfSmckusic 
182389af1dfSmckusic /*
183389af1dfSmckusic  * bit map related macros
184389af1dfSmckusic  */
185389af1dfSmckusic #define	setbit(a,i)	((a)[(i)/NBBY] |= 1<<((i)%NBBY))
186389af1dfSmckusic #define	clrbit(a,i)	((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
187389af1dfSmckusic #define	isset(a,i)	((a)[(i)/NBBY] & (1<<((i)%NBBY)))
188389af1dfSmckusic #define	isclr(a,i)	(((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
189389af1dfSmckusic 
190389af1dfSmckusic /*
191389af1dfSmckusic  * Macros for fast min/max.
192389af1dfSmckusic  */
193389af1dfSmckusic #define	MIN(a,b) (((a)<(b))?(a):(b))
194389af1dfSmckusic #define	MAX(a,b) (((a)>(b))?(a):(b))
195389af1dfSmckusic 
196389af1dfSmckusic /*
197389af1dfSmckusic  * Macros for counting and rounding.
198389af1dfSmckusic  */
199389af1dfSmckusic #define	howmany(x, y)	(((x)+((y)-1))/(y))
200389af1dfSmckusic #define	roundup(x, y)	((((x)+((y)-1))/(y))*(y))
201389af1dfSmckusic 
202389af1dfSmckusic /*
203389af1dfSmckusic  * Provide about n microseconds of delay.
204e0ff83f9Swnj  */
205e0ff83f9Swnj #define	DELAY(n)	{ register int N = (n); while (--N > 0); }
206