RTEMS CPU Kit with SuperCore  4.11.3
mman.h
Go to the documentation of this file.
1 /* $NetBSD: mman.h,v 1.36 2005/09/13 01:42:51 christos Exp $ */
2 
3 /*-
4  * Copyright (c) 1982, 1986, 1993
5  * The Regents of the University of California. All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  * 3. Neither the name of the University nor the names of its contributors
16  * may be used to endorse or promote products derived from this software
17  * without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29  * SUCH DAMAGE.
30  *
31  * @(#)mman.h 8.2 (Berkeley) 1/9/95
32  */
33 
34 #ifndef _SYS_MMAN_H_
35 #define _SYS_MMAN_H_
36 
37 #ifdef __rtems__
38 
39 #include <inttypes.h>
40 #include <stddef.h>
41 #include <sys/types.h>
42 
43 #else /* __rtems__ */
44 #include <sys/featuretest.h>
45 
46 #include <machine/ansi.h>
47 
48 #ifdef _BSD_SIZE_T_
49 typedef _BSD_SIZE_T_ size_t;
50 #undef _BSD_SIZE_T_
51 #endif
52 
53 #include <sys/ansi.h>
54 
55 #ifndef mode_t
56 typedef __mode_t mode_t;
57 #define mode_t __mode_t
58 #endif
59 
60 #ifndef off_t
61 typedef __off_t off_t; /* file offset */
62 #define off_t __off_t
63 #endif
64 #endif /* __rtems__ */
65 
66 
67 /*
68  * Protections are chosen from these bits, or-ed together
69  */
70 #define PROT_NONE 0x00 /* no permissions */
71 #define PROT_READ 0x01 /* pages can be read */
72 #define PROT_WRITE 0x02 /* pages can be written */
73 #define PROT_EXEC 0x04 /* pages can be executed */
74 
75 /*
76  * Flags contain sharing type and options.
77  * Sharing types; choose one.
78  */
79 #define MAP_SHARED 0x0001 /* share changes */
80 #define MAP_PRIVATE 0x0002 /* changes are private */
81 
82 #ifdef _KERNEL
83 /*
84  * Deprecated flag; these are treated as MAP_PRIVATE internally by
85  * the kernel.
86  */
87 #define MAP_COPY 0x0004 /* "copy" region at mmap time */
88 #endif
89 
90 /*
91  * Other flags
92  */
93 #define MAP_FIXED 0x0010 /* map addr must be exactly as requested */
94 #define MAP_RENAME 0x0020 /* Sun: rename private pages to file */
95 #define MAP_NORESERVE 0x0040 /* Sun: don't reserve needed swap area */
96 #define MAP_INHERIT 0x0080 /* region is retained after exec */
97 #define MAP_HASSEMAPHORE 0x0200 /* region may contain semaphores */
98 #define MAP_TRYFIXED 0x0400 /* attempt hint address, even within break */
99 #define MAP_WIRED 0x0800 /* mlock() mapping when it is established */
100 
101 /*
102  * Mapping type
103  */
104 #define MAP_FILE 0x0000 /* map from file (default) */
105 #define MAP_ANON 0x1000 /* allocated from memory, swap space */
106 
107 /*
108  * Alignment (expressed in log2). Must be >= log2(PAGE_SIZE) and
109  * < # bits in a pointer (26 (acorn26), 32 or 64).
110  */
111 #define MAP_ALIGNED(n) ((n) << MAP_ALIGNMENT_SHIFT)
112 #define MAP_ALIGNMENT_SHIFT 24
113 #define MAP_ALIGNMENT_MASK MAP_ALIGNED(0xff)
114 #define MAP_ALIGNMENT_64KB MAP_ALIGNED(16) /* 2^16 */
115 #define MAP_ALIGNMENT_16MB MAP_ALIGNED(24) /* 2^24 */
116 #define MAP_ALIGNMENT_4GB MAP_ALIGNED(32) /* 2^32 */
117 #define MAP_ALIGNMENT_1TB MAP_ALIGNED(40) /* 2^40 */
118 #define MAP_ALIGNMENT_256TB MAP_ALIGNED(48) /* 2^48 */
119 #define MAP_ALIGNMENT_64PB MAP_ALIGNED(56) /* 2^56 */
120 
121 /*
122  * Error indicator returned by mmap(2)
123  */
124 #define MAP_FAILED ((void *) -1) /* mmap() failed */
125 
126 /*
127  * Flags to msync
128  */
129 #define MS_ASYNC 0x01 /* perform asynchronous writes */
130 #define MS_INVALIDATE 0x02 /* invalidate cached data */
131 #define MS_SYNC 0x04 /* perform synchronous writes */
132 
133 /*
134  * Flags to mlockall
135  */
136 #define MCL_CURRENT 0x01 /* lock all pages currently mapped */
137 #define MCL_FUTURE 0x02 /* lock all pages mapped in the future */
138 
139 #if defined(_NETBSD_SOURCE)
140 /*
141  * Advice to madvise
142  */
143 #define MADV_NORMAL 0 /* no further special treatment */
144 #define MADV_RANDOM 1 /* expect random page references */
145 #define MADV_SEQUENTIAL 2 /* expect sequential page references */
146 #define MADV_WILLNEED 3 /* will need these pages */
147 #define MADV_DONTNEED 4 /* dont need these pages */
148 #define MADV_SPACEAVAIL 5 /* insure that resources are reserved */
149 #define MADV_FREE 6 /* pages are empty, free them */
150 /*
151  * Flags to minherit
152  */
153 #define MAP_INHERIT_SHARE 0 /* share with child */
154 #define MAP_INHERIT_COPY 1 /* copy into child */
155 #define MAP_INHERIT_NONE 2 /* absent from child */
156 #define MAP_INHERIT_DONATE_COPY 3 /* copy and delete -- not
157  implemented in UVM */
158 #define MAP_INHERIT_DEFAULT MAP_INHERIT_COPY
159 #endif
160 
161 #ifndef _KERNEL
162 
163 #include <sys/cdefs.h>
164 
165 __BEGIN_DECLS
166 void *mmap(void *, size_t, int, int, int, off_t);
167 int munmap(void *, size_t);
168 int mprotect(void *, size_t, int);
169 #ifndef __LIBC12_SOURCE__
170 #if defined(__rtems__)
171 int msync(void *, size_t, int);
172 #else
173 int msync(void *, size_t, int) __RENAME(__msync13);
174 #endif
175 #endif
176 int mlock(const void *, size_t);
177 int munlock(const void *, size_t);
178 int mlockall(int);
179 int munlockall(void);
180 #if defined(_NETBSD_SOURCE)
181 int madvise(void *, size_t, int);
182 int mincore(void *, size_t, char *);
183 int minherit(void *, size_t, int);
184 #endif
185 __END_DECLS
186 
187 #endif /* !_KERNEL */
188 
189 #endif /* !_SYS_MMAN_H_ */