xref: /original-bsd/sys/sys/param.h (revision 248881f8)
1*248881f8Swnj /*	param.h	4.14	81/11/26	*/
25db792e4Sbill 
35db792e4Sbill /*
445ac661dSwnj  * Tunable variables which do not usually vary per system.
55db792e4Sbill  *
645ac661dSwnj  * The sizes of most system tables are configured
745ac661dSwnj  * into each system description.  The file system buffer
845ac661dSwnj  * cache size is assigned based on available memory.
945ac661dSwnj  * The tables whose sizes don't vary often are given here.
105db792e4Sbill  */
115db792e4Sbill 
1216850871Sbill #define	NMOUNT	15		/* number of mountable file systems */
1316850871Sbill #define	MSWAPX	15		/* pseudo mount table index for swapdev */
145db792e4Sbill #define	MAXUPRC	25		/* max processes per user */
155db792e4Sbill #define	SSIZE	4		/* initial stack size (*512 bytes) */
165db792e4Sbill #define	SINCR	4		/* increment of stack (*512 bytes) */
175db792e4Sbill #define	NOFILE	20		/* max open files per process */
1845ac661dSwnj /* NOFILE MUST NOT BE >= 31; SEE pte.h */
195db792e4Sbill #define	CANBSIZ	256		/* max size of typewriter line */
205eb5d423Sbill #define	NCARGS	10240		/* # characters in exec arglist */
2145ac661dSwnj 
225db792e4Sbill /*
235db792e4Sbill  * priorities
245db792e4Sbill  * probably should not be
255db792e4Sbill  * altered too much
265db792e4Sbill  */
275db792e4Sbill 
285db792e4Sbill #define	PSWP	0
295db792e4Sbill #define	PINOD	10
305db792e4Sbill #define	PRIBIO	20
315db792e4Sbill #define	PRIUBA	24
325db792e4Sbill #define	PZERO	25
335db792e4Sbill #define	PPIPE	26
345db792e4Sbill #define	PWAIT	30
355db792e4Sbill #define	PSLEP	40
365db792e4Sbill #define	PUSER	50
375db792e4Sbill 
385db792e4Sbill #define	NZERO	20
395db792e4Sbill 
405db792e4Sbill /*
415db792e4Sbill  * signals
425db792e4Sbill  * dont change
435db792e4Sbill  */
445db792e4Sbill 
4546cc71adSbill #ifndef	NSIG
4646cc71adSbill #include <signal.h>
4746cc71adSbill #endif
48c6983186Sbill 
49c6983186Sbill /*
50c6983186Sbill  * Return values from tsleep().
51c6983186Sbill  */
52c6983186Sbill #define	TS_OK	0	/* normal wakeup */
53c6983186Sbill #define	TS_TIME	1	/* timed-out wakeup */
54c6983186Sbill #define	TS_SIG	2	/* asynchronous signal wakeup */
555db792e4Sbill 
565db792e4Sbill /*
575db792e4Sbill  * fundamental constants of the implementation--
585db792e4Sbill  * cannot be changed easily.
595db792e4Sbill  */
605db792e4Sbill 
61e163c03cSwnj #define	NBBY		8		/* number of bits in a byte */
625db792e4Sbill #define	NBPW		sizeof(int)	/* number of bytes in an integer */
63e163c03cSwnj #define	NBPG		512
64e163c03cSwnj #define	PGOFSET		(NBPG-1)	/* byte offset into page */
65e163c03cSwnj #define	PGSHIFT		9		/* LOG2(NBPG) */
665db792e4Sbill 
67e163c03cSwnj #define	UPAGES	8		/* pages of u-area */
685db792e4Sbill #define	NULL	0
695db792e4Sbill #define	CMASK	0		/* default mask for file creation */
705db792e4Sbill #define	NODEV	(dev_t)(-1)
715db792e4Sbill #define	ROOTINO	((ino_t)2)	/* i number of all roots */
725db792e4Sbill #define	SUPERB	((daddr_t)1)	/* block number of the super block */
735db792e4Sbill #define	DIRSIZ	14		/* max characters per directory */
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
85*248881f8Swnj #define	CLBYTES		(CLSIZE*NBPG)
86e163c03cSwnj #define	CLOFSET		(CLSIZE*NBPG-1)	/* for clusters, like PGOFSET */
87*248881f8Swnj #define	claligned(x)	((((int)(x))&CLOFSET)==0)
88*248881f8Swnj #define	CLOFF		CLOFSET
89*248881f8Swnj #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 #if CLSIZE==1
985db792e4Sbill #define	BSIZE	512		/* size of secondary block (bytes) */
995db792e4Sbill #define	INOPB	8		/* 8 inodes per block */
1005db792e4Sbill #define	BMASK	0777		/* BSIZE-1 */
1015db792e4Sbill #define	BSHIFT	9		/* LOG2(BSIZE) */
1025db792e4Sbill #define	NMASK	0177		/* NINDIR-1 */
1035db792e4Sbill #define	NSHIFT	7		/* LOG2(NINDIR) */
1045db792e4Sbill #define	NICINOD	100		/* number of superblock inodes */
1055db792e4Sbill #define	NICFREE	50		/* number of superblock free blocks */
1065db792e4Sbill 
1075db792e4Sbill #endif
1085db792e4Sbill 
1095db792e4Sbill #if CLSIZE==2
1105db792e4Sbill #define	BSIZE	1024
1115db792e4Sbill #define	INOPB	16
1125db792e4Sbill #define	BMASK	01777
1135db792e4Sbill #define	BSHIFT	10
1145db792e4Sbill #define	NMASK	0377
1155db792e4Sbill #define	NSHIFT	8
1165db792e4Sbill #define	NICINOD	100
1175db792e4Sbill #define	NICFREE	178
1185db792e4Sbill #endif
1195db792e4Sbill 
1205db792e4Sbill #if CLSIZE==4
1215db792e4Sbill #define	BSIZE	2048
1225db792e4Sbill #define	INOPB	32
1235db792e4Sbill #define	BMASK	03777
1245db792e4Sbill #define	BSHIFT	11
1255db792e4Sbill #define	NMASK	0777
1265db792e4Sbill #define	NSHIFT	9
1275db792e4Sbill #define	NICINOD	100
1285db792e4Sbill #define	NICFREE	434
1295db792e4Sbill #endif
1305db792e4Sbill 
1315db792e4Sbill #ifndef INTRLVE
1325db792e4Sbill /* macros replacing interleaving functions */
1335db792e4Sbill #define	dkblock(bp)	((bp)->b_blkno)
1345db792e4Sbill #define	dkunit(bp)	(minor((bp)->b_dev) >> 3)
1355db792e4Sbill #endif
1365db792e4Sbill 
1375db792e4Sbill /* inumber to disk address and inumber to disk offset */
1385db792e4Sbill #define	itod(x)	((daddr_t)((((unsigned)(x)+2*INOPB-1)/INOPB)))
1395db792e4Sbill #define	itoo(x)	((int)(((x)+2*INOPB-1)%INOPB))
1405db792e4Sbill 
1415db792e4Sbill /* file system blocks to disk blocks and back */
1425db792e4Sbill #define	fsbtodb(b)	((b)*CLSIZE)
1435db792e4Sbill #define	dbtofsb(b)	((b)/CLSIZE)
1445db792e4Sbill 
1455db792e4Sbill #define	NINDIR	(BSIZE/sizeof(daddr_t))
1465db792e4Sbill 
1475db792e4Sbill #define	CBSIZE	28		/* number of chars in a clist block */
1485db792e4Sbill #define	CROUND	0x1F		/* clist rounding; sizeof(int *) + CBSIZE -1*/
1495db792e4Sbill 
1505db792e4Sbill /*
1515db792e4Sbill  * Macros for fast min/max
1525db792e4Sbill  */
1535db792e4Sbill #define	MIN(a,b) (((a)<(b))?(a):(b))
1545db792e4Sbill #define	MAX(a,b) (((a)>(b))?(a):(b))
1555db792e4Sbill 
1565db792e4Sbill /*
1575db792e4Sbill  * Some macros for units conversion
1585db792e4Sbill  */
1595db792e4Sbill /* Core clicks (512 bytes) to segments and vice versa */
1605db792e4Sbill #define	ctos(x)	(x)
1615db792e4Sbill #define	stoc(x)	(x)
1625db792e4Sbill 
1635db792e4Sbill /* Core clicks (512 bytes) to disk blocks */
1645db792e4Sbill #define	ctod(x)	(x)
1655db792e4Sbill 
1665db792e4Sbill /* clicks to bytes */
1675db792e4Sbill #define	ctob(x)	((x)<<9)
1685db792e4Sbill 
1695db792e4Sbill /* bytes to clicks */
1705db792e4Sbill #define	btoc(x)	((((unsigned)(x)+511)>>9))
1715db792e4Sbill 
172e0ff83f9Swnj #ifndef KERNEL
173e0ff83f9Swnj #include	<sys/types.h>
174e0ff83f9Swnj #else
175e0ff83f9Swnj #include	"../h/types.h"
176e0ff83f9Swnj #endif
17776379a38Sbill 
1785db792e4Sbill /*
1795db792e4Sbill  * Machine-dependent bits and macros
1805db792e4Sbill  */
1815db792e4Sbill #define	UMODE	PSL_CURMOD		/* usermode bits */
1825db792e4Sbill #define	USERMODE(ps)	(((ps) & UMODE) == UMODE)
1835db792e4Sbill 
1845db792e4Sbill #define	BASEPRI(ps)	(((ps) & PSL_IPL) != 0)
185e0ff83f9Swnj 
186e0ff83f9Swnj /*
187e0ff83f9Swnj  * Provide about n microseconds of delay
188e0ff83f9Swnj  */
189e0ff83f9Swnj #define	DELAY(n)	{ register int N = (n); while (--N > 0); }
190