00001 /*- 00002 * Copyright (c) 1982, 1986, 1989, 1993 00003 * The Regents of the University of California. All rights reserved. 00004 * (c) UNIX System Laboratories, Inc. 00005 * All or some portions of this file are derived from material licensed 00006 * to the University of California by American Telephone and Telegraph 00007 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 00008 * the permission of UNIX System Laboratories, Inc. 00009 * 00010 * Redistribution and use in source and binary forms, with or without 00011 * modification, are permitted provided that the following conditions 00012 * are met: 00013 * 1. Redistributions of source code must retain the above copyright 00014 * notice, this list of conditions and the following disclaimer. 00015 * 2. Redistributions in binary form must reproduce the above copyright 00016 * notice, this list of conditions and the following disclaimer in the 00017 * documentation and/or other materials provided with the distribution. 00018 * 4. Neither the name of the University nor the names of its contributors 00019 * may be used to endorse or promote products derived from this software 00020 * without specific prior written permission. 00021 * 00022 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 00023 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00024 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00025 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 00026 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00027 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 00028 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00029 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00030 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 00031 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00032 * SUCH DAMAGE. 00033 * 00034 * @(#)param.h 8.3 (Berkeley) 4/4/95 00035 * $FreeBSD: src/sys/sys/param.h,v 1.244.2.2 2005/08/13 21:27:58 rwatson Exp $ 00036 */ 00037 00038 #ifndef _SYS_PARAM_H_ 00039 #define _SYS_PARAM_H_ 00040 00041 #include <sys/_null.h> 00042 00043 #define BSD 199506 /* System version (year & month). */ 00044 #define BSD4_3 1 00045 #define BSD4_4 1 00046 00047 /* 00048 * __FreeBSD_version numbers are documented in the Porter's Handbook. 00049 * If you bump the version for any reason, you should update the documentation 00050 * there. 00051 * Currently this lives here: 00052 * 00053 * doc/en_US.ISO8859-1/books/porters-handbook/book.sgml 00054 * 00055 * scheme is: <major><two digit minor>Rxx 00056 * 'R' is 0 if release branch or x.0-CURRENT before RELENG_*_0 00057 * is created, otherwise 1. 00058 */ 00059 #undef __FreeBSD_version 00060 #define __FreeBSD_version 600034 /* Master, propagated to newvers */ 00061 00062 #ifndef LOCORE 00063 #include <sys/types.h> 00064 #endif 00065 00066 /* 00067 * Machine-independent constants (some used in following include files). 00068 * Redefined constants are from POSIX 1003.1 limits file. 00069 * 00070 * MAXCOMLEN should be >= sizeof(ac_comm) (see <acct.h>) 00071 * MAXLOGNAME should be == UT_NAMESIZE+1 (see <utmp.h>) 00072 */ 00073 #include <sys/syslimits.h> 00074 00075 #define MAXCOMLEN 19 /* max command name remembered */ 00076 #define MAXINTERP 32 /* max interpreter file name length */ 00077 #define MAXLOGNAME 17 /* max login name length (incl. NUL) */ 00078 #define MAXUPRC CHILD_MAX /* max simultaneous processes */ 00079 #define NCARGS ARG_MAX /* max bytes for an exec function */ 00080 #define NGROUPS NGROUPS_MAX /* max number groups */ 00081 #define NOFILE OPEN_MAX /* max open files per process */ 00082 #define NOGROUP 65535 /* marker for empty group set member */ 00083 #define MAXHOSTNAMELEN 256 /* max hostname size */ 00084 #define SPECNAMELEN 63 /* max length of devicename */ 00085 00086 /* More types and definitions used throughout the kernel. */ 00087 #ifdef _KERNEL 00088 #if 0 00089 #if (defined(BURN_BRIDGES) || __FreeBSD_version >= 600000) \ 00090 && defined(OBSOLETE_IN_6) 00091 #error "This file contains obsolete code to be removed in 6.0-current" 00092 #endif 00093 #endif 00094 #include <sys/cdefs.h> 00095 #include <sys/errno.h> 00096 #include <sys/time.h> 00097 00098 #ifndef __SYMBIAN32__ 00099 #include <sys/priority.h> 00100 //__SYMBIAN32__ 00101 #endif 00102 00103 #define FALSE 0 00104 #define TRUE 1 00105 #endif 00106 00107 #ifndef _KERNEL 00108 /* Signals. */ 00109 #ifndef __SYMBIAN32__ 00110 #include <sys/signal.h> 00111 //__SYMBIAN32__ 00112 #endif 00113 #endif 00114 00115 /* Machine type dependent parameters. */ 00116 #include <machine/param.h> 00117 #ifndef _KERNEL 00118 #include <sys/limits.h> 00119 #endif 00120 00121 #ifndef _NO_NAMESPACE_POLLUTION 00122 00123 #ifndef DEV_BSHIFT 00124 #define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */ 00125 #endif 00126 #define DEV_BSIZE (1<<DEV_BSHIFT) 00127 00128 #ifndef BLKDEV_IOSIZE 00129 #define BLKDEV_IOSIZE PAGE_SIZE /* default block device I/O size */ 00130 #endif 00131 #ifndef DFLTPHYS 00132 #define DFLTPHYS (64 * 1024) /* default max raw I/O transfer size */ 00133 #endif 00134 #ifndef MAXPHYS 00135 #define MAXPHYS (128 * 1024) /* max raw I/O transfer size */ 00136 #endif 00137 #ifndef MAXDUMPPGS 00138 #define MAXDUMPPGS (DFLTPHYS/PAGE_SIZE) 00139 #endif 00140 00141 /* 00142 * Constants related to network buffer management. 00143 * MCLBYTES must be no larger than PAGE_SIZE. 00144 */ 00145 #ifndef MSIZE 00146 #define MSIZE 256 /* size of an mbuf */ 00147 #endif /* MSIZE */ 00148 00149 #ifndef MCLSHIFT 00150 #define MCLSHIFT 11 /* convert bytes to mbuf clusters */ 00151 #endif /* MCLSHIFT */ 00152 00153 #define MCLBYTES (1 << MCLSHIFT) /* size of an mbuf cluster */ 00154 00155 /* 00156 * Some macros for units conversion 00157 */ 00158 00159 /* clicks to bytes */ 00160 #ifndef ctob 00161 #define ctob(x) ((x)<<PAGE_SHIFT) 00162 #endif 00163 00164 /* bytes to clicks */ 00165 #ifndef btoc 00166 #define btoc(x) (((vm_offset_t)(x)+PAGE_MASK)>>PAGE_SHIFT) 00167 #endif 00168 00169 /* 00170 * btodb() is messy and perhaps slow because `bytes' may be an off_t. We 00171 * want to shift an unsigned type to avoid sign extension and we don't 00172 * want to widen `bytes' unnecessarily. Assume that the result fits in 00173 * a daddr_t. 00174 */ 00175 #ifndef btodb 00176 #define btodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \ 00177 (sizeof (bytes) > sizeof(long) \ 00178 ? (daddr_t)((unsigned long long)(bytes) >> DEV_BSHIFT) \ 00179 : (daddr_t)((unsigned long)(bytes) >> DEV_BSHIFT)) 00180 #endif 00181 00182 #ifndef dbtob 00183 #define dbtob(db) /* calculates (db * DEV_BSIZE) */ \ 00184 ((off_t)(db) << DEV_BSHIFT) 00185 #endif 00186 00187 #endif /* _NO_NAMESPACE_POLLUTION */ 00188 00189 #define PRIMASK 0x0ff 00190 #define PCATCH 0x100 /* OR'd with pri for tsleep to check signals */ 00191 #define PDROP 0x200 /* OR'd with pri to stop re-entry of interlock mutex */ 00192 00193 #define NZERO 0 /* default "nice" */ 00194 00195 #define NBBY 8 /* number of bits in a byte */ 00196 #define NBPW sizeof(int) /* number of bytes per word (integer) */ 00197 00198 #define CMASK 022 /* default file mask: S_IWGRP|S_IWOTH */ 00199 00200 #define NODEV (dev_t)(-1) /* non-existent device */ 00201 00202 #define CBLOCK 128 /* Clist block size, must be a power of 2. */ 00203 #define CBQSIZE (CBLOCK/NBBY) /* Quote bytes/cblock - can do better. */ 00204 /* Data chars/clist. */ 00205 #define CBSIZE (CBLOCK - sizeof(struct cblock *) - CBQSIZE) 00206 #define CROUND (CBLOCK - 1) /* Clist rounding. */ 00207 00208 /* 00209 * File system parameters and macros. 00210 * 00211 * MAXBSIZE - Filesystems are made out of blocks of at most MAXBSIZE bytes 00212 * per block. MAXBSIZE may be made larger without effecting 00213 * any existing filesystems as long as it does not exceed MAXPHYS, 00214 * and may be made smaller at the risk of not being able to use 00215 * filesystems which require a block size exceeding MAXBSIZE. 00216 * 00217 * BKVASIZE - Nominal buffer space per buffer, in bytes. BKVASIZE is the 00218 * minimum KVM memory reservation the kernel is willing to make. 00219 * Filesystems can of course request smaller chunks. Actual 00220 * backing memory uses a chunk size of a page (PAGE_SIZE). 00221 * 00222 * If you make BKVASIZE too small you risk seriously fragmenting 00223 * the buffer KVM map which may slow things down a bit. If you 00224 * make it too big the kernel will not be able to optimally use 00225 * the KVM memory reserved for the buffer cache and will wind 00226 * up with too-few buffers. 00227 * 00228 * The default is 16384, roughly 2x the block size used by a 00229 * normal UFS filesystem. 00230 */ 00231 #define MAXBSIZE 65536 /* must be power of 2 */ 00232 #define BKVASIZE 16384 /* must be power of 2 */ 00233 #define BKVAMASK (BKVASIZE-1) 00234 00235 /* 00236 * MAXPATHLEN defines the longest permissible path length after expanding 00237 * symbolic links. It is used to allocate a temporary buffer from the buffer 00238 * pool in which to do the name expansion, hence should be a power of two, 00239 * and must be less than or equal to MAXBSIZE. MAXSYMLINKS defines the 00240 * maximum number of symbolic links that may be expanded in a path name. 00241 * It should be set high enough to allow all legitimate uses, but halt 00242 * infinite loops reasonably quickly. 00243 */ 00244 #define MAXPATHLEN PATH_MAX 00245 #define MAXSYMLINKS 32 00246 00247 /* Bit map related macros. */ 00248 #define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY)) 00249 #define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY))) 00250 #define isset(a,i) ((a)[(i)/NBBY] & (1<<((i)%NBBY))) 00251 #define isclr(a,i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0) 00252 00253 /* Macros for counting and rounding. */ 00254 #ifndef howmany 00255 #define howmany(x, y) (((x)+((y)-1))/(y)) 00256 #endif 00257 #define rounddown(x, y) (((x)/(y))*(y)) 00258 #define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) /* to any y */ 00259 #define roundup2(x, y) (((x)+((y)-1))&(~((y)-1))) /* if y is powers of two */ 00260 #define powerof2(x) ((((x)-1)&(x))==0) 00261 00262 /* Macros for min/max. */ 00263 #define MIN(a,b) (((a)<(b))?(a):(b)) 00264 #define MAX(a,b) (((a)>(b))?(a):(b)) 00265 00266 #ifdef _KERNEL 00267 /* 00268 * Basic byte order function prototypes for non-inline functions. 00269 */ 00270 #ifndef _BYTEORDER_PROTOTYPED 00271 #define _BYTEORDER_PROTOTYPED 00272 __BEGIN_DECLS 00273 __uint32_t htonl(__uint32_t); 00274 __uint16_t htons(__uint16_t); 00275 __uint32_t ntohl(__uint32_t); 00276 __uint16_t ntohs(__uint16_t); 00277 __END_DECLS 00278 #endif 00279 00280 #ifndef lint 00281 #ifndef _BYTEORDER_FUNC_DEFINED 00282 #define _BYTEORDER_FUNC_DEFINED 00283 #define htonl(x) __htonl(x) 00284 #define htons(x) __htons(x) 00285 #define ntohl(x) __ntohl(x) 00286 #define ntohs(x) __ntohs(x) 00287 #endif /* !_BYTEORDER_FUNC_DEFINED */ 00288 #endif /* lint */ 00289 #endif /* _KERNEL */ 00290 00291 /* 00292 * Constants for setting the parameters of the kernel memory allocator. 00293 * 00294 * 2 ** MINBUCKET is the smallest unit of memory that will be 00295 * allocated. It must be at least large enough to hold a pointer. 00296 * 00297 * Units of memory less or equal to MAXALLOCSAVE will permanently 00298 * allocate physical memory; requests for these size pieces of 00299 * memory are quite fast. Allocations greater than MAXALLOCSAVE must 00300 * always allocate and free physical memory; requests for these 00301 * size allocations should be done infrequently as they will be slow. 00302 * 00303 * Constraints: PAGE_SIZE <= MAXALLOCSAVE <= 2 ** (MINBUCKET + 14), and 00304 * MAXALLOCSIZE must be a power of two. 00305 */ 00306 #if defined(__alpha__) || defined(__ia64__) || defined(__sparc64__) 00307 #define MINBUCKET 5 /* 5 => min allocation of 32 bytes */ 00308 #else 00309 #define MINBUCKET 4 /* 4 => min allocation of 16 bytes */ 00310 #endif 00311 #define MAXALLOCSAVE (2 * PAGE_SIZE) 00312 00313 /* 00314 * Scale factor for scaled integers used to count %cpu time and load avgs. 00315 * 00316 * The number of CPU `tick's that map to a unique `%age' can be expressed 00317 * by the formula (1 / (2 ^ (FSHIFT - 11))). The maximum load average that 00318 * can be calculated (assuming 32 bits) can be closely approximated using 00319 * the formula (2 ^ (2 * (16 - FSHIFT))) for (FSHIFT < 15). 00320 * 00321 * For the scheduler to maintain a 1:1 mapping of CPU `tick' to `%age', 00322 * FSHIFT must be at least 11; this gives us a maximum load avg of ~1024. 00323 */ 00324 #define FSHIFT 11 /* bits to right of fixed binary point */ 00325 #define FSCALE (1<<FSHIFT) 00326 00327 #define dbtoc(db) /* calculates devblks to pages */ \ 00328 ((db + (ctodb(1) - 1)) >> (PAGE_SHIFT - DEV_BSHIFT)) 00329 00330 #define ctodb(db) /* calculates pages to devblks */ \ 00331 ((db) << (PAGE_SHIFT - DEV_BSHIFT)) 00332 00333 #endif /* _SYS_PARAM_H_ */