summaryrefslogtreecommitdiff
path: root/legacy/escape/src/lib/sys/mman.h
diff options
context:
space:
mode:
authorYouness Alaoui <kakaroto@kakaroto.homelinux.net>2011-09-07 07:18:07 +0000
committerYouness Alaoui <kakaroto@kakaroto.homelinux.net>2011-09-07 07:18:07 +0000
commitf26611c3de57b4a90232aed44535e80d3c855ea7 (patch)
tree9ed07ed608ba4a47b17d6b62af791ef6cb1033ef /legacy/escape/src/lib/sys/mman.h
parentdf91f38ffbbcbaa375e4f62d984d7ef1e3000d91 (diff)
Adding Escape: A compatibility library for jailbroken PS3s (PSL1GHT)
SVN revision: 63260
Diffstat (limited to '')
-rw-r--r--legacy/escape/src/lib/sys/mman.h183
1 files changed, 183 insertions, 0 deletions
diff --git a/legacy/escape/src/lib/sys/mman.h b/legacy/escape/src/lib/sys/mman.h
new file mode 100644
index 0000000000..e60bb45d4b
--- /dev/null
+++ b/legacy/escape/src/lib/sys/mman.h
@@ -0,0 +1,183 @@
1#ifndef __ESCAPE_SYS_MMAN_H__
2#define __ESCAPE_SYS_MMAN_H__
3
4#include <Escape.h>
5
6
7#ifdef __cplusplus
8extern "C" {
9#endif
10
11
12/**
13 * @def PROT_NONE
14 * Data can not be accessed.
15 */
16
17/**
18 * @def PROT_READ
19 * Data can be read.
20 */
21
22/**
23 * @def PROT_WRITE
24 * Data can be written.
25 */
26
27/**
28 * @def PROT_EXEC
29 * Data can be executed.
30 */
31
32#define PROT_NONE 0x00
33#define PROT_READ 0x01
34#define PROT_WRITE 0x02
35#define PROT_EXEC 0x04
36
37/**
38 * @def MAP_SHARED
39 * Changes are shared.
40 */
41
42/**
43 * @def MAP_PRIVATE
44 * Changes are private.
45 */
46
47/**
48 * @def MAP_FIXED
49 * Interpret the address (addr) exactly.
50 */
51
52/**
53 * @def MAP_FAILED
54 * Error return from mmap().
55 */
56
57#define MAP_SHARED 0x0001
58#define MAP_PRIVATE 0x0002
59#define MAP_FIXED 0x0010
60
61#define MAP_FAILED ((void *)-1)
62
63
64/**
65 * @file mman.h
66 * @brief The file that provides the memory map functions
67 * @defgroup Mman Functions that manage memory mappping.
68 *
69 * This header provides the meomry map functions mmap and munmap.
70 *
71 */
72
73/**
74 * Creates or opens a named or unnamed file mapping object for a
75 * specified file and maps a view of a file mapping into the
76 * address space of a calling process.
77 *
78 * @param addr Unused
79 * @param len Number of bytes to be mapped.
80 * @param prot Protections.
81 * @param flags Type of the mapped object.
82 * @param fd File descriptor that describes the object to map.
83 * @param offset Number of bytes from which to start the mapping.
84 * @return The starting address of the mapped view on success, -1 otherwise.
85 *
86 * Create or open an unnamed file mapping object for a specified
87 * file described by the file descriptor @p fd. The number of
88 * bytes that are mapped is given by @p len and start after
89 * @p offset bytes. The parameter @p addr is unused.
90 *
91 * The only type of the mapped object that is supported is
92 * @c MAP_SHARED. If another value if given, -1 is returned.
93 *
94 * @p prot specifies the protection of the mapped region. If
95 * PROT_EXEC is used, it set the execute access. If PROT_READ
96 * is used, it sets the read access. If PROT_WRITE is used, it
97 * sets the write access.
98 *
99 * If the map view of file can not be created, -1 is returned.
100 * If the mappping can not be done, -1 is returned.
101 *
102 * If no error occured, the starting address of the mapped view
103 * is returned.
104 *
105 * Conformity: None.
106 *
107 * @ingroup Mman
108 */
109EAPI void *mmap(void *addr,
110 size_t len,
111 int prot,
112 int flags,
113 int fd,
114 off_t offset);
115
116/**
117 * Unmaps a mapped view of a file from the calling process's
118 * address space.
119 *
120 * @param addr Pointer to the base address.
121 * @param len Unused.
122 * @return 0 on success, -1 otherwise.
123 *
124 * Unmaps a mapped view of a file from the calling process's
125 * address space. @p addr is the pointer to the base address.
126 * This value must be identical to the value returned by a
127 * previous call to mmap(). The parameter @p len is unsed.
128 *
129 * Conformity: None.
130 *
131 * @ingroup Mman
132 */
133EAPI int munmap(void *addr,
134 size_t len);
135
136
137# define MADV_NORMAL 0 /* No further special treatment. */
138# define MADV_RANDOM 1 /* Expect random page references. */
139# define MADV_SEQUENTIAL 2 /* Expect sequential page references. */
140# define MADV_WILLNEED 3 /* Will need these pages. */
141# define MADV_DONTNEED 4 /* Don't need these pages. */
142# define MADV_REMOVE 9 /* Remove these pages and resources. */
143# define MADV_DONTFORK 10 /* Do not inherit across fork. */
144# define MADV_DOFORK 11 /* Do inherit across fork. */
145# define MADV_MERGEABLE 12 /* KSM may merge identical pages. */
146# define MADV_UNMERGEABLE 13 /* KSM may not merge identical pages. */
147# define MADV_HUGEPAGE 14 /* Worth backing with hugepages. */
148# define MADV_NOHUGEPAGE 15 /* Not worth backing with hugepages. */
149# define MADV_HWPOISON 100 /* Poison a page for testing. */
150
151/**
152 * give advice about use of memory
153 *
154 * @param addr Unused.
155 * @param length Unused.
156 * @param advice Unused.
157 * @return 0 on success, -1 otherwise.
158 *
159 * The madvise() system call advises the kernel about how to handle
160 * paging input/output in the address range beginning at address addr and
161 * with size length bytes. It allows an application to tell the kernel
162 * how it expects to use some mapped or shared memory areas, so that
163 * the kernel can choose appropriate read-ahead and caching techniques.
164 * This call does not influence the semantics of the application (except
165 * in the case of MADV_DONTNEED), but may influence its performance.
166 * The kernel is free to ignore the advice.
167
168 * Conformity: None.
169 *
170 * @ingroup Mman
171 */
172EAPI int madvise(void *addr,
173 size_t length,
174 int advice);
175
176
177#ifdef __cplusplus
178}
179#endif
180
181
182#endif /* __ESCAPE_SYS_MMAN_H__ */
183