xref: /csrg-svn/sys/sys/param.h (revision 176)
1*176Sbill /*	param.h	3.5	10/14/12	*/
263Sbill 
363Sbill /*
463Sbill  * tunable variables
563Sbill  *
663Sbill  * NB: NBUF is well known in locore.s
763Sbill  */
863Sbill 
963Sbill #define	NBUF	48		/* size of buffer cache */
1063Sbill #define	NINODE	250		/* number of in core inodes */
1163Sbill #define	NFILE	225		/* number of in core file structures */
1263Sbill #define	NMOUNT	8		/* number of mountable file systems */
1363Sbill #define	MAXUPRC	25		/* max processes per user */
1463Sbill #define	SSIZE	4		/* initial stack size (*512 bytes) */
1563Sbill #define	SINCR	4		/* increment of stack (*512 bytes) */
1663Sbill #define	NOFILE	20		/* max open files per process */
1763Sbill #define	CANBSIZ	256		/* max size of typewriter line */
1863Sbill #define	SMAPSIZ	(4*NPROC)	/* size of swap allocation area */
1963Sbill #define	NCALL	40		/* max simultaneous time callouts */
2063Sbill #define	NPROC	150		/* max number of processes */
2163Sbill #define	NTEXT	60		/* max number of pure texts */
2263Sbill #define	NCLIST	500		/* max total clist size */
2363Sbill #define	HZ	60		/* Ticks/second of the clock */
2463Sbill #define	TIMEZONE (8*60)		/* Minutes westward from Greenwich */
2563Sbill #define	DSTFLAG	1		/* Daylight Saving Time applies in this locality */
2663Sbill #define	MSGBUFS	128		/* Characters saved from error messages */
2763Sbill #define	NCARGS	5120		/* # characters in exec arglist */
2863Sbill /*
2963Sbill  * priorities
3063Sbill  * probably should not be
3163Sbill  * altered too much
3263Sbill  */
3363Sbill 
3463Sbill #define	PSWP	0
3563Sbill #define	PINOD	10
3663Sbill #define	PRIBIO	20
3763Sbill #define	PRIUBA	24
3863Sbill #define	PZERO	25
3963Sbill #define	PPIPE	26
4063Sbill #define	PWAIT	30
4163Sbill #define	PSLEP	40
4263Sbill #define	PUSER	50
4363Sbill 
4463Sbill #define	NZERO	20
4563Sbill 
4663Sbill /*
4763Sbill  * signals
4863Sbill  * dont change
4963Sbill  */
5063Sbill 
51*176Sbill #ifndef	NSIG
52*176Sbill #include <signal.h>
53*176Sbill #endif
5463Sbill 
5563Sbill /*
5697Sbill  * Return values from tsleep().
5797Sbill  */
5897Sbill #define	TS_OK	0	/* normal wakeup */
5997Sbill #define	TS_TIME	1	/* timed-out wakeup */
6097Sbill #define	TS_SIG	2	/* asynchronous signal wakeup */
6197Sbill 
6297Sbill /*
6363Sbill  * fundamental constants of the implementation--
6463Sbill  * cannot be changed easily.
6563Sbill  * note: UPAGES is well known in locore.s
6663Sbill  */
6763Sbill 
6863Sbill #define	NBPW	sizeof(int)	/* number of bytes in an integer */
6963Sbill 
7063Sbill #define	UPAGES	6		/* pages of u-area */
7163Sbill #define	NULL	0
7263Sbill #define	CMASK	0		/* default mask for file creation */
7363Sbill #define	NODEV	(dev_t)(-1)
7463Sbill #define	ROOTINO	((ino_t)2)	/* i number of all roots */
7563Sbill #define	SUPERB	((daddr_t)1)	/* block number of the super block */
7663Sbill #define	DIRSIZ	14		/* max characters per directory */
7763Sbill 
7863Sbill /*
7963Sbill  * Clustering of hardware pages on machines with ridiculously small
8063Sbill  * page sizes is done here.  The paging subsystem deals with units of
8163Sbill  * CLSIZE pte's describing NBPG (from vm.h) pages each... BSIZE must
8263Sbill  * be CLSIZE*NBPG in the current implementation, that is the paging subsystem
8363Sbill  * deals with the same size blocks that the file system uses.
8463Sbill  *
8563Sbill  * NOTE: SSIZE, SINCR and UPAGES must be multiples of CLSIZE
8663Sbill  *
8763Sbill  * NB: CLSIZE is well known in locore.s.
8863Sbill  */
8963Sbill #define	CLSIZE	2
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 #define	CLKTICK	(1000000/(HZ))	/* microseconds in a clock tick */
15063Sbill 
15163Sbill /*
15263Sbill  * Macros for fast min/max
15363Sbill  */
15463Sbill #define	MIN(a,b) (((a)<(b))?(a):(b))
15563Sbill #define	MAX(a,b) (((a)>(b))?(a):(b))
15663Sbill 
15763Sbill /*
15863Sbill  * Some macros for units conversion
15963Sbill  */
16063Sbill /* Core clicks (512 bytes) to segments and vice versa */
16163Sbill #define	ctos(x)	(x)
16263Sbill #define	stoc(x)	(x)
16363Sbill 
16463Sbill /* Core clicks (512 bytes) to disk blocks */
16563Sbill #define	ctod(x)	(x)
16663Sbill 
16763Sbill /* clicks to bytes */
16863Sbill #define	ctob(x)	((x)<<9)
16963Sbill 
17063Sbill /* bytes to clicks */
17163Sbill #define	btoc(x)	((((unsigned)(x)+511)>>9))
17263Sbill 
17363Sbill /* major part of a device */
17463Sbill #define	major(x)	((int)(((unsigned)(x)>>8)&0377))
17563Sbill 
17663Sbill /* minor part of a device */
17763Sbill #define	minor(x)	((int)((x)&0377))
17863Sbill 
17963Sbill /* make a device number */
18063Sbill #define	makedev(x,y)	((dev_t)(((x)<<8) | (y)))
18163Sbill 
18263Sbill typedef	struct { int r[1]; } *	physadr;
18363Sbill typedef	int		daddr_t;
18463Sbill typedef	char *		caddr_t;
18563Sbill typedef	unsigned short	ino_t;
18663Sbill typedef	int		swblk_t;
18763Sbill typedef	int		size_t;
18863Sbill typedef	int		time_t;
18963Sbill typedef	int		label_t[14];
19063Sbill typedef	short		dev_t;
19163Sbill typedef	int		off_t;
19263Sbill 
19363Sbill /*
19463Sbill  * Machine-dependent bits and macros
19563Sbill  */
19663Sbill #define	UMODE	PSL_CURMOD		/* usermode bits */
19763Sbill #define	USERMODE(ps)	(((ps) & UMODE) == UMODE)
19863Sbill 
19963Sbill #define	BASEPRI(ps)	(((ps) & PSL_IPL) != 0)
200