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.18 (Berkeley) 12/05/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 KERNEL 51 #include <sys/types.h> 52 #else 53 #ifndef LOCORE 54 #include "types.h" 55 #endif 56 #endif 57 58 /* 59 * Signals 60 */ 61 #ifdef KERNEL 62 #include "signal.h" 63 #else 64 #include <sys/signal.h> 65 #endif 66 67 /* 68 * Machine type dependent parameters. 69 */ 70 #ifdef KERNEL 71 #include "machine/machparam.h" 72 #else 73 #include <machine/machparam.h> 74 #endif 75 76 #define NBPW sizeof(int) /* number of bytes in an integer */ 77 78 #ifndef NULL 79 #define NULL 0 80 #endif 81 #define CMASK 022 /* default mask for file creation */ 82 #define NODEV (dev_t)(-1) 83 84 /* 85 * Clustering of hardware pages on machines with ridiculously small 86 * page sizes is done here. The paging subsystem deals with units of 87 * CLSIZE pte's describing NBPG (from machine/machparam.h) pages each. 88 * 89 * NOTE: SSIZE, SINCR and UPAGES must be multiples of CLSIZE 90 */ 91 #define CLBYTES (CLSIZE*NBPG) 92 #define CLOFSET (CLSIZE*NBPG-1) /* for clusters, like PGOFSET */ 93 #define claligned(x) ((((int)(x))&CLOFSET)==0) 94 #define CLOFF CLOFSET 95 #define CLSHIFT (PGSHIFT+CLSIZELOG2) 96 97 #if CLSIZE==1 98 #define clbase(i) (i) 99 #define clrnd(i) (i) 100 #else 101 /* give the base virtual address (first of CLSIZE) */ 102 #define clbase(i) ((i) &~ (CLSIZE-1)) 103 /* round a number of clicks up to a whole cluster */ 104 #define clrnd(i) (((i) + (CLSIZE-1)) &~ (CLSIZE-1)) 105 #endif 106 107 /* CBLOCK is the size of a clist block, must be power of 2 */ 108 #define CBLOCK 64 109 #define CBQSIZE (CBLOCK/NBBY) /* quote bytes/cblock - can do better */ 110 #define CBSIZE (CBLOCK - sizeof(struct cblock *) - CBQSIZE) /* data chars/clist */ 111 #define CROUND (CBLOCK - 1) /* clist rounding */ 112 113 /* 114 * File system parameters and macros. 115 * 116 * The file system is made out of blocks of at most MAXBSIZE units, 117 * with smaller units (fragments) only in the last direct block. 118 * MAXBSIZE primarily determines the size of buffers in the buffer 119 * pool. It may be made larger without any effect on existing 120 * file systems; however making it smaller make make some file 121 * systems unmountable. 122 */ 123 #define MAXBSIZE 8192 124 #define MAXFRAG 8 125 126 /* 127 * MAXPATHLEN defines the longest permissable path length 128 * after expanding symbolic links. It is used to allocate 129 * a temporary buffer from the buffer pool in which to do the 130 * name expansion, hence should be a power of two, and must 131 * be less than or equal to MAXBSIZE. 132 * MAXSYMLINKS defines the maximum number of symbolic links 133 * that may be expanded in a path name. It should be set high 134 * enough to allow all legitimate uses, but halt infinite loops 135 * reasonably quickly. 136 */ 137 #define MAXPATHLEN PATH_MAX 138 #define MAXSYMLINKS 8 139 140 /* 141 * bit map related macros 142 */ 143 #define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY)) 144 #define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY))) 145 #define isset(a,i) ((a)[(i)/NBBY] & (1<<((i)%NBBY))) 146 #define isclr(a,i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0) 147 148 /* 149 * Macros for counting and rounding. 150 */ 151 #ifndef howmany 152 #define howmany(x, y) (((x)+((y)-1))/(y)) 153 #endif 154 #define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) 155 #define powerof2(x) ((((x)-1)&(x))==0) 156 157 /* 158 * Macros for fast min/max: 159 * with inline expansion, the "function" is faster. 160 */ 161 #ifdef KERNEL 162 #define MIN(a,b) min((a), (b)) 163 #define MAX(a,b) max((a), (b)) 164 #else 165 #define MIN(a,b) (((a)<(b))?(a):(b)) 166 #define MAX(a,b) (((a)>(b))?(a):(b)) 167 #endif 168 169 /* 170 * Constants for setting the parameters of the kernel memory allocator. 171 * 172 * 2 ** MINBUCKET is the smallest unit of memory that will be 173 * allocated. It must be at least large enough to hold a pointer. 174 * 175 * Units of memory less or equal to MAXALLOCSAVE will permanently 176 * allocate physical memory; requests for these size pieces of 177 * memory are quite fast. Allocations greater than MAXALLOCSAVE must 178 * always allocate and free physical memory; requests for these 179 * size allocations should be done infrequently as they will be slow. 180 * Constraints: CLBYTES <= MAXALLOCSAVE <= 2 ** (MINBUCKET + 14) 181 * and MAXALLOCSIZE must be a power of two. 182 */ 183 #define MINBUCKET 4 /* 4 => min allocation of 16 bytes */ 184 #define MAXALLOCSAVE (2 * CLBYTES) 185 186 /* 187 * Scale factor for scaled integers used to count %cpu time and load avgs. 188 * 189 * The number of CPU `tick's that map to a unique `%age' can be expressed 190 * by the formula (1 / (2 ^ (FSHIFT - 11))). The maximum load average that 191 * can be calculated (assuming 32 bits) can be closely approximated using 192 * the formula (2 ^ (2 * (16 - FSHIFT))) for (FSHIFT < 15). 193 * 194 * For the scheduler to maintain a 1:1 mapping of CPU `tick' to `%age', 195 * FSHIFT must be at least 11; this gives us a maximum load avg of ~1024. 196 */ 197 #define FSHIFT 11 /* bits to right of fixed binary point */ 198 #define FSCALE (1<<FSHIFT) 199