17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5ae115bc7Smrj * Common Development and Distribution License (the "License"). 6ae115bc7Smrj * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 21*c55d6659SMarcel Telka 227c478bd9Sstevel@tonic-gate /* 23*c55d6659SMarcel Telka * Copyright 2014 Nexenta Systems, Inc. All rights reserved. 24cb15d5d9SPeter Rival * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ 287c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate /* 317c478bd9Sstevel@tonic-gate * University Copyright- Copyright (c) 1982, 1986, 1988 327c478bd9Sstevel@tonic-gate * The Regents of the University of California 337c478bd9Sstevel@tonic-gate * All Rights Reserved 347c478bd9Sstevel@tonic-gate * 357c478bd9Sstevel@tonic-gate * University Acknowledgment- Portions of this document are derived from 367c478bd9Sstevel@tonic-gate * software developed by the University of California, Berkeley, and its 377c478bd9Sstevel@tonic-gate * contributors. 387c478bd9Sstevel@tonic-gate */ 397c478bd9Sstevel@tonic-gate 407c478bd9Sstevel@tonic-gate #ifndef _SYS_PARAM_H 417c478bd9Sstevel@tonic-gate #define _SYS_PARAM_H 427c478bd9Sstevel@tonic-gate 437c478bd9Sstevel@tonic-gate #ifndef _ASM /* Avoid typedef headaches for assembly files */ 447c478bd9Sstevel@tonic-gate #include <sys/types.h> 457c478bd9Sstevel@tonic-gate #include <sys/isa_defs.h> 467c478bd9Sstevel@tonic-gate #endif /* _ASM */ 477c478bd9Sstevel@tonic-gate 487c478bd9Sstevel@tonic-gate 497c478bd9Sstevel@tonic-gate #ifdef __cplusplus 507c478bd9Sstevel@tonic-gate extern "C" { 517c478bd9Sstevel@tonic-gate #endif 527c478bd9Sstevel@tonic-gate 537c478bd9Sstevel@tonic-gate /* 547c478bd9Sstevel@tonic-gate * Fundamental variables; don't change too often. 557c478bd9Sstevel@tonic-gate */ 567c478bd9Sstevel@tonic-gate 577c478bd9Sstevel@tonic-gate /* 587c478bd9Sstevel@tonic-gate * _POSIX_VDISABLE has historically been defined in <sys/param.h> since 597c478bd9Sstevel@tonic-gate * an early merge with AT&T source. It has also historically been defined 607c478bd9Sstevel@tonic-gate * in <sys/termios.h>. The POSIX standard, IEEE Std. 1003.1-1988 initially 617c478bd9Sstevel@tonic-gate * required the existence of _POSIX_VDISABLE in <sys/termios.h>. 627c478bd9Sstevel@tonic-gate * Subsequent versions of the IEEE Standard as well as the X/Open 637c478bd9Sstevel@tonic-gate * specifications required that _POSIX_VDISABLE be defined in <unistd.h> 647c478bd9Sstevel@tonic-gate * while still allowing for it's existence in other headers. With the 657c478bd9Sstevel@tonic-gate * introduction of XPG6, _POSIX_VDISABLE can only be defined in <unistd.h>. 667c478bd9Sstevel@tonic-gate */ 677c478bd9Sstevel@tonic-gate #if !defined(_XPG6) || defined(__EXTENSIONS__) 687c478bd9Sstevel@tonic-gate #ifndef _POSIX_VDISABLE 697c478bd9Sstevel@tonic-gate #define _POSIX_VDISABLE 0 /* Disable special character functions */ 707c478bd9Sstevel@tonic-gate #endif 717c478bd9Sstevel@tonic-gate #endif /* !defined(_XPG6) || defined(__EXTENSIONS__) */ 727c478bd9Sstevel@tonic-gate 737c478bd9Sstevel@tonic-gate #ifndef MAX_INPUT 747c478bd9Sstevel@tonic-gate #define MAX_INPUT 512 /* Maximum bytes stored in the input queue */ 757c478bd9Sstevel@tonic-gate #endif 767c478bd9Sstevel@tonic-gate 777c478bd9Sstevel@tonic-gate #ifndef MAX_CANON 787c478bd9Sstevel@tonic-gate #define MAX_CANON 256 /* Maximum bytes for canonical processing */ 797c478bd9Sstevel@tonic-gate #endif 807c478bd9Sstevel@tonic-gate 817c478bd9Sstevel@tonic-gate #define UID_NOBODY 60001 /* user ID no body */ 827c478bd9Sstevel@tonic-gate #define GID_NOBODY UID_NOBODY 83e913d9ecSLisa Week #define UID_UNKNOWN 96 84e913d9ecSLisa Week #define GID_UNKNOWN UID_UNKNOWN 85b9e076dcSyz147064 #define UID_DLADM 15 866ba597c5SAnurag S. Maskey #define UID_NETADM 16 876ba597c5SAnurag S. Maskey #define GID_NETADM 65 887c478bd9Sstevel@tonic-gate #define UID_NOACCESS 60002 /* user ID no access */ 897c478bd9Sstevel@tonic-gate 907c478bd9Sstevel@tonic-gate #ifdef _KERNEL 917c478bd9Sstevel@tonic-gate #define MAX_TASKID 999999 927c478bd9Sstevel@tonic-gate #define MAX_MAXPID 999999 93f48205beScasper #define MAXEPHUID 0xfffffffcu /* max ephemeral user id */ 9435a5a358SJonathan Adams 9535a5a358SJonathan Adams #define FAMOUS_PID_SCHED 0 9635a5a358SJonathan Adams #define FAMOUS_PID_INIT 1 9735a5a358SJonathan Adams #define FAMOUS_PID_PAGEOUT 2 9835a5a358SJonathan Adams #define FAMOUS_PID_FSFLUSH 3 9935a5a358SJonathan Adams #define FAMOUS_PIDS 4 1007c478bd9Sstevel@tonic-gate #endif 1017c478bd9Sstevel@tonic-gate 1027c478bd9Sstevel@tonic-gate #ifdef DEBUG 1037c478bd9Sstevel@tonic-gate #define DEFAULT_MAXPID 999999 1047c478bd9Sstevel@tonic-gate #define DEFAULT_JUMPPID 100000 1057c478bd9Sstevel@tonic-gate #else 1067c478bd9Sstevel@tonic-gate #define DEFAULT_MAXPID 30000 1077c478bd9Sstevel@tonic-gate #define DEFAULT_JUMPPID 0 1087c478bd9Sstevel@tonic-gate #endif 1097c478bd9Sstevel@tonic-gate 1107c478bd9Sstevel@tonic-gate #define MAXUID 2147483647 /* max user id */ 111f48205beScasper 1127c478bd9Sstevel@tonic-gate #define MAXPROJID MAXUID /* max project id */ 1137c478bd9Sstevel@tonic-gate #define MAXLINK 32767 /* max links */ 1147c478bd9Sstevel@tonic-gate 115f48205beScasper #define MINEPHUID 0x80000000u /* min ephemeral user id */ 116f48205beScasper 1177c478bd9Sstevel@tonic-gate #define NMOUNT 40 /* est. of # mountable fs for quota calc */ 1187c478bd9Sstevel@tonic-gate 1197c478bd9Sstevel@tonic-gate #define CANBSIZ 256 /* max size of typewriter line */ 1207c478bd9Sstevel@tonic-gate 1217c478bd9Sstevel@tonic-gate #define NOFILE 20 /* this define is here for */ 1227c478bd9Sstevel@tonic-gate /* compatibility purposes only */ 1237c478bd9Sstevel@tonic-gate /* and will be removed in a */ 1247c478bd9Sstevel@tonic-gate /* later release */ 1257c478bd9Sstevel@tonic-gate 1267c478bd9Sstevel@tonic-gate /* 1277c478bd9Sstevel@tonic-gate * These define the maximum and minimum allowable values of the 1287c478bd9Sstevel@tonic-gate * configurable parameter NGROUPS_MAX. 1297c478bd9Sstevel@tonic-gate */ 1307c478bd9Sstevel@tonic-gate #define NGROUPS_UMIN 0 13167dbe2beSCasper H.S. Dik #define NGROUPS_UMAX 1024 13267dbe2beSCasper H.S. Dik #define NGROUPS_OLDMAX 32 1337c478bd9Sstevel@tonic-gate 1347c478bd9Sstevel@tonic-gate /* 1357c478bd9Sstevel@tonic-gate * NGROUPS_MAX_DEFAULT: *MUST* match NGROUPS_MAX value in limits.h. 1367c478bd9Sstevel@tonic-gate */ 1377c478bd9Sstevel@tonic-gate #define NGROUPS_MAX_DEFAULT 16 1387c478bd9Sstevel@tonic-gate 1397c478bd9Sstevel@tonic-gate /* 1407c478bd9Sstevel@tonic-gate * Default process priority. Keep it in sync with limits.h. 1417c478bd9Sstevel@tonic-gate */ 1427c478bd9Sstevel@tonic-gate #define NZERO 20 1437c478bd9Sstevel@tonic-gate 1447c478bd9Sstevel@tonic-gate /* 1457c478bd9Sstevel@tonic-gate * Fundamental constants of the implementation--cannot be changed easily. 1467c478bd9Sstevel@tonic-gate */ 1477c478bd9Sstevel@tonic-gate 1487c478bd9Sstevel@tonic-gate #define NBPW sizeof (int) /* number of bytes in an integer */ 1497c478bd9Sstevel@tonic-gate 1507c478bd9Sstevel@tonic-gate #ifndef NULL 1517c478bd9Sstevel@tonic-gate #if defined(_LP64) 1527c478bd9Sstevel@tonic-gate #define NULL 0L 1537c478bd9Sstevel@tonic-gate #else 1547c478bd9Sstevel@tonic-gate #define NULL 0 1557c478bd9Sstevel@tonic-gate #endif 1567c478bd9Sstevel@tonic-gate #endif 1577c478bd9Sstevel@tonic-gate 1587c478bd9Sstevel@tonic-gate #define CMASK 022 /* default mask for file creation */ 1597c478bd9Sstevel@tonic-gate #define CDLIMIT (1L<<11) /* default max write address */ 1607c478bd9Sstevel@tonic-gate #define NBPS 0x20000 /* Number of bytes per segment */ 1617c478bd9Sstevel@tonic-gate #define NBPSCTR 512 /* Bytes per disk sector. */ 1627c478bd9Sstevel@tonic-gate #define UBSIZE 512 /* unix block size. */ 1637c478bd9Sstevel@tonic-gate #define SCTRSHFT 9 /* Shift for BPSECT. */ 1647c478bd9Sstevel@tonic-gate 1657c478bd9Sstevel@tonic-gate #ifdef _LITTLE_ENDIAN 1667c478bd9Sstevel@tonic-gate #define lobyte(X) (((unsigned char *)&(X))[0]) 1677c478bd9Sstevel@tonic-gate #define hibyte(X) (((unsigned char *)&(X))[1]) 1687c478bd9Sstevel@tonic-gate #define loword(X) (((ushort_t *)&(X))[0]) 1697c478bd9Sstevel@tonic-gate #define hiword(X) (((ushort_t *)&(X))[1]) 1707c478bd9Sstevel@tonic-gate #endif 1717c478bd9Sstevel@tonic-gate #ifdef _BIG_ENDIAN 1727c478bd9Sstevel@tonic-gate #define lobyte(X) (((unsigned char *)&(X))[1]) 1737c478bd9Sstevel@tonic-gate #define hibyte(X) (((unsigned char *)&(X))[0]) 1747c478bd9Sstevel@tonic-gate #define loword(X) (((ushort_t *)&(X))[1]) 1757c478bd9Sstevel@tonic-gate #define hiword(X) (((ushort_t *)&(X))[0]) 1767c478bd9Sstevel@tonic-gate #endif 1777c478bd9Sstevel@tonic-gate 1787c478bd9Sstevel@tonic-gate /* REMOTE -- whether machine is primary, secondary, or regular */ 1797c478bd9Sstevel@tonic-gate #define SYSNAME 9 /* # chars in system name */ 1807c478bd9Sstevel@tonic-gate #define PREMOTE 39 1817c478bd9Sstevel@tonic-gate 1827c478bd9Sstevel@tonic-gate /* 1837c478bd9Sstevel@tonic-gate * MAXPATHLEN defines the longest permissible path length, 1847c478bd9Sstevel@tonic-gate * including the terminating null, after expanding symbolic links. 1857c478bd9Sstevel@tonic-gate * TYPICALMAXPATHLEN is used in a few places as an optimization 1867c478bd9Sstevel@tonic-gate * with a local buffer on the stack to avoid kmem_alloc(). 1877c478bd9Sstevel@tonic-gate * MAXSYMLINKS defines the maximum number of symbolic links 1887c478bd9Sstevel@tonic-gate * that may be expanded in a path name. It should be set high 1897c478bd9Sstevel@tonic-gate * enough to allow all legitimate uses, but halt infinite loops 1907c478bd9Sstevel@tonic-gate * reasonably quickly. 1917c478bd9Sstevel@tonic-gate * MAXNAMELEN is the length (including the terminating null) of 1927c478bd9Sstevel@tonic-gate * the longest permissible file (component) name. 1937c478bd9Sstevel@tonic-gate */ 1947c478bd9Sstevel@tonic-gate #define MAXPATHLEN 1024 1957c478bd9Sstevel@tonic-gate #define TYPICALMAXPATHLEN 64 1967c478bd9Sstevel@tonic-gate #define MAXSYMLINKS 20 1977c478bd9Sstevel@tonic-gate #define MAXNAMELEN 256 1987c478bd9Sstevel@tonic-gate 199d62bc4baSyz147064 /* 200d62bc4baSyz147064 * MAXLINKNAMELEN defines the longest possible permitted datalink name, 201d62bc4baSyz147064 * including the terminating NUL. Note that this must not be larger 202d62bc4baSyz147064 * than related networking constants such as LIFNAMSIZ. 203d62bc4baSyz147064 */ 204d62bc4baSyz147064 #define MAXLINKNAMELEN 32 205d62bc4baSyz147064 2067c478bd9Sstevel@tonic-gate #ifndef NADDR 2077c478bd9Sstevel@tonic-gate #define NADDR 13 2087c478bd9Sstevel@tonic-gate #endif 2097c478bd9Sstevel@tonic-gate 2107c478bd9Sstevel@tonic-gate /* 2117c478bd9Sstevel@tonic-gate * The following are defined to be the same as 2127c478bd9Sstevel@tonic-gate * defined in /usr/include/limits.h. They are 2137c478bd9Sstevel@tonic-gate * needed for pipe and FIFO compatibility. 2147c478bd9Sstevel@tonic-gate */ 2157c478bd9Sstevel@tonic-gate #ifndef PIPE_BUF /* max # bytes atomic in write to a pipe */ 2167c478bd9Sstevel@tonic-gate #define PIPE_BUF 5120 2177c478bd9Sstevel@tonic-gate #endif /* PIPE_BUF */ 2187c478bd9Sstevel@tonic-gate 2197c478bd9Sstevel@tonic-gate #ifndef PIPE_MAX /* max # bytes written to a pipe in a write */ 2207c478bd9Sstevel@tonic-gate #define PIPE_MAX 5120 2217c478bd9Sstevel@tonic-gate #endif /* PIPE_MAX */ 2227c478bd9Sstevel@tonic-gate 2237c478bd9Sstevel@tonic-gate #ifndef NBBY 2247c478bd9Sstevel@tonic-gate #define NBBY 8 /* number of bits per byte */ 2257c478bd9Sstevel@tonic-gate #endif 2267c478bd9Sstevel@tonic-gate 2277c478bd9Sstevel@tonic-gate /* macros replacing interleaving functions */ 2287c478bd9Sstevel@tonic-gate #define dkblock(bp) ((bp)->b_blkno) 2297c478bd9Sstevel@tonic-gate #define dkunit(bp) (minor((bp)->b_dev) >> 3) 2307c478bd9Sstevel@tonic-gate 2317c478bd9Sstevel@tonic-gate /* 2327c478bd9Sstevel@tonic-gate * File system parameters and macros. 2337c478bd9Sstevel@tonic-gate * 2347c478bd9Sstevel@tonic-gate * The file system is made out of blocks of at most MAXBSIZE units, 2357c478bd9Sstevel@tonic-gate * with smaller units (fragments) only in the last direct block. 2367c478bd9Sstevel@tonic-gate * MAXBSIZE primarily determines the size of buffers in the buffer 2377c478bd9Sstevel@tonic-gate * pool. It may be made larger without any effect on existing 2387c478bd9Sstevel@tonic-gate * file systems; however making it smaller make make some file 2397c478bd9Sstevel@tonic-gate * systems unmountable. 2407c478bd9Sstevel@tonic-gate * 2417c478bd9Sstevel@tonic-gate * Note that the blocked devices are assumed to have DEV_BSIZE 2427c478bd9Sstevel@tonic-gate * "sectors" and that fragments must be some multiple of this size. 2437c478bd9Sstevel@tonic-gate */ 2447c478bd9Sstevel@tonic-gate #define MAXBSIZE 8192 2457c478bd9Sstevel@tonic-gate #define DEV_BSIZE 512 2467c478bd9Sstevel@tonic-gate #define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */ 2477c478bd9Sstevel@tonic-gate #define MAXFRAG 8 2487c478bd9Sstevel@tonic-gate #ifdef _SYSCALL32 2497c478bd9Sstevel@tonic-gate #define MAXOFF32_T 0x7fffffff 2507c478bd9Sstevel@tonic-gate #endif 2517c478bd9Sstevel@tonic-gate #ifdef _LP64 2527c478bd9Sstevel@tonic-gate #define MAXOFF_T 0x7fffffffffffffffl 2537c478bd9Sstevel@tonic-gate #define MAXOFFSET_T 0x7fffffffffffffffl 2547c478bd9Sstevel@tonic-gate #else 2557c478bd9Sstevel@tonic-gate #define MAXOFF_T 0x7fffffffl 2567c478bd9Sstevel@tonic-gate #ifdef _LONGLONG_TYPE 2577c478bd9Sstevel@tonic-gate #define MAXOFFSET_T 0x7fffffffffffffffLL 2587c478bd9Sstevel@tonic-gate #else 2597c478bd9Sstevel@tonic-gate #define MAXOFFSET_T 0x7fffffff 2607c478bd9Sstevel@tonic-gate #endif 2617c478bd9Sstevel@tonic-gate #endif /* _LP64 */ 2627c478bd9Sstevel@tonic-gate 2637c478bd9Sstevel@tonic-gate #define btodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \ 2647c478bd9Sstevel@tonic-gate ((unsigned long)(bytes) >> DEV_BSHIFT) 2657c478bd9Sstevel@tonic-gate #define dbtob(db) /* calculates (db * DEV_BSIZE) */ \ 2667c478bd9Sstevel@tonic-gate ((unsigned long)(db) << DEV_BSHIFT) 2677c478bd9Sstevel@tonic-gate 2687c478bd9Sstevel@tonic-gate /* 64 bit versions of btodb and dbtob */ 2697c478bd9Sstevel@tonic-gate #define lbtodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \ 2707c478bd9Sstevel@tonic-gate ((u_offset_t)(bytes) >> DEV_BSHIFT) 2717c478bd9Sstevel@tonic-gate #define ldbtob(db) /* calculates (db * DEV_BSIZE) */ \ 2727c478bd9Sstevel@tonic-gate ((u_offset_t)(db) << DEV_BSHIFT) 2737c478bd9Sstevel@tonic-gate 2747c478bd9Sstevel@tonic-gate #ifndef _ASM /* Avoid typedef headaches for assembly files */ 2757c478bd9Sstevel@tonic-gate #ifndef NODEV 2767c478bd9Sstevel@tonic-gate #define NODEV (dev_t)(-1l) 2777c478bd9Sstevel@tonic-gate #ifdef _SYSCALL32 2787c478bd9Sstevel@tonic-gate #define NODEV32 (dev32_t)(-1) 2797c478bd9Sstevel@tonic-gate #endif /* _SYSCALL32 */ 2807c478bd9Sstevel@tonic-gate #endif /* NODEV */ 2817c478bd9Sstevel@tonic-gate #endif /* _ASM */ 2827c478bd9Sstevel@tonic-gate 2837c478bd9Sstevel@tonic-gate /* 2847c478bd9Sstevel@tonic-gate * Size of arg list passed in by user. 2857c478bd9Sstevel@tonic-gate */ 2867c478bd9Sstevel@tonic-gate #define NCARGS32 0x100000 2877c478bd9Sstevel@tonic-gate #define NCARGS64 0x200000 2887c478bd9Sstevel@tonic-gate #ifdef _LP64 2897c478bd9Sstevel@tonic-gate #define NCARGS NCARGS64 2907c478bd9Sstevel@tonic-gate #else /* _LP64 */ 2917c478bd9Sstevel@tonic-gate #define NCARGS NCARGS32 2927c478bd9Sstevel@tonic-gate #endif /* _LP64 */ 2937c478bd9Sstevel@tonic-gate 2947c478bd9Sstevel@tonic-gate /* 2957c478bd9Sstevel@tonic-gate * Scale factor for scaled integers used to count 2967c478bd9Sstevel@tonic-gate * %cpu time and load averages. 2977c478bd9Sstevel@tonic-gate */ 2987c478bd9Sstevel@tonic-gate #define FSHIFT 8 /* bits to right of fixed binary point */ 2997c478bd9Sstevel@tonic-gate #define FSCALE (1<<FSHIFT) 3007c478bd9Sstevel@tonic-gate 3017c478bd9Sstevel@tonic-gate /* 3027c478bd9Sstevel@tonic-gate * Delay units are in microseconds. 3037c478bd9Sstevel@tonic-gate * 3047c478bd9Sstevel@tonic-gate * XXX These macros are not part of the DDI! 3057c478bd9Sstevel@tonic-gate */ 3067c478bd9Sstevel@tonic-gate #if defined(_KERNEL) && !defined(_ASM) 3077c478bd9Sstevel@tonic-gate extern void drv_usecwait(clock_t); 3087c478bd9Sstevel@tonic-gate #define DELAY(n) drv_usecwait(n) 3097c478bd9Sstevel@tonic-gate #define CDELAY(c, n) \ 3107c478bd9Sstevel@tonic-gate { \ 3117c478bd9Sstevel@tonic-gate register int N = n; \ 3127c478bd9Sstevel@tonic-gate while (--N > 0) { \ 3137c478bd9Sstevel@tonic-gate if (c) \ 3147c478bd9Sstevel@tonic-gate break; \ 3157c478bd9Sstevel@tonic-gate drv_usecwait(1); \ 3167c478bd9Sstevel@tonic-gate } \ 3177c478bd9Sstevel@tonic-gate } 3187c478bd9Sstevel@tonic-gate #endif /* defined(_KERNEL) && !defined(_ASM) */ 3197c478bd9Sstevel@tonic-gate 3207c478bd9Sstevel@tonic-gate #ifdef __cplusplus 3217c478bd9Sstevel@tonic-gate } 3227c478bd9Sstevel@tonic-gate #endif 3237c478bd9Sstevel@tonic-gate 3247c478bd9Sstevel@tonic-gate /* 3257c478bd9Sstevel@tonic-gate * The following is to free utilities from machine dependencies within 3267c478bd9Sstevel@tonic-gate * an architecture. Must be included after definition of DEV_BSIZE. 3277c478bd9Sstevel@tonic-gate */ 3287c478bd9Sstevel@tonic-gate 3297c478bd9Sstevel@tonic-gate #if (defined(_KERNEL) || defined(_KMEMUSER)) 3307c478bd9Sstevel@tonic-gate 3317c478bd9Sstevel@tonic-gate #if defined(_MACHDEP) 3327c478bd9Sstevel@tonic-gate #include <sys/machparam.h> 3337c478bd9Sstevel@tonic-gate #endif 3347c478bd9Sstevel@tonic-gate 3357c478bd9Sstevel@tonic-gate #ifdef __cplusplus 3367c478bd9Sstevel@tonic-gate extern "C" { 3377c478bd9Sstevel@tonic-gate #endif 3387c478bd9Sstevel@tonic-gate 3397c478bd9Sstevel@tonic-gate #if defined(_KERNEL) && !defined(_ASM) 3407c478bd9Sstevel@tonic-gate extern int cpu_decay_factor; 3417c478bd9Sstevel@tonic-gate extern pid_t maxpid; 3427c478bd9Sstevel@tonic-gate extern pid_t jump_pid; 3437c478bd9Sstevel@tonic-gate 3447c478bd9Sstevel@tonic-gate extern uintptr_t _kernelbase; 3457c478bd9Sstevel@tonic-gate extern uintptr_t _userlimit; 3467c478bd9Sstevel@tonic-gate extern uintptr_t _userlimit32; 3477c478bd9Sstevel@tonic-gate #endif /* defined(_KERNEL) && !defined(_ASM) */ 3487c478bd9Sstevel@tonic-gate 3498793b36bSNick Todd /* 3508793b36bSNick Todd * These three variables have been added within the #if defined(lint) 3518793b36bSNick Todd * below to ensure visibility to lint. This is a short term workaround 3528793b36bSNick Todd * to handle poor interaction between SS12 lint and these variables. 3538793b36bSNick Todd * CR 6742611 has been logged to address these issues. 3548793b36bSNick Todd */ 3558793b36bSNick Todd #if defined(lint) 3568793b36bSNick Todd extern int snooping; 3578793b36bSNick Todd extern uint_t snoop_interval; 3588793b36bSNick Todd extern const unsigned int _pageshift; 3598793b36bSNick Todd #endif /* lint */ 3607c478bd9Sstevel@tonic-gate 3617c478bd9Sstevel@tonic-gate #if !defined(_MACHDEP) 3627c478bd9Sstevel@tonic-gate 3637c478bd9Sstevel@tonic-gate /* 3647c478bd9Sstevel@tonic-gate * Implementation architecture independent sections of the kernel use 3657c478bd9Sstevel@tonic-gate * this section. 3667c478bd9Sstevel@tonic-gate */ 3677c478bd9Sstevel@tonic-gate #if defined(_KERNEL) && !defined(_ASM) 3687c478bd9Sstevel@tonic-gate extern int hz; 3697c478bd9Sstevel@tonic-gate extern int snooping; 3707c478bd9Sstevel@tonic-gate extern uint_t snoop_interval; 3717c478bd9Sstevel@tonic-gate extern const unsigned long _pagesize; 3727c478bd9Sstevel@tonic-gate extern const unsigned int _pageshift; 3737c478bd9Sstevel@tonic-gate extern const unsigned long _pageoffset; 3747c478bd9Sstevel@tonic-gate extern const unsigned long long _pagemask; 3757c478bd9Sstevel@tonic-gate extern const unsigned long _mmu_pagesize; 3767c478bd9Sstevel@tonic-gate extern const unsigned int _mmu_pageshift; 3777c478bd9Sstevel@tonic-gate extern const unsigned long _mmu_pageoffset; 3787c478bd9Sstevel@tonic-gate extern const unsigned long _mmu_pagemask; 3797c478bd9Sstevel@tonic-gate extern const uintptr_t _argsbase; 3807c478bd9Sstevel@tonic-gate extern const unsigned long _defaultstksz; 3817c478bd9Sstevel@tonic-gate extern const unsigned int _nbpg; 3827c478bd9Sstevel@tonic-gate extern const int _ncpu; 38323d9e5acSMichael Corcoran extern const int _ncpu_log2; 384cb15d5d9SPeter Rival extern const int _ncpu_p2; 3857c478bd9Sstevel@tonic-gate extern const int _clsize; 3867c478bd9Sstevel@tonic-gate #endif /* defined(_KERNEL) && !defined(_ASM) */ 3877c478bd9Sstevel@tonic-gate 38842a4b3dcSJonathan Adams /* Any additions to these #defines must be reflected in mdb_param.h+mdb_ks.c */ 3897c478bd9Sstevel@tonic-gate #define PAGESIZE _pagesize 3907c478bd9Sstevel@tonic-gate #define PAGESHIFT _pageshift 3917c478bd9Sstevel@tonic-gate #define PAGEOFFSET _pageoffset 3927c478bd9Sstevel@tonic-gate #define PAGEMASK _pagemask 3937c478bd9Sstevel@tonic-gate #define MMU_PAGESIZE _mmu_pagesize 3947c478bd9Sstevel@tonic-gate #define MMU_PAGESHIFT _mmu_pageshift 3957c478bd9Sstevel@tonic-gate #define MMU_PAGEOFFSET _mmu_pageoffset 3967c478bd9Sstevel@tonic-gate #define MMU_PAGEMASK _mmu_pagemask 3977c478bd9Sstevel@tonic-gate 3987c478bd9Sstevel@tonic-gate #define KERNELBASE _kernelbase 3997c478bd9Sstevel@tonic-gate #define USERLIMIT _userlimit 4007c478bd9Sstevel@tonic-gate #define USERLIMIT32 _userlimit32 4017c478bd9Sstevel@tonic-gate #define ARGSBASE _argsbase 4027c478bd9Sstevel@tonic-gate #define DEFAULTSTKSZ _defaultstksz 4037c478bd9Sstevel@tonic-gate #define NCPU _ncpu 40423d9e5acSMichael Corcoran #define NCPU_LOG2 _ncpu_log2 405cb15d5d9SPeter Rival #define NCPU_P2 _ncpu_p2 4067c478bd9Sstevel@tonic-gate 4077c478bd9Sstevel@tonic-gate #endif /* defined(_MACHDEP) */ 4087c478bd9Sstevel@tonic-gate 4097c478bd9Sstevel@tonic-gate /* 4107c478bd9Sstevel@tonic-gate * Some random macros for units conversion. 4117c478bd9Sstevel@tonic-gate * 4127c478bd9Sstevel@tonic-gate * These are machine independent but contain constants (*PAGESHIFT) which 4137c478bd9Sstevel@tonic-gate * are only defined in the machine dependent file. 4147c478bd9Sstevel@tonic-gate */ 4157c478bd9Sstevel@tonic-gate 4167c478bd9Sstevel@tonic-gate /* 4177c478bd9Sstevel@tonic-gate * MMU pages to bytes, and back (with and without rounding) 4187c478bd9Sstevel@tonic-gate */ 4197c478bd9Sstevel@tonic-gate #define mmu_ptob(x) ((x) << MMU_PAGESHIFT) 4207c478bd9Sstevel@tonic-gate #define mmu_btop(x) (((x)) >> MMU_PAGESHIFT) 4217c478bd9Sstevel@tonic-gate #define mmu_btopr(x) ((((x) + MMU_PAGEOFFSET) >> MMU_PAGESHIFT)) 4227c478bd9Sstevel@tonic-gate 4237c478bd9Sstevel@tonic-gate /* 4247c478bd9Sstevel@tonic-gate * 2 versions of pages to disk blocks 4257c478bd9Sstevel@tonic-gate */ 4267c478bd9Sstevel@tonic-gate #define mmu_ptod(x) ((x) << (MMU_PAGESHIFT - DEV_BSHIFT)) 4277c478bd9Sstevel@tonic-gate #define ptod(x) ((x) << (PAGESHIFT - DEV_BSHIFT)) 4287c478bd9Sstevel@tonic-gate 4297c478bd9Sstevel@tonic-gate /* 4307c478bd9Sstevel@tonic-gate * pages to bytes, and back (with and without rounding) 4317c478bd9Sstevel@tonic-gate * Large Files: The explicit cast of x to unsigned int is deliberately 4327c478bd9Sstevel@tonic-gate * removed as part of large files work. We pass longlong values to 4337c478bd9Sstevel@tonic-gate * theses macros. 4347c478bd9Sstevel@tonic-gate * 4357c478bd9Sstevel@tonic-gate * Cast the input to ptob() to be a page count. This enforces 64-bit 4367c478bd9Sstevel@tonic-gate * math on 64-bit kernels. For 32-bit kernels, callers must explicitly 4377c478bd9Sstevel@tonic-gate * cast the input to be a 64-bit type if values greater than 4GB/PAGESIZE 4387c478bd9Sstevel@tonic-gate * are possible. 4397c478bd9Sstevel@tonic-gate */ 4407c478bd9Sstevel@tonic-gate 4417c478bd9Sstevel@tonic-gate #ifdef _LP64 4427c478bd9Sstevel@tonic-gate #define ptob(x) (((pgcnt_t)(x)) << PAGESHIFT) 4437c478bd9Sstevel@tonic-gate #else 4447c478bd9Sstevel@tonic-gate #define ptob(x) ((x) << PAGESHIFT) 4457c478bd9Sstevel@tonic-gate #endif /* _LP64 */ 4467c478bd9Sstevel@tonic-gate #define btop(x) (((x) >> PAGESHIFT)) 4477c478bd9Sstevel@tonic-gate #define btopr(x) ((((x) + PAGEOFFSET) >> PAGESHIFT)) 4487c478bd9Sstevel@tonic-gate 4497c478bd9Sstevel@tonic-gate /* 4507c478bd9Sstevel@tonic-gate * disk blocks to pages, rounded and truncated 4517c478bd9Sstevel@tonic-gate */ 4527c478bd9Sstevel@tonic-gate #define NDPP (PAGESIZE/DEV_BSIZE) /* # of disk blocks per page */ 4537c478bd9Sstevel@tonic-gate #define dtop(DD) (((DD) + NDPP - 1) >> (PAGESHIFT - DEV_BSHIFT)) 4547c478bd9Sstevel@tonic-gate #define dtopt(DD) ((DD) >> (PAGESHIFT - DEV_BSHIFT)) 4557c478bd9Sstevel@tonic-gate 4567c478bd9Sstevel@tonic-gate /* 457ae115bc7Smrj * kB to pages and back 458ae115bc7Smrj */ 459ae115bc7Smrj #define kbtop(x) ((x) >> (PAGESHIFT - 10)) 460ae115bc7Smrj #define ptokb(x) ((x) << (PAGESHIFT - 10)) 461ae115bc7Smrj 462ae115bc7Smrj /* 4637c478bd9Sstevel@tonic-gate * POSIX.4 related configuration parameters 4647c478bd9Sstevel@tonic-gate */ 4657c478bd9Sstevel@tonic-gate #define _AIO_LISTIO_MAX (4096) 4667c478bd9Sstevel@tonic-gate #define _AIO_MAX (-1) 46706a502e8Scasper #define _MQ_OPEN_MAX (-1) 4687c478bd9Sstevel@tonic-gate #define _MQ_PRIO_MAX (32) 4697c478bd9Sstevel@tonic-gate #define _SEM_NSEMS_MAX INT_MAX 4707c478bd9Sstevel@tonic-gate #define _SEM_VALUE_MAX INT_MAX 4717c478bd9Sstevel@tonic-gate 4727c478bd9Sstevel@tonic-gate #ifdef __cplusplus 4737c478bd9Sstevel@tonic-gate } 4747c478bd9Sstevel@tonic-gate #endif 4757c478bd9Sstevel@tonic-gate 4767c478bd9Sstevel@tonic-gate #else /* (defined(_KERNEL) || defined(_KMEMUSER)) */ 4777c478bd9Sstevel@tonic-gate 4787c478bd9Sstevel@tonic-gate /* 4797c478bd9Sstevel@tonic-gate * The following are assorted machine dependent values which can be 4807c478bd9Sstevel@tonic-gate * obtained in a machine independent manner through sysconf(2) or 4817c478bd9Sstevel@tonic-gate * sysinfo(2). In order to guarantee that these provide the expected 4827c478bd9Sstevel@tonic-gate * value at all times, the System Private interface (leading underscore) 4837c478bd9Sstevel@tonic-gate * is used. 4847c478bd9Sstevel@tonic-gate */ 4857c478bd9Sstevel@tonic-gate 4867c478bd9Sstevel@tonic-gate #include <sys/unistd.h> 4877c478bd9Sstevel@tonic-gate 4887c478bd9Sstevel@tonic-gate #ifdef __cplusplus 4897c478bd9Sstevel@tonic-gate extern "C" { 4907c478bd9Sstevel@tonic-gate #endif 4917c478bd9Sstevel@tonic-gate 4927c478bd9Sstevel@tonic-gate #if !defined(_ASM) 4937c478bd9Sstevel@tonic-gate extern long _sysconf(int); /* System Private interface to sysconf() */ 4947c478bd9Sstevel@tonic-gate #endif /* !defined(_ASM) */ 4957c478bd9Sstevel@tonic-gate 4967c478bd9Sstevel@tonic-gate #define HZ ((clock_t)_sysconf(_SC_CLK_TCK)) 4977c478bd9Sstevel@tonic-gate #define TICK (1000000000/((clock_t)_sysconf(_SC_CLK_TCK))) 4987c478bd9Sstevel@tonic-gate #define PAGESIZE (_sysconf(_SC_PAGESIZE)) 4997c478bd9Sstevel@tonic-gate #define PAGEOFFSET (PAGESIZE - 1) 5007c478bd9Sstevel@tonic-gate #define PAGEMASK (~PAGEOFFSET) 5017c478bd9Sstevel@tonic-gate #define MAXPID ((pid_t)_sysconf(_SC_MAXPID)) 502f48205beScasper #define MAXEPHUID ((uid_t)_sysconf(_SC_EPHID_MAX)) 5037c478bd9Sstevel@tonic-gate 5047c478bd9Sstevel@tonic-gate #ifdef __cplusplus 5057c478bd9Sstevel@tonic-gate } 5067c478bd9Sstevel@tonic-gate #endif 5077c478bd9Sstevel@tonic-gate 5087c478bd9Sstevel@tonic-gate #endif /* (defined(_KERNEL) || defined(_KMEMUSER)) && defined(_MACHDEP) */ 5097c478bd9Sstevel@tonic-gate 5107c478bd9Sstevel@tonic-gate #endif /* _SYS_PARAM_H */ 511