xref: /csrg-svn/sys/sys/param.h (revision 5080)
1*5080Swnj /*	param.h	4.14	81/11/26	*/
263Sbill 
363Sbill /*
42751Swnj  * Tunable variables which do not usually vary per system.
563Sbill  *
62751Swnj  * The sizes of most system tables are configured
72751Swnj  * into each system description.  The file system buffer
82751Swnj  * cache size is assigned based on available memory.
92751Swnj  * The tables whose sizes don't vary often are given here.
1063Sbill  */
1163Sbill 
12356Sbill #define	NMOUNT	15		/* number of mountable file systems */
13356Sbill #define	MSWAPX	15		/* pseudo mount table index for swapdev */
1463Sbill #define	MAXUPRC	25		/* max processes per user */
1563Sbill #define	SSIZE	4		/* initial stack size (*512 bytes) */
1663Sbill #define	SINCR	4		/* increment of stack (*512 bytes) */
1763Sbill #define	NOFILE	20		/* max open files per process */
182751Swnj /* NOFILE MUST NOT BE >= 31; SEE pte.h */
1963Sbill #define	CANBSIZ	256		/* max size of typewriter line */
20874Sbill #define	NCARGS	10240		/* # characters in exec arglist */
212751Swnj 
2263Sbill /*
2363Sbill  * priorities
2463Sbill  * probably should not be
2563Sbill  * altered too much
2663Sbill  */
2763Sbill 
2863Sbill #define	PSWP	0
2963Sbill #define	PINOD	10
3063Sbill #define	PRIBIO	20
3163Sbill #define	PRIUBA	24
3263Sbill #define	PZERO	25
3363Sbill #define	PPIPE	26
3463Sbill #define	PWAIT	30
3563Sbill #define	PSLEP	40
3663Sbill #define	PUSER	50
3763Sbill 
3863Sbill #define	NZERO	20
3963Sbill 
4063Sbill /*
4163Sbill  * signals
4263Sbill  * dont change
4363Sbill  */
4463Sbill 
45176Sbill #ifndef	NSIG
46176Sbill #include <signal.h>
47176Sbill #endif
4863Sbill 
4963Sbill /*
5097Sbill  * Return values from tsleep().
5197Sbill  */
5297Sbill #define	TS_OK	0	/* normal wakeup */
5397Sbill #define	TS_TIME	1	/* timed-out wakeup */
5497Sbill #define	TS_SIG	2	/* asynchronous signal wakeup */
5597Sbill 
5697Sbill /*
5763Sbill  * fundamental constants of the implementation--
5863Sbill  * cannot be changed easily.
5963Sbill  */
6063Sbill 
612637Swnj #define	NBBY		8		/* number of bits in a byte */
622637Swnj #define	NBPW		sizeof(int)	/* number of bytes in an integer */
632637Swnj #define	NBPG		512
642637Swnj #define	PGOFSET		(NBPG-1)	/* byte offset into page */
652637Swnj #define	PGSHIFT		9		/* LOG2(NBPG) */
6663Sbill 
672637Swnj #define	UPAGES	8		/* pages of u-area */
6863Sbill #define	NULL	0
6963Sbill #define	CMASK	0		/* default mask for file creation */
7063Sbill #define	NODEV	(dev_t)(-1)
7163Sbill #define	ROOTINO	((ino_t)2)	/* i number of all roots */
7263Sbill #define	SUPERB	((daddr_t)1)	/* block number of the super block */
7363Sbill #define	DIRSIZ	14		/* max characters per directory */
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  */
84*5080Swnj #define	CLSIZE		2
85*5080Swnj #define	CLBYTES		(CLSIZE*NBPG)
862637Swnj #define	CLOFSET		(CLSIZE*NBPG-1)	/* for clusters, like PGOFSET */
87*5080Swnj #define	claligned(x)	((((int)(x))&CLOFSET)==0)
88*5080Swnj #define	CLOFF		CLOFSET
89*5080Swnj #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 #if CLSIZE==1
9863Sbill #define	BSIZE	512		/* size of secondary block (bytes) */
9963Sbill #define	INOPB	8		/* 8 inodes per block */
10063Sbill #define	BMASK	0777		/* BSIZE-1 */
10163Sbill #define	BSHIFT	9		/* LOG2(BSIZE) */
10263Sbill #define	NMASK	0177		/* NINDIR-1 */
10363Sbill #define	NSHIFT	7		/* LOG2(NINDIR) */
10463Sbill #define	NICINOD	100		/* number of superblock inodes */
10563Sbill #define	NICFREE	50		/* number of superblock free blocks */
10663Sbill 
10763Sbill #endif
10863Sbill 
10963Sbill #if CLSIZE==2
11063Sbill #define	BSIZE	1024
11163Sbill #define	INOPB	16
11263Sbill #define	BMASK	01777
11363Sbill #define	BSHIFT	10
11463Sbill #define	NMASK	0377
11563Sbill #define	NSHIFT	8
11663Sbill #define	NICINOD	100
11763Sbill #define	NICFREE	178
11863Sbill #endif
11963Sbill 
12063Sbill #if CLSIZE==4
12163Sbill #define	BSIZE	2048
12263Sbill #define	INOPB	32
12363Sbill #define	BMASK	03777
12463Sbill #define	BSHIFT	11
12563Sbill #define	NMASK	0777
12663Sbill #define	NSHIFT	9
12763Sbill #define	NICINOD	100
12863Sbill #define	NICFREE	434
12963Sbill #endif
13063Sbill 
13163Sbill #ifndef INTRLVE
13263Sbill /* macros replacing interleaving functions */
13363Sbill #define	dkblock(bp)	((bp)->b_blkno)
13463Sbill #define	dkunit(bp)	(minor((bp)->b_dev) >> 3)
13563Sbill #endif
13663Sbill 
13763Sbill /* inumber to disk address and inumber to disk offset */
13863Sbill #define	itod(x)	((daddr_t)((((unsigned)(x)+2*INOPB-1)/INOPB)))
13963Sbill #define	itoo(x)	((int)(((x)+2*INOPB-1)%INOPB))
14063Sbill 
14163Sbill /* file system blocks to disk blocks and back */
14263Sbill #define	fsbtodb(b)	((b)*CLSIZE)
14363Sbill #define	dbtofsb(b)	((b)/CLSIZE)
14463Sbill 
14563Sbill #define	NINDIR	(BSIZE/sizeof(daddr_t))
14663Sbill 
14763Sbill #define	CBSIZE	28		/* number of chars in a clist block */
14863Sbill #define	CROUND	0x1F		/* clist rounding; sizeof(int *) + CBSIZE -1*/
14963Sbill 
15063Sbill /*
15163Sbill  * Macros for fast min/max
15263Sbill  */
15363Sbill #define	MIN(a,b) (((a)<(b))?(a):(b))
15463Sbill #define	MAX(a,b) (((a)>(b))?(a):(b))
15563Sbill 
15663Sbill /*
15763Sbill  * Some macros for units conversion
15863Sbill  */
15963Sbill /* Core clicks (512 bytes) to segments and vice versa */
16063Sbill #define	ctos(x)	(x)
16163Sbill #define	stoc(x)	(x)
16263Sbill 
16363Sbill /* Core clicks (512 bytes) to disk blocks */
16463Sbill #define	ctod(x)	(x)
16563Sbill 
16663Sbill /* clicks to bytes */
16763Sbill #define	ctob(x)	((x)<<9)
16863Sbill 
16963Sbill /* bytes to clicks */
17063Sbill #define	btoc(x)	((((unsigned)(x)+511)>>9))
17163Sbill 
1723069Swnj #ifndef KERNEL
1733069Swnj #include	<sys/types.h>
1743069Swnj #else
1753069Swnj #include	"../h/types.h"
1763069Swnj #endif
17763Sbill 
17863Sbill /*
17963Sbill  * Machine-dependent bits and macros
18063Sbill  */
18163Sbill #define	UMODE	PSL_CURMOD		/* usermode bits */
18263Sbill #define	USERMODE(ps)	(((ps) & UMODE) == UMODE)
18363Sbill 
18463Sbill #define	BASEPRI(ps)	(((ps) & PSL_IPL) != 0)
1853069Swnj 
1863069Swnj /*
1873069Swnj  * Provide about n microseconds of delay
1883069Swnj  */
1893069Swnj #define	DELAY(n)	{ register int N = (n); while (--N > 0); }
190