1 /* $NetBSD: mach_vm.h,v 1.27 2005/02/26 23:10:20 perry Exp $ */
2
3 /*-
4 * Copyright (c) 2002-2003 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Emmanuel Dreyfus
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the NetBSD
21 * Foundation, Inc. and its contributors.
22 * 4. Neither the name of The NetBSD Foundation nor the names of its
23 * contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39 #ifndef _MACH_VM_H_
40 #define _MACH_VM_H_
41
42
43 #include <sys/types.h>
44 #include <sys/param.h>
45
46 #include <compat/mach/mach_types.h>
47 #include <compat/mach/mach_message.h>
48
49 #define MACH_ALTERNATE_LOAD_SITE 1
50 #define MACH_NEW_LOCAL_SHARED_REGIONS 2
51 #define MACH_QUERY_IS_SYSTEM_REGION 4
52 #define MACH_SF_PREV_LOADED 1
53 #define MACH_SYSTEM_REGION_BACKED 2
54
55 #define MACH_VM_PROT_COW 0x8
56 #define MACH_VM_PROT_ZF 0x10
57
58 typedef struct mach_sf_mapping {
59 mach_vm_offset_t mapping_offset;
60 mach_vm_size_t size;
61 mach_vm_offset_t file_offset;
62 mach_vm_prot_t protection;
63 mach_vm_offset_t cksum;
64 } mach_sf_mapping_t;
65
66 struct mach_vm_region_basic_info {
67 mach_vm_prot_t protection;
68 mach_vm_prot_t max_protection;
69 mach_vm_inherit_t inheritance;
70 mach_boolean_t shared;
71 mach_boolean_t reserved;
72 mach_vm_offset_t offset;
73 mach_vm_behavior_t behavior;
74 unsigned short user_wired_count;
75 };
76
77 /* There is no difference between 32 and 64 bits versions */
78 struct mach_vm_region_basic_info_64 {
79 mach_vm_prot_t protection;
80 mach_vm_prot_t max_protection;
81 mach_vm_inherit_t inheritance;
82 mach_boolean_t shared;
83 mach_boolean_t reserved;
84 mach_vm_offset_t offset;
85 mach_vm_behavior_t behavior;
86 unsigned short user_wired_count;
87 };
88
89 /* mach_vm_behavior_t values */
90 #define MACH_VM_BEHAVIOR_DEFAULT 0
91 #define MACH_VM_BEHAVIOR_RANDOM 1
92 #define MACH_VM_BEHAVIOR_SEQUENTIAL 2
93 #define MACH_VM_BEHAVIOR_RSEQNTL 3
94 #define MACH_VM_BEHAVIOR_WILLNEED 4
95 #define MACH_VM_BEHAVIOR_DONTNEED 5
96
97 /* vm_map */
98 #define MACH_VM_INHERIT_SHARE 0
99 #define MACH_VM_INHERIT_COPY 1
100 #define MACH_VM_INHERIT_NONE 2
101 #define MACH_VM_INHERIT_DONATE_COPY 3
102 typedef struct {
103 mach_msg_header_t req_msgh;
104 mach_msg_body_t req_body;
105 mach_msg_port_descriptor_t req_object;
106 mach_ndr_record_t req_ndr;
107 mach_vm_address_t req_address;
108 mach_vm_size_t req_size;
109 mach_vm_address_t req_mask;
110 int req_flags;
111 mach_vm_offset_t req_offset;
112 mach_boolean_t req_copy;
113 mach_vm_prot_t req_cur_protection;
114 mach_vm_prot_t req_max_protection;
115 mach_vm_inherit_t req_inherance;
116 } mach_vm_map_request_t;
117
118 typedef struct {
119 mach_msg_header_t rep_msgh;
120 mach_ndr_record_t rep_ndr;
121 mach_kern_return_t rep_retval;
122 mach_vm_address_t rep_address;
123 mach_msg_trailer_t rep_trailer;
124 } mach_vm_map_reply_t;
125
126 /* vm_allocate */
127 #define MACH_VM_FLAGS_ANYWHERE 1
128 typedef struct {
129 mach_msg_header_t req_msgh;
130 mach_ndr_record_t req_ndr;
131 mach_vm_address_t req_address;
132 mach_vm_size_t req_size;
133 int req_flags;
134 } mach_vm_allocate_request_t;
135
136
137 typedef struct {
138 mach_msg_header_t rep_msgh;
139 mach_ndr_record_t rep_ndr;
140 mach_kern_return_t rep_retval;
141 mach_vm_address_t rep_address;
142 mach_msg_trailer_t rep_trailer;
143 } mach_vm_allocate_reply_t;
144
145 /* vm_deallocate */
146
147 typedef struct {
148 mach_msg_header_t req_msgh;
149 mach_ndr_record_t req_ndr;
150 mach_vm_address_t req_address;
151 mach_vm_size_t req_size;
152 } mach_vm_deallocate_request_t;
153
154 typedef struct {
155 mach_msg_header_t rep_msgh;
156 mach_ndr_record_t rep_ndr;
157 mach_kern_return_t rep_retval;
158 mach_msg_trailer_t rep_trailer;
159 } mach_vm_deallocate_reply_t;
160
161 /* vm_wire */
162
163 typedef struct {
164 mach_msg_header_t req_msgh;
165 mach_msg_body_t req_body;
166 mach_msg_port_descriptor_t req_task;
167 mach_ndr_record_t req_ndr;
168 mach_vm_address_t req_address;
169 mach_vm_size_t req_size;
170 mach_vm_prot_t req_access;
171 } mach_vm_wire_request_t;
172
173 typedef struct {
174 mach_msg_header_t rep_msgh;
175 mach_ndr_record_t rep_ndr;
176 mach_kern_return_t rep_retval;
177 mach_msg_trailer_t rep_trailer;
178 } mach_vm_wire_reply_t;
179
180 /* vm_protect */
181
182 typedef struct {
183 mach_msg_header_t req_msgh;
184 mach_ndr_record_t req_ndr;
185 mach_vm_address_t req_addr;
186 mach_vm_size_t req_size;
187 mach_boolean_t req_set_maximum;
188 mach_vm_prot_t req_prot;
189 } mach_vm_protect_request_t;
190
191 typedef struct {
192 mach_msg_header_t rep_msgh;
193 mach_ndr_record_t rep_ndr;
194 mach_kern_return_t rep_retval;
195 mach_msg_trailer_t rep_trailer;
196 } mach_vm_protect_reply_t;
197
198 /* vm_inherit */
199 typedef struct {
200 mach_msg_header_t req_msgh;
201 mach_ndr_record_t req_ndr;
202 mach_vm_address_t req_addr;
203 mach_vm_size_t req_size;
204 mach_vm_inherit_t req_inh;
205 } mach_vm_inherit_request_t;
206
207 typedef struct {
208 mach_msg_header_t rep_msgh;
209 mach_ndr_record_t rep_ndr;
210 mach_kern_return_t rep_retval;
211 mach_msg_trailer_t rep_trailer;
212 } mach_vm_inherit_reply_t;
213
214 /*
215 * make_memory_entry_64
216 */
217
218 typedef struct {
219 mach_msg_header_t req_msgh;
220 mach_msg_body_t req_body;
221 mach_msg_port_descriptor_t req_parent_entry;
222 mach_ndr_record_t req_ndr;
223 mach_memory_object_size_t req_size;
224 mach_memory_object_offset_t req_offset;
225 mach_vm_prot_t req_perm;
226 } __attribute__((packed)) mach_make_memory_entry_64_request_t;
227
228 typedef struct {
229 mach_msg_header_t rep_msgh;
230 mach_msg_body_t rep_body;
231 mach_msg_port_descriptor_t rep_obj_handle;
232 mach_ndr_record_t rep_ndr;
233 mach_memory_object_size_t rep_size;
234 mach_msg_trailer_t rep_trailer;
235 } __attribute__((packed)) mach_make_memory_entry_64_reply_t;
236
237 /* vm_region */
238
239 #define MACH_VM_REGION_BASIC_INFO 10
240 typedef struct {
241 mach_msg_header_t req_msgh;
242 mach_ndr_record_t req_ndr;
243 mach_vm_address_t req_addr;
244 mach_vm_region_flavor_t req_flavor;
245 mach_msg_type_number_t req_count;
246 } mach_vm_region_request_t;
247
248 typedef struct {
249 mach_msg_header_t rep_msgh;
250 mach_msg_body_t rep_body;
251 mach_msg_port_descriptor_t rep_obj;
252 mach_ndr_record_t rep_ndr;
253 mach_msg_type_number_t rep_addr;
254 mach_vm_size_t rep_size;
255 mach_msg_type_number_t rep_count;
256 int rep_info[9];
257 mach_msg_trailer_t rep_trailer;
258 } mach_vm_region_reply_t;
259
260 /* vm_region_64 */
261
262 typedef struct {
263 mach_msg_header_t req_msgh;
264 mach_ndr_record_t req_ndr;
265 mach_vm_address_t req_addr;
266 mach_vm_region_flavor_t req_flavor;
267 mach_msg_type_number_t req_count;
268 } mach_vm_region_64_request_t;
269
270 typedef struct {
271 mach_msg_header_t rep_msgh;
272 mach_msg_body_t rep_body;
273 mach_msg_port_descriptor_t rep_obj;
274 mach_ndr_record_t rep_ndr;
275 mach_vm_address_t rep_addr;
276 mach_vm_size_t rep_size;
277 mach_msg_type_number_t rep_count;
278 int rep_info[10];
279 mach_msg_trailer_t rep_trailer;
280 } mach_vm_region_64_reply_t;
281
282 /* vm_msync */
283 #define MACH_VM_SYNC_ASYNCHRONOUS 0x01
284 #define MACH_VM_SYNC_SYNCHRONOUS 0x02
285 #define MACH_VM_SYNC_INVALIDATE 0x04
286 #define MACH_VM_SYNC_KILLPAGES 0x08
287 #define MACH_VM_SYNC_DEACTIVATE 0x10
288 typedef struct {
289 mach_msg_header_t req_msgh;
290 mach_ndr_record_t req_ndr;
291 mach_vm_address_t req_addr;
292 mach_vm_size_t req_size;
293 mach_vm_sync_t req_flags;
294 } mach_vm_msync_request_t;
295
296 typedef struct {
297 mach_msg_header_t rep_msgh;
298 mach_ndr_record_t rep_ndr;
299 mach_kern_return_t rep_retval;
300 mach_msg_trailer_t rep_trailer;
301 } mach_vm_msync_reply_t;
302
303 /* vm_copy */
304 typedef struct {
305 mach_msg_header_t req_msgh;
306 mach_ndr_record_t req_ndr;
307 mach_vm_address_t req_src;
308 mach_vm_size_t req_size;
309 mach_vm_address_t req_addr;
310 } mach_vm_copy_request_t;
311
312 typedef struct {
313 mach_msg_header_t rep_msgh;
314 mach_ndr_record_t rep_ndr;
315 mach_kern_return_t rep_retval;
316 mach_msg_trailer_t rep_trailer;
317 } mach_vm_copy_reply_t;
318
319 /* vm_read */
320
321 typedef struct {
322 mach_msg_header_t req_msgh;
323 mach_ndr_record_t req_ndr;
324 mach_vm_address_t req_addr;
325 mach_vm_size_t req_size;
326 } mach_vm_read_request_t;
327
328 typedef struct {
329 mach_msg_header_t rep_msgh;
330 mach_msg_body_t rep_body;
331 mach_msg_ool_descriptor_t rep_data;
332 mach_ndr_record_t rep_ndr;
333 mach_msg_type_number_t rep_count;
334 mach_msg_trailer_t rep_trailer;
335 } mach_vm_read_reply_t;
336
337 /* vm_write */
338
339 typedef struct {
340 mach_msg_header_t req_msgh;
341 mach_msg_body_t req_body;
342 mach_msg_ool_descriptor_t req_data;
343 mach_ndr_record_t req_ndr;
344 mach_vm_address_t req_addr;
345 mach_msg_type_number_t req_count;
346 } mach_vm_write_request_t;
347
348 typedef struct {
349 mach_msg_header_t rep_msgh;
350 mach_ndr_record_t rep_ndr;
351 mach_msg_type_number_t rep_retval;
352 mach_msg_trailer_t rep_trailer;
353 } mach_vm_write_reply_t;
354
355 /* vm_machine_attribute */
356
357 #define MACH_MATTR_CACHE 1
358 #define MACH_MATTR_MIGRATE 2
359 #define MACH_MATTR_REPLICATE 4
360
361 #define MACH_MATTR_VAL_OFF 0
362 #define MACH_MATTR_VAL_ON 1
363 #define MACH_MATTR_VAL_GET 2
364 #define MACH_MATTR_VAL_CACHE_FLUSH 6
365 #define MACH_MATTR_VAL_DCACHE_FLUSH 7
366 #define MACH_MATTR_VAL_ICACHE_FLUSH 8
367 #define MACH_MATTR_VAL_CACHE_SYNC 9
368 #define MACH_MATTR_VAL_GET_INFO 10
369
370 typedef struct {
371 mach_msg_header_t req_msgh;
372 mach_ndr_record_t req_ndr;
373 mach_vm_address_t req_addr;
374 mach_vm_address_t req_size;
375 mach_vm_machine_attribute_t req_attribute;
376 mach_vm_machine_attribute_val_t req_value;
377 } mach_vm_machine_attribute_request_t;
378
379 typedef struct {
380 mach_msg_header_t rep_msgh;
381 mach_ndr_record_t rep_ndr;
382 mach_msg_type_number_t rep_retval;
383 mach_vm_machine_attribute_val_t rep_value;
384 mach_msg_trailer_t rep_trailer;
385 } mach_vm_machine_attribute_reply_t;
386
387 /* Kernel-private structures */
388
389 struct mach_memory_entry {
390 struct proc *mme_proc;
391 vaddr_t mme_offset;
392 size_t mme_size;
393 };
394
395 /* These are machine dependent functions */
396 int mach_vm_machine_attribute_machdep(struct lwp *, vaddr_t, size_t, int *);
397
398 #endif /* _MACH_VM_H_ */
Cache object: eb49a545be910bb94c190cfe0c2587ca
|