xref: /csrg-svn/sys/sys/param.h (revision 2752)
1*2752Swnj /*	param.h	4.9	81/02/27	*/
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 
12*2752Swnj #define	MAXNBUF	128
13356Sbill #define	NMOUNT	15		/* number of mountable file systems */
14356Sbill #define	MSWAPX	15		/* pseudo mount table index for swapdev */
1563Sbill #define	MAXUPRC	25		/* max processes per user */
1663Sbill #define	SSIZE	4		/* initial stack size (*512 bytes) */
1763Sbill #define	SINCR	4		/* increment of stack (*512 bytes) */
1863Sbill #define	NOFILE	20		/* max open files per process */
192751Swnj /* NOFILE MUST NOT BE >= 31; SEE pte.h */
2063Sbill #define	CANBSIZ	256		/* max size of typewriter line */
21874Sbill #define	NCARGS	10240		/* # characters in exec arglist */
222751Swnj 
2363Sbill /*
2463Sbill  * priorities
2563Sbill  * probably should not be
2663Sbill  * altered too much
2763Sbill  */
2863Sbill 
2963Sbill #define	PSWP	0
3063Sbill #define	PINOD	10
3163Sbill #define	PRIBIO	20
3263Sbill #define	PRIUBA	24
3363Sbill #define	PZERO	25
3463Sbill #define	PPIPE	26
3563Sbill #define	PWAIT	30
3663Sbill #define	PSLEP	40
3763Sbill #define	PUSER	50
3863Sbill 
3963Sbill #define	NZERO	20
4063Sbill 
4163Sbill /*
4263Sbill  * signals
4363Sbill  * dont change
4463Sbill  */
4563Sbill 
46176Sbill #ifndef	NSIG
47176Sbill #include <signal.h>
48176Sbill #endif
4963Sbill 
5063Sbill /*
5197Sbill  * Return values from tsleep().
5297Sbill  */
5397Sbill #define	TS_OK	0	/* normal wakeup */
5497Sbill #define	TS_TIME	1	/* timed-out wakeup */
5597Sbill #define	TS_SIG	2	/* asynchronous signal wakeup */
5697Sbill 
5797Sbill /*
5863Sbill  * fundamental constants of the implementation--
5963Sbill  * cannot be changed easily.
6063Sbill  */
6163Sbill 
622637Swnj #define	NBBY		8		/* number of bits in a byte */
632637Swnj #define	NBPW		sizeof(int)	/* number of bytes in an integer */
642637Swnj #define	NBPG		512
652637Swnj #define	PGOFSET		(NBPG-1)	/* byte offset into page */
662637Swnj #define	PGSHIFT		9		/* LOG2(NBPG) */
6763Sbill 
682637Swnj #define	UPAGES	8		/* pages of u-area */
6963Sbill #define	NULL	0
7063Sbill #define	CMASK	0		/* default mask for file creation */
7163Sbill #define	NODEV	(dev_t)(-1)
7263Sbill #define	ROOTINO	((ino_t)2)	/* i number of all roots */
7363Sbill #define	SUPERB	((daddr_t)1)	/* block number of the super block */
7463Sbill #define	DIRSIZ	14		/* max characters per directory */
7563Sbill 
7663Sbill /*
7763Sbill  * Clustering of hardware pages on machines with ridiculously small
7863Sbill  * page sizes is done here.  The paging subsystem deals with units of
7963Sbill  * CLSIZE pte's describing NBPG (from vm.h) pages each... BSIZE must
8063Sbill  * be CLSIZE*NBPG in the current implementation, that is the paging subsystem
8163Sbill  * deals with the same size blocks that the file system uses.
8263Sbill  *
8363Sbill  * NOTE: SSIZE, SINCR and UPAGES must be multiples of CLSIZE
8463Sbill  */
8563Sbill #define	CLSIZE	2
862637Swnj #define	CLOFSET		(CLSIZE*NBPG-1)	/* for clusters, like PGOFSET */
8763Sbill 
8863Sbill /* give the base virtual address (first of CLSIZE) */
8963Sbill #define	clbase(i)	((i) &~ (CLSIZE-1))
9063Sbill 
9163Sbill /* round a number of clicks up to a whole cluster */
9263Sbill #define	clrnd(i)	(((i) + (CLSIZE-1)) &~ (CLSIZE-1))
9363Sbill 
9463Sbill #if CLSIZE==1
9563Sbill #define	BSIZE	512		/* size of secondary block (bytes) */
9663Sbill #define	INOPB	8		/* 8 inodes per block */
9763Sbill #define	BMASK	0777		/* BSIZE-1 */
9863Sbill #define	BSHIFT	9		/* LOG2(BSIZE) */
9963Sbill #define	NMASK	0177		/* NINDIR-1 */
10063Sbill #define	NSHIFT	7		/* LOG2(NINDIR) */
10163Sbill #define	NICINOD	100		/* number of superblock inodes */
10263Sbill #define	NICFREE	50		/* number of superblock free blocks */
10363Sbill 
10463Sbill #endif
10563Sbill 
10663Sbill #if CLSIZE==2
10763Sbill #define	BSIZE	1024
10863Sbill #define	INOPB	16
10963Sbill #define	BMASK	01777
11063Sbill #define	BSHIFT	10
11163Sbill #define	NMASK	0377
11263Sbill #define	NSHIFT	8
11363Sbill #define	NICINOD	100
11463Sbill #define	NICFREE	178
11563Sbill #endif
11663Sbill 
11763Sbill #if CLSIZE==4
11863Sbill #define	BSIZE	2048
11963Sbill #define	INOPB	32
12063Sbill #define	BMASK	03777
12163Sbill #define	BSHIFT	11
12263Sbill #define	NMASK	0777
12363Sbill #define	NSHIFT	9
12463Sbill #define	NICINOD	100
12563Sbill #define	NICFREE	434
12663Sbill #endif
12763Sbill 
12863Sbill #ifndef INTRLVE
12963Sbill /* macros replacing interleaving functions */
13063Sbill #define	dkblock(bp)	((bp)->b_blkno)
13163Sbill #define	dkunit(bp)	(minor((bp)->b_dev) >> 3)
13263Sbill #endif
13363Sbill 
13463Sbill /* inumber to disk address and inumber to disk offset */
13563Sbill #define	itod(x)	((daddr_t)((((unsigned)(x)+2*INOPB-1)/INOPB)))
13663Sbill #define	itoo(x)	((int)(((x)+2*INOPB-1)%INOPB))
13763Sbill 
13863Sbill /* file system blocks to disk blocks and back */
13963Sbill #define	fsbtodb(b)	((b)*CLSIZE)
14063Sbill #define	dbtofsb(b)	((b)/CLSIZE)
14163Sbill 
14263Sbill #define	NINDIR	(BSIZE/sizeof(daddr_t))
14363Sbill 
14463Sbill #define	CBSIZE	28		/* number of chars in a clist block */
14563Sbill #define	CROUND	0x1F		/* clist rounding; sizeof(int *) + CBSIZE -1*/
14663Sbill #define	CLKTICK	(1000000/(HZ))	/* microseconds in a clock tick */
14763Sbill 
14863Sbill /*
14963Sbill  * Macros for fast min/max
15063Sbill  */
15163Sbill #define	MIN(a,b) (((a)<(b))?(a):(b))
15263Sbill #define	MAX(a,b) (((a)>(b))?(a):(b))
15363Sbill 
15463Sbill /*
15563Sbill  * Some macros for units conversion
15663Sbill  */
15763Sbill /* Core clicks (512 bytes) to segments and vice versa */
15863Sbill #define	ctos(x)	(x)
15963Sbill #define	stoc(x)	(x)
16063Sbill 
16163Sbill /* Core clicks (512 bytes) to disk blocks */
16263Sbill #define	ctod(x)	(x)
16363Sbill 
16463Sbill /* clicks to bytes */
16563Sbill #define	ctob(x)	((x)<<9)
16663Sbill 
16763Sbill /* bytes to clicks */
16863Sbill #define	btoc(x)	((((unsigned)(x)+511)>>9))
16963Sbill 
17063Sbill /* major part of a device */
17163Sbill #define	major(x)	((int)(((unsigned)(x)>>8)&0377))
17263Sbill 
17363Sbill /* minor part of a device */
17463Sbill #define	minor(x)	((int)((x)&0377))
17563Sbill 
17663Sbill /* make a device number */
17763Sbill #define	makedev(x,y)	((dev_t)(((x)<<8) | (y)))
17863Sbill 
17963Sbill typedef	struct { int r[1]; } *	physadr;
18063Sbill typedef	int		daddr_t;
18163Sbill typedef	char *		caddr_t;
18263Sbill typedef	unsigned short	ino_t;
18363Sbill typedef	int		swblk_t;
18463Sbill typedef	int		size_t;
18563Sbill typedef	int		time_t;
18663Sbill typedef	int		label_t[14];
18763Sbill typedef	short		dev_t;
18863Sbill typedef	int		off_t;
18963Sbill 
190582Sbill typedef	unsigned char	u_char;
191582Sbill typedef	unsigned short	u_short;
192582Sbill typedef	unsigned int	u_int;
193582Sbill typedef	unsigned long	u_long;
194582Sbill 
19563Sbill /*
19663Sbill  * Machine-dependent bits and macros
19763Sbill  */
19863Sbill #define	UMODE	PSL_CURMOD		/* usermode bits */
19963Sbill #define	USERMODE(ps)	(((ps) & UMODE) == UMODE)
20063Sbill 
20163Sbill #define	BASEPRI(ps)	(((ps) & PSL_IPL) != 0)
202