Loading...
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
/*
 * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
 *
 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
 * 
 * This file contains Original Code and/or Modifications of Original Code
 * as defined in and that are subject to the Apple Public Source License
 * Version 2.0 (the 'License'). You may not use this file except in
 * compliance with the License. The rights granted to you under the License
 * may not be used to create, or enable the creation or redistribution of,
 * unlawful or unlicensed copies of an Apple operating system, or to
 * circumvent, violate, or enable the circumvention or violation of, any
 * terms of an Apple operating system software license agreement.
 * 
 * Please obtain a copy of the License at
 * http://www.opensource.apple.com/apsl/ and read it before using this file.
 * 
 * The Original Code and all software distributed under the License are
 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
 * Please see the License for the specific language governing rights and
 * limitations under the License.
 * 
 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
 */
/*
 * @OSF_FREE_COPYRIGHT@
 */
/* 
 * Mach Operating System
 * Copyright (c) 1991,1990,1989 Carnegie Mellon University
 * All Rights Reserved.
 * 
 * Permission to use, copy, modify and distribute this software and its
 * documentation is hereby granted, provided that both the copyright
 * notice and this permission notice appear in all copies of the
 * software, derivative works or modified versions, and any portions
 * thereof, and that both notices appear in supporting documentation.
 * 
 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
 * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
 * 
 * Carnegie Mellon requests users of this software to return to
 * 
 *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
 *  School of Computer Science
 *  Carnegie Mellon University
 *  Pittsburgh PA 15213-3890
 * 
 * any improvements or extensions that they make and grant Carnegie Mellon
 * the rights to redistribute these changes.
 */
/*
 */
/*
 *	File:	mach/vm_map.defs
 *
 *	Exported (native-sized) kernel VM calls.
 */

subsystem
#if	KERNEL_SERVER || KOBJECT_SERVER
	KernelServer
#endif	/* KERNEL_SERVER || KOBJECT_SERVER */
	  vm_map 3800;

#if KERNEL_SERVER
#define VM_KERNEL_SERVER 1
#endif

#include <mach/std_types.defs>
#include <mach/mach_types.defs>
#include <mach_debug/mach_debug_types.defs>

#define CONCAT(a,b) a ## b
#if !KERNEL && !LIBSYSCALL_INTERFACE && !KERNEL_VM_TEST
#define PREFIX(NAME) CONCAT(_kernelrpc_, NAME)
#else
#define PREFIX(NAME) NAME
#endif

#if	KERNEL_SERVER
#define KERNEL_SERVER_SUFFIX(NAME) CONCAT(NAME, _external)
#else
#define KERNEL_SERVER_SUFFIX(NAME) NAME
#endif

/* If building for Sandbox, keep NAME unchanged */
#if SANDBOX_COMPILER
#define KERNEL_SERVER_SUFFIX_SANDBOX(NAME) NAME
#else
#define KERNEL_SERVER_SUFFIX_SANDBOX(NAME) KERNEL_SERVER_SUFFIX(NAME)
#endif

/*
 *      Returns information about the contents of the virtual
 *      address space of the target task at the specified
 *      address.  The returned protection, inheritance, sharing
 *      and memory object values apply to the entire range described
 *      by the address range returned; the memory object offset
 *      corresponds to the beginning of the address range.
 *      [If the specified address is not allocated, the next
 *      highest address range is described.  If no addresses beyond
 *      the one specified are allocated, the call returns KERN_NO_SPACE.]
 */
routine vm_region(
                target_task     : vm_map_read_t;
	inout	address		: vm_address_t;
        out     size            : vm_size_t;
		flavor		: vm_region_flavor_t;
	out	info		: vm_region_info_t, CountInOut;
        out     object_name     : memory_object_name_t =
                                        MACH_MSG_TYPE_MOVE_SEND
                                        ctype: mach_port_t);

/*
 *	Allocate zero-filled memory in the address space
 *	of the target task, either at the specified address,
 *	or wherever space can be found (if anywhere is TRUE),
 *	of the specified size.  The address at which the
 *	allocation actually took place is returned.
 */

