1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 /* 22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ 27 /* All Rights Reserved */ 28 29 /* 30 * University Copyright- Copyright (c) 1982, 1986, 1988 31 * The Regents of the University of California 32 * All Rights Reserved 33 * 34 * University Acknowledgment- Portions of this document are derived from 35 * software developed by the University of California, Berkeley, and its 36 * contributors. 37 */ 38 39 #ifndef _SYS_PARAM_H 40 #define _SYS_PARAM_H 41 42 #ifndef _ASM /* Avoid typedef headaches for assembly files */ 43 #include <sys/types.h> 44 #include <sys/isa_defs.h> 45 #endif /* _ASM */ 46 47 48 #ifdef __cplusplus 49 extern "C" { 50 #endif 51 52 /* 53 * Fundamental variables; don't change too often. 54 */ 55 56 /* 57 * _POSIX_VDISABLE has historically been defined in <sys/param.h> since 58 * an early merge with AT&T source. It has also historically been defined 59 * in <sys/termios.h>. The POSIX standard, IEEE Std. 1003.1-1988 initially 60 * required the existence of _POSIX_VDISABLE in <sys/termios.h>. 61 * Subsequent versions of the IEEE Standard as well as the X/Open 62 * specifications required that _POSIX_VDISABLE be defined in <unistd.h> 63 * while still allowing for it's existence in other headers. With the 64 * introduction of XPG6, _POSIX_VDISABLE can only be defined in <unistd.h>. 65 */ 66 #if !defined(_XPG6) || defined(__EXTENSIONS__) 67 #ifndef _POSIX_VDISABLE 68 #define _POSIX_VDISABLE 0 /* Disable special character functions */ 69 #endif 70 #endif /* !defined(_XPG6) || defined(__EXTENSIONS__) */ 71 72 #ifndef MAX_INPUT 73 #define MAX_INPUT 512 /* Maximum bytes stored in the input queue */ 74 #endif 75 76 #ifndef MAX_CANON 77 #define MAX_CANON 256 /* Maximum bytes for canonical processing */ 78 #endif 79 80 #define UID_NOBODY 60001 /* user ID no body */ 81 #define GID_NOBODY UID_NOBODY 82 #define GID_SYS 3 83 #define UID_DLADM 15 84 #define UID_NOACCESS 60002 /* user ID no access */ 85 86 #ifdef _KERNEL 87 #define MAX_TASKID 999999 88 #define MAX_MAXPID 999999 89 #define MAXEPHUID 0xfffffffcu /* max ephemeral user id */ 90 91 #define FAMOUS_PID_SCHED 0 92 #define FAMOUS_PID_INIT 1 93 #define FAMOUS_PID_PAGEOUT 2 94 #define FAMOUS_PID_FSFLUSH 3 95 #define FAMOUS_PIDS 4 96 #endif 97 98 #ifdef DEBUG 99 #define DEFAULT_MAXPID 999999 100 #define DEFAULT_JUMPPID 100000 101 #else 102 #define DEFAULT_MAXPID 30000 103 #define DEFAULT_JUMPPID 0 104 #endif 105 106 #define MAXUID 2147483647 /* max user id */ 107 108 #define MAXPROJID MAXUID /* max project id */ 109 #define MAXLINK 32767 /* max links */ 110 111 #define MINEPHUID 0x80000000u /* min ephemeral user id */ 112 113 #define NMOUNT 40 /* est. of # mountable fs for quota calc */ 114 115 #define CANBSIZ 256 /* max size of typewriter line */ 116 117 #define NOFILE 20 /* this define is here for */ 118 /* compatibility purposes only */ 119 /* and will be removed in a */ 120 /* later release */ 121 122 /* 123 * These define the maximum and minimum allowable values of the 124 * configurable parameter NGROUPS_MAX. 125 */ 126 #define NGROUPS_UMIN 0 127 #define NGROUPS_UMAX 1024 128 #define NGROUPS_OLDMAX 32 129 130 /* 131 * NGROUPS_MAX_DEFAULT: *MUST* match NGROUPS_MAX value in limits.h. 132 * Remember that the NFS protocol must rev. before this can be increased 133 */ 134 #define NGROUPS_MAX_DEFAULT 16 135 136 /* 137 * Default process priority. Keep it in sync with limits.h. 138 */ 139 #define NZERO 20 140 141 /* 142 * Fundamental constants of the implementation--cannot be changed easily. 143 */ 144 145 #define NBPW sizeof (int) /* number of bytes in an integer */ 146 147 #ifndef NULL 148 #if defined(_LP64) 149 #define NULL 0L 150 #else 151 #define NULL 0 152 #endif 153 #endif 154 155 #define CMASK 022 /* default mask for file creation */ 156 #define CDLIMIT (1L<<11) /* default max write address */ 157 #define NBPS 0x20000 /* Number of bytes per segment */ 158 #define NBPSCTR 512 /* Bytes per disk sector. */ 159 #define UBSIZE 512 /* unix block size. */ 160 #define SCTRSHFT 9 /* Shift for BPSECT. */ 161 162 #ifdef _LITTLE_ENDIAN 163 #define lobyte(X) (((unsigned char *)&(X))[0]) 164 #define hibyte(X) (((unsigned char *)&(X))[1]) 165 #define loword(X) (((ushort_t *)&(X))[0]) 166 #define hiword(X) (((ushort_t *)&(X))[1]) 167 #endif 168 #ifdef _BIG_ENDIAN 169 #define lobyte(X) (((unsigned char *)&(X))[1]) 170 #define hibyte(X) (((unsigned char *)&(X))[0]) 171 #define loword(X) (((ushort_t *)&(X))[1]) 172 #define hiword(X) (((ushort_t *)&(X))[0]) 173 #endif 174 175 /* REMOTE -- whether machine is primary, secondary, or regular */ 176 #define SYSNAME 9 /* # chars in system name */ 177 #define PREMOTE 39 178 179 /* 180 * MAXPATHLEN defines the longest permissible path length, 181 * including the terminating null, after expanding symbolic links. 182 * TYPICALMAXPATHLEN is used in a few places as an optimization 183 * with a local buffer on the stack to avoid kmem_alloc(). 184 * MAXSYMLINKS defines the maximum number of symbolic links 185 * that may be expanded in a path name. It should be set high 186 * enough to allow all legitimate uses, but halt infinite loops 187 * reasonably quickly. 188 * MAXNAMELEN is the length (including the terminating null) of 189 * the longest permissible file (component) name. 190 */ 191 #define MAXPATHLEN 1024 192 #define TYPICALMAXPATHLEN 64 193 #define MAXSYMLINKS 20 194 #define MAXNAMELEN 256 195 196 /* 197 * MAXLINKNAMELEN defines the longest possible permitted datalink name, 198 * including the terminating NUL. Note that this must not be larger 199 * than related networking constants such as LIFNAMSIZ. 200 */ 201 #define MAXLINKNAMELEN 32 202 203 #ifndef NADDR 204 #define NADDR 13 205 #endif 206 207 /* 208 * The following are defined to be the same as 209 * defined in /usr/include/limits.h. They are 210 * needed for pipe and FIFO compatibility. 211 */ 212 #ifndef PIPE_BUF /* max # bytes atomic in write to a pipe */ 213 #define PIPE_BUF 5120 214 #endif /* PIPE_BUF */ 215 216 #ifndef PIPE_MAX /* max # bytes written to a pipe in a write */ 217 #define PIPE_MAX 5120 218 #endif /* PIPE_MAX */ 219 220 #ifndef NBBY 221 #define NBBY 8 /* number of bits per byte */ 222 #endif 223 224 /* macros replacing interleaving functions */ 225 #define dkblock(bp) ((bp)->b_blkno) 226 #define dkunit(bp) (minor((bp)->b_dev) >> 3) 227 228 /* 229 * File system parameters and macros. 230 * 231 * The file system is made out of blocks of at most MAXBSIZE units, 232 * with smaller units (fragments) only in the last direct block. 233 * MAXBSIZE primarily determines the size of buffers in the buffer 234 * pool. It may be made larger without any effect on existing 235 * file systems; however making it smaller make make some file 236 * systems unmountable. 237 * 238 * Note that the blocked devices are assumed to have DEV_BSIZE 239 * "sectors" and that fragments must be some multiple of this size. 240 */ 241 #define MAXBSIZE 8192 242 #define DEV_BSIZE 512 243 #define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */ 244 #define MAXFRAG 8 245 #ifdef _SYSCALL32 246 #define MAXOFF32_T 0x7fffffff 247 #endif 248 #ifdef _LP64 249 #define MAXOFF_T 0x7fffffffffffffffl 250 #define MAXOFFSET_T 0x7fffffffffffffffl 251 #else 252 #define MAXOFF_T 0x7fffffffl 253 #ifdef _LONGLONG_TYPE 254 #define MAXOFFSET_T 0x7fffffffffffffffLL 255 #else 256 #define MAXOFFSET_T 0x7fffffff 257 #endif 258 #endif /* _LP64 */ 259 260 #define btodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \ 261 ((unsigned long)(bytes) >> DEV_BSHIFT) 262 #define dbtob(db) /* calculates (db * DEV_BSIZE) */ \ 263 ((unsigned long)(db) << DEV_BSHIFT) 264 265 /* 64 bit versions of btodb and dbtob */ 266 #define lbtodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \ 267 ((u_offset_t)(bytes) >> DEV_BSHIFT) 268 #define ldbtob(db) /* calculates (db * DEV_BSIZE) */ \ 269 ((u_offset_t)(db) << DEV_BSHIFT) 270 271 #ifndef _ASM /* Avoid typedef headaches for assembly files */ 272 #ifndef NODEV 273 #define NODEV (dev_t)(-1l) 274 #ifdef _SYSCALL32 275 #define NODEV32 (dev32_t)(-1) 276 #endif /* _SYSCALL32 */ 277 #endif /* NODEV */ 278 #endif /* _ASM */ 279 280 /* 281 * Size of arg list passed in by user. 282 */ 283 #define NCARGS32 0x100000 284 #define NCARGS64 0x200000 285 #ifdef _LP64 286 #define NCARGS NCARGS64 287 #else /* _LP64 */ 288 #define NCARGS NCARGS32 289 #endif /* _LP64 */ 290 291 /* 292 * Scale factor for scaled integers used to count 293 * %cpu time and load averages. 294 */ 295 #define FSHIFT 8 /* bits to right of fixed binary point */ 296 #define FSCALE (1<<FSHIFT) 297 298 /* 299 * Delay units are in microseconds. 300 * 301 * XXX These macros are not part of the DDI! 302 */ 303 #if defined(_KERNEL) && !defined(_ASM) 304 extern void drv_usecwait(clock_t); 305 #define DELAY(n) drv_usecwait(n) 306 #define CDELAY(c, n) \ 307 { \ 308 register int N = n; \ 309 while (--N > 0) { \ 310 if (c) \ 311 break; \ 312 drv_usecwait(1); \ 313 } \ 314 } 315 #endif /* defined(_KERNEL) && !defined(_ASM) */ 316 317 #ifdef __cplusplus 318 } 319 #endif 320 321 /* 322 * The following is to free utilities from machine dependencies within 323 * an architecture. Must be included after definition of DEV_BSIZE. 324 */ 325 326 #if (defined(_KERNEL) || defined(_KMEMUSER)) 327 328 #if defined(_MACHDEP) 329 #include <sys/machparam.h> 330 #endif 331 332 #ifdef __cplusplus 333 extern "C" { 334 #endif 335 336 #if defined(_KERNEL) && !defined(_ASM) 337 extern int cpu_decay_factor; 338 extern pid_t maxpid; 339 extern pid_t jump_pid; 340 341 extern uintptr_t _kernelbase; 342 extern uintptr_t _userlimit; 343 extern uintptr_t _userlimit32; 344 #endif /* defined(_KERNEL) && !defined(_ASM) */ 345 346 /* 347 * These three variables have been added within the #if defined(lint) 348 * below to ensure visibility to lint. This is a short term workaround 349 * to handle poor interaction between SS12 lint and these variables. 350 * CR 6742611 has been logged to address these issues. 351 */ 352 #if defined(lint) 353 extern int snooping; 354 extern uint_t snoop_interval; 355 extern const unsigned int _pageshift; 356 #endif /* lint */ 357 358 #if !defined(_MACHDEP) 359 360 /* 361 * Implementation architecture independent sections of the kernel use 362 * this section. 363 */ 364 #if defined(_KERNEL) && !defined(_ASM) 365 extern int hz; 366 extern int snooping; 367 extern uint_t snoop_interval; 368 extern const unsigned long _pagesize; 369 extern const unsigned int _pageshift; 370 extern const unsigned long _pageoffset; 371 extern const unsigned long long _pagemask; 372 extern const unsigned long _mmu_pagesize; 373 extern const unsigned int _mmu_pageshift; 374 extern const unsigned long _mmu_pageoffset; 375 extern const unsigned long _mmu_pagemask; 376 extern const uintptr_t _argsbase; 377 extern const unsigned long _defaultstksz; 378 extern const unsigned int _nbpg; 379 extern const int _ncpu; 380 extern const int _clsize; 381 #endif /* defined(_KERNEL) && !defined(_ASM) */ 382 383 #define PAGESIZE _pagesize 384 #define PAGESHIFT _pageshift 385 #define PAGEOFFSET _pageoffset 386 #define PAGEMASK _pagemask 387 #define MMU_PAGESIZE _mmu_pagesize 388 #define MMU_PAGESHIFT _mmu_pageshift 389 #define MMU_PAGEOFFSET _mmu_pageoffset 390 #define MMU_PAGEMASK _mmu_pagemask 391 392 #define KERNELBASE _kernelbase 393 #define USERLIMIT _userlimit 394 #define USERLIMIT32 _userlimit32 395 #define ARGSBASE _argsbase 396 #define DEFAULTSTKSZ _defaultstksz 397 #define NCPU _ncpu 398 399 #endif /* defined(_MACHDEP) */ 400 401 /* 402 * Some random macros for units conversion. 403 * 404 * These are machine independent but contain constants (*PAGESHIFT) which 405 * are only defined in the machine dependent file. 406 */ 407 408 /* 409 * MMU pages to bytes, and back (with and without rounding) 410 */ 411 #define mmu_ptob(x) ((x) << MMU_PAGESHIFT) 412 #define mmu_btop(x) (((x)) >> MMU_PAGESHIFT) 413 #define mmu_btopr(x) ((((x) + MMU_PAGEOFFSET) >> MMU_PAGESHIFT)) 414 415 /* 416 * 2 versions of pages to disk blocks 417 */ 418 #define mmu_ptod(x) ((x) << (MMU_PAGESHIFT - DEV_BSHIFT)) 419 #define ptod(x) ((x) << (PAGESHIFT - DEV_BSHIFT)) 420 421 /* 422 * pages to bytes, and back (with and without rounding) 423 * Large Files: The explicit cast of x to unsigned int is deliberately 424 * removed as part of large files work. We pass longlong values to 425 * theses macros. 426 * 427 * Cast the input to ptob() to be a page count. This enforces 64-bit 428 * math on 64-bit kernels. For 32-bit kernels, callers must explicitly 429 * cast the input to be a 64-bit type if values greater than 4GB/PAGESIZE 430 * are possible. 431 */ 432 433 #ifdef _LP64 434 #define ptob(x) (((pgcnt_t)(x)) << PAGESHIFT) 435 #else 436 #define ptob(x) ((x) << PAGESHIFT) 437 #endif /* _LP64 */ 438 #define btop(x) (((x) >> PAGESHIFT)) 439 #define btopr(x) ((((x) + PAGEOFFSET) >> PAGESHIFT)) 440 441 /* 442 * disk blocks to pages, rounded and truncated 443 */ 444 #define NDPP (PAGESIZE/DEV_BSIZE) /* # of disk blocks per page */ 445 #define dtop(DD) (((DD) + NDPP - 1) >> (PAGESHIFT - DEV_BSHIFT)) 446 #define dtopt(DD) ((DD) >> (PAGESHIFT - DEV_BSHIFT)) 447 448 /* 449 * kB to pages and back 450 */ 451 #define kbtop(x) ((x) >> (PAGESHIFT - 10)) 452 #define ptokb(x) ((x) << (PAGESHIFT - 10)) 453 454 /* 455 * POSIX.4 related configuration parameters 456 */ 457 #define _AIO_LISTIO_MAX (4096) 458 #define _AIO_MAX (-1) 459 #define _MQ_OPEN_MAX (-1) 460 #define _MQ_PRIO_MAX (32) 461 #define _SEM_NSEMS_MAX INT_MAX 462 #define _SEM_VALUE_MAX INT_MAX 463 464 #ifdef __cplusplus 465 } 466 #endif 467 468 #else /* (defined(_KERNEL) || defined(_KMEMUSER)) */ 469 470 /* 471 * The following are assorted machine dependent values which can be 472 * obtained in a machine independent manner through sysconf(2) or 473 * sysinfo(2). In order to guarantee that these provide the expected 474 * value at all times, the System Private interface (leading underscore) 475 * is used. 476 */ 477 478 #include <sys/unistd.h> 479 480 #ifdef __cplusplus 481 extern "C" { 482 #endif 483 484 #if !defined(_ASM) 485 extern long _sysconf(int); /* System Private interface to sysconf() */ 486 #endif /* !defined(_ASM) */ 487 488 #define HZ ((clock_t)_sysconf(_SC_CLK_TCK)) 489 #define TICK (1000000000/((clock_t)_sysconf(_SC_CLK_TCK))) 490 #define PAGESIZE (_sysconf(_SC_PAGESIZE)) 491 #define PAGEOFFSET (PAGESIZE - 1) 492 #define PAGEMASK (~PAGEOFFSET) 493 #define MAXPID ((pid_t)_sysconf(_SC_MAXPID)) 494 #define MAXEPHUID ((uid_t)_sysconf(_SC_EPHID_MAX)) 495 496 #ifdef __cplusplus 497 } 498 #endif 499 500 #endif /* (defined(_KERNEL) || defined(_KMEMUSER)) && defined(_MACHDEP) */ 501 502 #endif /* _SYS_PARAM_H */ 503