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