]>
Commit | Line | Data |
---|---|---|
2aa62f2b | 1 | /* $NetBSD: param.h,v 1.244.2.9.2.2 2008/10/05 08:44:03 bouyer Exp $ */\r |
2 | \r | |
3 | /*-\r | |
4 | * Copyright (c) 1982, 1986, 1989, 1993\r | |
5 | * The Regents of the University of California. All rights reserved.\r | |
6 | * (c) UNIX System Laboratories, Inc.\r | |
7 | * All or some portions of this file are derived from material licensed\r | |
8 | * to the University of California by American Telephone and Telegraph\r | |
9 | * Co. or Unix System Laboratories, Inc. and are reproduced herein with\r | |
10 | * the permission of UNIX System Laboratories, Inc.\r | |
11 | *\r | |
12 | * Redistribution and use in source and binary forms, with or without\r | |
13 | * modification, are permitted provided that the following conditions\r | |
14 | * are met:\r | |
15 | * 1. Redistributions of source code must retain the above copyright\r | |
16 | * notice, this list of conditions and the following disclaimer.\r | |
17 | * 2. Redistributions in binary form must reproduce the above copyright\r | |
18 | * notice, this list of conditions and the following disclaimer in the\r | |
19 | * documentation and/or other materials provided with the distribution.\r | |
20 | * 3. Neither the name of the University nor the names of its contributors\r | |
21 | * may be used to endorse or promote products derived from this software\r | |
22 | * without specific prior written permission.\r | |
23 | *\r | |
24 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND\r | |
25 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r | |
26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r | |
27 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE\r | |
28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r | |
29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\r | |
30 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r | |
31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r | |
32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\r | |
33 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\r | |
34 | * SUCH DAMAGE.\r | |
35 | *\r | |
36 | * @(#)param.h 8.3 (Berkeley) 4/4/95\r | |
37 | */\r | |
38 | \r | |
39 | #ifndef _SYS_PARAM_H_\r | |
40 | #define _SYS_PARAM_H_\r | |
41 | \r | |
42 | /*\r | |
43 | * Historic BSD #defines -- probably will remain untouched for all time.\r | |
44 | */\r | |
45 | #define BSD 199506 /* System version (year & month). */\r | |
46 | #define BSD4_3 1\r | |
47 | #define BSD4_4 1\r | |
48 | \r | |
49 | /*\r | |
50 | * #define __NetBSD_Version__ MMmmrrpp00\r | |
51 | *\r | |
52 | * M = major version\r | |
53 | * m = minor version; a minor number of 99 indicates current.\r | |
54 | * r = 0 (*)\r | |
55 | * p = patchlevel\r | |
56 | *\r | |
57 | * When new releases are made, src/gnu/usr.bin/groff/tmac/mdoc.local\r | |
58 | * needs to be updated and the changes sent back to the groff maintainers.\r | |
59 | *\r | |
60 | * (*) Up to 2.0I "release" used to be "",A-Z,Z[A-Z] but numeric\r | |
61 | * e.g. NetBSD-1.2D = 102040000 ('D' == 4)\r | |
62 | * NetBSD-2.0H (200080000) was changed on 20041001 to:\r | |
63 | * 2.99.9 (299000900)\r | |
64 | */\r | |
65 | \r | |
66 | #define __NetBSD_Version__ 400000003 /* NetBSD 4.0.1 */\r | |
67 | \r | |
68 | #define __NetBSD_Prereq__(M,m,p) (((((M) * 100000000) + \\r | |
69 | (m) * 1000000) + (p) * 100) <= __NetBSD_Version__)\r | |
70 | \r | |
71 | /*\r | |
72 | * Historical NetBSD #define\r | |
73 | *\r | |
74 | * NetBSD 1.4 was the last release for which this value was incremented.\r | |
75 | * The value is now permanently fixed at 199905. It will never be\r | |
76 | * changed again.\r | |
77 | *\r | |
78 | * New code must use __NetBSD_Version__ instead, and should not even\r | |
79 | * count on NetBSD being defined.\r | |
80 | *\r | |
81 | */\r | |
82 | \r | |
83 | #define NetBSD 199905 /* NetBSD version (year & month). */\r | |
84 | \r | |
85 | #ifndef _LOCORE\r | |
86 | //#include <sys/inttypes.h>\r | |
87 | #include <sys/types.h>\r | |
88 | #endif\r | |
89 | \r | |
90 | /*\r | |
91 | * Machine-independent constants (some used in following include files).\r | |
92 | * Redefined constants are from POSIX 1003.1 limits file.\r | |
93 | *\r | |
94 | * MAXCOMLEN should be >= sizeof(ac_comm) (see <acct.h>)\r | |
95 | * MAXLOGNAME should be >= UT_NAMESIZE (see <utmp.h>)\r | |
96 | */\r | |
97 | #include <sys/syslimits.h>\r | |
98 | \r | |
99 | #define MAXCOMLEN 16 /* max command name remembered */\r | |
100 | #define MAXINTERP PATH_MAX /* max interpreter file name length */\r | |
101 | /* DEPRECATED: use LOGIN_NAME_MAX instead. */\r | |
102 | #define MAXLOGNAME (LOGIN_NAME_MAX - 1) /* max login name length */\r | |
103 | #define NCARGS ARG_MAX /* max bytes for an exec function */\r | |
104 | #define NGROUPS NGROUPS_MAX /* max number groups */\r | |
105 | #define NOGROUP 65535 /* marker for empty group set member */\r | |
106 | #define MAXHOSTNAMELEN 256 /* max hostname size */\r | |
107 | \r | |
108 | #ifndef NOFILE\r | |
109 | #define NOFILE OPEN_MAX /* max open files per process */\r | |
110 | #endif\r | |
111 | #ifndef MAXUPRC /* max simultaneous processes */\r | |
112 | #define MAXUPRC CHILD_MAX /* POSIX 1003.1-compliant default */\r | |
113 | #else\r | |
114 | #if (MAXUPRC - 0) < CHILD_MAX\r | |
115 | #error MAXUPRC less than CHILD_MAX. See options(4) for details.\r | |
116 | #endif /* (MAXUPRC - 0) < CHILD_MAX */\r | |
117 | #endif /* !defined(MAXUPRC) */\r | |
118 | \r | |
119 | /* Signals. */\r | |
120 | #include <sys/signal.h>\r | |
121 | \r | |
122 | /* Machine type dependent parameters. */\r | |
123 | #include <machine/param.h>\r | |
124 | #include <machine/limits.h>\r | |
125 | \r | |
126 | /* pages ("clicks") to disk blocks */\r | |
127 | #define ctod(x) ((x) << (PGSHIFT - DEV_BSHIFT))\r | |
128 | #define dtoc(x) ((x) >> (PGSHIFT - DEV_BSHIFT))\r | |
129 | \r | |
130 | /* bytes to pages */\r | |
131 | #define ctob(x) ((x) << PGSHIFT)\r | |
132 | #define btoc(x) (((x) + PGOFSET) >> PGSHIFT)\r | |
133 | \r | |
134 | /* bytes to disk blocks */\r | |
135 | #define dbtob(x) ((x) << DEV_BSHIFT)\r | |
136 | #define btodb(x) ((x) >> DEV_BSHIFT)\r | |
137 | \r | |
138 | /*\r | |
139 | * Stack macros. On most architectures, the stack grows down,\r | |
140 | * towards lower addresses; it is the rare architecture where\r | |
141 | * it grows up, towards higher addresses.\r | |
142 | *\r | |
143 | * STACK_GROW and STACK_SHRINK adjust a stack pointer by some\r | |
144 | * size, no questions asked. STACK_ALIGN aligns a stack pointer.\r | |
145 | *\r | |
146 | * STACK_ALLOC returns a pointer to allocated stack space of\r | |
147 | * some size; given such a pointer and a size, STACK_MAX gives\r | |
148 | * the maximum (in the "maxsaddr" sense) stack address of the\r | |
149 | * allocated memory.\r | |
150 | */\r | |
151 | #if defined(_KERNEL) || defined(__EXPOSE_STACK)\r | |
152 | #ifdef __MACHINE_STACK_GROWS_UP\r | |
153 | #define STACK_GROW(sp, _size) (((caddr_t)(sp)) + (_size))\r | |
154 | #define STACK_SHRINK(sp, _size) (((caddr_t)(sp)) - (_size))\r | |
155 | #define STACK_ALIGN(sp, bytes) \\r | |
156 | ((caddr_t)((((unsigned long)(sp)) + (bytes)) & ~(bytes)))\r | |
157 | #define STACK_ALLOC(sp, _size) ((caddr_t)(sp))\r | |
158 | #define STACK_MAX(p, _size) (((caddr_t)(p)) + (_size))\r | |
159 | #else\r | |
160 | #define STACK_GROW(sp, _size) (((caddr_t)(sp)) - (_size))\r | |
161 | #define STACK_SHRINK(sp, _size) (((caddr_t)(sp)) + (_size))\r | |
162 | #define STACK_ALIGN(sp, bytes) \\r | |
163 | ((caddr_t)(((unsigned long)(sp)) & ~(bytes)))\r | |
164 | #define STACK_ALLOC(sp, _size) (((caddr_t)(sp)) - (_size))\r | |
165 | #define STACK_MAX(p, _size) ((caddr_t)(p))\r | |
166 | #endif\r | |
167 | #endif /* defined(_KERNEL) || defined(__EXPOSE_STACK) */\r | |
168 | \r | |
169 | /*\r | |
170 | * Priorities. Note that with 32 run queues, differences less than 4 are\r | |
171 | * insignificant.\r | |
172 | */\r | |
173 | #define PSWP 0\r | |
174 | #define PVM 4\r | |
175 | #define PINOD 8\r | |
176 | #define PRIBIO 16\r | |
177 | #define PVFS 20\r | |
178 | #define PZERO 22 /* No longer magic, shouldn't be here. XXX */\r | |
179 | #define PSOCK 24\r | |
180 | #define PWAIT 32\r | |
181 | #define PLOCK 36\r | |
182 | #define PPAUSE 40\r | |
183 | #define PUSER 50\r | |
184 | #define MAXPRI 127 /* Priorities range from 0 through MAXPRI. */\r | |
185 | \r | |
186 | #define PRIMASK 0x0ff\r | |
187 | #define PCATCH 0x100 /* OR'd with pri for tsleep to check signals */\r | |
188 | #define PNORELOCK 0x200 /* OR'd with pri for cond_wait() to not relock\r | |
189 | the interlock */\r | |
190 | #define PNOEXITERR 0x400 /* OR'd with pri for tsleep to not exit\r | |
191 | with an error code when LWPs are exiting */\r | |
192 | #define NBPW sizeof(int) /* number of bytes per word (integer) */\r | |
193 | \r | |
194 | #define CMASK 022 /* default file mask: S_IWGRP|S_IWOTH */\r | |
195 | #define NODEV (dev_t)(-1) /* non-existent device */\r | |
196 | \r | |
197 | #define CBLOCK 64 /* Clist block size, must be a power of 2. */\r | |
198 | #define CBQSIZE (CBLOCK/NBBY) /* Quote bytes/cblock - can do better. */\r | |
199 | /* Data chars/clist. */\r | |
200 | #define CBSIZE (CBLOCK - (int)sizeof(struct cblock *) - CBQSIZE)\r | |
201 | #define CROUND (CBLOCK - 1) /* Clist rounding. */\r | |
202 | \r | |
203 | /*\r | |
204 | * File system parameters and macros.\r | |
205 | *\r | |
206 | * The file system is made out of blocks of at most MAXBSIZE units, with\r | |
207 | * smaller units (fragments) only in the last direct block. MAXBSIZE\r | |
208 | * primarily determines the size of buffers in the buffer pool. It may be\r | |
209 | * made larger without any effect on existing file systems; however making\r | |
210 | * it smaller may make some file systems unmountable.\r | |
211 | */\r | |
212 | #ifndef MAXBSIZE /* XXX */\r | |
213 | #define MAXBSIZE MAXPHYS\r | |
214 | #endif\r | |
215 | #define MAXFRAG 8\r | |
216 | \r | |
217 | /*\r | |
218 | * MAXPATHLEN defines the longest permissible path length after expanding\r | |
219 | * symbolic links. It is used to allocate a temporary buffer from the buffer\r | |
220 | * pool in which to do the name expansion, hence should be a power of two,\r | |
221 | * and must be less than or equal to MAXBSIZE. MAXSYMLINKS defines the\r | |
222 | * maximum number of symbolic links that may be expanded in a path name.\r | |
223 | * It should be set high enough to allow all legitimate uses, but halt\r | |
224 | * infinite loops reasonably quickly.\r | |
225 | */\r | |
226 | #define MAXPATHLEN PATH_MAX\r | |
227 | #define MAXSYMLINKS 32\r | |
228 | \r | |
229 | /* Bit map related macros. */\r | |
230 | #define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY))\r | |
231 | #define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))\r | |
232 | #define isset(a,i) ((a)[(i)/NBBY] & (1<<((i)%NBBY)))\r | |
233 | #define isclr(a,i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)\r | |
234 | \r | |
235 | /* Macros for counting and rounding. */\r | |
236 | #ifndef howmany\r | |
237 | #define howmany(x, y) (((x)+((y)-1))/(y))\r | |
238 | #endif\r | |
239 | #define roundup(x, y) ((((x)+((y)-1))/(y))*(y))\r | |
240 | #define rounddown(x,y) (((x)/(y))*(y))\r | |
241 | #define powerof2(x) ((((x)-1)&(x))==0)\r | |
242 | \r | |
243 | ///* Macros for min/max. */\r | |
244 | //#define MIN(a,b) (((a)<(b))?(a):(b))\r | |
245 | //#define MAX(a,b) (((a)>(b))?(a):(b))\r | |
246 | \r | |
247 | /*\r | |
248 | * Constants for setting the parameters of the kernel memory allocator.\r | |
249 | *\r | |
250 | * 2 ** MINBUCKET is the smallest unit of memory that will be\r | |
251 | * allocated. It must be at least large enough to hold a pointer.\r | |
252 | *\r | |
253 | * Units of memory less or equal to MAXALLOCSAVE will permanently\r | |
254 | * allocate physical memory; requests for these size pieces of\r | |
255 | * memory are quite fast. Allocations greater than MAXALLOCSAVE must\r | |
256 | * always allocate and free physical memory; requests for these\r | |
257 | * size allocations should be done infrequently as they will be slow.\r | |
258 | *\r | |
259 | * Constraints: NBPG <= MAXALLOCSAVE <= 2 ** (MINBUCKET + 14), and\r | |
260 | * MAXALLOCSAVE must be a power of two.\r | |
261 | */\r | |
262 | #ifdef _LP64\r | |
263 | #define MINBUCKET 5 /* 5 => min allocation of 32 bytes */\r | |
264 | #else\r | |
265 | #define MINBUCKET 4 /* 4 => min allocation of 16 bytes */\r | |
266 | #endif\r | |
267 | #define MAXALLOCSAVE (2 * NBPG)\r | |
268 | \r | |
269 | /*\r | |
270 | * Scale factor for scaled integers used to count %cpu time and load avgs.\r | |
271 | *\r | |
272 | * The number of CPU `tick's that map to a unique `%age' can be expressed\r | |
273 | * by the formula (1 / (2 ^ (FSHIFT - 11))). The maximum load average that\r | |
274 | * can be calculated (assuming 32 bits) can be closely approximated using\r | |
275 | * the formula (2 ^ (2 * (16 - FSHIFT))) for (FSHIFT < 15).\r | |
276 | *\r | |
277 | * For the scheduler to maintain a 1:1 mapping of CPU `tick' to `%age',\r | |
278 | * FSHIFT must be at least 11; this gives us a maximum load avg of ~1024.\r | |
279 | */\r | |
280 | #define FSHIFT 11 /* bits to right of fixed binary point */\r | |
281 | #define FSCALE (1<<FSHIFT)\r | |
282 | \r | |
283 | /*\r | |
284 | * The time for a process to be blocked before being very swappable.\r | |
285 | * This is a number of seconds which the system takes as being a non-trivial\r | |
286 | * amount of real time. You probably shouldn't change this;\r | |
287 | * it is used in subtle ways (fractions and multiples of it are, that is, like\r | |
288 | * half of a ``long time'', almost a long time, etc.)\r | |
289 | * It is related to human patience and other factors which don't really\r | |
290 | * change over time.\r | |
291 | */\r | |
292 | #define MAXSLP 20\r | |
293 | \r | |
294 | /*\r | |
295 | * Defaults for Unified Buffer Cache parameters.\r | |
296 | * These may be overridden in <machine/param.h>.\r | |
297 | */\r | |
298 | \r | |
299 | #ifndef UBC_WINSHIFT\r | |
300 | #define UBC_WINSHIFT 13\r | |
301 | #endif\r | |
302 | #ifndef UBC_NWINS\r | |
303 | #define UBC_NWINS 1024\r | |
304 | #endif\r | |
305 | \r | |
306 | #ifdef _KERNEL\r | |
307 | /*\r | |
308 | * macro to convert from milliseconds to hz without integer overflow\r | |
309 | * Default version using only 32bits arithmetics.\r | |
310 | * 64bit port can define 64bit version in their <machine/param.h>\r | |
311 | * 0x20000 is safe for hz < 20000\r | |
312 | */\r | |
313 | #ifndef mstohz\r | |
314 | #define mstohz(ms) \\r | |
315 | (__predict_false((ms) >= 0x20000) ? \\r | |
316 | ((ms +0u) / 1000u) * hz : \\r | |
317 | ((ms +0u) * hz) / 1000u)\r | |
318 | #endif\r | |
319 | #endif /* _KERNEL */\r | |
320 | \r | |
321 | #endif /* !_SYS_PARAM_H_ */\r |