#if !KERNEL && !LIBSYSCALL_INTERFACE && !KERNEL_VM_TEST
skip;
#else
routine PREFIX(KERNEL_SERVER_SUFFIX(vm_allocate))(
		target_task	: vm_task_entry_t;
	inout	address		: vm_address_t;
		size		: vm_size_t;
		flags		: int);

#endif

/*
 *	Deallocate the specified range from the virtual
 *	address space of the target task.
 */

#if !KERNEL && !LIBSYSCALL_INTERFACE && !KERNEL_VM_TEST
skip;
#else
routine PREFIX(vm_deallocate)(
		target_task	: vm_task_entry_t;
		address		: vm_address_t;
		size		: vm_size_t);

#endif

/*
 *	Set the current or maximum protection attribute
 *	for the specified range of the virtual address
 *	space of the target task.  The current protection
 *	limits the memory access rights of threads within
 *	the task; the maximum protection limits the accesses
 *	that may be given in the current protection.
 *	Protections are specified as a set of {read, write, execute}
 *	*permissions*.
 */

#if !KERNEL && !LIBSYSCALL_INTERFACE && !KERNEL_VM_TEST
skip;
#else
routine PREFIX(vm_protect)(
		target_task	: vm_task_entry_t;
		address		: vm_address_t;
		size		: vm_size_t;
		set_maximum	: boolean_t;
		new_protection	: vm_prot_t);
#endif

/*
 *	Set the inheritance attribute for the specified range
 *	of the virtual address space of the target task.
 *	The inheritance value is one of {none, copy, share}, and
 *	specifies how the child address space should acquire
 *	this memory at the time of a task_create call.
 */
routine vm_inherit(
		target_task	: vm_task_entry_t;
		address		: vm_address_t;
		size		: vm_size_t;
		new_inheritance	: vm_inherit_t);

/*
 *	Returns the contents of the specified range of the
 *	virtual address space of the target task.  [The
 *	range must be aligned on a virtual page boundary,
 *	and must be a multiple of pages in extent.  The
 *	protection on the specified range must permit reading.]
 */
routine PREFIX(vm_read) (
		target_task	: vm_map_read_t;
		address		: vm_address_t;
		size		: vm_size_t;
	out	data		: pointer_t);

/* 
 * List corrollary to vm_read, returns mapped contents of specified
 * ranges within target address space.
 */
routine vm_read_list(
		target_task 	: vm_map_read_t;
	inout	data_list   	: vm_read_entry_t;
		count		: natural_t);

/*
 *	Writes the contents of the specified range of the
 *	virtual address space of the target task.  [The
 *	range must be aligned on a virtual page boundary,
 *	and must be a multiple of pages in extent.  The
 *	protection on the specified range must permit writing.]
 */
routine vm_write(
		target_task	: vm_map_t;
		address		: vm_address_t;
		data		: pointer_t);

/*
 *	Copy the contents of the source range of the virtual
 *	address space of the target task to the destination
 *	range in that same address space.  [Both of the
 *	ranges must be aligned on a virtual page boundary,
 *	and must be multiples of pages in extent.  The
 *	protection on the source range must permit reading,
 *	and the protection on the destination range must
 *	permit writing.]
 */
routine vm_copy(
		target_task	: vm_map_t;
		source_address	: vm_address_t;
		size		: vm_size_t;
		dest_address	: vm_address_t);

/*
 *	Returns the contents of the specified range of the
 *	virtual address space of the target task.  [There
 *	are no alignment restrictions, and the results will
 *      overwrite the area pointed to by data - which must
 *      already exist. The protection on the specified range
 *	must permit reading.]
 */
routine vm_read_overwrite(
		target_task	: vm_map_read_t;
		address		: vm_address_t;
		size		: vm_size_t;
		data		: vm_address_t;
	out	outsize		: vm_size_t);


routine vm_msync(
		target_task	: vm_map_t;
		address		: vm_address_t;
		size		: vm_size_t;
		sync_flags	: vm_sync_t);

/*
 *	Set the paging behavior attribute for the specified range
 *	of the virtual address space of the target task.
 *	The behavior value is one of {default, random, forward 
 *	sequential, reverse sequential} and indicates the expected
 *	page reference pattern for the specified range.
 */
routine vm_behavior_set(
		target_task	: vm_map_t;
		address		: vm_address_t;
		size		: vm_size_t;
		new_behavior	: vm_behavior_t);


