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.
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.
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]
23 * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
24 * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
27 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
28 /* All Rights Reserved */
31 * University Copyright- Copyright (c) 1982, 1986, 1988
32 * The Regents of the University of California
35 * University Acknowledgment- Portions of this document are derived from
36 * software developed by the University of California, Berkeley, and its
43 #ifndef _ASM /* Avoid typedef headaches for assembly files */
44 #include <sys/types.h>
45 #include <sys/isa_defs.h>
55 * Fundamental variables; don't change too often.
59 * _POSIX_VDISABLE has historically been defined in <sys/param.h> since
60 * an early merge with AT&T source. It has also historically been defined
61 * in <sys/termios.h>. The POSIX standard, IEEE Std. 1003.1-1988 initially
62 * required the existence of _POSIX_VDISABLE in <sys/termios.h>.
63 * Subsequent versions of the IEEE Standard as well as the X/Open
64 * specifications required that _POSIX_VDISABLE be defined in <unistd.h>
65 * while still allowing for it's existence in other headers. With the
66 * introduction of XPG6, _POSIX_VDISABLE can only be defined in <unistd.h>.
68 #if !defined(_XPG6) || defined(__EXTENSIONS__)
69 #ifndef _POSIX_VDISABLE
70 #define _POSIX_VDISABLE 0 /* Disable special character functions */
72 #endif /* !defined(_XPG6) || defined(__EXTENSIONS__) */
74 /* The actual size of the TTY input queue */
75 #define _TTY_BUFSIZ 2048
78 * These defines all have their historical value. The actual size of the tty
79 * buffer both for the line-editor in ldterm, and in general, is above as
82 * We leave these defines at their historical value to match the behaviour of
86 #define MAX_INPUT 512 /* Maximum bytes stored in the input queue */
89 #define MAX_CANON 256 /* Maximum bytes for canonical processing */
91 #define CANBSIZ 256 /* max size of typewriter line */
94 #define UID_NOBODY 60001 /* user ID no body */
95 #define GID_NOBODY UID_NOBODY
96 #define UID_UNKNOWN 96
97 #define GID_UNKNOWN UID_UNKNOWN
100 #define GID_NETADM 65
101 #define UID_NOACCESS 60002 /* user ID no access */
104 #define MAX_TASKID 999999
105 #define MAX_MAXPID 999999
106 #define MAXEPHUID 0xfffffffcu /* max ephemeral user id */
108 #define FAMOUS_PID_SCHED 0
109 #define FAMOUS_PID_INIT 1
110 #define FAMOUS_PID_PAGEOUT 2
111 #define FAMOUS_PID_FSFLUSH 3
112 #define FAMOUS_PIDS 4
116 #define DEFAULT_MAXPID 999999
117 #define DEFAULT_JUMPPID 100000
119 #define DEFAULT_MAXPID 30000
120 #define DEFAULT_JUMPPID 0
123 #define MAXUID 2147483647 /* max user id */
125 #define MAXPROJID MAXUID /* max project id */
126 #define MAXLINK 32767 /* max links */
128 #define MINEPHUID 0x80000000u /* min ephemeral user id */
130 #define NMOUNT 40 /* est. of # mountable fs for quota calc */
132 #define NOFILE 20 /* this define is here for */
133 /* compatibility purposes only */
134 /* and will be removed in a */
138 * These define the maximum and minimum allowable values of the
139 * configurable parameter NGROUPS_MAX.
141 #define NGROUPS_UMIN 0
142 #define NGROUPS_UMAX 1024
143 #define NGROUPS_OLDMAX 32
146 * NGROUPS_MAX_DEFAULT: *MUST* match NGROUPS_MAX value in limits.h.
148 #define NGROUPS_MAX_DEFAULT 16
151 * Default process priority. Keep it in sync with limits.h.
156 * Fundamental constants of the implementation--cannot be changed easily.
159 #define CMASK 022 /* default mask for file creation */
160 #define CDLIMIT (1L<<11) /* default max write address */
161 #define NBPS 0x20000 /* Number of bytes per segment */
162 #define NBPSCTR 512 /* Bytes per disk sector. */
163 #define UBSIZE 512 /* unix block size. */
164 #define SCTRSHFT 9 /* Shift for BPSECT. */
166 #ifdef _LITTLE_ENDIAN
167 #define lobyte(X) (((unsigned char *)&(X))[0])
168 #define hibyte(X) (((unsigned char *)&(X))[1])
169 #define loword(X) (((ushort_t *)&(X))[0])
170 #define hiword(X) (((ushort_t *)&(X))[1])
173 #define lobyte(X) (((unsigned char *)&(X))[1])
174 #define hibyte(X) (((unsigned char *)&(X))[0])
175 #define loword(X) (((ushort_t *)&(X))[1])
176 #define hiword(X) (((ushort_t *)&(X))[0])
179 /* REMOTE -- whether machine is primary, secondary, or regular */
180 #define SYSNAME 9 /* # chars in system name */
184 * MAXPATHLEN defines the longest permissible path length,
185 * including the terminating null, after expanding symbolic links.
186 * TYPICALMAXPATHLEN is used in a few places as an optimization
187 * with a local buffer on the stack to avoid kmem_alloc().
188 * MAXSYMLINKS defines the maximum number of symbolic links
189 * that may be expanded in a path name. It should be set high
190 * enough to allow all legitimate uses, but halt infinite loops
191 * reasonably quickly.
192 * MAXNAMELEN is the length (including the terminating null) of
193 * the longest permissible file (component) name.
195 #define MAXPATHLEN 1024
196 #define TYPICALMAXPATHLEN 64
197 #define MAXSYMLINKS 20
198 #define MAXNAMELEN 256
201 * MAXLINKNAMELEN defines the longest possible permitted datalink name,
202 * including the terminating NUL. Note that this must not be larger
203 * than related networking constants such as LIFNAMSIZ.
205 #define MAXLINKNAMELEN 32
212 * The following are defined to be the same as
213 * defined in /usr/include/limits.h. They are
214 * needed for pipe and FIFO compatibility.
216 #ifndef PIPE_BUF /* max # bytes atomic in write to a pipe */
217 #define PIPE_BUF 5120
218 #endif /* PIPE_BUF */
220 #ifndef PIPE_MAX /* max # bytes written to a pipe in a write */
221 #define PIPE_MAX 5120
222 #endif /* PIPE_MAX */
225 #define NBBY 8 /* number of bits per byte */
228 /* macros replacing interleaving functions */
229 #define dkblock(bp) ((bp)->b_blkno)
230 #define dkunit(bp) (minor((bp)->b_dev) >> 3)
233 * File system parameters and macros.
235 * The file system is made out of blocks of at most MAXBSIZE units,
236 * with smaller units (fragments) only in the last direct block.
237 * MAXBSIZE primarily determines the size of buffers in the buffer
238 * pool. It may be made larger without any effect on existing
239 * file systems; however making it smaller make make some file
240 * systems unmountable.
242 * Note that the blocked devices are assumed to have DEV_BSIZE
243 * "sectors" and that fragments must be some multiple of this size.
245 #define MAXBSIZE 8192
246 #define DEV_BSIZE 512
247 #define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */
249 #define MAXOFF_T 0x7fffffffffffffffLL
250 #define MAXOFFSET_T MAXOFF_T
252 #define btodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \
253 ((unsigned long)(bytes) >> DEV_BSHIFT)
254 #define dbtob(db) /* calculates (db * DEV_BSIZE) */ \
255 ((unsigned long)(db) << DEV_BSHIFT)
257 /* 64 bit versions of btodb and dbtob */
258 #define lbtodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \
259 ((uoff_t)(bytes) >> DEV_BSHIFT)
260 #define ldbtob(db) /* calculates (db * DEV_BSIZE) */ \
261 ((uoff_t)(db) << DEV_BSHIFT)
263 #ifndef _ASM /* Avoid typedef headaches for assembly files */
265 #define NODEV (dev_t)(-1l)
267 #define NODEV32 (dev32_t)(-1)
268 #endif /* _SYSCALL32 */
273 * Size of arg list passed in by user.
275 #define NCARGS32 0x100000
276 #define NCARGS64 0x200000
278 #define NCARGS NCARGS64
280 #define NCARGS NCARGS32
284 * Scale factor for scaled integers used to count
285 * %cpu time and load averages.
287 #define FSHIFT 8 /* bits to right of fixed binary point */
288 #define FSCALE (1<<FSHIFT)
291 * Delay units are in microseconds.
293 * XXX These macros are not part of the DDI!
295 #if defined(_KERNEL) && !defined(_ASM)
296 extern void drv_usecwait(clock_t);
297 #define DELAY(n) drv_usecwait(n)
298 #define CDELAY(c, n) \
300 register int N = n; \
307 #endif /* defined(_KERNEL) && !defined(_ASM) */
314 * The following is to free utilities from machine dependencies within
315 * an architecture. Must be included after definition of DEV_BSIZE.
318 #if defined(_KERNEL) || defined(_KMEMUSER) || defined(_BOOT)
320 #if defined(_MACHDEP)
321 #include <sys/machparam.h>
328 #if defined(_KERNEL) && !defined(_ASM)
329 extern int cpu_decay_factor
;
331 extern pid_t jump_pid
;
333 extern uintptr_t _kernelbase
;
334 extern uintptr_t _userlimit
;
335 extern uintptr_t _userlimit32
;
336 #endif /* defined(_KERNEL) && !defined(_ASM) */
339 * These three variables have been added within the #if defined(lint)
340 * below to ensure visibility to lint. This is a short term workaround
341 * to handle poor interaction between SS12 lint and these variables.
342 * CR 6742611 has been logged to address these issues.
346 extern uint_t snoop_interval
;
347 extern const unsigned int _pageshift
;
350 #if !defined(_MACHDEP)
353 * Implementation architecture independent sections of the kernel use
356 #if defined(_KERNEL) && !defined(_ASM)
359 extern uint_t snoop_interval
;
360 extern const unsigned long _pagesize
;
361 extern const unsigned int _pageshift
;
362 extern const unsigned long _pageoffset
;
363 extern const unsigned long long _pagemask
;
364 extern const unsigned long _mmu_pagesize
;
365 extern const unsigned int _mmu_pageshift
;
366 extern const unsigned long _mmu_pageoffset
;
367 extern const unsigned long _mmu_pagemask
;
368 extern const uintptr_t _argsbase
;
369 extern const unsigned long _defaultstksz
;
370 extern const unsigned int _nbpg
;
371 extern const int _ncpu
;
372 extern const int _ncpu_log2
;
373 extern const int _ncpu_p2
;
374 extern const int _clsize
;
375 #endif /* defined(_KERNEL) && !defined(_ASM) */
377 /* Any additions to these #defines must be reflected in mdb_param.h+mdb_ks.c */
378 #define PAGESIZE _pagesize
379 #define PAGESHIFT _pageshift
380 #define PAGEOFFSET _pageoffset
381 #define PAGEMASK _pagemask
382 #define MMU_PAGESIZE _mmu_pagesize
383 #define MMU_PAGESHIFT _mmu_pageshift
384 #define MMU_PAGEOFFSET _mmu_pageoffset
385 #define MMU_PAGEMASK _mmu_pagemask
387 #define KERNELBASE _kernelbase
388 #define USERLIMIT _userlimit
389 #define USERLIMIT32 _userlimit32
390 #define ARGSBASE _argsbase
391 #define DEFAULTSTKSZ _defaultstksz
393 #define NCPU_LOG2 _ncpu_log2
394 #define NCPU_P2 _ncpu_p2
396 #endif /* defined(_MACHDEP) */
399 * Some random macros for units conversion.
401 * These are machine independent but contain constants (*PAGESHIFT) which
402 * are only defined in the machine dependent file.
406 * MMU pages to bytes, and back (with and without rounding)
408 #define mmu_ptob(x) ((x) << MMU_PAGESHIFT)
409 #define mmu_btop(x) (((x)) >> MMU_PAGESHIFT)
410 #define mmu_btopr(x) ((((x) + MMU_PAGEOFFSET) >> MMU_PAGESHIFT))
413 * 2 versions of pages to disk blocks
415 #define mmu_ptod(x) ((x) << (MMU_PAGESHIFT - DEV_BSHIFT))
416 #define ptod(x) ((x) << (PAGESHIFT - DEV_BSHIFT))
419 * pages to bytes, and back (with and without rounding)
420 * Large Files: The explicit cast of x to unsigned int is deliberately
421 * removed as part of large files work. We pass longlong values to
424 * Cast the input to ptob() to be a page count. This enforces 64-bit
425 * math on 64-bit kernels. For 32-bit kernels, callers must explicitly
426 * cast the input to be a 64-bit type if values greater than 4GB/PAGESIZE
431 #define ptob(x) (((pgcnt_t)(x)) << PAGESHIFT)
433 #define ptob(x) ((x) << PAGESHIFT)
435 #define btop(x) (((x) >> PAGESHIFT))
436 #define btopr(x) ((((x) + PAGEOFFSET) >> PAGESHIFT))
439 * disk blocks to pages, rounded and truncated
441 #define NDPP (PAGESIZE/DEV_BSIZE) /* # of disk blocks per page */
442 #define dtop(DD) (((DD) + NDPP - 1) >> (PAGESHIFT - DEV_BSHIFT))
443 #define dtopt(DD) ((DD) >> (PAGESHIFT - DEV_BSHIFT))
446 * kB to pages and back
448 #define kbtop(x) ((x) >> (PAGESHIFT - 10))
449 #define ptokb(x) ((x) << (PAGESHIFT - 10))
452 * POSIX.4 related configuration parameters
454 #define _AIO_LISTIO_MAX (4096)
455 #define _AIO_MAX (-1)
456 #define _MQ_OPEN_MAX (-1)
457 #define _MQ_PRIO_MAX (32)
458 #define _SEM_NSEMS_MAX INT_MAX
459 #define _SEM_VALUE_MAX INT_MAX
465 #else /* defined(_KERNEL) || defined(_KMEMUSER) || defined(_BOOT) */
468 * The following are assorted machine dependent values which can be
469 * obtained in a machine independent manner through sysconf(2) or
470 * sysinfo(2). In order to guarantee that these provide the expected
471 * value at all times, the System Private interface (leading underscore)
475 #include <sys/unistd.h>
482 extern long _sysconf(int); /* System Private interface to sysconf() */
483 #endif /* !defined(_ASM) */
485 #define HZ ((clock_t)_sysconf(_SC_CLK_TCK))
486 #define TICK (1000000000/((clock_t)_sysconf(_SC_CLK_TCK)))
487 #define PAGESIZE (_sysconf(_SC_PAGESIZE))
488 #define PAGEOFFSET (PAGESIZE - 1)
489 #define PAGEMASK (~PAGEOFFSET)
490 #define MAXPID ((pid_t)_sysconf(_SC_MAXPID))
491 #define MAXEPHUID ((uid_t)_sysconf(_SC_EPHID_MAX))
497 #endif /* defined(_KERNEL) || defined(_KMEMUSER) || defined(_BOOT) */
499 #endif /* _SYS_PARAM_H */