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