/*
 *	Map a user-defined memory object into the virtual address
 *	space of the target task.  If desired (anywhere is TRUE),
 *	the kernel will find a suitable address range of the
 *	specified size; else, the specific address will be allocated.
 *
 *	The beginning address of the range will be aligned on a virtual
 *	page boundary, be at or beyond the address specified, and
 *	meet the mask requirements (bits turned on in the mask must not
 *	be turned on in the result); the size of the range, in bytes,
 *	will be rounded	up to an integral number of virtual pages.
 *
 *	The memory in the resulting range will be associated with the
 *	specified memory object, with the beginning of the memory range
 *	referring to the specified offset into the memory object.
 *
 *	The mapping will take the current and maximum protections and
 *	the inheritance attributes specified; see the vm_protect and
 *	vm_inherit calls for a description of these attributes.
 *
 *	If desired (copy is TRUE), the memory range will be filled
 *	with a copy of the data from the memory object; this copy will
 *	be private to this mapping in this target task.  Otherwise,
 *	the memory in this mapping will be shared with other mappings
 *	of the same memory object at the same offset (in this task or
 *	in other tasks).  [The Mach kernel only enforces shared memory
 *	consistency among mappings on one host with similar page alignments.
 *	The user-defined memory manager for this object is responsible
 *	for further consistency.]
 */
routine PREFIX(KERNEL_SERVER_SUFFIX(vm_map)) (
		target_task	: vm_task_entry_t;
	inout	address		: vm_address_t;
		size		: vm_size_t;
		mask		: vm_address_t;
		flags		: int;
		object		: mem_entry_name_port_t;
		offset		: vm_offset_t;
		copy		: boolean_t;
		cur_protection	: vm_prot_t;
		max_protection	: vm_prot_t;
		inheritance	: vm_inherit_t);

/*
 *	Set/Get special properties of memory associated
 *	to some virtual address range, such as cachability, 
 *	migrability, replicability.  Machine-dependent.
 */
routine vm_machine_attribute(
		target_task	: vm_map_t;
		address		: vm_address_t;
		size		: vm_size_t;
		attribute	: vm_machine_attribute_t;
	inout	value		: vm_machine_attribute_val_t);

/*
 *      Map portion of a task's address space.
 */
routine PREFIX(KERNEL_SERVER_SUFFIX(vm_remap)) (
		target_task	: vm_map_t;
	inout	target_address	: vm_address_t;
		size		: vm_size_t;
		mask		: vm_address_t;
		flags		: int;
		src_task	: vm_map_t;
		src_address	: vm_address_t;
		copy		: boolean_t;
	out	cur_protection	: vm_prot_t;
	out	max_protection	: vm_prot_t;
		inheritance	: vm_inherit_t);

/*
 *	Require that all future virtual memory allocation
 *	allocates wired memory.  Setting must_wire to FALSE
 *	disables the wired future feature.
 */
routine task_wire(
		target_task	: vm_map_t;
		must_wire	: boolean_t);

	
/*
 *	Allow application level processes to create named entries which
 *	correspond to mapped portions of their address space.  These named
 *	entries can then be manipulated, shared with other processes in
 *	other address spaces and ultimately mapped in ohter address spaces
 */

routine mach_make_memory_entry(
		target_task	:vm_map_t;
	inout	size		:vm_size_t;
		offset		:vm_offset_t;
		permission	:vm_prot_t;
	out	object_handle	:mem_entry_name_port_move_send_t;
		parent_entry	:mem_entry_name_port_t);

/*
 *      Give the caller information on the given location in a virtual
 *      address space.  If a page is mapped return ref and dirty info.
 */
routine vm_map_page_query(
                target_map      :vm_map_read_t;
                offset          :vm_offset_t;
        out     disposition     :integer_t;
        out     ref_count       :integer_t);

/*
 *	Returns information about a region of memory.
 *	Includes info about the chain of objects rooted at that region.
 *      Only available in MACH_VM_DEBUG compiled kernels,
 *      otherwise returns KERN_FAILURE.
 */
routine mach_vm_region_info(
		task		: vm_map_read_t;
		address		: vm_address_t;
	out	region		: vm_info_region_t;
	out	objects		: vm_info_object_array_t);

