Project

General

Profile

Statistics
| Revision:

root / lab4 / .minix-src / include / sys / mman.h @ 13

History | View | Annotate | Download (7.24 KB)

1 13 up20180614
/*        $NetBSD: mman.h,v 1.48 2014/08/03 19:14:24 wiz 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
#include <sys/featuretest.h>
38
39
#include <machine/ansi.h>
40
41
#ifdef        _BSD_SIZE_T_
42
typedef        _BSD_SIZE_T_        size_t;
43
#undef        _BSD_SIZE_T_
44
#endif
45
46
#include <sys/ansi.h>
47
48
#ifndef        mode_t
49
typedef        __mode_t        mode_t;
50
#define        mode_t                __mode_t
51
#endif
52
53
#ifndef        off_t
54
typedef        __off_t                off_t;                /* file offset */
55
#define        off_t                __off_t
56
#endif
57
58
59
/*
60
 * Protections are chosen from these bits, or-ed together
61
 */
62
#define        PROT_NONE        0x00        /* no permissions */
63
#define        PROT_READ        0x01        /* pages can be read */
64
#define        PROT_WRITE        0x02        /* pages can be written */
65
#define        PROT_EXEC        0x04        /* pages can be executed */
66
67
/*
68
 * Flags contain sharing type and options.
69
 * Sharing types; choose one.
70
 */
71
#define        MAP_SHARED        0x0001        /* share changes */
72
#define        MAP_PRIVATE        0x0002        /* changes are private */
73
74
#ifdef _KERNEL
75
/*
76
 * Deprecated flag; these are treated as MAP_PRIVATE internally by
77
 * the kernel.
78
 */
79
#define        MAP_COPY        0x0004        /* "copy" region at mmap time */
80
#endif
81
82
/*
83
 * Other flags
84
 */
85
#define        MAP_FIXED         0x0010        /* map addr must be exactly as requested */
86
#define        MAP_RENAME         0x0020        /* Sun: rename private pages to file */
87
#define        MAP_NORESERVE         0x0040        /* Sun: don't reserve needed swap area */
88
#define        MAP_INHERIT         0x0080        /* region is retained after exec */
89
#define        MAP_HASSEMAPHORE 0x0200        /* region may contain semaphores */
90
#define        MAP_TRYFIXED     0x0400 /* attempt hint address, even within break */
91
#define        MAP_WIRED         0x0800        /* mlock() mapping when it is established */
92
93
/*
94
 * Mapping type
95
 */
96
#define        MAP_FILE        0x0000        /* map from file (default) */
97
#define        MAP_ANONYMOUS        0x1000        /* allocated from memory, swap space */
98
#define        MAP_ANON        MAP_ANONYMOUS
99
#define        MAP_STACK        0x2000        /* allocated from memory, swap space (stack) */
100
101
/*
102
 * Alignment (expressed in log2).  Must be >= log2(PAGE_SIZE) and
103
 * < # bits in a pointer (26 (acorn26), 32 or 64).
104
 */
105
#define        MAP_ALIGNED(n)                ((n) << MAP_ALIGNMENT_SHIFT)
106
#define        MAP_ALIGNMENT_SHIFT        24
107
#define        MAP_ALIGNMENT_MASK        MAP_ALIGNED(0xff)
108
#define        MAP_ALIGNMENT_64KB        MAP_ALIGNED(16)        /* 2^16 */
109
#define        MAP_ALIGNMENT_16MB        MAP_ALIGNED(24)        /* 2^24 */
110
#define        MAP_ALIGNMENT_4GB        MAP_ALIGNED(32)        /* 2^32 */
111
#define        MAP_ALIGNMENT_1TB        MAP_ALIGNED(40)        /* 2^40 */
112
#define        MAP_ALIGNMENT_256TB        MAP_ALIGNED(48)        /* 2^48 */
113
#define        MAP_ALIGNMENT_64PB        MAP_ALIGNED(56)        /* 2^56 */
114
115
#if defined(__minix)
116
/*
117
 * Minix-specific flags
118
 */
119
#define MAP_UNINITIALIZED        0x040000       /* do not clear memory */
120
#define MAP_PREALLOC                0x080000        /* not on-demand */
121
#define MAP_CONTIG                0x100000        /* contiguous in physical memory */
122
#define MAP_LOWER16M                0x200000        /* physically below 16MB */
123
#define MAP_LOWER1M                0x400000        /* physically below 16MB */
124
#define MAP_THIRDPARTY                0x800000        /* perform on behalf of any process */
125
#endif /* defined(__minix) */
126
127
/*
128
 * Error indicator returned by mmap(2)
129
 */
