comparison packages/net/tcpip/current/include/sys/param.h @ 97:ced4577552cd ecos-sw-2000-06-06

Merge from eCos master repository on 2000-06-06-08:44:00-BST
author jlarmour
date Tue, 06 Jun 2000 08:39:36 +0000
parents
children 95f3e12a6327
comparison
equal deleted inserted replaced
96:b15c60e34c84 97:ced4577552cd
1 //==========================================================================
2 //
3 // include/sys/param.h
4 //
5 //
6 //
7 //==========================================================================
8 //####COPYRIGHTBEGIN####
9 //
10 // -------------------------------------------
11 // The contents of this file are subject to the Red Hat eCos Public License
12 // Version 1.1 (the "License"); you may not use this file except in
13 // compliance with the License. You may obtain a copy of the License at
14 // http://www.redhat.com/
15 //
16 // Software distributed under the License is distributed on an "AS IS"
17 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
18 // License for the specific language governing rights and limitations under
19 // the License.
20 //
21 // The Original Code is eCos - Embedded Configurable Operating System,
22 // released September 30, 1998.
23 //
24 // The Initial Developer of the Original Code is Red Hat.
25 // Portions created by Red Hat are
26 // Copyright (C) 1998, 1999, 2000 Red Hat, Inc.
27 // All Rights Reserved.
28 // -------------------------------------------
29 //
30 //####COPYRIGHTEND####
31 //####BSDCOPYRIGHTBEGIN####
32 //
33 // -------------------------------------------
34 //
35 // Portions of this software may have been derived from OpenBSD or other sources,
36 // and are covered by the appropriate copyright disclaimers included herein.
37 //
38 // -------------------------------------------
39 //
40 //####BSDCOPYRIGHTEND####
41 //==========================================================================
42 //#####DESCRIPTIONBEGIN####
43 //
44 // Author(s): gthomas
45 // Contributors: gthomas
46 // Date: 2000-01-10
47 // Purpose:
48 // Description:
49 //
50 //
51 //####DESCRIPTIONEND####
52 //
53 //==========================================================================
54
55
56 /* $OpenBSD: param.h,v 1.25 1999/09/23 08:25:01 deraadt Exp $ */
57 /* $NetBSD: param.h,v 1.23 1996/03/17 01:02:29 thorpej Exp $ */
58
59 /*-
60 * Copyright (c) 1982, 1986, 1989, 1993
61 * The Regents of the University of California. All rights reserved.
62 * (c) UNIX System Laboratories, Inc.
63 * All or some portions of this file are derived from material licensed
64 * to the University of California by American Telephone and Telegraph
65 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
66 * the permission of UNIX System Laboratories, Inc.
67 *
68 * Redistribution and use in source and binary forms, with or without
69 * modification, are permitted provided that the following conditions
70 * are met:
71 * 1. Redistributions of source code must retain the above copyright
72 * notice, this list of conditions and the following disclaimer.
73 * 2. Redistributions in binary form must reproduce the above copyright
74 * notice, this list of conditions and the following disclaimer in the
75 * documentation and/or other materials provided with the distribution.
76 * 3. All advertising materials mentioning features or use of this software
77 * must display the following acknowledgement:
78 * This product includes software developed by the University of
79 * California, Berkeley and its contributors.
80 * 4. Neither the name of the University nor the names of its contributors
81 * may be used to endorse or promote products derived from this software
82 * without specific prior written permission.
83 *
84 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
85 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
86 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
87 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
88 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
89 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
90 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
91 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
92 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
93 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
94 * SUCH DAMAGE.
95 *
96 * @(#)param.h 8.2 (Berkeley) 1/21/94
97 */
98
99 #ifndef _SYS_PARAM_H_
100 #define _SYS_PARAM_H_
101
102 #define BSD 199306 /* System version (year & month). */
103 #define BSD4_3 1
104 #define BSD4_4 1
105
106 #define OpenBSD 199912 /* OpenBSD version (year & month). */
107 #define OpenBSD2_6 1 /* OpenBSD 2.6 */
108
109 #ifndef NULL
110 #ifdef __GNUG__
111 #define NULL __null
112 #else
113 #define NULL 0
114 #endif
115 #endif
116
117 #ifndef _LOCORE
118 #include <sys/types.h>
119 #ifndef __ECOS
120 #include <sys/simplelock.h>
121 #endif
122 #endif
123
124 #ifndef __ECOS
125 /*
126 * Machine-independent constants (some used in following include files).
127 * Redefined constants are from POSIX 1003.1 limits file.
128 *
129 * MAXCOMLEN should be >= sizeof(ac_comm) (see <acct.h>)
130 * MAXLOGNAME should be >= UT_NAMESIZE (see <utmp.h>)
131 */
132 #include <sys/syslimits.h>
133
134 #define MAXCOMLEN 16 /* max command name remembered */
135 #define MAXINTERP 64 /* max interpreter file name length */
136 #define MAXLOGNAME 12 /* max login name length */
137 #define MAXUPRC CHILD_MAX /* max simultaneous processes */
138 #define NCARGS ARG_MAX /* max bytes for an exec function */
139 #define NGROUPS NGROUPS_MAX /* max number groups */
140 #define NOFILE OPEN_MAX /* max open files per process (soft) */
141 #define NOFILE_MAX 1024 /* max open files per process (hard) */
142 #define NOGROUP 65535 /* marker for empty group set member */
143 #endif
144 #define MAXHOSTNAMELEN 256 /* max hostname size */
145
146 /* More types and definitions used throughout the kernel. */
147 #ifdef _KERNEL
148 #include <sys/cdefs.h>
149 #include <sys/errno.h>
150 #include <sys/time.h>
151 #ifdef __ECOS
152 #include <cyg/io/file.h>
153 #else
154 #include <sys/resource.h>
155 #include <sys/ucred.h>
156 #include <sys/uio.h>
157 #endif
158 #endif
159
160 #ifndef __ECOS
161 /* Signals. */
162 #include <sys/signal.h>
163 #endif
164
165 /* Machine type dependent parameters. */
166 #include <machine/param.h>
167 #include <machine/limits.h>
168
169 #ifndef __ECOS
170 /*
171 * Priorities. Note that with 32 run queues, differences less than 4 are
172 * insignificant.
173 */
174 #define PSWP 0
175 #define PVM 4
176 #define PINOD 8
177 #define PRIBIO 16
178 #define PVFS 20
179 #define PZERO 22 /* No longer magic, shouldn't be here. XXX */
180 #define PSOCK 24
181 #define PWAIT 32
182 #define PLOCK 36
183 #define PPAUSE 40
184 #define PUSER 50
185 #define MAXPRI 127 /* Priorities range from 0 through MAXPRI. */
186
187 #define PRIMASK 0x0ff
188 #define PCATCH 0x100 /* OR'd with pri for tsleep to check signals */
189 #endif
190
191 #define NBPW sizeof(int) /* number of bytes per word (integer) */
192
193 #ifndef __ECOS
194 #define CMASK 022 /* default file mask: S_IWGRP|S_IWOTH */
195 #define NODEV (dev_t)(-1) /* non-existent device */
196
197 /*
198 * Clustering of hardware pages on machines with ridiculously small
199 * page sizes is done here. The paging subsystem deals with units of
200 * CLSIZE pte's describing NBPG (from machine/machparam.h) pages each.
201 */
202 #define CLBYTES (CLSIZE*NBPG)
203 #define CLOFSET (CLSIZE*NBPG-1) /* for clusters, like PGOFSET */
204 #define claligned(x) ((((int)(x))&CLOFSET)==0)
205 #define CLOFF CLOFSET
206 #define CLSHIFT (PGSHIFT+CLSIZELOG2)
207
208 #if CLSIZE==1
209 #define clbase(i) (i)
210 #define clrnd(i) (i)
211 #else
212 /* Give the base virtual address (first of CLSIZE). */
213 #define clbase(i) ((i) &~ (CLSIZE-1))
214 /* Round a number of clicks up to a whole cluster. */
215 #define clrnd(i) (((i) + (CLSIZE-1)) &~ (CLSIZE-1))
216 #endif
217
218 #define CBLOCK 64 /* Clist block size, must be a power of 2. */
219 #define CBQSIZE (CBLOCK/NBBY) /* Quote bytes/cblock - can do better. */
220 /* Data chars/clist. */
221 #define CBSIZE (CBLOCK - sizeof(struct cblock *) - CBQSIZE)
222 #define CROUND (CBLOCK - 1) /* Clist rounding. */
223
224 /*
225 * File system parameters and macros.
226 *
227 * The file system is made out of blocks of at most MAXBSIZE units, with
228 * smaller units (fragments) only in the last direct block. MAXBSIZE
229 * primarily determines the size of buffers in the buffer pool. It may be
230 * made larger without any effect on existing file systems; however making
231 * it smaller makes some file systems unmountable.
232 */
233 #ifndef MAXBSIZE /* XXX temp until sun3 DMA chaining */
234 #define MAXBSIZE MAXPHYS
235 #endif
236 #define MAXFRAG 8
237
238 /*
239 * MAXPATHLEN defines the longest permissable path length after expanding
240 * symbolic links. It is used to allocate a temporary buffer from the buffer
241 * pool in which to do the name expansion, hence should be a power of two,
242 * and must be less than or equal to MAXBSIZE. MAXSYMLINKS defines the
243 * maximum number of symbolic links that may be expanded in a path name.
244 * It should be set high enough to allow all legitimate uses, but halt
245 * infinite loops reasonably quickly.
246 */
247 #define MAXPATHLEN PATH_MAX
248 #define MAXSYMLINKS 32
249
250 #endif // __ECOS
251
252 /* Bit map related macros. */
253 #define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY))
254 #define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
255 #define isset(a,i) ((a)[(i)/NBBY] & (1<<((i)%NBBY)))
256 #define isclr(a,i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
257
258 /* Macros for counting and rounding. */
259 #ifndef howmany
260 #define howmany(x, y) (((x)+((y)-1))/(y))
261 #endif
262 #define roundup(x, y) ((((x)+((y)-1))/(y))*(y))
263 #define powerof2(x) ((((x)-1)&(x))==0)
264
265 /* Macros for min/max. */
266 #ifndef _KERNEL
267 #define MIN(a,b) (((a)<(b))?(a):(b))
268 #define MAX(a,b) (((a)>(b))?(a):(b))
269 #endif
270
271 #ifndef __ECOS
272 /*
273 * Constants for setting the parameters of the kernel memory allocator.
274 *
275 * 2 ** MINBUCKET is the smallest unit of memory that will be
276 * allocated. It must be at least large enough to hold a pointer.
277 *
278 * Units of memory less or equal to MAXALLOCSAVE will permanently
279 * allocate physical memory; requests for these size pieces of
280 * memory are quite fast. Allocations greater than MAXALLOCSAVE must
281 * always allocate and free physical memory; requests for these
282 * size allocations should be done infrequently as they will be slow.
283 *
284 * Constraints: CLBYTES <= MAXALLOCSAVE <= 2 ** (MINBUCKET + 14), and
285 * MAXALLOCSIZE must be a power of two.
286 */
287 #define MINBUCKET 4 /* 4 => min allocation of 16 bytes */
288 #define MAXALLOCSAVE (2 * CLBYTES)
289
290 /*
291 * Scale factor for scaled integers used to count %cpu time and load avgs.
292 *
293 * The number of CPU `tick's that map to a unique `%age' can be expressed
294 * by the formula (1 / (2 ^ (FSHIFT - 11))). The maximum load average that
295 * can be calculated (assuming 32 bits) can be closely approximated using
296 * the formula (2 ^ (2 * (16 - FSHIFT))) for (FSHIFT < 15).
297 *
298 * For the scheduler to maintain a 1:1 mapping of CPU `tick' to `%age',
299 * FSHIFT must be at least 11; this gives us a maximum load avg of ~1024.
300 */
301 #define FSHIFT 11 /* bits to right of fixed binary point */
302 #define FSCALE (1<<FSHIFT)
303
304 /*
305 * rfork() options.
306 *
307 * XXX currently, operations without RFPROC set are not supported.
308 */
309 #define RFNAMEG (1<<0) /* UNIMPL new plan9 `name space' */
310 #define RFENVG (1<<1) /* UNIMPL copy plan9 `env space' */
311 #define RFFDG (1<<2) /* copy fd table */
312 #define RFNOTEG (1<<3) /* UNIMPL create new plan9 `note group' */
313 #define RFPROC (1<<4) /* change child (else changes curproc) */
314 #define RFMEM (1<<5) /* share `address space' */
315 #define RFNOWAIT (1<<6) /* parent need not wait() on child */
316 #define RFCNAMEG (1<<10) /* UNIMPL zero plan9 `name space' */
317 #define RFCENVG (1<<11) /* UNIMPL zero plan9 `env space' */
318 #define RFCFDG (1<<12) /* zero fd table */
319 #endif // __ECOS
320
321 #ifdef __ECOS
322 // Function mappings
323
324 extern int cyg_tsleep(void *, int, char *, int);
325 extern void cyg_wakeup(void *);
326 #define tsleep(e,p,w,t) cyg_tsleep(e,0,w,t)
327 #define wakeup(e) cyg_wakeup(e)
328
329 extern cyg_uint32 cyg_splimp(void);
330 extern cyg_uint32 cyg_splnet(void);
331 extern cyg_uint32 cyg_splclock(void);
332 extern cyg_uint32 cyg_splsoftnet(void);
333 extern void cyg_splx(cyg_uint32);
334 #define splimp cyg_splimp
335 #define splnet cyg_splnet
336 #define splclock cyg_splclock
337 #define splsoftnet cyg_splsoftnet
338 #define splx cyg_splx
339
340 extern void cyg_panic(const char *msg, ...);
341 #define panic cyg_panic
342 #endif
343
344 #endif // __SYS_PARAM_H_