routine	vm_mapped_pages_info(  /* OBSOLETE */
		task		: vm_map_read_t;
	out	pages		: page_address_array_t);

skip; /* was vm_region_object_create */

/*
 *	A recursive form of vm_region which probes submaps withint the
 *	address space.
 */
routine vm_region_recurse(
                target_task     : vm_map_read_t;
	inout	address		: vm_address_t;
        out     size            : vm_size_t;
	inout	nesting_depth	: natural_t;
	out	info		: vm_region_recurse_info_t,CountInOut);


/* 
 *	The routines below are temporary, meant for transitional use
 *	as their counterparts are moved from 32 to 64 bit data path
 */


routine vm_region_recurse_64(
                target_task     : vm_map_read_t;
	inout	address		: vm_address_t;
        out     size            : vm_size_t;
	inout	nesting_depth	: natural_t;
	out	info		: vm_region_recurse_info_t,CountInOut);

routine mach_vm_region_info_64( /* OBSOLETE */
		task		: vm_map_read_t;
		address		: vm_address_t;
	out	region		: vm_info_region_64_t;
	out	objects		: vm_info_object_array_t);

routine vm_region_64(
                target_task     : vm_map_read_t;
	inout	address		: vm_address_t;
        out     size            : vm_size_t;
		flavor		: vm_region_flavor_t;
	out	info		: vm_region_info_t, CountInOut;
        out     object_name     : memory_object_name_t =
                                        MACH_MSG_TYPE_MOVE_SEND
                                        ctype: mach_port_t);

routine mach_make_memory_entry_64(
		target_task	:vm_map_t;
	inout	size		:memory_object_size_t;
		offset		:memory_object_offset_t;
		permission	:vm_prot_t;
	out	object_handle	:mach_port_move_send_t;
		parent_entry	:mem_entry_name_port_t);



routine KERNEL_SERVER_SUFFIX(vm_map_64)(
		target_task	: vm_task_entry_t;
	inout	address		: vm_address_t;
		size		: vm_size_t;
		mask		: vm_address_t;
		flags		: int;
		object		: mem_entry_name_port_t;
		offset		: memory_object_offset_t;
		copy		: boolean_t;
		cur_protection	: vm_prot_t;
		max_protection	: vm_prot_t;
		inheritance	: vm_inherit_t);

skip; /* was vm_map_get_upl */
skip; /* was vm_upl_map */
skip; /* was vm_upl_unmap */

/*
 *	Control behavior and investigate state of a "purgable" object in
 *	the virtual address space of the target task.  A purgable object is
 *	created via a call to vm_allocate() with VM_FLAGS_PURGABLE
 *	specified.  See the routine implementation for a complete
 *	definition of the routine.
 */
routine PREFIX(KERNEL_SERVER_SUFFIX_SANDBOX(vm_purgable_control)) (
#if KERNEL_SERVER
		target_tport: mach_port_t;
#else
		target_task	: vm_map_t;
#endif
		address		: vm_address_t;
		control		: vm_purgable_t;
	inout	state		: int);


routine vm_map_exec_lockdown(
		target_task 	: vm_map_t);

routine PREFIX(KERNEL_SERVER_SUFFIX(vm_remap_new)) (
		target_task	: vm_map_t;
	inout	target_address	: vm_address_t;
		size		: vm_size_t;
		mask		: vm_address_t;
		flags		: int;
#ifdef KERNEL_SERVER
		src_tport	: mach_port_t;
#else
		src_task	: vm_map_read_t;
#endif
		src_address	: vm_address_t;
		copy		: boolean_t;
	inout	cur_protection	: vm_prot_t;
	inout	max_protection	: vm_prot_t;
		inheritance	: vm_inherit_t);

/*
 * Relocate the pages of the source range of the specified map to a new range
 * of the given size in bytes within the same map.
 */
routine PREFIX(vm_reallocate) (
			target_task		: vm_map_t;
			src				: vm_address_t;
			src_size		: vm_size_t;
	inout	dst				: vm_address_t;
  			dst_size 		: vm_size_t;
			align_mask		: vm_offset_t;
			options		    : int;
			flags			: int);

/* vim: set ft=c : */