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