xref: /original-bsd/sys/sys/param.h (revision d25e1985)
1 /*	param.h	3.11	09/14/80	*/
2 
3 /*
4  * tunable variables
5  *
6  * NB: NBUF is well known in locore.s
7  */
8 
9 #define	NBUF	62		/* size of buffer cache */
10 #define	NINODE	400		/* number of in core inodes */
11 #define	NFILE	350		/* number of in core file structures */
12 #define	NMOUNT	15		/* number of mountable file systems */
13 #define	MSWAPX	15		/* pseudo mount table index for swapdev */
14 #define	MAXUPRC	25		/* max processes per user */
15 #define	SSIZE	4		/* initial stack size (*512 bytes) */
16 #define	SINCR	4		/* increment of stack (*512 bytes) */
17 #define	NOFILE	20		/* max open files per process */
18 #define	CANBSIZ	256		/* max size of typewriter line */
19 #define	SMAPSIZ	(4*NPROC)	/* size of swap allocation area */
20 #define	NCALL	40		/* max simultaneous time callouts */
21 #define	NPROC	250		/* max number of processes */
22 #define	NTEXT	60		/* max number of pure texts */
23 #define	NCLIST	500		/* max total clist size */
24 #define	HZ	60		/* Ticks/second of the clock */
25 #define	TIMEZONE (8*60)		/* Minutes westward from Greenwich */
26 #define	DSTFLAG	1		/* Daylight Saving Time applies in this locality */
27 #define	MSGBUFS	128		/* Characters saved from error messages */
28 #define	NCARGS	10240		/* # characters in exec arglist */
29 /*
30  * priorities
31  * probably should not be
32  * altered too much
33  */
34 
35 #define	PSWP	0
36 #define	PINOD	10
37 #define	PRIBIO	20
38 #define	PRIUBA	24
39 #define	PZERO	25
40 #define	PPIPE	26
41 #define	PWAIT	30
42 #define	PSLEP	40
43 #define	PUSER	50
44 
45 #define	NZERO	20
46 
47 /*
48  * signals
49  * dont change
50  */
51 
52 #ifndef	NSIG
53 #include <signal.h>
54 #endif
55 
56 /*
57  * Return values from tsleep().
58  */
59 #define	TS_OK	0	/* normal wakeup */
60 #define	TS_TIME	1	/* timed-out wakeup */
61 #define	TS_SIG	2	/* asynchronous signal wakeup */
62 
63 /*
64  * fundamental constants of the implementation--
65  * cannot be changed easily.
66  * note: UPAGES is well known in locore.s
67  */
68 
69 #define	NBPW	sizeof(int)	/* number of bytes in an integer */
70 
71 #define	UPAGES	6		/* pages of u-area */
72 #define	NULL	0
73 #define	CMASK	0		/* default mask for file creation */
74 #define	NODEV	(dev_t)(-1)
75 #define	ROOTINO	((ino_t)2)	/* i number of all roots */
76 #define	SUPERB	((daddr_t)1)	/* block number of the super block */
77 #define	DIRSIZ	14		/* max characters per directory */
78 
79 /*
80  * Clustering of hardware pages on machines with ridiculously small
81  * page sizes is done here.  The paging subsystem deals with units of
82  * CLSIZE pte's describing NBPG (from vm.h) pages each... BSIZE must
83  * be CLSIZE*NBPG in the current implementation, that is the paging subsystem
84  * deals with the same size blocks that the file system uses.
85  *
86  * NOTE: SSIZE, SINCR and UPAGES must be multiples of CLSIZE
87  *
88  * NB: CLSIZE is well known in locore.s.
89  */
90 #define	CLSIZE	2
91 
92 /* give the base virtual address (first of CLSIZE) */
93 #define	clbase(i)	((i) &~ (CLSIZE-1))
94 
95 /* round a number of clicks up to a whole cluster */
96 #define	clrnd(i)	(((i) + (CLSIZE-1)) &~ (CLSIZE-1))
97 
98 #if CLSIZE==1
99 #define	BSIZE	512		/* size of secondary block (bytes) */
100 #define	INOPB	8		/* 8 inodes per block */
101 #define	BMASK	0777		/* BSIZE-1 */
102 #define	BSHIFT	9		/* LOG2(BSIZE) */
103 #define	NMASK	0177		/* NINDIR-1 */
104 #define	NSHIFT	7		/* LOG2(NINDIR) */
105 #define	NICINOD	100		/* number of superblock inodes */
106 #define	NICFREE	50		/* number of superblock free blocks */
107 
108 #endif
109 
110 #if CLSIZE==2
111 #define	BSIZE	1024
112 #define	INOPB	16
113 #define	BMASK	01777
114 #define	BSHIFT	10
115 #define	NMASK	0377
116 #define	NSHIFT	8
117 #define	NICINOD	100
118 #define	NICFREE	178
119 #endif
120 
121 #if CLSIZE==4
122 #define	BSIZE	2048
123 #define	INOPB	32
124 #define	BMASK	03777
125 #define	BSHIFT	11
126 #define	NMASK	0777
127 #define	NSHIFT	9
128 #define	NICINOD	100
129 #define	NICFREE	434
130 #endif
131 
132 #ifndef INTRLVE
133 /* macros replacing interleaving functions */
134 #define	dkblock(bp)	((bp)->b_blkno)
135 #define	dkunit(bp)	(minor((bp)->b_dev) >> 3)
136 #endif
137 
138 /* inumber to disk address and inumber to disk offset */
139 #define	itod(x)	((daddr_t)((((unsigned)(x)+2*INOPB-1)/INOPB)))
140 #define	itoo(x)	((int)(((x)+2*INOPB-1)%INOPB))
141 
142 /* file system blocks to disk blocks and back */
143 #define	fsbtodb(b)	((b)*CLSIZE)
144 #define	dbtofsb(b)	((b)/CLSIZE)
145 
146 #define	NINDIR	(BSIZE/sizeof(daddr_t))
147 
148 #define	CBSIZE	28		/* number of chars in a clist block */
149 #define	CROUND	0x1F		/* clist rounding; sizeof(int *) + CBSIZE -1*/
150 #define	CLKTICK	(1000000/(HZ))	/* microseconds in a clock tick */
151 
152 /*
153  * Macros for fast min/max
154  */
155 #define	MIN(a,b) (((a)<(b))?(a):(b))
156 #define	MAX(a,b) (((a)>(b))?(a):(b))
157 
158 /*
159  * Some macros for units conversion
160  */
161 /* Core clicks (512 bytes) to segments and vice versa */
162 #define	ctos(x)	(x)
163 #define	stoc(x)	(x)
164 
165 /* Core clicks (512 bytes) to disk blocks */
166 #define	ctod(x)	(x)
167 
168 /* clicks to bytes */
169 #define	ctob(x)	((x)<<9)
170 
171 /* bytes to clicks */
172 #define	btoc(x)	((((unsigned)(x)+511)>>9))
173 
174 /* major part of a device */
175 #define	major(x)	((int)(((unsigned)(x)>>8)&0377))
176 
177 /* minor part of a device */
178 #define	minor(x)	((int)((x)&0377))
179 
180 /* make a device number */
181 #define	makedev(x,y)	((dev_t)(((x)<<8) | (y)))
182 
183 typedef	struct { int r[1]; } *	physadr;
184 typedef	int		daddr_t;
185 typedef	char *		caddr_t;
186 typedef	unsigned short	ino_t;
187 typedef	int		swblk_t;
188 typedef	int		size_t;
189 typedef	int		time_t;
190 typedef	int		label_t[14];
191 typedef	short		dev_t;
192 typedef	int		off_t;
193 
194 typedef	unsigned char	u_char;
195 typedef	unsigned short	u_short;
196 typedef	unsigned int	u_int;
197 typedef	unsigned long	u_long;
198 
199 /*
200  * Machine-dependent bits and macros
201  */
202 #define	UMODE	PSL_CURMOD		/* usermode bits */
203 #define	USERMODE(ps)	(((ps) & UMODE) == UMODE)
204 
205 #define	BASEPRI(ps)	(((ps) & PSL_IPL) != 0)
206