]> git.saurik.com Git - apple/xnu.git/blob - osfmk/mach/memory_object.h
c23bd85c71bb503aa723da737df5af30b4c345c8
[apple/xnu.git] / osfmk / mach / memory_object.h
1 /*
2 * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23 /*
24 * @OSF_COPYRIGHT@
25 */
26 /*
27 * Mach Operating System
28 * Copyright (c) 1991,1990,1989,1988 Carnegie Mellon University
29 * All Rights Reserved.
30 *
31 * Permission to use, copy, modify and distribute this software and its
32 * documentation is hereby granted, provided that both the copyright
33 * notice and this permission notice appear in all copies of the
34 * software, derivative works or modified versions, and any portions
35 * thereof, and that both notices appear in supporting documentation.
36 *
37 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
38 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
39 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
40 *
41 * Carnegie Mellon requests users of this software to return to
42 *
43 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
44 * School of Computer Science
45 * Carnegie Mellon University
46 * Pittsburgh PA 15213-3890
47 *
48 * any improvements or extensions that they make and grant Carnegie Mellon
49 * the rights to redistribute these changes.
50 */
51 /*
52 */
53 /*
54 * File: memory_object.h
55 * Author: Michael Wayne Young
56 *
57 * External memory management interface definition.
58 */
59
60 #ifndef _MACH_MEMORY_OBJECT_H_
61 #define _MACH_MEMORY_OBJECT_H_
62
63 /*
64 * User-visible types used in the external memory
65 * management interface:
66 */
67
68 #include <mach/port.h>
69 #include <mach/message.h>
70 #include <mach/machine/vm_types.h>
71
72 typedef mach_port_t memory_object_t;
73 /* A memory object ... */
74 /* Used by the kernel to retrieve */
75 /* or store data */
76
77 typedef mach_port_t memory_object_control_t;
78 /* Provided to a memory manager; ... */
79 /* used to control a memory object */
80
81 typedef mach_port_t memory_object_name_t;
82 /* Used to describe the memory ... */
83 /* object in vm_regions() calls */
84
85 typedef mach_port_t memory_object_rep_t;
86 /* Per-client handle for mem object */
87 /* Used by user programs to specify */
88 /* the object to map */
89
90 typedef int memory_object_copy_strategy_t;
91 /* How memory manager handles copy: */
92 #define MEMORY_OBJECT_COPY_NONE 0
93 /* ... No special support */
94 #define MEMORY_OBJECT_COPY_CALL 1
95 /* ... Make call on memory manager */
96 #define MEMORY_OBJECT_COPY_DELAY 2
97 /* ... Memory manager doesn't
98 * change data externally.
99 */
100 #define MEMORY_OBJECT_COPY_TEMPORARY 3
101 /* ... Memory manager doesn't
102 * change data externally, and
103 * doesn't need to see changes.
104 */
105 #define MEMORY_OBJECT_COPY_SYMMETRIC 4
106 /* ... Memory manager doesn't
107 * change data externally,
108 * doesn't need to see changes,
109 * and object will not be
110 * multiply mapped.
111 *
112 * XXX
113 * Not yet safe for non-kernel use.
114 */
115
116 #define MEMORY_OBJECT_COPY_INVALID 5
117 /* ... An invalid copy strategy,
118 * for external objects which
119 * have not been initialized.
120 * Allows copy_strategy to be
121 * examined without also
122 * examining pager_ready and
123 * internal.
124 */
125
126 typedef int memory_object_return_t;
127 /* Which pages to return to manager
128 this time (lock_request) */
129 #define MEMORY_OBJECT_RETURN_NONE 0
130 /* ... don't return any. */
131 #define MEMORY_OBJECT_RETURN_DIRTY 1
132 /* ... only dirty pages. */
133 #define MEMORY_OBJECT_RETURN_ALL 2
134 /* ... dirty and precious pages. */
135 #define MEMORY_OBJECT_RETURN_ANYTHING 3
136 /* ... any resident page. */
137
138 #define MEMORY_OBJECT_NULL MACH_PORT_NULL
139
140
141 /*
142 * Types for the memory object flavor interfaces
143 */
144
145 #define MEMORY_OBJECT_INFO_MAX (1024)
146 typedef int *memory_object_info_t;
147 typedef int memory_object_flavor_t;
148 typedef int memory_object_info_data_t[MEMORY_OBJECT_INFO_MAX];
149
150
151 #define OLD_MEMORY_OBJECT_BEHAVIOR_INFO 10
152 #define MEMORY_OBJECT_PERFORMANCE_INFO 11
153 #define OLD_MEMORY_OBJECT_ATTRIBUTE_INFO 12
154 #define MEMORY_OBJECT_ATTRIBUTE_INFO 14
155 #define MEMORY_OBJECT_BEHAVIOR_INFO 15
156
157
158 struct old_memory_object_behave_info {
159 memory_object_copy_strategy_t copy_strategy;
160 boolean_t temporary;
161 boolean_t invalidate;
162 };
163
164 struct memory_object_perf_info {
165 memory_object_cluster_size_t cluster_size;
166 boolean_t may_cache;
167 };
168
169 struct old_memory_object_attr_info { /* old attr list */
170 boolean_t object_ready;
171 boolean_t may_cache;
172 memory_object_copy_strategy_t copy_strategy;
173 };
174
175 struct memory_object_attr_info {
176 memory_object_copy_strategy_t copy_strategy;
177 memory_object_cluster_size_t cluster_size;
178 boolean_t may_cache_object;
179 boolean_t temporary;
180 };
181
182 struct memory_object_behave_info {
183 memory_object_copy_strategy_t copy_strategy;
184 boolean_t temporary;
185 boolean_t invalidate;
186 boolean_t silent_overwrite;
187 boolean_t advisory_pageout;
188 };
189
190 typedef struct old_memory_object_behave_info *old_memory_object_behave_info_t;
191 typedef struct old_memory_object_behave_info old_memory_object_behave_info_data_t;
192
193 typedef struct memory_object_behave_info *memory_object_behave_info_t;
194 typedef struct memory_object_behave_info memory_object_behave_info_data_t;
195
196 typedef struct memory_object_perf_info *memory_object_perf_info_t;
197 typedef struct memory_object_perf_info memory_object_perf_info_data_t;
198
199 typedef struct old_memory_object_attr_info *old_memory_object_attr_info_t;
200 typedef struct old_memory_object_attr_info old_memory_object_attr_info_data_t;
201
202 typedef struct memory_object_attr_info *memory_object_attr_info_t;
203 typedef struct memory_object_attr_info memory_object_attr_info_data_t;
204
205 #define OLD_MEMORY_OBJECT_BEHAVE_INFO_COUNT ((mach_msg_type_number_t) \
206 (sizeof(old_memory_object_behave_info_data_t)/sizeof(int)))
207 #define MEMORY_OBJECT_BEHAVE_INFO_COUNT ((mach_msg_type_number_t) \
208 (sizeof(memory_object_behave_info_data_t)/sizeof(int)))
209 #define MEMORY_OBJECT_PERF_INFO_COUNT ((mach_msg_type_number_t) \
210 (sizeof(memory_object_perf_info_data_t)/sizeof(int)))
211 #define OLD_MEMORY_OBJECT_ATTR_INFO_COUNT ((mach_msg_type_number_t) \
212 (sizeof(old_memory_object_attr_info_data_t)/sizeof(int)))
213 #define MEMORY_OBJECT_ATTR_INFO_COUNT ((mach_msg_type_number_t) \
214 (sizeof(memory_object_attr_info_data_t)/sizeof(int)))
215
216 #define invalid_memory_object_flavor(f) \
217 (f != MEMORY_OBJECT_ATTRIBUTE_INFO && \
218 f != MEMORY_OBJECT_PERFORMANCE_INFO && \
219 f != OLD_MEMORY_OBJECT_BEHAVIOR_INFO && \
220 f != MEMORY_OBJECT_BEHAVIOR_INFO && \
221 f != OLD_MEMORY_OBJECT_ATTRIBUTE_INFO)
222
223 #endif /* _MACH_MEMORY_OBJECT_H_ */