1 /* $NetBSD: mach_vm.h,v 1.29 2007/12/25 18:33:35 perry Exp $ */
4 * Copyright (c) 2002-2003 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
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.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
36 #include <sys/types.h>
37 #include <sys/param.h>
39 #include <compat/mach/mach_types.h>
40 #include <compat/mach/mach_message.h>
42 #define MACH_ALTERNATE_LOAD_SITE 1
43 #define MACH_NEW_LOCAL_SHARED_REGIONS 2
44 #define MACH_QUERY_IS_SYSTEM_REGION 4
45 #define MACH_SF_PREV_LOADED 1
46 #define MACH_SYSTEM_REGION_BACKED 2
48 #define MACH_VM_PROT_COW 0x8
49 #define MACH_VM_PROT_ZF 0x10
51 typedef struct mach_sf_mapping
{
52 mach_vm_offset_t mapping_offset
;
54 mach_vm_offset_t file_offset
;
55 mach_vm_prot_t protection
;
56 mach_vm_offset_t cksum
;
59 struct mach_vm_region_basic_info
{
60 mach_vm_prot_t protection
;
61 mach_vm_prot_t max_protection
;
62 mach_vm_inherit_t inheritance
;
63 mach_boolean_t shared
;
64 mach_boolean_t reserved
;
65 mach_vm_offset_t offset
;
66 mach_vm_behavior_t behavior
;
67 unsigned short user_wired_count
;
70 /* There is no difference between 32 and 64 bits versions */
71 struct mach_vm_region_basic_info_64
{
72 mach_vm_prot_t protection
;
73 mach_vm_prot_t max_protection
;
74 mach_vm_inherit_t inheritance
;
75 mach_boolean_t shared
;
76 mach_boolean_t reserved
;
77 mach_vm_offset_t offset
;
78 mach_vm_behavior_t behavior
;
79 unsigned short user_wired_count
;
82 /* mach_vm_behavior_t values */
83 #define MACH_VM_BEHAVIOR_DEFAULT 0
84 #define MACH_VM_BEHAVIOR_RANDOM 1
85 #define MACH_VM_BEHAVIOR_SEQUENTIAL 2
86 #define MACH_VM_BEHAVIOR_RSEQNTL 3
87 #define MACH_VM_BEHAVIOR_WILLNEED 4
88 #define MACH_VM_BEHAVIOR_DONTNEED 5
91 #define MACH_VM_INHERIT_SHARE 0
92 #define MACH_VM_INHERIT_COPY 1
93 #define MACH_VM_INHERIT_NONE 2
94 #define MACH_VM_INHERIT_DONATE_COPY 3
96 mach_msg_header_t req_msgh
;
97 mach_msg_body_t req_body
;
98 mach_msg_port_descriptor_t req_object
;
99 mach_ndr_record_t req_ndr
;
100 mach_vm_address_t req_address
;
101 mach_vm_size_t req_size
;
102 mach_vm_address_t req_mask
;
104 mach_vm_offset_t req_offset
;
105 mach_boolean_t req_copy
;
106 mach_vm_prot_t req_cur_protection
;
107 mach_vm_prot_t req_max_protection
;
108 mach_vm_inherit_t req_inherance
;
109 } mach_vm_map_request_t
;
112 mach_msg_header_t rep_msgh
;
113 mach_ndr_record_t rep_ndr
;
114 mach_kern_return_t rep_retval
;
115 mach_vm_address_t rep_address
;
116 mach_msg_trailer_t rep_trailer
;
117 } mach_vm_map_reply_t
;
120 #define MACH_VM_FLAGS_ANYWHERE 1
122 mach_msg_header_t req_msgh
;
123 mach_ndr_record_t req_ndr
;
124 mach_vm_address_t req_address
;
125 mach_vm_size_t req_size
;
127 } mach_vm_allocate_request_t
;
131 mach_msg_header_t rep_msgh
;
132 mach_ndr_record_t rep_ndr
;
133 mach_kern_return_t rep_retval
;
134 mach_vm_address_t rep_address
;
135 mach_msg_trailer_t rep_trailer
;
136 } mach_vm_allocate_reply_t
;
141 mach_msg_header_t req_msgh
;
142 mach_ndr_record_t req_ndr
;
143 mach_vm_address_t req_address
;
144 mach_vm_size_t req_size
;
145 } mach_vm_deallocate_request_t
;
148 mach_msg_header_t rep_msgh
;
149 mach_ndr_record_t rep_ndr
;
150 mach_kern_return_t rep_retval
;
151 mach_msg_trailer_t rep_trailer
;
152 } mach_vm_deallocate_reply_t
;
157 mach_msg_header_t req_msgh
;
158 mach_msg_body_t req_body
;
159 mach_msg_port_descriptor_t req_task
;
160 mach_ndr_record_t req_ndr
;
161 mach_vm_address_t req_address
;
162 mach_vm_size_t req_size
;
163 mach_vm_prot_t req_access
;
164 } mach_vm_wire_request_t
;
167 mach_msg_header_t rep_msgh
;
168 mach_ndr_record_t rep_ndr
;
169 mach_kern_return_t rep_retval
;
170 mach_msg_trailer_t rep_trailer
;
171 } mach_vm_wire_reply_t
;
176 mach_msg_header_t req_msgh
;
177 mach_ndr_record_t req_ndr
;
178 mach_vm_address_t req_addr
;
179 mach_vm_size_t req_size
;
180 mach_boolean_t req_set_maximum
;
181 mach_vm_prot_t req_prot
;
182 } mach_vm_protect_request_t
;
185 mach_msg_header_t rep_msgh
;
186 mach_ndr_record_t rep_ndr
;
187 mach_kern_return_t rep_retval
;
188 mach_msg_trailer_t rep_trailer
;
189 } mach_vm_protect_reply_t
;
193 mach_msg_header_t req_msgh
;
194 mach_ndr_record_t req_ndr
;
195 mach_vm_address_t req_addr
;
196 mach_vm_size_t req_size
;
197 mach_vm_inherit_t req_inh
;
198 } mach_vm_inherit_request_t
;
201 mach_msg_header_t rep_msgh
;
202 mach_ndr_record_t rep_ndr
;
203 mach_kern_return_t rep_retval
;
204 mach_msg_trailer_t rep_trailer
;
205 } mach_vm_inherit_reply_t
;
208 * make_memory_entry_64
212 mach_msg_header_t req_msgh
;
213 mach_msg_body_t req_body
;
214 mach_msg_port_descriptor_t req_parent_entry
;
215 mach_ndr_record_t req_ndr
;
216 mach_memory_object_size_t req_size
;
217 mach_memory_object_offset_t req_offset
;
218 mach_vm_prot_t req_perm
;
219 } __packed mach_make_memory_entry_64_request_t
;
222 mach_msg_header_t rep_msgh
;
223 mach_msg_body_t rep_body
;
224 mach_msg_port_descriptor_t rep_obj_handle
;
225 mach_ndr_record_t rep_ndr
;
226 mach_memory_object_size_t rep_size
;
227 mach_msg_trailer_t rep_trailer
;
228 } __packed mach_make_memory_entry_64_reply_t
;
232 #define MACH_VM_REGION_BASIC_INFO 10
234 mach_msg_header_t req_msgh
;
235 mach_ndr_record_t req_ndr
;
236 mach_vm_address_t req_addr
;
237 mach_vm_region_flavor_t req_flavor
;
238 mach_msg_type_number_t req_count
;
239 } mach_vm_region_request_t
;
242 mach_msg_header_t rep_msgh
;
243 mach_msg_body_t rep_body
;
244 mach_msg_port_descriptor_t rep_obj
;
245 mach_ndr_record_t rep_ndr
;
246 mach_msg_type_number_t rep_addr
;
247 mach_vm_size_t rep_size
;
248 mach_msg_type_number_t rep_count
;
250 mach_msg_trailer_t rep_trailer
;
251 } mach_vm_region_reply_t
;
256 mach_msg_header_t req_msgh
;
257 mach_ndr_record_t req_ndr
;
258 mach_vm_address_t req_addr
;
259 mach_vm_region_flavor_t req_flavor
;
260 mach_msg_type_number_t req_count
;
261 } mach_vm_region_64_request_t
;
264 mach_msg_header_t rep_msgh
;
265 mach_msg_body_t rep_body
;
266 mach_msg_port_descriptor_t rep_obj
;
267 mach_ndr_record_t rep_ndr
;
268 mach_vm_address_t rep_addr
;
269 mach_vm_size_t rep_size
;
270 mach_msg_type_number_t rep_count
;
272 mach_msg_trailer_t rep_trailer
;
273 } mach_vm_region_64_reply_t
;
276 #define MACH_VM_SYNC_ASYNCHRONOUS 0x01
277 #define MACH_VM_SYNC_SYNCHRONOUS 0x02
278 #define MACH_VM_SYNC_INVALIDATE 0x04
279 #define MACH_VM_SYNC_KILLPAGES 0x08
280 #define MACH_VM_SYNC_DEACTIVATE 0x10
282 mach_msg_header_t req_msgh
;
283 mach_ndr_record_t req_ndr
;
284 mach_vm_address_t req_addr
;
285 mach_vm_size_t req_size
;
286 mach_vm_sync_t req_flags
;
287 } mach_vm_msync_request_t
;
290 mach_msg_header_t rep_msgh
;
291 mach_ndr_record_t rep_ndr
;
292 mach_kern_return_t rep_retval
;
293 mach_msg_trailer_t rep_trailer
;
294 } mach_vm_msync_reply_t
;
298 mach_msg_header_t req_msgh
;
299 mach_ndr_record_t req_ndr
;
300 mach_vm_address_t req_src
;
301 mach_vm_size_t req_size
;
302 mach_vm_address_t req_addr
;
303 } mach_vm_copy_request_t
;
306 mach_msg_header_t rep_msgh
;
307 mach_ndr_record_t rep_ndr
;
308 mach_kern_return_t rep_retval
;
309 mach_msg_trailer_t rep_trailer
;
310 } mach_vm_copy_reply_t
;
315 mach_msg_header_t req_msgh
;
316 mach_ndr_record_t req_ndr
;
317 mach_vm_address_t req_addr
;
318 mach_vm_size_t req_size
;
319 } mach_vm_read_request_t
;
322 mach_msg_header_t rep_msgh
;
323 mach_msg_body_t rep_body
;
324 mach_msg_ool_descriptor_t rep_data
;
325 mach_ndr_record_t rep_ndr
;
326 mach_msg_type_number_t rep_count
;
327 mach_msg_trailer_t rep_trailer
;
328 } mach_vm_read_reply_t
;
333 mach_msg_header_t req_msgh
;
334 mach_msg_body_t req_body
;
335 mach_msg_ool_descriptor_t req_data
;
336 mach_ndr_record_t req_ndr
;
337 mach_vm_address_t req_addr
;
338 mach_msg_type_number_t req_count
;
339 } mach_vm_write_request_t
;
342 mach_msg_header_t rep_msgh
;
343 mach_ndr_record_t rep_ndr
;
344 mach_msg_type_number_t rep_retval
;
345 mach_msg_trailer_t rep_trailer
;
346 } mach_vm_write_reply_t
;
348 /* vm_machine_attribute */
350 #define MACH_MATTR_CACHE 1
351 #define MACH_MATTR_MIGRATE 2
352 #define MACH_MATTR_REPLICATE 4
354 #define MACH_MATTR_VAL_OFF 0
355 #define MACH_MATTR_VAL_ON 1
356 #define MACH_MATTR_VAL_GET 2
357 #define MACH_MATTR_VAL_CACHE_FLUSH 6
358 #define MACH_MATTR_VAL_DCACHE_FLUSH 7
359 #define MACH_MATTR_VAL_ICACHE_FLUSH 8
360 #define MACH_MATTR_VAL_CACHE_SYNC 9
361 #define MACH_MATTR_VAL_GET_INFO 10
364 mach_msg_header_t req_msgh
;
365 mach_ndr_record_t req_ndr
;
366 mach_vm_address_t req_addr
;
367 mach_vm_address_t req_size
;
368 mach_vm_machine_attribute_t req_attribute
;
369 mach_vm_machine_attribute_val_t req_value
;
370 } mach_vm_machine_attribute_request_t
;
373 mach_msg_header_t rep_msgh
;
374 mach_ndr_record_t rep_ndr
;
375 mach_msg_type_number_t rep_retval
;
376 mach_vm_machine_attribute_val_t rep_value
;
377 mach_msg_trailer_t rep_trailer
;
378 } mach_vm_machine_attribute_reply_t
;
380 /* Kernel-private structures */
382 struct mach_memory_entry
{
383 struct proc
*mme_proc
;
388 /* These are machine dependent functions */
389 int mach_vm_machine_attribute_machdep(struct lwp
*, vaddr_t
, size_t, int *);
391 #endif /* _MACH_VM_H_ */