130
#define        MAP_FAILED        ((void *) -1)        /* mmap() failed */
131
132
/*
133
 * Flags to msync
134
 */
135
#define        MS_ASYNC        0x01        /* perform asynchronous writes */
136
#define        MS_INVALIDATE        0x02        /* invalidate cached data */
137
#define        MS_SYNC                0x04        /* perform synchronous writes */
138
139
/*
140
 * Flags to mlockall
141
 */
142
#define        MCL_CURRENT        0x01        /* lock all pages currently mapped */
143
#define        MCL_FUTURE        0x02        /* lock all pages mapped in the future */
144
145
/*
146
 * POSIX memory avissory values.
147
 * Note: keep consistent with the original definitions below.
148
 */
149
#define        POSIX_MADV_NORMAL        0        /* No further special treatment */
150
#define        POSIX_MADV_RANDOM        1        /* Expect random page references */
151
#define        POSIX_MADV_SEQUENTIAL        2        /* Expect sequential page references */
152
#define        POSIX_MADV_WILLNEED        3        /* Will need these pages */
153
#define        POSIX_MADV_DONTNEED        4        /* Don't need these pages */
154
155
#if defined(_NETBSD_SOURCE)
156
/*
157
 * Original advice values, equivalent to POSIX definitions,
158
 * and few implementation-specific ones.
159
 */
160
#define        MADV_NORMAL                POSIX_MADV_NORMAL
161
#define        MADV_RANDOM                POSIX_MADV_RANDOM
162
#define        MADV_SEQUENTIAL                POSIX_MADV_SEQUENTIAL
163
#define        MADV_WILLNEED                POSIX_MADV_WILLNEED
164
#define        MADV_DONTNEED                POSIX_MADV_DONTNEED
165
#define        MADV_SPACEAVAIL                5        /* Insure that resources are reserved */
166
#define        MADV_FREE                6        /* Pages are empty, free them */
167
168
/*
169
 * Flags to minherit
170
 */
171
#define        MAP_INHERIT_SHARE        0        /* share with child */
172
#define        MAP_INHERIT_COPY        1        /* copy into child */
173
#define        MAP_INHERIT_NONE        2        /* absent from child */
174
#define        MAP_INHERIT_DONATE_COPY        3        /* copy and delete -- not
175
                                           implemented in UVM */
176
#define        MAP_INHERIT_ZERO        4        /* zero in child */
177
#define        MAP_INHERIT_DEFAULT        MAP_INHERIT_COPY
178
#endif
179
180
#ifndef _KERNEL
181
182
#include <sys/cdefs.h>
183
184
__BEGIN_DECLS
185
void *        mmap(void *, size_t, int, int, int, off_t);
186
int        munmap(void *, size_t);
187
int        mprotect(void *, size_t, int);
188
#ifndef __LIBC12_SOURCE__
189
int        msync(void *, size_t, int) __RENAME(__msync13);
190
#endif
191
int        mlock(const void *, size_t);
192
int        munlock(const void *, size_t);
193
int        mlockall(int);
194
int        munlockall(void);
195
#if defined(_NETBSD_SOURCE)
196
int        madvise(void *, size_t, int);
197
int        mincore(void *, size_t, char *);
198
int        minherit(void *, size_t, int);
199
void *        mremap(void *, size_t, void *, size_t, int);
200
#endif
201
int        posix_madvise(void *, size_t, int);
202
int        shm_open(const char *, int, mode_t);
203
int        shm_unlink(const char *);
204
205
#if defined(__minix) && defined(_MINIX_SYSTEM)
206
#include <minix/endpoint.h>
207
void *         vm_remap(endpoint_t d, endpoint_t s, void *da, void *sa, size_t si);
208
void *         vm_remap_ro(endpoint_t d, endpoint_t s, void *da, void *sa, size_t si);
209
int            vm_unmap(endpoint_t endpt, void *addr);
210
unsigned long  vm_getphys(endpoint_t endpt, void *addr);
211
u8_t           vm_getrefcount(endpoint_t endpt, void *addr);
212
#endif /* defined(__minix) && defined(_MINIX_SYSTEM) */
213
214
__END_DECLS
215
216
#endif /* !_KERNEL */
217
218
#endif /* !_SYS_MMAN_H_ */