1 //==========================================================================
7 //==========================================================================
8 //####BSDCOPYRIGHTBEGIN####
10 // -------------------------------------------
12 // Portions of this software may have been derived from OpenBSD or other sources,
13 // and are covered by the appropriate copyright disclaimers included herein.
15 // -------------------------------------------
17 //####BSDCOPYRIGHTEND####
18 //==========================================================================
19 //#####DESCRIPTIONBEGIN####
22 // Contributors: gthomas
28 //####DESCRIPTIONEND####
30 //==========================================================================
33 /* $OpenBSD: param.h,v 1.25 1999/09/23 08:25:01 deraadt Exp $ */
34 /* $NetBSD: param.h,v 1.23 1996/03/17 01:02:29 thorpej Exp $ */
37 * Copyright (c) 1982, 1986, 1989, 1993
38 * The Regents of the University of California. All rights reserved.
39 * (c) UNIX System Laboratories, Inc.
40 * All or some portions of this file are derived from material licensed
41 * to the University of California by American Telephone and Telegraph
42 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
43 * the permission of UNIX System Laboratories, Inc.
45 * Redistribution and use in source and binary forms, with or without
46 * modification, are permitted provided that the following conditions
48 * 1. Redistributions of source code must retain the above copyright
49 * notice, this list of conditions and the following disclaimer.
50 * 2. Redistributions in binary form must reproduce the above copyright
51 * notice, this list of conditions and the following disclaimer in the
52 * documentation and/or other materials provided with the distribution.
53 * 3. All advertising materials mentioning features or use of this software
54 * must display the following acknowledgement:
55 * This product includes software developed by the University of
56 * California, Berkeley and its contributors.
57 * 4. Neither the name of the University nor the names of its contributors
58 * may be used to endorse or promote products derived from this software
59 * without specific prior written permission.
61 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
62 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
63 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
64 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
65 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
66 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
67 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
68 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
69 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
70 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
73 * @(#)param.h 8.2 (Berkeley) 1/21/94
79 #define BSD 199306 /* System version (year & month). */
83 #define OpenBSD 199912 /* OpenBSD version (year & month). */
84 #define OpenBSD2_6 1 /* OpenBSD 2.6 */
95 #include <sys/types.h>
97 #include <sys/simplelock.h>
103 * Machine-independent constants (some used in following include files).
104 * Redefined constants are from POSIX 1003.1 limits file.
106 * MAXCOMLEN should be >= sizeof(ac_comm) (see <acct.h>)
107 * MAXLOGNAME should be >= UT_NAMESIZE (see <utmp.h>)
109 #include <sys/syslimits.h>
111 #define MAXCOMLEN 16 /* max command name remembered */
112 #define MAXINTERP 64 /* max interpreter file name length */
113 #define MAXLOGNAME 12 /* max login name length */
114 #define MAXUPRC CHILD_MAX /* max simultaneous processes */
115 #define NCARGS ARG_MAX /* max bytes for an exec function */
116 #define NGROUPS NGROUPS_MAX /* max number groups */
117 #define NOFILE OPEN_MAX /* max open files per process (soft) */
118 #define NOFILE_MAX 1024 /* max open files per process (hard) */
119 #define NOGROUP 65535 /* marker for empty group set member */
121 #define MAXHOSTNAMELEN 256 /* max hostname size */
123 /* More types and definitions used throughout the kernel. */
125 #include <sys/cdefs.h>
126 #include <sys/errno.h>
127 #include <sys/time.h>
129 #include <cyg/io/file.h>
131 #include <sys/resource.h>
132 #include <sys/ucred.h>
139 #include <sys/signal.h>
144 * Priorities. Note that with 32 run queues, differences less than 4 are
152 #define PZERO 22 /* No longer magic, shouldn't be here. XXX */
158 #define MAXPRI 127 /* Priorities range from 0 through MAXPRI. */
160 #define PRIMASK 0x0ff
161 #define PCATCH 0x100 /* OR'd with pri for tsleep to check signals */
164 #define NBPW sizeof(int) /* number of bytes per word (integer) */
167 #define CMASK 022 /* default file mask: S_IWGRP|S_IWOTH */
168 #define NODEV (dev_t)(-1) /* non-existent device */
171 * Clustering of hardware pages on machines with ridiculously small
172 * page sizes is done here. The paging subsystem deals with units of
173 * CLSIZE pte's describing NBPG (from machine/machparam.h) pages each.
175 #define CLBYTES (CLSIZE*NBPG)
176 #define CLOFSET (CLSIZE*NBPG-1) /* for clusters, like PGOFSET */
177 #define claligned(x) ((((int)(x))&CLOFSET)==0)
178 #define CLOFF CLOFSET
179 #define CLSHIFT (PGSHIFT+CLSIZELOG2)
182 #define clbase(i) (i)
185 /* Give the base virtual address (first of CLSIZE). */
186 #define clbase(i) ((i) &~ (CLSIZE-1))
187 /* Round a number of clicks up to a whole cluster. */
188 #define clrnd(i) (((i) + (CLSIZE-1)) &~ (CLSIZE-1))
191 #define CBLOCK 64 /* Clist block size, must be a power of 2. */
192 #define CBQSIZE (CBLOCK/NBBY) /* Quote bytes/cblock - can do better. */
193 /* Data chars/clist. */
194 #define CBSIZE (CBLOCK - sizeof(struct cblock *) - CBQSIZE)
195 #define CROUND (CBLOCK - 1) /* Clist rounding. */
198 * File system parameters and macros.
200 * The file system is made out of blocks of at most MAXBSIZE units, with
201 * smaller units (fragments) only in the last direct block. MAXBSIZE
202 * primarily determines the size of buffers in the buffer pool. It may be
203 * made larger without any effect on existing file systems; however making
204 * it smaller makes some file systems unmountable.
206 #ifndef MAXBSIZE /* XXX temp until sun3 DMA chaining */
207 #define MAXBSIZE MAXPHYS
212 * MAXPATHLEN defines the longest permissable path length after expanding
213 * symbolic links. It is used to allocate a temporary buffer from the buffer
214 * pool in which to do the name expansion, hence should be a power of two,
215 * and must be less than or equal to MAXBSIZE. MAXSYMLINKS defines the
216 * maximum number of symbolic links that may be expanded in a path name.
217 * It should be set high enough to allow all legitimate uses, but halt
218 * infinite loops reasonably quickly.
220 #define MAXPATHLEN PATH_MAX
221 #define MAXSYMLINKS 32
225 /* Bit map related macros. */
226 #define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY))
227 #define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
228 #define isset(a,i) ((a)[(i)/NBBY] & (1<<((i)%NBBY)))
229 #define isclr(a,i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
231 /* Macros for counting and rounding. */
233 #define howmany(x, y) (((x)+((y)-1))/(y))
235 #define roundup(x, y) ((((x)+((y)-1))/(y))*(y))
236 #define powerof2(x) ((((x)-1)&(x))==0)
238 /* Macros for min/max. */
241 # define MIN(a,b) (((a)<(b))?(a):(b))
244 # define MAX(a,b) (((a)>(b))?(a):(b))
250 * Constants for setting the parameters of the kernel memory allocator.
252 * 2 ** MINBUCKET is the smallest unit of memory that will be
253 * allocated. It must be at least large enough to hold a pointer.
255 * Units of memory less or equal to MAXALLOCSAVE will permanently
256 * allocate physical memory; requests for these size pieces of
257 * memory are quite fast. Allocations greater than MAXALLOCSAVE must
258 * always allocate and free physical memory; requests for these
259 * size allocations should be done infrequently as they will be slow.
261 * Constraints: CLBYTES <= MAXALLOCSAVE <= 2 ** (MINBUCKET + 14), and
262 * MAXALLOCSIZE must be a power of two.
264 #define MINBUCKET 4 /* 4 => min allocation of 16 bytes */
265 #define MAXALLOCSAVE (2 * CLBYTES)
268 * Scale factor for scaled integers used to count %cpu time and load avgs.
270 * The number of CPU `tick's that map to a unique `%age' can be expressed
271 * by the formula (1 / (2 ^ (FSHIFT - 11))). The maximum load average that
272 * can be calculated (assuming 32 bits) can be closely approximated using
273 * the formula (2 ^ (2 * (16 - FSHIFT))) for (FSHIFT < 15).
275 * For the scheduler to maintain a 1:1 mapping of CPU `tick' to `%age',
276 * FSHIFT must be at least 11; this gives us a maximum load avg of ~1024.
278 #define FSHIFT 11 /* bits to right of fixed binary point */
279 #define FSCALE (1<<FSHIFT)
284 * XXX currently, operations without RFPROC set are not supported.
286 #define RFNAMEG (1<<0) /* UNIMPL new plan9 `name space' */
287 #define RFENVG (1<<1) /* UNIMPL copy plan9 `env space' */
288 #define RFFDG (1<<2) /* copy fd table */
289 #define RFNOTEG (1<<3) /* UNIMPL create new plan9 `note group' */
290 #define RFPROC (1<<4) /* change child (else changes curproc) */
291 #define RFMEM (1<<5) /* share `address space' */
292 #define RFNOWAIT (1<<6) /* parent need not wait() on child */
293 #define RFCNAMEG (1<<10) /* UNIMPL zero plan9 `name space' */
294 #define RFCENVG (1<<11) /* UNIMPL zero plan9 `env space' */
295 #define RFCFDG (1<<12) /* zero fd table */
301 extern int cyg_tsleep(void *, int, char *, int);
302 extern void cyg_wakeup(void *);
303 #define tsleep(e,p,w,t) cyg_tsleep(e,0,w,t)
304 #define wakeup(e) cyg_wakeup(e)
306 #ifdef CYGIMPL_TRACE_SPLX
307 extern cyg_uint32 cyg_splimp(const char *file, const int line);
308 extern cyg_uint32 cyg_splnet(const char *file, const int line);
309 extern cyg_uint32 cyg_splclock(const char *file, const int line);
310 extern cyg_uint32 cyg_splsoftnet(const char *file, const int line);
311 extern void cyg_splx(cyg_uint32, const char *file, const int line);
312 #define splimp() cyg_splimp(__FUNCTION__, __LINE__)
313 #define splnet() cyg_splnet(__FUNCTION__, __LINE__)
314 #define splclock() cyg_splclock(__FUNCTION__, __LINE__)
315 #define splsoftnet() cyg_splsoftnet(__FUNCTION__, __LINE__)
316 #define splx(x) cyg_splx(x, __FUNCTION__, __LINE__)
317 #define cyg_scheduler_lock() _cyg_scheduler_lock(__FUNCTION__, __LINE__)
318 #define cyg_scheduler_safe_lock() _cyg_scheduler_safe_lock(__FUNCTION__, __LINE__)
319 #define cyg_scheduler_unlock() _cyg_scheduler_unlock(__FUNCTION__, __LINE__)
321 extern cyg_uint32 cyg_splimp(void);
322 extern cyg_uint32 cyg_splnet(void);
323 extern cyg_uint32 cyg_splclock(void);
324 extern cyg_uint32 cyg_splsoftnet(void);
325 extern cyg_uint32 cyg_splhigh(void);
326 extern void cyg_splx(cyg_uint32);
327 #define splimp cyg_splimp
328 #define splnet cyg_splnet
329 #define splclock cyg_splclock
330 #define splsoftnet cyg_splsoftnet
331 #define splhigh cyg_splhigh
332 #define splx cyg_splx
335 extern void cyg_panic(const char *msg, ...);
336 #define panic cyg_panic
339 #define route_reinit cyg_route_reinit
340 #define arc4random cyg_arc4random
343 /* Machine type dependent parameters. */
344 #include <machine/param.h>
345 #include <machine/limits.h>
347 #endif // __SYS_PARAM_H_