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