xref: /onnv-gate/usr/src/uts/common/sys/mman.h (revision 8212:d757e7790cab)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
53383Sdamico  * Common Development and Distribution License (the "License").
63383Sdamico  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
217088Sraf 
220Sstevel@tonic-gate /*
237088Sraf  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
240Sstevel@tonic-gate  * Use is subject to license terms.
250Sstevel@tonic-gate  */
260Sstevel@tonic-gate 
270Sstevel@tonic-gate /*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
280Sstevel@tonic-gate /*	  All Rights Reserved	*/
290Sstevel@tonic-gate 
300Sstevel@tonic-gate /*
310Sstevel@tonic-gate  * University Copyright- Copyright (c) 1982, 1986, 1988
320Sstevel@tonic-gate  * The Regents of the University of California
330Sstevel@tonic-gate  * All Rights Reserved
340Sstevel@tonic-gate  *
350Sstevel@tonic-gate  * University Acknowledgment- Portions of this document are derived from
360Sstevel@tonic-gate  * software developed by the University of California, Berkeley, and its
370Sstevel@tonic-gate  * contributors.
380Sstevel@tonic-gate  */
390Sstevel@tonic-gate 
400Sstevel@tonic-gate #ifndef	_SYS_MMAN_H
410Sstevel@tonic-gate #define	_SYS_MMAN_H
420Sstevel@tonic-gate 
430Sstevel@tonic-gate #include <sys/feature_tests.h>
440Sstevel@tonic-gate 
450Sstevel@tonic-gate #ifdef	__cplusplus
460Sstevel@tonic-gate extern "C" {
470Sstevel@tonic-gate #endif
480Sstevel@tonic-gate 
490Sstevel@tonic-gate /*
500Sstevel@tonic-gate  * Protections are chosen from these bits, or-ed together.
510Sstevel@tonic-gate  * Note - not all implementations literally provide all possible
520Sstevel@tonic-gate  * combinations.  PROT_WRITE is often implemented as (PROT_READ |
530Sstevel@tonic-gate  * PROT_WRITE) and (PROT_EXECUTE as PROT_READ | PROT_EXECUTE).
540Sstevel@tonic-gate  * However, no implementation will permit a write to succeed
550Sstevel@tonic-gate  * where PROT_WRITE has not been set.  Also, no implementation will
560Sstevel@tonic-gate  * allow any access to succeed where prot is specified as PROT_NONE.
570Sstevel@tonic-gate  */
580Sstevel@tonic-gate #define	PROT_READ	0x1		/* pages can be read */
590Sstevel@tonic-gate #define	PROT_WRITE	0x2		/* pages can be written */
600Sstevel@tonic-gate #define	PROT_EXEC	0x4		/* pages can be executed */
610Sstevel@tonic-gate 
620Sstevel@tonic-gate #ifdef	_KERNEL
630Sstevel@tonic-gate #define	PROT_USER	0x8		/* pages are user accessable */
640Sstevel@tonic-gate #define	PROT_ZFOD	(PROT_READ | PROT_WRITE | PROT_EXEC | PROT_USER)
650Sstevel@tonic-gate #define	PROT_ALL	(PROT_READ | PROT_WRITE | PROT_EXEC | PROT_USER)
660Sstevel@tonic-gate #endif	/* _KERNEL */
670Sstevel@tonic-gate 
680Sstevel@tonic-gate #define	PROT_NONE	0x0		/* pages cannot be accessed */
690Sstevel@tonic-gate 
700Sstevel@tonic-gate /* sharing types:  must choose either SHARED or PRIVATE */
710Sstevel@tonic-gate #define	MAP_SHARED	1		/* share changes */
720Sstevel@tonic-gate #define	MAP_PRIVATE	2		/* changes are private */
730Sstevel@tonic-gate #define	MAP_TYPE	0xf		/* mask for share type */
740Sstevel@tonic-gate 
750Sstevel@tonic-gate /* other flags to mmap (or-ed in to MAP_SHARED or MAP_PRIVATE) */
760Sstevel@tonic-gate #define	MAP_FIXED	0x10		/* user assigns address */
770Sstevel@tonic-gate #define	MAP_NORESERVE	0x40		/* don't reserve needed swap area */
780Sstevel@tonic-gate #define	MAP_ANON	0x100		/* map anonymous pages directly */
790Sstevel@tonic-gate #define	MAP_ANONYMOUS	MAP_ANON	/* (source compatibility) */
800Sstevel@tonic-gate #define	MAP_ALIGN	0x200		/* addr specifies alignment */
810Sstevel@tonic-gate #define	MAP_TEXT	0x400		/* map code segment */
820Sstevel@tonic-gate #define	MAP_INITDATA	0x800		/* map data segment */
830Sstevel@tonic-gate 
844426Saguzovsk #ifdef _KERNEL
854426Saguzovsk #define	_MAP_TEXTREPL	0x1000
864426Saguzovsk #endif /* _KERNEL */
874426Saguzovsk 
880Sstevel@tonic-gate /* these flags not yet implemented */
890Sstevel@tonic-gate #define	MAP_RENAME	0x20		/* rename private pages to file */
900Sstevel@tonic-gate 
910Sstevel@tonic-gate #if	(_POSIX_C_SOURCE <= 2) && !defined(_XPG4_2)
920Sstevel@tonic-gate /* these flags are used by memcntl */
930Sstevel@tonic-gate #define	PROC_TEXT	(PROT_EXEC | PROT_READ)
940Sstevel@tonic-gate #define	PROC_DATA	(PROT_READ | PROT_WRITE | PROT_EXEC)
950Sstevel@tonic-gate #define	SHARED		0x10
960Sstevel@tonic-gate #define	PRIVATE		0x20
970Sstevel@tonic-gate #define	VALID_ATTR  (PROT_READ|PROT_WRITE|PROT_EXEC|SHARED|PRIVATE)
980Sstevel@tonic-gate #endif	/* (_POSIX_C_SOURCE <= 2) && !defined(_XPG4_2) */
990Sstevel@tonic-gate 
1000Sstevel@tonic-gate #if	(_POSIX_C_SOURCE <= 2) || defined(_XPG4_2)
1010Sstevel@tonic-gate #ifdef	_KERNEL
1020Sstevel@tonic-gate #define	PROT_EXCL	0x20
1030Sstevel@tonic-gate #define	_MAP_LOW32	0x80	/* force mapping in lower 4G of address space */
1040Sstevel@tonic-gate #endif	/* _KERNEL */
1050Sstevel@tonic-gate 
1060Sstevel@tonic-gate /*
1070Sstevel@tonic-gate  * For the sake of backward object compatibility, we use the _MAP_NEW flag.
1080Sstevel@tonic-gate  * This flag will be automatically or'ed in by the C library for all
1090Sstevel@tonic-gate  * new mmap calls.  Previous binaries with old mmap calls will continue
1100Sstevel@tonic-gate  * to get 0 or -1 for return values.  New mmap calls will get the mapped
1110Sstevel@tonic-gate  * address as the return value if successful and -1 on errors.  By default,
1120Sstevel@tonic-gate  * new mmap calls automatically have the kernel assign the map address
1130Sstevel@tonic-gate  * unless the MAP_FIXED flag is given.
1140Sstevel@tonic-gate  */
1150Sstevel@tonic-gate #define	_MAP_NEW	0x80000000	/* users should not need to use this */
1160Sstevel@tonic-gate #endif	/* (_POSIX_C_SOURCE <= 2) */
1170Sstevel@tonic-gate 
1180Sstevel@tonic-gate #if	!defined(_ASM) && !defined(_KERNEL)
1190Sstevel@tonic-gate 
1200Sstevel@tonic-gate #include <sys/types.h>
1210Sstevel@tonic-gate 
122*8212SMichael.Corcoran@Sun.COM #endif	/* !_ASM && !_KERNEL */
123*8212SMichael.Corcoran@Sun.COM 
124*8212SMichael.Corcoran@Sun.COM /* External flags for mmapobj syscall (Exclusive of MAP_* flags above) */
125*8212SMichael.Corcoran@Sun.COM #define	MMOBJ_PADDING		0x10000
126*8212SMichael.Corcoran@Sun.COM #define	MMOBJ_INTERPRET		0x20000
127*8212SMichael.Corcoran@Sun.COM 
128*8212SMichael.Corcoran@Sun.COM #define	MMOBJ_ALL_FLAGS		(MMOBJ_PADDING | MMOBJ_INTERPRET)
129*8212SMichael.Corcoran@Sun.COM 
130*8212SMichael.Corcoran@Sun.COM /*
131*8212SMichael.Corcoran@Sun.COM  * Values for mr_flags field of mmapobj_result_t below.
132*8212SMichael.Corcoran@Sun.COM  * The bottom 16 bits are mutually exclusive and thus only one
133*8212SMichael.Corcoran@Sun.COM  * of them can be set at a time.  Use MR_GET_TYPE below to check this value.
134*8212SMichael.Corcoran@Sun.COM  * The top 16 bits are used for flags which are not mutually exclusive and
135*8212SMichael.Corcoran@Sun.COM  * thus more than one of these flags can be set for a given mmapobj_result_t.
136*8212SMichael.Corcoran@Sun.COM  *
137*8212SMichael.Corcoran@Sun.COM  * MR_PADDING being set indicates that this memory range represents the user
138*8212SMichael.Corcoran@Sun.COM  * requested padding.
139*8212SMichael.Corcoran@Sun.COM  *
140*8212SMichael.Corcoran@Sun.COM  * MR_HDR_ELF being set indicates that the ELF header of the mapped object
141*8212SMichael.Corcoran@Sun.COM  * is mapped at mr_addr + mr_offset.
142*8212SMichael.Corcoran@Sun.COM  *
143*8212SMichael.Corcoran@Sun.COM  * MR_HDR_AOUT being set indicates that the AOUT (4.x) header of the mapped
144*8212SMichael.Corcoran@Sun.COM  * object is mapped at mr_addr + mr_offset.
145*8212SMichael.Corcoran@Sun.COM  */
146*8212SMichael.Corcoran@Sun.COM 
147*8212SMichael.Corcoran@Sun.COM /*
148*8212SMichael.Corcoran@Sun.COM  * External flags for mr_flags field below.
149*8212SMichael.Corcoran@Sun.COM  */
150*8212SMichael.Corcoran@Sun.COM #define	MR_PADDING	0x1
151*8212SMichael.Corcoran@Sun.COM #define	MR_HDR_ELF	0x2
152*8212SMichael.Corcoran@Sun.COM #define	MR_HDR_AOUT	0x3
153*8212SMichael.Corcoran@Sun.COM 
154*8212SMichael.Corcoran@Sun.COM /*
155*8212SMichael.Corcoran@Sun.COM  * Internal flags for mr_flags field below.
156*8212SMichael.Corcoran@Sun.COM  */
157*8212SMichael.Corcoran@Sun.COM #ifdef	_KERNEL
158*8212SMichael.Corcoran@Sun.COM #define	MR_RESV	0x80000000	/* overmapped /dev/null */
159*8212SMichael.Corcoran@Sun.COM #endif	/* _KERNEL */
160*8212SMichael.Corcoran@Sun.COM 
161*8212SMichael.Corcoran@Sun.COM #define	MR_TYPE_MASK 0x0000ffff
162*8212SMichael.Corcoran@Sun.COM #define	MR_GET_TYPE(val)	((val) & MR_TYPE_MASK)
163*8212SMichael.Corcoran@Sun.COM 
164*8212SMichael.Corcoran@Sun.COM #if	!defined(_ASM)
165*8212SMichael.Corcoran@Sun.COM typedef struct mmapobj_result {
166*8212SMichael.Corcoran@Sun.COM 	caddr_t		mr_addr;	/* mapping address */
167*8212SMichael.Corcoran@Sun.COM 	size_t		mr_msize;	/* mapping size */
168*8212SMichael.Corcoran@Sun.COM 	size_t		mr_fsize;	/* file size */
169*8212SMichael.Corcoran@Sun.COM 	size_t		mr_offset;	/* offset into file */
170*8212SMichael.Corcoran@Sun.COM 	uint_t		mr_prot;	/* the protections provided */
171*8212SMichael.Corcoran@Sun.COM 	uint_t		mr_flags;	/* info on the mapping */
172*8212SMichael.Corcoran@Sun.COM } mmapobj_result_t;
173*8212SMichael.Corcoran@Sun.COM 
174*8212SMichael.Corcoran@Sun.COM #if defined(_KERNEL) || defined(_SYSCALL32)
175*8212SMichael.Corcoran@Sun.COM typedef struct mmapobj_result32 {
176*8212SMichael.Corcoran@Sun.COM 	caddr32_t	mr_addr;	/* mapping address */
177*8212SMichael.Corcoran@Sun.COM 	size32_t	mr_msize;	/* mapping size */
178*8212SMichael.Corcoran@Sun.COM 	size32_t	mr_fsize;	/* file size */
179*8212SMichael.Corcoran@Sun.COM 	size32_t	mr_offset;	/* offset into file */
180*8212SMichael.Corcoran@Sun.COM 	uint_t		mr_prot;	/* the protections provided */
181*8212SMichael.Corcoran@Sun.COM 	uint_t		mr_flags;	/* info on the mapping */
182*8212SMichael.Corcoran@Sun.COM } mmapobj_result32_t;
183*8212SMichael.Corcoran@Sun.COM #endif	/* defined(_KERNEL) || defined(_SYSCALL32) */
184*8212SMichael.Corcoran@Sun.COM #endif	/* !defined(_ASM) */
185*8212SMichael.Corcoran@Sun.COM 
186*8212SMichael.Corcoran@Sun.COM #if	!defined(_ASM) && !defined(_KERNEL)
1870Sstevel@tonic-gate /*
1880Sstevel@tonic-gate  * large file compilation environment setup
1890Sstevel@tonic-gate  *
1900Sstevel@tonic-gate  * In the LP64 compilation environment, map large file interfaces
1910Sstevel@tonic-gate  * back to native versions where possible.
1920Sstevel@tonic-gate  */
1930Sstevel@tonic-gate 
1940Sstevel@tonic-gate #if !defined(_LP64) && _FILE_OFFSET_BITS == 64
1950Sstevel@tonic-gate #ifdef	__PRAGMA_REDEFINE_EXTNAME
1960Sstevel@tonic-gate #pragma redefine_extname	mmap	mmap64
1970Sstevel@tonic-gate #else
1980Sstevel@tonic-gate #define	mmap			mmap64
1990Sstevel@tonic-gate #endif
2000Sstevel@tonic-gate #endif /* !_LP64 && _FILE_OFFSET_BITS == 64 */
2010Sstevel@tonic-gate 
2020Sstevel@tonic-gate #if defined(_LP64) && defined(_LARGEFILE64_SOURCE)
2030Sstevel@tonic-gate #ifdef	__PRAGMA_REDEFINE_EXTNAME
2040Sstevel@tonic-gate #pragma	redefine_extname	mmap64	mmap
2050Sstevel@tonic-gate #else
2060Sstevel@tonic-gate #define	mmap64			mmap
2070Sstevel@tonic-gate #endif
2080Sstevel@tonic-gate #endif	/* _LP64 && _LARGEFILE64_SOURCE */
2090Sstevel@tonic-gate 
2105349Skchow #ifdef __PRAGMA_REDEFINE_EXTNAME
2115349Skchow #pragma redefine_extname	getpagesizes	getpagesizes2
2125349Skchow #else
2135349Skchow #define	getpagesizes	getpagesizes2
2145349Skchow #endif
2155349Skchow 
2160Sstevel@tonic-gate /*
2170Sstevel@tonic-gate  * Except for old binaries mmap() will return the resultant
2180Sstevel@tonic-gate  * address of mapping on success and (caddr_t)-1 on error.
2190Sstevel@tonic-gate  */
2200Sstevel@tonic-gate #ifdef	__STDC__
2210Sstevel@tonic-gate #if (_POSIX_C_SOURCE > 2) || defined(_XPG4_2)
2220Sstevel@tonic-gate extern void *mmap(void *, size_t, int, int, int, off_t);
223*8212SMichael.Corcoran@Sun.COM extern int mmapobj(int, uint_t, void *, uint_t *, void *);
2240Sstevel@tonic-gate extern int munmap(void *, size_t);
2250Sstevel@tonic-gate extern int mprotect(void *, size_t, int);
2260Sstevel@tonic-gate extern int msync(void *, size_t, int);
2270Sstevel@tonic-gate #if (!defined(_XPG4_2) || (_POSIX_C_SOURCE > 2)) || defined(__EXTENSIONS__)
2280Sstevel@tonic-gate extern int mlock(const void *, size_t);
2290Sstevel@tonic-gate extern int munlock(const void *, size_t);
2300Sstevel@tonic-gate #endif	/* (!defined(_XPG4_2) || (_POSIX_C_SOURCE > 2))... */
2310Sstevel@tonic-gate /* transitional large file interface version */
2320Sstevel@tonic-gate #if	defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
2330Sstevel@tonic-gate 	    !defined(__PRAGMA_REDEFINE_EXTNAME))
2340Sstevel@tonic-gate extern void *mmap64(void *, size_t, int, int, int, off64_t);
2350Sstevel@tonic-gate #endif	/* _LARGEFILE64_SOURCE... */
2360Sstevel@tonic-gate #else	/* (_POSIX_C_SOURCE > 2) || defined(_XPG4_2) */
2370Sstevel@tonic-gate extern caddr_t mmap(caddr_t, size_t, int, int, int, off_t);
2380Sstevel@tonic-gate extern int munmap(caddr_t, size_t);
239*8212SMichael.Corcoran@Sun.COM extern int mmapobj(int, uint_t, mmapobj_result_t *, uint_t *, void *);
2400Sstevel@tonic-gate extern int mprotect(caddr_t, size_t, int);
2410Sstevel@tonic-gate extern int msync(caddr_t, size_t, int);
2420Sstevel@tonic-gate extern int mlock(caddr_t, size_t);
2430Sstevel@tonic-gate extern int munlock(caddr_t, size_t);
2440Sstevel@tonic-gate extern int mincore(caddr_t, size_t, char *);
2450Sstevel@tonic-gate extern int memcntl(caddr_t, size_t, int, caddr_t, int, int);
2460Sstevel@tonic-gate extern int madvise(caddr_t, size_t, int);
2470Sstevel@tonic-gate #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
2480Sstevel@tonic-gate extern int getpagesizes(size_t *, int);
2495349Skchow extern int getpagesizes2(size_t *, int);
2500Sstevel@tonic-gate /* guard visibility of uint64_t */
2510Sstevel@tonic-gate #if defined(_INT64_TYPE)
2520Sstevel@tonic-gate extern int meminfo(const uint64_t *, int, const uint_t *, int, uint64_t *,
2530Sstevel@tonic-gate 	uint_t *);
2540Sstevel@tonic-gate #endif /* defined(_INT64_TYPE) */
2550Sstevel@tonic-gate #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
2560Sstevel@tonic-gate /* transitional large file interface version */
2570Sstevel@tonic-gate #ifdef	_LARGEFILE64_SOURCE
2580Sstevel@tonic-gate extern caddr_t mmap64(caddr_t, size_t, int, int, int, off64_t);
2590Sstevel@tonic-gate #endif
2600Sstevel@tonic-gate #endif	/* (_POSIX_C_SOURCE > 2)  || defined(_XPG4_2) */
2610Sstevel@tonic-gate 
2620Sstevel@tonic-gate #if (!defined(_XPG4_2) || (_POSIX_C_SOURCE > 2)) || defined(__EXTENSIONS__)
2630Sstevel@tonic-gate extern int mlockall(int);
2640Sstevel@tonic-gate extern int munlockall(void);
2653383Sdamico extern int shm_open(const char *, int, mode_t);
2663383Sdamico extern int shm_unlink(const char *);
2670Sstevel@tonic-gate #endif
2680Sstevel@tonic-gate 
2697088Sraf #if !defined(__XOPEN_OR_POSIX) || defined(_XPG6) || defined(__EXTENSIONS__)
2707088Sraf extern int posix_madvise(void *, size_t, int);
2717088Sraf #endif
2727088Sraf 
2730Sstevel@tonic-gate /* mmap failure value */
2740Sstevel@tonic-gate #define	MAP_FAILED	((void *) -1)
2750Sstevel@tonic-gate 
2760Sstevel@tonic-gate #else	/* __STDC__ */
2770Sstevel@tonic-gate extern caddr_t mmap();
2780Sstevel@tonic-gate extern int munmap();
279*8212SMichael.Corcoran@Sun.COM extern int mmapobj();
2800Sstevel@tonic-gate extern int mprotect();
2810Sstevel@tonic-gate extern int mincore();
2820Sstevel@tonic-gate extern int memcntl();
2830Sstevel@tonic-gate extern int msync();
2840Sstevel@tonic-gate extern int madvise();
2857088Sraf extern int posix_madvise();
2860Sstevel@tonic-gate extern int getpagesizes();
2875349Skchow extern int getpagesizes2();
2880Sstevel@tonic-gate extern int mlock();
2890Sstevel@tonic-gate extern int mlockall();
2900Sstevel@tonic-gate extern int munlock();
2910Sstevel@tonic-gate extern int munlockall();
2920Sstevel@tonic-gate extern int meminfo();
2933383Sdamico extern int shm_open();
2943383Sdamico extern int shm_unlink();
2953383Sdamico 
2960Sstevel@tonic-gate /* transitional large file interface version */
2970Sstevel@tonic-gate #if	defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
2980Sstevel@tonic-gate 	    !defined(__PRAGMA_REDEFINE_EXTNAME))
2990Sstevel@tonic-gate extern caddr_t mmap64();
3000Sstevel@tonic-gate #endif	/* _LARGEFILE64_SOURCE... */
3010Sstevel@tonic-gate #endif	/* __STDC__ */
3020Sstevel@tonic-gate 
3030Sstevel@tonic-gate 
3040Sstevel@tonic-gate #endif	/* !_ASM && !_KERNEL */
3050Sstevel@tonic-gate 
3060Sstevel@tonic-gate #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
3070Sstevel@tonic-gate #if !defined(_ASM)
3080Sstevel@tonic-gate /*
3090Sstevel@tonic-gate  * structure for memcntl hat advise operations.
3100Sstevel@tonic-gate  */
3110Sstevel@tonic-gate struct memcntl_mha {
3120Sstevel@tonic-gate 	uint_t 		mha_cmd;	/* command(s) */
3130Sstevel@tonic-gate 	uint_t		mha_flags;
3140Sstevel@tonic-gate 	size_t		mha_pagesize;
3150Sstevel@tonic-gate };
3160Sstevel@tonic-gate 
3170Sstevel@tonic-gate #if defined(_SYSCALL32)
3180Sstevel@tonic-gate struct memcntl_mha32 {
3190Sstevel@tonic-gate 	uint_t 		mha_cmd;	/* command(s) */
3200Sstevel@tonic-gate 	uint_t		mha_flags;
3210Sstevel@tonic-gate 	size32_t	mha_pagesize;
3220Sstevel@tonic-gate };
3230Sstevel@tonic-gate #endif	/* _SYSCALL32 */
3240Sstevel@tonic-gate #endif	/* !defined(_ASM) */
3250Sstevel@tonic-gate #endif	/* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
3260Sstevel@tonic-gate 
3270Sstevel@tonic-gate #if	(_POSIX_C_SOURCE <= 2) && !defined(_XPG4_2) || defined(__EXTENSIONS__)
3280Sstevel@tonic-gate /* advice to madvise */
3290Sstevel@tonic-gate #define	MADV_NORMAL		0	/* no further special treatment */
3300Sstevel@tonic-gate #define	MADV_RANDOM		1	/* expect random page references */
3310Sstevel@tonic-gate #define	MADV_SEQUENTIAL		2	/* expect sequential page references */
3320Sstevel@tonic-gate #define	MADV_WILLNEED		3	/* will need these pages */
3330Sstevel@tonic-gate #define	MADV_DONTNEED		4	/* don't need these pages */
3340Sstevel@tonic-gate #define	MADV_FREE		5	/* contents can be freed */
3350Sstevel@tonic-gate #define	MADV_ACCESS_DEFAULT	6	/* default access */
3360Sstevel@tonic-gate #define	MADV_ACCESS_LWP		7	/* next LWP to access heavily */
3370Sstevel@tonic-gate #define	MADV_ACCESS_MANY	8	/* many processes to access heavily */
3380Sstevel@tonic-gate #endif	/* (_POSIX_C_SOURCE <= 2) && !defined(_XPG4_2) ...  */
3390Sstevel@tonic-gate 
3407088Sraf #if !defined(__XOPEN_OR_POSIX) || defined(_XPG6) || defined(__EXTENSIONS__)
3417088Sraf /* advice to posix_madvise */
3427088Sraf /* these values must be kept in sync with the MADV_* values, above */
3437088Sraf #define	POSIX_MADV_NORMAL	0	/* MADV_NORMAL */
3447088Sraf #define	POSIX_MADV_RANDOM	1	/* MADV_RANDOM */
3457088Sraf #define	POSIX_MADV_SEQUENTIAL	2	/* MADV_SEQUENTIAL */
3467088Sraf #define	POSIX_MADV_WILLNEED	3	/* MADV_WILLNEED */
3477088Sraf #define	POSIX_MADV_DONTNEED	4	/* MADV_DONTNEED */
3487088Sraf #endif
3497088Sraf 
3500Sstevel@tonic-gate /* flags to msync */
3510Sstevel@tonic-gate #define	MS_OLDSYNC	0x0		/* old value of MS_SYNC */
3520Sstevel@tonic-gate 					/* modified for UNIX98 compliance */
3530Sstevel@tonic-gate #define	MS_SYNC		0x4		/* wait for msync */
3540Sstevel@tonic-gate #define	MS_ASYNC	0x1		/* return immediately */
3550Sstevel@tonic-gate #define	MS_INVALIDATE	0x2		/* invalidate caches */
3560Sstevel@tonic-gate 
3570Sstevel@tonic-gate #if	(_POSIX_C_SOURCE <= 2) && !defined(_XPG4_2) || defined(__EXTENSIONS__)
3580Sstevel@tonic-gate /* functions to mctl */
3590Sstevel@tonic-gate #define	MC_SYNC		1		/* sync with backing store */
3600Sstevel@tonic-gate #define	MC_LOCK		2		/* lock pages in memory */
3610Sstevel@tonic-gate #define	MC_UNLOCK	3		/* unlock pages from memory */
3620Sstevel@tonic-gate #define	MC_ADVISE	4		/* give advice to management */
3630Sstevel@tonic-gate #define	MC_LOCKAS	5		/* lock address space in memory */
3640Sstevel@tonic-gate #define	MC_UNLOCKAS	6		/* unlock address space from memory */
3650Sstevel@tonic-gate #define	MC_HAT_ADVISE	7		/* advise hat map size */
3660Sstevel@tonic-gate 
3670Sstevel@tonic-gate /* sub-commands for MC_HAT_ADVISE */
3680Sstevel@tonic-gate #define	MHA_MAPSIZE_VA		0x1	/* set preferred page size */
3690Sstevel@tonic-gate #define	MHA_MAPSIZE_BSSBRK	0x2	/* set preferred page size */
3700Sstevel@tonic-gate 					/* for last bss adjacent to */
3710Sstevel@tonic-gate 					/* brk area and brk area itself */
3720Sstevel@tonic-gate #define	MHA_MAPSIZE_STACK	0x4	/* set preferred page size */
3730Sstevel@tonic-gate 					/* processes main stack */
3740Sstevel@tonic-gate 
3750Sstevel@tonic-gate #endif	/* (_POSIX_C_SOURCE <= 2) && !defined(_XPG4_2) ... */
3760Sstevel@tonic-gate 
3770Sstevel@tonic-gate #if (!defined(_XPG4_2) || (_POSIX_C_SOURCE > 2)) || defined(__EXTENSIONS__)
3780Sstevel@tonic-gate /* flags to mlockall */
3790Sstevel@tonic-gate #define	MCL_CURRENT	0x1		/* lock current mappings */
3800Sstevel@tonic-gate #define	MCL_FUTURE	0x2		/* lock future mappings */
3810Sstevel@tonic-gate #endif /* (!defined(_XPG4_2) || (_POSIX_C_SOURCE)) || defined(__EXTENSIONS__) */
3820Sstevel@tonic-gate 
3830Sstevel@tonic-gate #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
3840Sstevel@tonic-gate 
3850Sstevel@tonic-gate /* definitions for meminfosys syscall */
3860Sstevel@tonic-gate #define	MISYS_MEMINFO		0x0
3870Sstevel@tonic-gate 
3880Sstevel@tonic-gate #if !defined(_ASM) && defined(__STDC__)
3890Sstevel@tonic-gate 
3900Sstevel@tonic-gate #if defined(_INT64_TYPE)
3910Sstevel@tonic-gate /* private structure for meminfo */
3920Sstevel@tonic-gate typedef struct meminfo {
3930Sstevel@tonic-gate 	const uint64_t *mi_inaddr;	/* array of input addresses */
3940Sstevel@tonic-gate 	const uint_t *mi_info_req;	/* array of types of info requested */
3950Sstevel@tonic-gate 	uint64_t *mi_outdata;		/* array of results are placed */
3960Sstevel@tonic-gate 	uint_t *mi_validity;		/* array of bitwise result codes */
3970Sstevel@tonic-gate 	int mi_info_count;		/* number of pieces of info requested */
3980Sstevel@tonic-gate } meminfo_t;
3990Sstevel@tonic-gate #endif /* defined(_INT64_TYPE) */
4000Sstevel@tonic-gate 
4010Sstevel@tonic-gate #if defined(_SYSCALL32)
4020Sstevel@tonic-gate typedef struct meminfo32 {
4030Sstevel@tonic-gate 	caddr32_t mi_inaddr;	/* array of input addresses */
4040Sstevel@tonic-gate 	caddr32_t mi_info_req;	/* array of types of information requested */
4050Sstevel@tonic-gate 	caddr32_t mi_outdata;	/* array of results are placed */
4060Sstevel@tonic-gate 	caddr32_t mi_validity;	/* array of bitwise result codes */
4070Sstevel@tonic-gate 	int32_t mi_info_count;	/* number of pieces of information requested */
4080Sstevel@tonic-gate } meminfo32_t;
4090Sstevel@tonic-gate #endif /* defined(_SYSCALL32) */
4100Sstevel@tonic-gate 
4110Sstevel@tonic-gate #endif /* !defined(_ASM) && defined(__STDC__) */
4120Sstevel@tonic-gate 
4130Sstevel@tonic-gate /*
4140Sstevel@tonic-gate  * info_req request type definitions for meminfo
4150Sstevel@tonic-gate  * request types starting with MEMINFO_V are used for Virtual addresses
4160Sstevel@tonic-gate  * and should not be mixed with MEMINFO_PLGRP which is targeted for Physical
4170Sstevel@tonic-gate  * addresses
4180Sstevel@tonic-gate  */
4190Sstevel@tonic-gate #define	MEMINFO_SHIFT		16
4200Sstevel@tonic-gate #define	MEMINFO_MASK		(0xFF << MEMINFO_SHIFT)
4210Sstevel@tonic-gate #define	MEMINFO_VPHYSICAL	(0x01 << MEMINFO_SHIFT)	/* get physical addr */
4220Sstevel@tonic-gate #define	MEMINFO_VLGRP		(0x02 << MEMINFO_SHIFT) /* get lgroup */
4230Sstevel@tonic-gate #define	MEMINFO_VPAGESIZE	(0x03 << MEMINFO_SHIFT) /* size of phys page */
4240Sstevel@tonic-gate #define	MEMINFO_VREPLCNT	(0x04 << MEMINFO_SHIFT) /* no. of replica */
4250Sstevel@tonic-gate #define	MEMINFO_VREPL		(0x05 << MEMINFO_SHIFT) /* physical replica */
4260Sstevel@tonic-gate #define	MEMINFO_VREPL_LGRP	(0x06 << MEMINFO_SHIFT) /* lgrp of replica */
4270Sstevel@tonic-gate #define	MEMINFO_PLGRP		(0x07 << MEMINFO_SHIFT) /* lgroup for paddr */
4280Sstevel@tonic-gate 
4290Sstevel@tonic-gate /* maximum number of addresses meminfo() can process at a time */
4300Sstevel@tonic-gate #define	MAX_MEMINFO_CNT	256
4310Sstevel@tonic-gate 
4320Sstevel@tonic-gate /* maximum number of request types */
4330Sstevel@tonic-gate #define	MAX_MEMINFO_REQ	31
4340Sstevel@tonic-gate 
4350Sstevel@tonic-gate #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
4360Sstevel@tonic-gate 
4370Sstevel@tonic-gate #ifdef	__cplusplus
4380Sstevel@tonic-gate }
4390Sstevel@tonic-gate #endif
4400Sstevel@tonic-gate 
4410Sstevel@tonic-gate #endif	/* _SYS_MMAN_H */
442