]> git.karo-electronics.de Git - karo-tx-redboot.git/blob - packages/net/tcpip/v2_0/include/sys/param.h
Initial revision
[karo-tx-redboot.git] / packages / net / tcpip / v2_0 / include / sys / param.h
1 //==========================================================================
2 //
3 //      include/sys/param.h
4 //
5 //      
6 //
7 //==========================================================================
8 //####BSDCOPYRIGHTBEGIN####
9 //
10 // -------------------------------------------
11 //
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.
14 //
15 // -------------------------------------------
16 //
17 //####BSDCOPYRIGHTEND####
18 //==========================================================================
19 //#####DESCRIPTIONBEGIN####
20 //
21 // Author(s):    gthomas
22 // Contributors: gthomas
23 // Date:         2000-01-10
24 // Purpose:      
25 // Description:  
26 //              
27 //
28 //####DESCRIPTIONEND####
29 //
30 //==========================================================================
31
32
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 $       */
35
36 /*-
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.
44  *
45  * Redistribution and use in source and binary forms, with or without
46  * modification, are permitted provided that the following conditions
47  * are met:
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.
60  *
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
71  * SUCH DAMAGE.
72  *
73  *      @(#)param.h     8.2 (Berkeley) 1/21/94
74  */
75
76 #ifndef _SYS_PARAM_H_
77 #define _SYS_PARAM_H_
78
79 #define BSD     199306          /* System version (year & month). */
80 #define BSD4_3  1
81 #define BSD4_4  1
82
83 #define OpenBSD 199912          /* OpenBSD version (year & month). */
84 #define OpenBSD2_6 1            /* OpenBSD 2.6 */
85
86 #ifndef NULL
87 #ifdef  __GNUG__
88 #define NULL    __null
89 #else
90 #define NULL    0
91 #endif
92 #endif
93
94 #ifndef _LOCORE
95 #include <sys/types.h>
96 #ifndef __ECOS
97 #include <sys/simplelock.h>
98 #endif
99 #endif
100
101 #ifndef __ECOS
102 /*
103  * Machine-independent constants (some used in following include files).
104  * Redefined constants are from POSIX 1003.1 limits file.
105  *
106  * MAXCOMLEN should be >= sizeof(ac_comm) (see <acct.h>)
107  * MAXLOGNAME should be >= UT_NAMESIZE (see <utmp.h>)
108  */
109 #include <sys/syslimits.h>
110
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 */
120 #endif
121 #define MAXHOSTNAMELEN  256             /* max hostname size */
122
123 /* More types and definitions used throughout the kernel. */
124 #ifdef _KERNEL
125 #include <sys/cdefs.h>
126 #include <sys/errno.h>
127 #include <sys/time.h>
128 #ifdef __ECOS
129 #include <cyg/io/file.h>
130 #else
131 #include <sys/resource.h>
132 #include <sys/ucred.h>
133 #include <sys/uio.h>
134 #endif
135 #endif
136
137 #ifndef __ECOS
138 /* Signals. */
139 #include <sys/signal.h>
140 #endif
141
142 #ifndef __ECOS
143 /*
144  * Priorities.  Note that with 32 run queues, differences less than 4 are
145  * insignificant.
146  */
147 #define PSWP    0
148 #define PVM     4
149 #define PINOD   8
150 #define PRIBIO  16
151 #define PVFS    20
152 #define PZERO   22              /* No longer magic, shouldn't be here.  XXX */
153 #define PSOCK   24
154 #define PWAIT   32
155 #define PLOCK   36
156 #define PPAUSE  40
157 #define PUSER   50
158 #define MAXPRI  127             /* Priorities range from 0 through MAXPRI. */
159
160 #define PRIMASK 0x0ff
161 #define PCATCH  0x100           /* OR'd with pri for tsleep to check signals */
162 #endif
163
164 #define NBPW    sizeof(int)     /* number of bytes per word (integer) */
165
166 #ifndef __ECOS
167 #define CMASK   022             /* default file mask: S_IWGRP|S_IWOTH */
168 #define NODEV   (dev_t)(-1)     /* non-existent device */
169
170 /*
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.
174  */
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)
180
181 #if CLSIZE==1
182 #define clbase(i)       (i)
183 #define clrnd(i)        (i)
184 #else
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))
189 #endif
190
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. */
196
197 /*
198  * File system parameters and macros.
199  *
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.
205  */
206 #ifndef MAXBSIZE        /* XXX temp until sun3 DMA chaining */
207 #define MAXBSIZE        MAXPHYS
208 #endif
209 #define MAXFRAG         8
210
211 /*
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.
219  */
220 #define MAXPATHLEN      PATH_MAX
221 #define MAXSYMLINKS     32
222
223 #endif // __ECOS
224
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)
230
231 /* Macros for counting and rounding. */
232 #ifndef howmany
233 #define howmany(x, y)   (((x)+((y)-1))/(y))
234 #endif
235 #define roundup(x, y)   ((((x)+((y)-1))/(y))*(y))
236 #define powerof2(x)     ((((x)-1)&(x))==0)
237
238 /* Macros for min/max. */
239 #ifndef _KERNEL
240 # ifndef MIN
241 #  define       MIN(a,b) (((a)<(b))?(a):(b))
242 # endif
243 # ifndef MAX
244 #  define       MAX(a,b) (((a)>(b))?(a):(b))
245 # endif
246 #endif
247
248 #ifndef __ECOS
249 /*
250  * Constants for setting the parameters of the kernel memory allocator.
251  *
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.
254  *
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.
260  *
261  * Constraints: CLBYTES <= MAXALLOCSAVE <= 2 ** (MINBUCKET + 14), and
262  * MAXALLOCSIZE must be a power of two.
263  */
264 #define MINBUCKET       4               /* 4 => min allocation of 16 bytes */
265 #define MAXALLOCSAVE    (2 * CLBYTES)
266
267 /*
268  * Scale factor for scaled integers used to count %cpu time and load avgs.
269  *
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).
274  *
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.
277  */
278 #define FSHIFT  11              /* bits to right of fixed binary point */
279 #define FSCALE  (1<<FSHIFT)
280
281 /*
282  * rfork() options.
283  *
284  * XXX currently, operations without RFPROC set are not supported.
285  */
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 */
296 #endif // __ECOS
297
298 #ifdef __ECOS
299 // Function mappings
300
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)
305
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__)
320 #else
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
333 #endif
334
335 extern void cyg_panic(const char *msg, ...);
336 #define panic cyg_panic
337
338 // Namespace changes
339 #define route_reinit cyg_route_reinit
340 #define arc4random cyg_arc4random
341 #endif
342
343 /* Machine type dependent parameters. */
344 #include <machine/param.h>
345 #include <machine/limits.h>
346
347 #endif // __SYS_PARAM_H_