xref: /illumos-gate/usr/src/uts/common/sys/mman.h (revision ba3594ba)
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
5bfe60e20Sdamico  * Common Development and Distribution License (the "License").
6bfe60e20Sdamico  * 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  */
21019c3c43Sraf 
221b3b16f3STheo Schlossnagle /* Copyright 2013 OmniTI Computer Consulting, Inc. All rights reserved. */
237c478bd9Sstevel@tonic-gate /*
24*ba3594baSGarrett D'Amore  * Copyright 2014 Garrett D'Amore <garrett@damore.org>
25*ba3594baSGarrett D'Amore  *
26019c3c43Sraf  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
277c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
287c478bd9Sstevel@tonic-gate  */
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate /*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
317c478bd9Sstevel@tonic-gate /*	  All Rights Reserved	*/
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate /*
347c478bd9Sstevel@tonic-gate  * University Copyright- Copyright (c) 1982, 1986, 1988
357c478bd9Sstevel@tonic-gate  * The Regents of the University of California
367c478bd9Sstevel@tonic-gate  * All Rights Reserved
377c478bd9Sstevel@tonic-gate  *
387c478bd9Sstevel@tonic-gate  * University Acknowledgment- Portions of this document are derived from
397c478bd9Sstevel@tonic-gate  * software developed by the University of California, Berkeley, and its
407c478bd9Sstevel@tonic-gate  * contributors.
417c478bd9Sstevel@tonic-gate  */
427c478bd9Sstevel@tonic-gate 
437c478bd9Sstevel@tonic-gate #ifndef	_SYS_MMAN_H
447c478bd9Sstevel@tonic-gate #define	_SYS_MMAN_H
457c478bd9Sstevel@tonic-gate 
467c478bd9Sstevel@tonic-gate #include <sys/feature_tests.h>
477c478bd9Sstevel@tonic-gate 
487c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
497c478bd9Sstevel@tonic-gate extern "C" {
507c478bd9Sstevel@tonic-gate #endif
517c478bd9Sstevel@tonic-gate 
5231c6c9d8SMichael Corcoran #if	!defined(_ASM) && !defined(_KERNEL)
5331c6c9d8SMichael Corcoran #include <sys/types.h>
5431c6c9d8SMichael Corcoran #endif	/* !_ASM && !_KERNEL */
5531c6c9d8SMichael Corcoran 
567c478bd9Sstevel@tonic-gate /*
577c478bd9Sstevel@tonic-gate  * Protections are chosen from these bits, or-ed together.
587c478bd9Sstevel@tonic-gate  * Note - not all implementations literally provide all possible
597c478bd9Sstevel@tonic-gate  * combinations.  PROT_WRITE is often implemented as (PROT_READ |
607c478bd9Sstevel@tonic-gate  * PROT_WRITE) and (PROT_EXECUTE as PROT_READ | PROT_EXECUTE).
617c478bd9Sstevel@tonic-gate  * However, no implementation will permit a write to succeed
627c478bd9Sstevel@tonic-gate  * where PROT_WRITE has not been set.  Also, no implementation will
637c478bd9Sstevel@tonic-gate  * allow any access to succeed where prot is specified as PROT_NONE.
647c478bd9Sstevel@tonic-gate  */
657c478bd9Sstevel@tonic-gate #define	PROT_READ	0x1		/* pages can be read */
667c478bd9Sstevel@tonic-gate #define	PROT_WRITE	0x2		/* pages can be written */
677c478bd9Sstevel@tonic-gate #define	PROT_EXEC	0x4		/* pages can be executed */
687c478bd9Sstevel@tonic-gate 
697c478bd9Sstevel@tonic-gate #ifdef	_KERNEL
707c478bd9Sstevel@tonic-gate #define	PROT_USER	0x8		/* pages are user accessable */
717c478bd9Sstevel@tonic-gate #define	PROT_ZFOD	(PROT_READ | PROT_WRITE | PROT_EXEC | PROT_USER)
727c478bd9Sstevel@tonic-gate #define	PROT_ALL	(PROT_READ | PROT_WRITE | PROT_EXEC | PROT_USER)
737c478bd9Sstevel@tonic-gate #endif	/* _KERNEL */
747c478bd9Sstevel@tonic-gate 
757c478bd9Sstevel@tonic-gate #define	PROT_NONE	0x0		/* pages cannot be accessed */
767c478bd9Sstevel@tonic-gate 
777c478bd9Sstevel@tonic-gate /* sharing types:  must choose either SHARED or PRIVATE */
787c478bd9Sstevel@tonic-gate #define	MAP_SHARED	1		/* share changes */
797c478bd9Sstevel@tonic-gate #define	MAP_PRIVATE	2		/* changes are private */
807c478bd9Sstevel@tonic-gate #define	MAP_TYPE	0xf		/* mask for share type */
817c478bd9Sstevel@tonic-gate 
827c478bd9Sstevel@tonic-gate /* other flags to mmap (or-ed in to MAP_SHARED or MAP_PRIVATE) */
837c478bd9Sstevel@tonic-gate #define	MAP_FIXED	0x10		/* user assigns address */
847c478bd9Sstevel@tonic-gate #define	MAP_NORESERVE	0x40		/* don't reserve needed swap area */
857c478bd9Sstevel@tonic-gate #define	MAP_ANON	0x100		/* map anonymous pages directly */
867c478bd9Sstevel@tonic-gate #define	MAP_ANONYMOUS	MAP_ANON	/* (source compatibility) */
877c478bd9Sstevel@tonic-gate #define	MAP_ALIGN	0x200		/* addr specifies alignment */
887c478bd9Sstevel@tonic-gate #define	MAP_TEXT	0x400		/* map code segment */
897c478bd9Sstevel@tonic-gate #define	MAP_INITDATA	0x800		/* map data segment */
907c478bd9Sstevel@tonic-gate 
912cb27123Saguzovsk #ifdef _KERNEL
922cb27123Saguzovsk #define	_MAP_TEXTREPL	0x1000
932cb27123Saguzovsk #endif /* _KERNEL */
942cb27123Saguzovsk 
957c478bd9Sstevel@tonic-gate /* these flags not yet implemented */
967c478bd9Sstevel@tonic-gate #define	MAP_RENAME	0x20		/* rename private pages to file */
977c478bd9Sstevel@tonic-gate 
987c478bd9Sstevel@tonic-gate #if	(_POSIX_C_SOURCE <= 2) && !defined(_XPG4_2)
997c478bd9Sstevel@tonic-gate /* these flags are used by memcntl */
1007c478bd9Sstevel@tonic-gate #define	PROC_TEXT	(PROT_EXEC | PROT_READ)
1017c478bd9Sstevel@tonic-gate #define	PROC_DATA	(PROT_READ | PROT_WRITE | PROT_EXEC)
1027c478bd9Sstevel@tonic-gate #define	SHARED		0x10
1037c478bd9Sstevel@tonic-gate #define	PRIVATE		0x20
1047c478bd9Sstevel@tonic-gate #define	VALID_ATTR  (PROT_READ|PROT_WRITE|PROT_EXEC|SHARED|PRIVATE)
1057c478bd9Sstevel@tonic-gate #endif	/* (_POSIX_C_SOURCE <= 2) && !defined(_XPG4_2) */
1067c478bd9Sstevel@tonic-gate 
1077c478bd9Sstevel@tonic-gate #if	(_POSIX_C_SOURCE <= 2) || defined(_XPG4_2)
1087c478bd9Sstevel@tonic-gate #ifdef	_KERNEL
1097c478bd9Sstevel@tonic-gate #define	PROT_EXCL	0x20
1107c478bd9Sstevel@tonic-gate #endif	/* _KERNEL */
1117c478bd9Sstevel@tonic-gate 
1121b3b16f3STheo Schlossnagle #define	_MAP_LOW32	0x80	/* force mapping in lower 4G of address space */
1131b3b16f3STheo Schlossnagle #define	MAP_32BIT	_MAP_LOW32
1141b3b16f3STheo Schlossnagle 
1157c478bd9Sstevel@tonic-gate /*
1167c478bd9Sstevel@tonic-gate  * For the sake of backward object compatibility, we use the _MAP_NEW flag.
1177c478bd9Sstevel@tonic-gate  * This flag will be automatically or'ed in by the C library for all
1187c478bd9Sstevel@tonic-gate  * new mmap calls.  Previous binaries with old mmap calls will continue
1197c478bd9Sstevel@tonic-gate  * to get 0 or -1 for return values.  New mmap calls will get the mapped
1207c478bd9Sstevel@tonic-gate  * address as the return value if successful and -1 on errors.  By default,
1217c478bd9Sstevel@tonic-gate  * new mmap calls automatically have the kernel assign the map address
1227c478bd9Sstevel@tonic-gate  * unless the MAP_FIXED flag is given.
1237c478bd9Sstevel@tonic-gate  */
1247c478bd9Sstevel@tonic-gate #define	_MAP_NEW	0x80000000	/* users should not need to use this */
1257c478bd9Sstevel@tonic-gate #endif	/* (_POSIX_C_SOURCE <= 2) */
1267c478bd9Sstevel@tonic-gate 
1270616c1c3SMichael Corcoran 
12831c6c9d8SMichael Corcoran #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
1290616c1c3SMichael Corcoran /* External flags for mmapobj syscall (Exclusive of MAP_* flags above) */
1300616c1c3SMichael Corcoran #define	MMOBJ_PADDING		0x10000
1310616c1c3SMichael Corcoran #define	MMOBJ_INTERPRET		0x20000
1320616c1c3SMichael Corcoran 
1330616c1c3SMichael Corcoran #define	MMOBJ_ALL_FLAGS		(MMOBJ_PADDING | MMOBJ_INTERPRET)
1340616c1c3SMichael Corcoran 
1350616c1c3SMichael Corcoran /*
1360616c1c3SMichael Corcoran  * Values for mr_flags field of mmapobj_result_t below.
1370616c1c3SMichael Corcoran  * The bottom 16 bits are mutually exclusive and thus only one
1380616c1c3SMichael Corcoran  * of them can be set at a time.  Use MR_GET_TYPE below to check this value.
1390616c1c3SMichael Corcoran  * The top 16 bits are used for flags which are not mutually exclusive and
1400616c1c3SMichael Corcoran  * thus more than one of these flags can be set for a given mmapobj_result_t.
1410616c1c3SMichael Corcoran  *
1420616c1c3SMichael Corcoran  * MR_PADDING being set indicates that this memory range represents the user
1430616c1c3SMichael Corcoran  * requested padding.
1440616c1c3SMichael Corcoran  *
1450616c1c3SMichael Corcoran  * MR_HDR_ELF being set indicates that the ELF header of the mapped object
1460616c1c3SMichael Corcoran  * is mapped at mr_addr + mr_offset.
1470616c1c3SMichael Corcoran  *
1480616c1c3SMichael Corcoran  * MR_HDR_AOUT being set indicates that the AOUT (4.x) header of the mapped
1490616c1c3SMichael Corcoran  * object is mapped at mr_addr + mr_offset.
1500616c1c3SMichael Corcoran  */
1510616c1c3SMichael Corcoran 
1520616c1c3SMichael Corcoran /*
1530616c1c3SMichael Corcoran  * External flags for mr_flags field below.
1540616c1c3SMichael Corcoran  */
1550616c1c3SMichael Corcoran #define	MR_PADDING	0x1
1560616c1c3SMichael Corcoran #define	MR_HDR_ELF	0x2
1570616c1c3SMichael Corcoran #define	MR_HDR_AOUT	0x3
1580616c1c3SMichael Corcoran 
1590616c1c3SMichael Corcoran /*
1600616c1c3SMichael Corcoran  * Internal flags for mr_flags field below.
1610616c1c3SMichael Corcoran  */
1620616c1c3SMichael Corcoran #ifdef	_KERNEL
1630616c1c3SMichael Corcoran #define	MR_RESV	0x80000000	/* overmapped /dev/null */
1640616c1c3SMichael Corcoran #endif	/* _KERNEL */
1650616c1c3SMichael Corcoran 
1660616c1c3SMichael Corcoran #define	MR_TYPE_MASK 0x0000ffff
1670616c1c3SMichael Corcoran #define	MR_GET_TYPE(val)	((val) & MR_TYPE_MASK)
1680616c1c3SMichael Corcoran 
1690616c1c3SMichael Corcoran #if	!defined(_ASM)
1700616c1c3SMichael Corcoran typedef struct mmapobj_result {
1710616c1c3SMichael Corcoran 	caddr_t		mr_addr;	/* mapping address */
1720616c1c3SMichael Corcoran 	size_t		mr_msize;	/* mapping size */
1730616c1c3SMichael Corcoran 	size_t		mr_fsize;	/* file size */
1740616c1c3SMichael Corcoran 	size_t		mr_offset;	/* offset into file */
1750616c1c3SMichael Corcoran 	uint_t		mr_prot;	/* the protections provided */
1760616c1c3SMichael Corcoran 	uint_t		mr_flags;	/* info on the mapping */
1770616c1c3SMichael Corcoran } mmapobj_result_t;
1780616c1c3SMichael Corcoran 
1790616c1c3SMichael Corcoran #if defined(_KERNEL) || defined(_SYSCALL32)
1800616c1c3SMichael Corcoran typedef struct mmapobj_result32 {
1810616c1c3SMichael Corcoran 	caddr32_t	mr_addr;	/* mapping address */
1820616c1c3SMichael Corcoran 	size32_t	mr_msize;	/* mapping size */
1830616c1c3SMichael Corcoran 	size32_t	mr_fsize;	/* file size */
1840616c1c3SMichael Corcoran 	size32_t	mr_offset;	/* offset into file */
1850616c1c3SMichael Corcoran 	uint_t		mr_prot;	/* the protections provided */
1860616c1c3SMichael Corcoran 	uint_t		mr_flags;	/* info on the mapping */
1870616c1c3SMichael Corcoran } mmapobj_result32_t;
1880616c1c3SMichael Corcoran #endif	/* defined(_KERNEL) || defined(_SYSCALL32) */
1890616c1c3SMichael Corcoran #endif	/* !defined(_ASM) */
19031c6c9d8SMichael Corcoran #endif	/* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
1910616c1c3SMichael Corcoran 
1920616c1c3SMichael Corcoran #if	!defined(_ASM) && !defined(_KERNEL)
1937c478bd9Sstevel@tonic-gate /*
1947c478bd9Sstevel@tonic-gate  * large file compilation environment setup
1957c478bd9Sstevel@tonic-gate  *
1967c478bd9Sstevel@tonic-gate  * In the LP64 compilation environment, map large file interfaces
1977c478bd9Sstevel@tonic-gate  * back to native versions where possible.
1987c478bd9Sstevel@tonic-gate  */
1997c478bd9Sstevel@tonic-gate 
2007c478bd9Sstevel@tonic-gate #if !defined(_LP64) && _FILE_OFFSET_BITS == 64
2017c478bd9Sstevel@tonic-gate #ifdef	__PRAGMA_REDEFINE_EXTNAME
2027c478bd9Sstevel@tonic-gate #pragma redefine_extname	mmap	mmap64
2037c478bd9Sstevel@tonic-gate #else
2047c478bd9Sstevel@tonic-gate #define	mmap			mmap64
2057c478bd9Sstevel@tonic-gate #endif
2067c478bd9Sstevel@tonic-gate #endif /* !_LP64 && _FILE_OFFSET_BITS == 64 */
2077c478bd9Sstevel@tonic-gate 
2087c478bd9Sstevel@tonic-gate #if defined(_LP64) && defined(_LARGEFILE64_SOURCE)
2097c478bd9Sstevel@tonic-gate #ifdef	__PRAGMA_REDEFINE_EXTNAME
2107c478bd9Sstevel@tonic-gate #pragma	redefine_extname	mmap64	mmap
2117c478bd9Sstevel@tonic-gate #else
2127c478bd9Sstevel@tonic-gate #define	mmap64			mmap
2137c478bd9Sstevel@tonic-gate #endif
2147c478bd9Sstevel@tonic-gate #endif	/* _LP64 && _LARGEFILE64_SOURCE */
2157c478bd9Sstevel@tonic-gate 
21602bc52beSkchow #ifdef __PRAGMA_REDEFINE_EXTNAME
21702bc52beSkchow #pragma redefine_extname	getpagesizes	getpagesizes2
21802bc52beSkchow #else
21902bc52beSkchow #define	getpagesizes	getpagesizes2
22002bc52beSkchow #endif
22102bc52beSkchow 
2227c478bd9Sstevel@tonic-gate /*
2237c478bd9Sstevel@tonic-gate  * Except for old binaries mmap() will return the resultant
2247c478bd9Sstevel@tonic-gate  * address of mapping on success and (caddr_t)-1 on error.
2257c478bd9Sstevel@tonic-gate  */
2267c478bd9Sstevel@tonic-gate #if (_POSIX_C_SOURCE > 2) || defined(_XPG4_2)
2277c478bd9Sstevel@tonic-gate extern void *mmap(void *, size_t, int, int, int, off_t);
2287c478bd9Sstevel@tonic-gate extern int munmap(void *, size_t);
2297c478bd9Sstevel@tonic-gate extern int mprotect(void *, size_t, int);
2307c478bd9Sstevel@tonic-gate extern int msync(void *, size_t, int);
2317c478bd9Sstevel@tonic-gate #if (!defined(_XPG4_2) || (_POSIX_C_SOURCE > 2)) || defined(__EXTENSIONS__)
2327c478bd9Sstevel@tonic-gate extern int mlock(const void *, size_t);
2337c478bd9Sstevel@tonic-gate extern int munlock(const void *, size_t);
2347c478bd9Sstevel@tonic-gate #endif	/* (!defined(_XPG4_2) || (_POSIX_C_SOURCE > 2))... */
2357c478bd9Sstevel@tonic-gate /* transitional large file interface version */
2367c478bd9Sstevel@tonic-gate #if	defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
2377c478bd9Sstevel@tonic-gate 	    !defined(__PRAGMA_REDEFINE_EXTNAME))
2387c478bd9Sstevel@tonic-gate extern void *mmap64(void *, size_t, int, int, int, off64_t);
2397c478bd9Sstevel@tonic-gate #endif	/* _LARGEFILE64_SOURCE... */
2407c478bd9Sstevel@tonic-gate #else	/* (_POSIX_C_SOURCE > 2) || defined(_XPG4_2) */
2417c478bd9Sstevel@tonic-gate extern caddr_t mmap(caddr_t, size_t, int, int, int, off_t);
2427c478bd9Sstevel@tonic-gate extern int munmap(caddr_t, size_t);
2437c478bd9Sstevel@tonic-gate extern int mprotect(caddr_t, size_t, int);
2447c478bd9Sstevel@tonic-gate extern int msync(caddr_t, size_t, int);
2457c478bd9Sstevel@tonic-gate extern int mlock(caddr_t, size_t);
2467c478bd9Sstevel@tonic-gate extern int munlock(caddr_t, size_t);
2477c478bd9Sstevel@tonic-gate extern int mincore(caddr_t, size_t, char *);
2487c478bd9Sstevel@tonic-gate extern int memcntl(caddr_t, size_t, int, caddr_t, int, int);
2497c478bd9Sstevel@tonic-gate extern int madvise(caddr_t, size_t, int);
2507c478bd9Sstevel@tonic-gate #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
2517c478bd9Sstevel@tonic-gate extern int getpagesizes(size_t *, int);
25202bc52beSkchow extern int getpagesizes2(size_t *, int);
25331c6c9d8SMichael Corcoran extern int mmapobj(int, uint_t, mmapobj_result_t *, uint_t *, void *);
2547c478bd9Sstevel@tonic-gate /* guard visibility of uint64_t */
2557c478bd9Sstevel@tonic-gate #if defined(_INT64_TYPE)
2567c478bd9Sstevel@tonic-gate extern int meminfo(const uint64_t *, int, const uint_t *, int, uint64_t *,
2577c478bd9Sstevel@tonic-gate 	uint_t *);
2587c478bd9Sstevel@tonic-gate #endif /* defined(_INT64_TYPE) */
2597c478bd9Sstevel@tonic-gate #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
2607c478bd9Sstevel@tonic-gate /* transitional large file interface version */
2617c478bd9Sstevel@tonic-gate #ifdef	_LARGEFILE64_SOURCE
2627c478bd9Sstevel@tonic-gate extern caddr_t mmap64(caddr_t, size_t, int, int, int, off64_t);
2637c478bd9Sstevel@tonic-gate #endif
2647c478bd9Sstevel@tonic-gate #endif	/* (_POSIX_C_SOURCE > 2)  || defined(_XPG4_2) */
2657c478bd9Sstevel@tonic-gate 
2667c478bd9Sstevel@tonic-gate #if (!defined(_XPG4_2) || (_POSIX_C_SOURCE > 2)) || defined(__EXTENSIONS__)
2677c478bd9Sstevel@tonic-gate extern int mlockall(int);
2687c478bd9Sstevel@tonic-gate extern int munlockall(void);
269bfe60e20Sdamico extern int shm_open(const char *, int, mode_t);
270bfe60e20Sdamico extern int shm_unlink(const char *);
2717c478bd9Sstevel@tonic-gate #endif
2727c478bd9Sstevel@tonic-gate 
273019c3c43Sraf #if !defined(__XOPEN_OR_POSIX) || defined(_XPG6) || defined(__EXTENSIONS__)
274019c3c43Sraf extern int posix_madvise(void *, size_t, int);
275019c3c43Sraf #endif
276019c3c43Sraf 
2777c478bd9Sstevel@tonic-gate /* mmap failure value */
2787c478bd9Sstevel@tonic-gate #define	MAP_FAILED	((void *) -1)
2797c478bd9Sstevel@tonic-gate 
2807c478bd9Sstevel@tonic-gate 
2817c478bd9Sstevel@tonic-gate #endif	/* !_ASM && !_KERNEL */
2827c478bd9Sstevel@tonic-gate 
2837c478bd9Sstevel@tonic-gate #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
2847c478bd9Sstevel@tonic-gate #if !defined(_ASM)
2857c478bd9Sstevel@tonic-gate /*
2867c478bd9Sstevel@tonic-gate  * structure for memcntl hat advise operations.
2877c478bd9Sstevel@tonic-gate  */
2887c478bd9Sstevel@tonic-gate struct memcntl_mha {
2897c478bd9Sstevel@tonic-gate 	uint_t 		mha_cmd;	/* command(s) */
2907c478bd9Sstevel@tonic-gate 	uint_t		mha_flags;
2917c478bd9Sstevel@tonic-gate 	size_t		mha_pagesize;
2927c478bd9Sstevel@tonic-gate };
2937c478bd9Sstevel@tonic-gate 
2947c478bd9Sstevel@tonic-gate #if defined(_SYSCALL32)
2957c478bd9Sstevel@tonic-gate struct memcntl_mha32 {
2967c478bd9Sstevel@tonic-gate 	uint_t 		mha_cmd;	/* command(s) */
2977c478bd9Sstevel@tonic-gate 	uint_t		mha_flags;
2987c478bd9Sstevel@tonic-gate 	size32_t	mha_pagesize;
2997c478bd9Sstevel@tonic-gate };
3007c478bd9Sstevel@tonic-gate #endif	/* _SYSCALL32 */
3017c478bd9Sstevel@tonic-gate #endif	/* !defined(_ASM) */
3027c478bd9Sstevel@tonic-gate #endif	/* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
3037c478bd9Sstevel@tonic-gate 
3047c478bd9Sstevel@tonic-gate #if	(_POSIX_C_SOURCE <= 2) && !defined(_XPG4_2) || defined(__EXTENSIONS__)
3057c478bd9Sstevel@tonic-gate /* advice to madvise */
3067c478bd9Sstevel@tonic-gate #define	MADV_NORMAL		0	/* no further special treatment */
3077c478bd9Sstevel@tonic-gate #define	MADV_RANDOM		1	/* expect random page references */
3087c478bd9Sstevel@tonic-gate #define	MADV_SEQUENTIAL		2	/* expect sequential page references */
3097c478bd9Sstevel@tonic-gate #define	MADV_WILLNEED		3	/* will need these pages */
3107c478bd9Sstevel@tonic-gate #define	MADV_DONTNEED		4	/* don't need these pages */
3117c478bd9Sstevel@tonic-gate #define	MADV_FREE		5	/* contents can be freed */
3127c478bd9Sstevel@tonic-gate #define	MADV_ACCESS_DEFAULT	6	/* default access */
3137c478bd9Sstevel@tonic-gate #define	MADV_ACCESS_LWP		7	/* next LWP to access heavily */
3147c478bd9Sstevel@tonic-gate #define	MADV_ACCESS_MANY	8	/* many processes to access heavily */
3157c478bd9Sstevel@tonic-gate #endif	/* (_POSIX_C_SOURCE <= 2) && !defined(_XPG4_2) ...  */
3167c478bd9Sstevel@tonic-gate 
317019c3c43Sraf #if !defined(__XOPEN_OR_POSIX) || defined(_XPG6) || defined(__EXTENSIONS__)
318019c3c43Sraf /* advice to posix_madvise */
319019c3c43Sraf /* these values must be kept in sync with the MADV_* values, above */
320019c3c43Sraf #define	POSIX_MADV_NORMAL	0	/* MADV_NORMAL */
321019c3c43Sraf #define	POSIX_MADV_RANDOM	1	/* MADV_RANDOM */
322019c3c43Sraf #define	POSIX_MADV_SEQUENTIAL	2	/* MADV_SEQUENTIAL */
323019c3c43Sraf #define	POSIX_MADV_WILLNEED	3	/* MADV_WILLNEED */
324019c3c43Sraf #define	POSIX_MADV_DONTNEED	4	/* MADV_DONTNEED */
325019c3c43Sraf #endif
326019c3c43Sraf 
3277c478bd9Sstevel@tonic-gate /* flags to msync */
3287c478bd9Sstevel@tonic-gate #define	MS_OLDSYNC	0x0		/* old value of MS_SYNC */
3297c478bd9Sstevel@tonic-gate 					/* modified for UNIX98 compliance */
3307c478bd9Sstevel@tonic-gate #define	MS_SYNC		0x4		/* wait for msync */
3317c478bd9Sstevel@tonic-gate #define	MS_ASYNC	0x1		/* return immediately */
3327c478bd9Sstevel@tonic-gate #define	MS_INVALIDATE	0x2		/* invalidate caches */
3337c478bd9Sstevel@tonic-gate 
3347c478bd9Sstevel@tonic-gate #if	(_POSIX_C_SOURCE <= 2) && !defined(_XPG4_2) || defined(__EXTENSIONS__)
3357c478bd9Sstevel@tonic-gate /* functions to mctl */
3367c478bd9Sstevel@tonic-gate #define	MC_SYNC		1		/* sync with backing store */
3377c478bd9Sstevel@tonic-gate #define	MC_LOCK		2		/* lock pages in memory */
3387c478bd9Sstevel@tonic-gate #define	MC_UNLOCK	3		/* unlock pages from memory */
3397c478bd9Sstevel@tonic-gate #define	MC_ADVISE	4		/* give advice to management */
3407c478bd9Sstevel@tonic-gate #define	MC_LOCKAS	5		/* lock address space in memory */
3417c478bd9Sstevel@tonic-gate #define	MC_UNLOCKAS	6		/* unlock address space from memory */
3427c478bd9Sstevel@tonic-gate #define	MC_HAT_ADVISE	7		/* advise hat map size */
3437c478bd9Sstevel@tonic-gate 
3447c478bd9Sstevel@tonic-gate /* sub-commands for MC_HAT_ADVISE */
3457c478bd9Sstevel@tonic-gate #define	MHA_MAPSIZE_VA		0x1	/* set preferred page size */
3467c478bd9Sstevel@tonic-gate #define	MHA_MAPSIZE_BSSBRK	0x2	/* set preferred page size */
3477c478bd9Sstevel@tonic-gate 					/* for last bss adjacent to */
3487c478bd9Sstevel@tonic-gate 					/* brk area and brk area itself */
3497c478bd9Sstevel@tonic-gate #define	MHA_MAPSIZE_STACK	0x4	/* set preferred page size */
3507c478bd9Sstevel@tonic-gate 					/* processes main stack */
3517c478bd9Sstevel@tonic-gate 
3527c478bd9Sstevel@tonic-gate #endif	/* (_POSIX_C_SOURCE <= 2) && !defined(_XPG4_2) ... */
3537c478bd9Sstevel@tonic-gate 
3547c478bd9Sstevel@tonic-gate #if (!defined(_XPG4_2) || (_POSIX_C_SOURCE > 2)) || defined(__EXTENSIONS__)
3557c478bd9Sstevel@tonic-gate /* flags to mlockall */
3567c478bd9Sstevel@tonic-gate #define	MCL_CURRENT	0x1		/* lock current mappings */
3577c478bd9Sstevel@tonic-gate #define	MCL_FUTURE	0x2		/* lock future mappings */
3587c478bd9Sstevel@tonic-gate #endif /* (!defined(_XPG4_2) || (_POSIX_C_SOURCE)) || defined(__EXTENSIONS__) */
3597c478bd9Sstevel@tonic-gate 
3607c478bd9Sstevel@tonic-gate #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
3617c478bd9Sstevel@tonic-gate 
3627c478bd9Sstevel@tonic-gate /* definitions for meminfosys syscall */
3637c478bd9Sstevel@tonic-gate #define	MISYS_MEMINFO		0x0
3647c478bd9Sstevel@tonic-gate 
365*ba3594baSGarrett D'Amore #if !defined(_ASM)
3667c478bd9Sstevel@tonic-gate 
3677c478bd9Sstevel@tonic-gate #if defined(_INT64_TYPE)
3687c478bd9Sstevel@tonic-gate /* private structure for meminfo */
3697c478bd9Sstevel@tonic-gate typedef struct meminfo {
3707c478bd9Sstevel@tonic-gate 	const uint64_t *mi_inaddr;	/* array of input addresses */
3717c478bd9Sstevel@tonic-gate 	const uint_t *mi_info_req;	/* array of types of info requested */
3727c478bd9Sstevel@tonic-gate 	uint64_t *mi_outdata;		/* array of results are placed */
3737c478bd9Sstevel@tonic-gate 	uint_t *mi_validity;		/* array of bitwise result codes */
3747c478bd9Sstevel@tonic-gate 	int mi_info_count;		/* number of pieces of info requested */
3757c478bd9Sstevel@tonic-gate } meminfo_t;
3767c478bd9Sstevel@tonic-gate #endif /* defined(_INT64_TYPE) */
3777c478bd9Sstevel@tonic-gate 
3787c478bd9Sstevel@tonic-gate #if defined(_SYSCALL32)
3797c478bd9Sstevel@tonic-gate typedef struct meminfo32 {
3807c478bd9Sstevel@tonic-gate 	caddr32_t mi_inaddr;	/* array of input addresses */
3817c478bd9Sstevel@tonic-gate 	caddr32_t mi_info_req;	/* array of types of information requested */
3827c478bd9Sstevel@tonic-gate 	caddr32_t mi_outdata;	/* array of results are placed */
3837c478bd9Sstevel@tonic-gate 	caddr32_t mi_validity;	/* array of bitwise result codes */
3847c478bd9Sstevel@tonic-gate 	int32_t mi_info_count;	/* number of pieces of information requested */
3857c478bd9Sstevel@tonic-gate } meminfo32_t;
3867c478bd9Sstevel@tonic-gate #endif /* defined(_SYSCALL32) */
3877c478bd9Sstevel@tonic-gate 
388*ba3594baSGarrett D'Amore #endif /* !defined(_ASM) */
3897c478bd9Sstevel@tonic-gate 
3907c478bd9Sstevel@tonic-gate /*
3917c478bd9Sstevel@tonic-gate  * info_req request type definitions for meminfo
3927c478bd9Sstevel@tonic-gate  * request types starting with MEMINFO_V are used for Virtual addresses
3937c478bd9Sstevel@tonic-gate  * and should not be mixed with MEMINFO_PLGRP which is targeted for Physical
3947c478bd9Sstevel@tonic-gate  * addresses
3957c478bd9Sstevel@tonic-gate  */
3967c478bd9Sstevel@tonic-gate #define	MEMINFO_SHIFT		16
3977c478bd9Sstevel@tonic-gate #define	MEMINFO_MASK		(0xFF << MEMINFO_SHIFT)
3987c478bd9Sstevel@tonic-gate #define	MEMINFO_VPHYSICAL	(0x01 << MEMINFO_SHIFT)	/* get physical addr */
3997c478bd9Sstevel@tonic-gate #define	MEMINFO_VLGRP		(0x02 << MEMINFO_SHIFT) /* get lgroup */
4007c478bd9Sstevel@tonic-gate #define	MEMINFO_VPAGESIZE	(0x03 << MEMINFO_SHIFT) /* size of phys page */
4017c478bd9Sstevel@tonic-gate #define	MEMINFO_VREPLCNT	(0x04 << MEMINFO_SHIFT) /* no. of replica */
4027c478bd9Sstevel@tonic-gate #define	MEMINFO_VREPL		(0x05 << MEMINFO_SHIFT) /* physical replica */
4037c478bd9Sstevel@tonic-gate #define	MEMINFO_VREPL_LGRP	(0x06 << MEMINFO_SHIFT) /* lgrp of replica */
4047c478bd9Sstevel@tonic-gate #define	MEMINFO_PLGRP		(0x07 << MEMINFO_SHIFT) /* lgroup for paddr */
4057c478bd9Sstevel@tonic-gate 
4067c478bd9Sstevel@tonic-gate /* maximum number of addresses meminfo() can process at a time */
4077c478bd9Sstevel@tonic-gate #define	MAX_MEMINFO_CNT	256
4087c478bd9Sstevel@tonic-gate 
4097c478bd9Sstevel@tonic-gate /* maximum number of request types */
4107c478bd9Sstevel@tonic-gate #define	MAX_MEMINFO_REQ	31
4117c478bd9Sstevel@tonic-gate 
4127c478bd9Sstevel@tonic-gate #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
4137c478bd9Sstevel@tonic-gate 
4147c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
4157c478bd9Sstevel@tonic-gate }
4167c478bd9Sstevel@tonic-gate #endif
4177c478bd9Sstevel@tonic-gate 
4187c478bd9Sstevel@tonic-gate #endif	/* _SYS_MMAN_H */
419