1 |
148 |
jeremybenn |
/*-
|
2 |
|
|
* Copyright (c) 1982, 1986, 1989, 1993
|
3 |
|
|
* The Regents of the University of California. All rights reserved.
|
4 |
|
|
* (c) UNIX System Laboratories, Inc.
|
5 |
|
|
* All or some portions of this file are derived from material licensed
|
6 |
|
|
* to the University of California by American Telephone and Telegraph
|
7 |
|
|
* Co. or Unix System Laboratories, Inc. and are reproduced herein with
|
8 |
|
|
* the permission of UNIX System Laboratories, Inc.
|
9 |
|
|
*
|
10 |
|
|
* Redistribution and use in source and binary forms, with or without
|
11 |
|
|
* modification, are permitted provided that the following conditions
|
12 |
|
|
* are met:
|
13 |
|
|
* 1. Redistributions of source code must retain the above copyright
|
14 |
|
|
* notice, this list of conditions and the following disclaimer.
|
15 |
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
16 |
|
|
* notice, this list of conditions and the following disclaimer in the
|
17 |
|
|
* documentation and/or other materials provided with the distribution.
|
18 |
|
|
* 3. All advertising materials mentioning features or use of this software
|
19 |
|
|
* must display the following acknowledgement:
|
20 |
|
|
* This product includes software developed by the University of
|
21 |
|
|
* California, Berkeley and its contributors.
|
22 |
|
|
* 4. Neither the name of the University nor the names of its contributors
|
23 |
|
|
* may be used to endorse or promote products derived from this software
|
24 |
|
|
* without specific prior written permission.
|
25 |
|
|
*
|
26 |
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
27 |
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
28 |
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
29 |
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
30 |
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
31 |
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
32 |
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
33 |
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
34 |
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
35 |
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
36 |
|
|
* SUCH DAMAGE.
|
37 |
|
|
*
|
38 |
|
|
* @(#)param.h 8.3 (Berkeley) 4/4/95
|
39 |
|
|
* $Id: param.h 148 2010-06-30 19:21:22Z jeremybennett $
|
40 |
|
|
*/
|
41 |
|
|
|
42 |
|
|
#ifndef _SYS_PARAM_H_
|
43 |
|
|
#define _SYS_PARAM_H_
|
44 |
|
|
|
45 |
|
|
/* from newlib's <sys/param.h> */
|
46 |
|
|
|
47 |
|
|
#include <sys/config.h>
|
48 |
|
|
#include <machine/endian.h>
|
49 |
|
|
|
50 |
|
|
# define HZ (60)
|
51 |
|
|
# define PATHSIZE (1024)
|
52 |
|
|
|
53 |
|
|
/* end of from newlib's <sys/param.h> */
|
54 |
|
|
|
55 |
|
|
#include <unistd.h>
|
56 |
|
|
|
57 |
|
|
#define BSD 199506 /* System version (year & month). */
|
58 |
|
|
#define BSD4_3 1
|
59 |
|
|
#define BSD4_4 1
|
60 |
|
|
|
61 |
|
|
#ifndef NULL
|
62 |
|
|
#define NULL 0
|
63 |
|
|
#endif
|
64 |
|
|
|
65 |
|
|
#ifndef LOCORE
|
66 |
|
|
#include <sys/types.h>
|
67 |
|
|
#endif
|
68 |
|
|
|
69 |
|
|
/*
|
70 |
|
|
* Machine-independent constants (some used in following include files).
|
71 |
|
|
* Redefined constants are from POSIX 1003.1 limits file.
|
72 |
|
|
*
|
73 |
|
|
* MAXCOMLEN should be >= sizeof(ac_comm) (see <acct.h>)
|
74 |
|
|
* MAXLOGNAME should be >= UT_NAMESIZE (see <utmp.h>)
|
75 |
|
|
*/
|
76 |
|
|
#include <sys/syslimits.h>
|
77 |
|
|
|
78 |
|
|
#define MAXCOMLEN 16 /* max command name remembered */
|
79 |
|
|
#define MAXINTERP 32 /* max interpreter file name length */
|
80 |
|
|
#define MAXLOGNAME 12 /* max login name length */
|
81 |
|
|
#define MAXUPRC CHILD_MAX /* max simultaneous processes */
|
82 |
|
|
#define NCARGS ARG_MAX /* max bytes for an exec function */
|
83 |
|
|
#define NGROUPS NGROUPS_MAX /* max number groups */
|
84 |
|
|
#define NOFILE OPEN_MAX /* max open files per process */
|
85 |
|
|
#define NOGROUP 65535 /* marker for empty group set member */
|
86 |
|
|
#define MAXHOSTNAMELEN 256 /* max hostname size */
|
87 |
|
|
|
88 |
|
|
/* More types and definitions used throughout the kernel. */
|
89 |
|
|
#ifdef KERNEL
|
90 |
|
|
#include <sys/cdefs.h>
|
91 |
|
|
#include <sys/errno.h>
|
92 |
|
|
#include <sys/time.h>
|
93 |
|
|
#include <sys/resource.h>
|
94 |
|
|
#include <sys/ucred.h>
|
95 |
|
|
#include <sys/uio.h>
|
96 |
|
|
|
97 |
|
|
#ifndef FALSE
|
98 |
|
|
#define FALSE 0
|
99 |
|
|
#endif
|
100 |
|
|
#ifndef TRUE
|
101 |
|
|
#define TRUE 1
|
102 |
|
|
#endif
|
103 |
|
|
#endif
|
104 |
|
|
|
105 |
|
|
/* Signals. */
|
106 |
|
|
#include <sys/signal.h>
|
107 |
|
|
|
108 |
|
|
/* Machine type dependent parameters. */
|
109 |
|
|
#include <machine/param.h>
|
110 |
|
|
#include <machine/limits.h>
|
111 |
|
|
|
112 |
|
|
/*
|
113 |
|
|
* Priorities. Note that with 32 run queues, differences less than 4 are
|
114 |
|
|
* insignificant.
|
115 |
|
|
*/
|
116 |
|
|
#define PSWP 0
|
117 |
|
|
#define PVM 4
|
118 |
|
|
#define PINOD 8
|
119 |
|
|
#define PRIBIO 16
|
120 |
|
|
#define PVFS 20
|
121 |
|
|
#define PZERO 22 /* No longer magic, shouldn't be here. XXX */
|
122 |
|
|
#define PSOCK 24
|
123 |
|
|
#define PWAIT 32
|
124 |
|
|
#define PLOCK 36
|
125 |
|
|
#define PPAUSE 40
|
126 |
|
|
#define PUSER 50
|
127 |
|
|
#define MAXPRI 127 /* Priorities range from 0 through MAXPRI. */
|
128 |
|
|
|
129 |
|
|
#define PRIMASK 0x0ff
|
130 |
|
|
#define PCATCH 0x100 /* OR'd with pri for tsleep to check signals */
|
131 |
|
|
|
132 |
|
|
#define NZERO 0 /* default "nice" */
|
133 |
|
|
|
134 |
|
|
#define NBPW sizeof(int) /* number of bytes per word (integer) */
|
135 |
|
|
|
136 |
|
|
#define CMASK 022 /* default file mask: S_IWGRP|S_IWOTH */
|
137 |
|
|
#define NODEV (dev_t)(-1) /* non-existent device */
|
138 |
|
|
|
139 |
|
|
/*
|
140 |
|
|
* Clustering of hardware pages on machines with ridiculously small
|
141 |
|
|
* page sizes is done here. The paging subsystem deals with units of
|
142 |
|
|
* CLSIZE pte's describing PAGE_SIZE (from machine/machparam.h) pages each.
|
143 |
|
|
*/
|
144 |
|
|
#if 0
|
145 |
|
|
#define CLBYTES (CLSIZE*PAGE_SIZE)
|
146 |
|
|
#endif
|
147 |
|
|
|
148 |
|
|
#define CBLOCK 128 /* Clist block size, must be a power of 2. */
|
149 |
|
|
#define CBQSIZE (CBLOCK/NBBY) /* Quote bytes/cblock - can do better. */
|
150 |
|
|
/* Data chars/clist. */
|
151 |
|
|
#define CBSIZE (CBLOCK - sizeof(struct cblock *) - CBQSIZE)
|
152 |
|
|
#define CROUND (CBLOCK - 1) /* Clist rounding. */
|
153 |
|
|
|
154 |
|
|
/*
|
155 |
|
|
* File system parameters and macros.
|
156 |
|
|
*
|
157 |
|
|
* The file system is made out of blocks of at most MAXBSIZE units, with
|
158 |
|
|
* smaller units (fragments) only in the last direct block. MAXBSIZE
|
159 |
|
|
* primarily determines the size of buffers in the buffer pool. It may be
|
160 |
|
|
* made larger without any effect on existing file systems; however making
|
161 |
|
|
* it smaller make make some file systems unmountable. Also, MAXBSIZE
|
162 |
|
|
* must be less than MAXPHYS!!! DFLTBSIZE is the average amount of
|
163 |
|
|
* memory allocated by vfs_bio per nbuf. BKVASIZE is the average amount
|
164 |
|
|
* of kernel virtual space allocated per nbuf. BKVASIZE should be >=
|
165 |
|
|
* DFLTBSIZE. If it is significantly bigger than DFLTBSIZE, then
|
166 |
|
|
* kva fragmentation causes fewer performance problems.
|
167 |
|
|
*/
|
168 |
|
|
#define MAXBSIZE 65536
|
169 |
|
|
#define BKVASIZE 8192
|
170 |
|
|
#define DFLTBSIZE 4096
|
171 |
|
|
#define MAXFRAG 8
|
172 |
|
|
|
173 |
|
|
/*
|
174 |
|
|
* MAXPATHLEN defines the longest permissible path length after expanding
|
175 |
|
|
* symbolic links. It is used to allocate a temporary buffer from the buffer
|
176 |
|
|
* pool in which to do the name expansion, hence should be a power of two,
|
177 |
|
|
* and must be less than or equal to MAXBSIZE. MAXSYMLINKS defines the
|
178 |
|
|
* maximum number of symbolic links that may be expanded in a path name.
|
179 |
|
|
* It should be set high enough to allow all legitimate uses, but halt
|
180 |
|
|
* infinite loops reasonably quickly.
|
181 |
|
|
*/
|
182 |
|
|
#if !defined(__rtems__)
|
183 |
|
|
#define MAXPATHLEN PATH_MAX
|
184 |
|
|
#endif
|
185 |
|
|
#define MAXSYMLINKS 32
|
186 |
|
|
|
187 |
|
|
/* Bit map related macros. */
|
188 |
|
|
#define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY))
|
189 |
|
|
#define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
|
190 |
|
|
#define isset(a,i) ((a)[(i)/NBBY] & (1<<((i)%NBBY)))
|
191 |
|
|
#define isclr(a,i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
|
192 |
|
|
|
193 |
|
|
/* Macros for counting and rounding. */
|
194 |
|
|
#ifndef howmany
|
195 |
|
|
#define howmany(x, y) (((x)+((y)-1))/(y))
|
196 |
|
|
#endif
|
197 |
|
|
#define rounddown(x, y) (((x)/(y))*(y))
|
198 |
|
|
#define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) /* to any y */
|
199 |
|
|
#define roundup2(x, y) (((x)+((y)-1))&(~((y)-1))) /* if y is powers of two */
|
200 |
|
|
#define powerof2(x) ((((x)-1)&(x))==0)
|
201 |
|
|
|
202 |
|
|
/* Macros for min/max. */
|
203 |
|
|
#ifndef KERNEL
|
204 |
|
|
#define MIN(a,b) (((a)<(b))?(a):(b))
|
205 |
|
|
#define MAX(a,b) (((a)>(b))?(a):(b))
|
206 |
|
|
#endif
|
207 |
|
|
|
208 |
|
|
/*
|
209 |
|
|
* Constants for setting the parameters of the kernel memory allocator.
|
210 |
|
|
*
|
211 |
|
|
* 2 ** MINBUCKET is the smallest unit of memory that will be
|
212 |
|
|
* allocated. It must be at least large enough to hold a pointer.
|
213 |
|
|
*
|
214 |
|
|
* Units of memory less or equal to MAXALLOCSAVE will permanently
|
215 |
|
|
* allocate physical memory; requests for these size pieces of
|
216 |
|
|
* memory are quite fast. Allocations greater than MAXALLOCSAVE must
|
217 |
|
|
* always allocate and free physical memory; requests for these
|
218 |
|
|
* size allocations should be done infrequently as they will be slow.
|
219 |
|
|
*
|
220 |
|
|
* Constraints: PAGE_SIZE <= MAXALLOCSAVE <= 2 ** (MINBUCKET + 14), and
|
221 |
|
|
* MAXALLOCSIZE must be a power of two.
|
222 |
|
|
*/
|
223 |
|
|
#define MINBUCKET 4 /* 4 => min allocation of 16 bytes */
|
224 |
|
|
#define MAXALLOCSAVE (2 * PAGE_SIZE)
|
225 |
|
|
|
226 |
|
|
/*
|
227 |
|
|
* Scale factor for scaled integers used to count %cpu time and load avgs.
|
228 |
|
|
*
|
229 |
|
|
* The number of CPU `tick's that map to a unique `%age' can be expressed
|
230 |
|
|
* by the formula (1 / (2 ^ (FSHIFT - 11))). The maximum load average that
|
231 |
|
|
* can be calculated (assuming 32 bits) can be closely approximated using
|
232 |
|
|
* the formula (2 ^ (2 * (16 - FSHIFT))) for (FSHIFT < 15).
|
233 |
|
|
*
|
234 |
|
|
* For the scheduler to maintain a 1:1 mapping of CPU `tick' to `%age',
|
235 |
|
|
* FSHIFT must be at least 11; this gives us a maximum load avg of ~1024.
|
236 |
|
|
*/
|
237 |
|
|
#define FSHIFT 11 /* bits to right of fixed binary point */
|
238 |
|
|
#define FSCALE (1<<FSHIFT)
|
239 |
|
|
|
240 |
|
|
#endif /* _SYS_PARAM_H_ */
|