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