1 /* 2 * Copyright (c) 1982, 1986, 1989 Regents of the University of California. 3 * All rights reserved. The Berkeley software License Agreement 4 * specifies the terms and conditions for redistribution. 5 * 6 * @(#)param.h 7.19 (Berkeley) 12/16/90 7 */ 8 9 #define BSD 199006 /* June, 1990 system version (year & month) */ 10 #define BSD4_3 1 11 #define BSD4_4 0.5 12 13 #include <sys/syslimits.h> 14 15 /* 16 * Machine-independent constants 17 */ 18 #define MAXUPRC CHILD_MAX /* max processes per user */ 19 #define NOFILE OPEN_MAX /* max open files per process */ 20 #define NCARGS ARG_MAX /* # characters in exec arglist */ 21 #define MAXINTERP 32 /* max interpreter file name length */ 22 #define NGROUPS NGROUPS_MAX /* max number groups */ 23 #define MAXHOSTNAMELEN 256 /* maximum hostname size */ 24 #define MAXCOMLEN 16 /* maximum command name remembered */ 25 /* MAXCOMLEN should be >= sizeof(ac_comm) (acct.h) */ 26 #define MAXLOGNAME 12 /* maximum login name length */ 27 /* MAXLOGNAME must be >= UT_NAMESIZE (<utmp.h>) */ 28 29 #define NOGROUP 65535 /* marker for empty group set member */ 30 31 /* 32 * Priorities 33 */ 34 #define PSWP 0 35 #define PVM 1 36 #define PINOD 10 37 #define PRIBIO 20 38 #define PVFS 22 39 #define PZERO 25 40 #define PSOCK 26 41 #define PWAIT 30 42 #define PLOCK 35 43 #define PPAUSE 40 44 #define PUSER 50 45 #define PRIMASK 0x0ff 46 #define PCATCH 0x100 /* or'd with pri for tsleep to check signals */ 47 48 #define NZERO 0 49 50 #ifndef LOCORE 51 #include <sys/types.h> 52 #endif 53 54 /* 55 * Signals 56 */ 57 #include <sys/signal.h> 58 59 /* 60 * Machine type dependent parameters. 61 */ 62 #include <machine/param.h> 63 #include <machine/endian.h> 64 #include <machine/limits.h> 65 66 #define NBPW sizeof(int) /* number of bytes in an integer */ 67 68 #ifndef NULL 69 #define NULL 0 70 #endif 71 #define CMASK 022 /* default mask for file creation */ 72 #define NODEV (dev_t)(-1) 73 74 /* 75 * Clustering of hardware pages on machines with ridiculously small 76 * page sizes is done here. The paging subsystem deals with units of 77 * CLSIZE pte's describing NBPG (from machine/machparam.h) pages each. 78 * 79 * NOTE: SSIZE, SINCR and UPAGES must be multiples of CLSIZE 80 */ 81 #define CLBYTES (CLSIZE*NBPG) 82 #define CLOFSET (CLSIZE*NBPG-1) /* for clusters, like PGOFSET */ 83 #define claligned(x) ((((int)(x))&CLOFSET)==0) 84 #define CLOFF CLOFSET 85 #define CLSHIFT (PGSHIFT+CLSIZELOG2) 86 87 #if CLSIZE==1 88 #define clbase(i) (i) 89 #define clrnd(i) (i) 90 #else 91 /* give the base virtual address (first of CLSIZE) */ 92 #define clbase(i) ((i) &~ (CLSIZE-1)) 93 /* round a number of clicks up to a whole cluster */ 94 #define clrnd(i) (((i) + (CLSIZE-1)) &~ (CLSIZE-1)) 95 #endif 96 97 /* CBLOCK is the size of a clist block, must be power of 2 */ 98 #define CBLOCK 64 99 #define CBQSIZE (CBLOCK/NBBY) /* quote bytes/cblock - can do better */ 100 #define CBSIZE (CBLOCK - sizeof(struct cblock *) - CBQSIZE) /* data chars/clist */ 101 #define CROUND (CBLOCK - 1) /* clist rounding */ 102 103 /* 104 * File system parameters and macros. 105 * 106 * The file system is made out of blocks of at most MAXBSIZE units, 107 * with smaller units (fragments) only in the last direct block. 108 * MAXBSIZE primarily determines the size of buffers in the buffer 109 * pool. It may be made larger without any effect on existing 110 * file systems; however making it smaller make make some file 111 * systems unmountable. 112 */ 113 #define MAXBSIZE 8192 114 #define MAXFRAG 8 115 116 /* 117 * MAXPATHLEN defines the longest permissable path length 118 * after expanding symbolic links. It is used to allocate 119 * a temporary buffer from the buffer pool in which to do the 120 * name expansion, hence should be a power of two, and must 121 * be less than or equal to MAXBSIZE. 122 * MAXSYMLINKS defines the maximum number of symbolic links 123 * that may be expanded in a path name. It should be set high 124 * enough to allow all legitimate uses, but halt infinite loops 125 * reasonably quickly. 126 */ 127 #define MAXPATHLEN PATH_MAX 128 #define MAXSYMLINKS 8 129 130 /* 131 * bit map related macros 132 */ 133 #define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY)) 134 #define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY))) 135 #define isset(a,i) ((a)[(i)/NBBY] & (1<<((i)%NBBY))) 136 #define isclr(a,i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0) 137 138 /* 139 * Macros for counting and rounding. 140 */ 141 #ifndef howmany 142 #define howmany(x, y) (((x)+((y)-1))/(y)) 143 #endif 144 #define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) 145 #define powerof2(x) ((((x)-1)&(x))==0) 146 147 /* 148 * Macros for fast min/max: 149 * with inline expansion, the "function" is faster. 150 */ 151 #ifdef KERNEL 152 #define MIN(a,b) min((a), (b)) 153 #define MAX(a,b) max((a), (b)) 154 #else 155 #define MIN(a,b) (((a)<(b))?(a):(b)) 156 #define MAX(a,b) (((a)>(b))?(a):(b)) 157 #endif 158 159 /* 160 * Constants for setting the parameters of the kernel memory allocator. 161 * 162 * 2 ** MINBUCKET is the smallest unit of memory that will be 163 * allocated. It must be at least large enough to hold a pointer. 164 * 165 * Units of memory less or equal to MAXALLOCSAVE will permanently 166 * allocate physical memory; requests for these size pieces of 167 * memory are quite fast. Allocations greater than MAXALLOCSAVE must 168 * always allocate and free physical memory; requests for these 169 * size allocations should be done infrequently as they will be slow. 170 * Constraints: CLBYTES <= MAXALLOCSAVE <= 2 ** (MINBUCKET + 14) 171 * and MAXALLOCSIZE must be a power of two. 172 */ 173 #define MINBUCKET 4 /* 4 => min allocation of 16 bytes */ 174 #define MAXALLOCSAVE (2 * CLBYTES) 175 176 /* 177 * Scale factor for scaled integers used to count %cpu time and load avgs. 178 * 179 * The number of CPU `tick's that map to a unique `%age' can be expressed 180 * by the formula (1 / (2 ^ (FSHIFT - 11))). The maximum load average that 181 * can be calculated (assuming 32 bits) can be closely approximated using 182 * the formula (2 ^ (2 * (16 - FSHIFT))) for (FSHIFT < 15). 183 * 184 * For the scheduler to maintain a 1:1 mapping of CPU `tick' to `%age', 185 * FSHIFT must be at least 11; this gives us a maximum load avg of ~1024. 186 */ 187 #define FSHIFT 11 /* bits to right of fixed binary point */ 188 #define FSCALE (1<<FSHIFT) 189