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