xref: /titanic_50/usr/src/lib/libbc/inc/include/sys/mman.h (revision b494511a9cf72b1fc4eb13a0e593f55c624ab829)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 1989 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _sys_mman_h
28 #define	_sys_mman_h
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 /*
33  * Protections are chosen from these bits, or-ed together.
34  * Note - not all implementations literally provide all possible
35  * combinations.  PROT_WRITE is often implemented as (PROT_READ |
36  * PROT_WRITE) and (PROT_EXECUTE as PROT_READ | PROT_EXECUTE).
37  * However, no implementation will permit a write to succeed
38  * where PROT_WRITE has not been set.  Also, no implementation will
39  * allow any access to succeed where prot is specified as PROT_NONE.
40  */
41 #define	PROT_READ	0x1		/* pages can be read */
42 #define	PROT_WRITE	0x2		/* pages can be written */
43 #define	PROT_EXEC	0x4		/* pages can be executed */
44 
45 #define	PROT_NONE	0x0		/* pages cannot be accessed */
46 
47 /* sharing types:  must choose either SHARED or PRIVATE */
48 #define	MAP_SHARED	1		/* share changes */
49 #define	MAP_PRIVATE	2		/* changes are private */
50 #define	MAP_TYPE	0xf		/* mask for share type */
51 
52 /* other flags to mmap (or-ed in to MAP_SHARED or MAP_PRIVATE) */
53 #define	MAP_FIXED	0x10		/* user assigns address */
54 
55 /* these flags not yet implemented */
56 #define	MAP_RENAME	0x20		/* rename private pages to file */
57 #define	MAP_NORESERVE	0x40		/* don't reserve needed swap area */
58 
59 /*
60  * For the sake of backward object compatibility, we use the _MAP_NEW flag.
61  * This flag will be automatically or'ed in by the C library for all
62  * new mmap calls.  Previous binaries with old mmap calls with continue
63  * to get 0 or -1 for return values.  New mmap calls will get the mapped
64  * address as the return value if successful and -1 on errors.  By default,
65  * new mmap calls automatically have the kernel assign the map address
66  * unless the MAP_FIXED flag is given.
67  */
68 #define	_MAP_NEW	0x80000000	/* user's should not need to use this */
69 
70 #if !defined(LOCORE) && !defined(KERNEL)
71 #include <sys/types.h>
72 
73 /*
74  * Except for old binaries mmap() will return the resultant
75  * address of mapping on success and (caddr_t)-1 on error.
76  */
77 extern caddr_t mmap();
78 #endif	/* !LOCORE && !KERNEL */
79 
80 /* advice to madvise */
81 #define	MADV_NORMAL	0		/* no further special treatment */
82 #define	MADV_RANDOM	1		/* expect random page references */
83 #define	MADV_SEQUENTIAL	2		/* expect sequential page references */
84 #define	MADV_WILLNEED	3		/* will need these pages */
85 #define	MADV_DONTNEED	4		/* don't need these pages */
86 
87 /* flags to msync */
88 #define	MS_ASYNC	0x1		/* return immediately */
89 #define	MS_INVALIDATE	0x2		/* invalidate caches */
90 
91 /* functions to mctl */
92 #define	MC_SYNC		1		/* sync with backing store */
93 #define	MC_LOCK		2		/* lock pages in memory */
94 #define	MC_UNLOCK	3		/* unlock pages from memory */
95 #define	MC_ADVISE	4		/* give advice to management */
96 #define	MC_LOCKAS	5		/* lock address space in memory */
97 #define	MC_UNLOCKAS	6		/* unlock address space from memory */
98 
99 /* flags to mlockall */
100 #define	MCL_CURRENT	0x1		/* lock current mappings */
101 #define	MCL_FUTURE	0x2		/* lock future mappings */
102 
103 #endif /* !_sys_mman_h */
104