]> git.saurik.com Git - apple/xnu.git/blob - osfmk/mach/memory_object_types.h
65c57e54046866d7432da75e73ff1c50557f50ca
[apple/xnu.git] / osfmk / mach / memory_object_types.h
1 /*
2 * Copyright (c) 2000-2006 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_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. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28 /*
29 * @OSF_COPYRIGHT@
30 */
31 /*
32 * Mach Operating System
33 * Copyright (c) 1991,1990,1989,1988 Carnegie Mellon University
34 * All Rights Reserved.
35 *
36 * Permission to use, copy, modify and distribute this software and its
37 * documentation is hereby granted, provided that both the copyright
38 * notice and this permission notice appear in all copies of the
39 * software, derivative works or modified versions, and any portions
40 * thereof, and that both notices appear in supporting documentation.
41 *
42 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
43 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
44 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
45 *
46 * Carnegie Mellon requests users of this software to return to
47 *
48 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
49 * School of Computer Science
50 * Carnegie Mellon University
51 * Pittsburgh PA 15213-3890
52 *
53 * any improvements or extensions that they make and grant Carnegie Mellon
54 * the rights to redistribute these changes.
55 */
56 /*
57 */
58 /*
59 * File: memory_object.h
60 * Author: Michael Wayne Young
61 *
62 * External memory management interface definition.
63 */
64
65 #ifndef _MACH_MEMORY_OBJECT_TYPES_H_
66 #define _MACH_MEMORY_OBJECT_TYPES_H_
67
68 /*
69 * User-visible types used in the external memory
70 * management interface:
71 */
72
73 #include <mach/port.h>
74 #include <mach/message.h>
75 #include <mach/vm_prot.h>
76 #include <mach/vm_sync.h>
77 #include <mach/vm_types.h>
78 #include <mach/machine/vm_types.h>
79
80 #include <sys/cdefs.h>
81
82 #define VM_64_BIT_DATA_OBJECTS
83
84 typedef unsigned long long memory_object_offset_t;
85 typedef unsigned long long memory_object_size_t;
86 typedef natural_t memory_object_cluster_size_t;
87 typedef natural_t * memory_object_fault_info_t;
88
89
90 /*
91 * Temporary until real EMMI version gets re-implemented
92 */
93
94 #ifdef KERNEL_PRIVATE
95
96 struct memory_object_pager_ops; /* forward declaration */
97
98 typedef struct memory_object {
99 const struct memory_object_pager_ops *mo_pager_ops;
100 } *memory_object_t;
101
102 typedef struct memory_object_control {
103 struct vm_object *moc_object;
104 unsigned int moc_ikot; /* XXX fake ip_kotype */
105 } *memory_object_control_t;
106
107 typedef const struct memory_object_pager_ops {
108 void (*memory_object_reference)(
109 memory_object_t mem_obj);
110 void (*memory_object_deallocate)(
111 memory_object_t mem_obj);
112 kern_return_t (*memory_object_init)(
113 memory_object_t mem_obj,
114 memory_object_control_t mem_control,
115 memory_object_cluster_size_t size);
116 kern_return_t (*memory_object_terminate)(
117 memory_object_t mem_obj);
118 kern_return_t (*memory_object_data_request)(
119 memory_object_t mem_obj,
120 memory_object_offset_t offset,
121 memory_object_cluster_size_t length,
122 vm_prot_t desired_access,
123 memory_object_fault_info_t fault_info);
124 kern_return_t (*memory_object_data_return)(
125 memory_object_t mem_obj,
126 memory_object_offset_t offset,
127 vm_size_t size,
128 memory_object_offset_t *resid_offset,
129 int *io_error,
130 boolean_t dirty,
131 boolean_t kernel_copy,
132 int upl_flags);
133 kern_return_t (*memory_object_data_initialize)(
134 memory_object_t mem_obj,
135 memory_object_offset_t offset,
136 vm_size_t size);
137 kern_return_t (*memory_object_data_unlock)(
138 memory_object_t mem_obj,
139 memory_object_offset_t offset,
140 vm_size_t size,
141 vm_prot_t desired_access);
142 kern_return_t (*memory_object_synchronize)(
143 memory_object_t mem_obj,
144 memory_object_offset_t offset,
145 vm_size_t size,
146 vm_sync_t sync_flags);
147 kern_return_t (*memory_object_unmap)(
148 memory_object_t mem_obj);
149 const char *memory_object_pager_name;
150 } * memory_object_pager_ops_t;
151
152 #else /* KERNEL_PRIVATE */
153
154 typedef mach_port_t memory_object_t;
155 typedef mach_port_t memory_object_control_t;
156
157 #endif /* KERNEL_PRIVATE */
158
159 typedef memory_object_t *memory_object_array_t;
160 /* A memory object ... */
161 /* Used by the kernel to retrieve */
162 /* or store data */
163
164 typedef mach_port_t memory_object_name_t;
165 /* Used to describe the memory ... */
166 /* object in vm_regions() calls */
167
168 typedef mach_port_t memory_object_default_t;
169 /* Registered with the host ... */
170 /* for creating new internal objects */
171
172 #define MEMORY_OBJECT_NULL ((memory_object_t) 0)
173 #define MEMORY_OBJECT_CONTROL_NULL ((memory_object_control_t) 0)
174 #define MEMORY_OBJECT_NAME_NULL ((memory_object_name_t) 0)
175 #define MEMORY_OBJECT_DEFAULT_NULL ((memory_object_default_t) 0)
176
177
178 typedef int memory_object_copy_strategy_t;
179 /* How memory manager handles copy: */
180 #define MEMORY_OBJECT_COPY_NONE 0
181 /* ... No special support */
182 #define MEMORY_OBJECT_COPY_CALL 1
183 /* ... Make call on memory manager */
184 #define MEMORY_OBJECT_COPY_DELAY 2
185 /* ... Memory manager doesn't
186 * change data externally.
187 */
188 #define MEMORY_OBJECT_COPY_TEMPORARY 3
189 /* ... Memory manager doesn't
190 * change data externally, and
191 * doesn't need to see changes.
192 */
193 #define MEMORY_OBJECT_COPY_SYMMETRIC 4
194 /* ... Memory manager doesn't
195 * change data externally,
196 * doesn't need to see changes,
197 * and object will not be
198 * multiply mapped.
199 *
200 * XXX
201 * Not yet safe for non-kernel use.
202 */
203
204 #define MEMORY_OBJECT_COPY_INVALID 5
205 /* ... An invalid copy strategy,
206 * for external objects which
207 * have not been initialized.
208 * Allows copy_strategy to be
209 * examined without also
210 * examining pager_ready and
211 * internal.
212 */
213
214 typedef int memory_object_return_t;
215 /* Which pages to return to manager
216 this time (lock_request) */
217 #define MEMORY_OBJECT_RETURN_NONE 0
218 /* ... don't return any. */
219 #define MEMORY_OBJECT_RETURN_DIRTY 1
220 /* ... only dirty pages. */
221 #define MEMORY_OBJECT_RETURN_ALL 2
222 /* ... dirty and precious pages. */
223 #define MEMORY_OBJECT_RETURN_ANYTHING 3
224 /* ... any resident page. */
225
226 /*
227 * Data lock request flags
228 */
229
230 #define MEMORY_OBJECT_DATA_FLUSH 0x1
231 #define MEMORY_OBJECT_DATA_NO_CHANGE 0x2
232 #define MEMORY_OBJECT_DATA_PURGE 0x4
233 #define MEMORY_OBJECT_COPY_SYNC 0x8
234 #define MEMORY_OBJECT_DATA_SYNC 0x10
235 #define MEMORY_OBJECT_IO_SYNC 0x20
236
237 /*
238 * Types for the memory object flavor interfaces
239 */
240
241 #define MEMORY_OBJECT_INFO_MAX (1024)
242 typedef int *memory_object_info_t;
243 typedef int memory_object_flavor_t;
244 typedef int memory_object_info_data_t[MEMORY_OBJECT_INFO_MAX];
245
246
247 #define MEMORY_OBJECT_PERFORMANCE_INFO 11
248 #define MEMORY_OBJECT_ATTRIBUTE_INFO 14
249 #define MEMORY_OBJECT_BEHAVIOR_INFO 15
250
251 #ifdef PRIVATE
252
253 #define OLD_MEMORY_OBJECT_BEHAVIOR_INFO 10
254 #define OLD_MEMORY_OBJECT_ATTRIBUTE_INFO 12
255
256 struct old_memory_object_behave_info {
257 memory_object_copy_strategy_t copy_strategy;
258 boolean_t temporary;
259 boolean_t invalidate;
260 };
261
262 struct old_memory_object_attr_info { /* old attr list */
263 boolean_t object_ready;
264 boolean_t may_cache;
265 memory_object_copy_strategy_t copy_strategy;
266 };
267
268 typedef struct old_memory_object_behave_info *old_memory_object_behave_info_t;
269 typedef struct old_memory_object_behave_info old_memory_object_behave_info_data_t;
270 typedef struct old_memory_object_attr_info *old_memory_object_attr_info_t;
271 typedef struct old_memory_object_attr_info old_memory_object_attr_info_data_t;
272
273 #define OLD_MEMORY_OBJECT_BEHAVE_INFO_COUNT ((mach_msg_type_number_t) \
274 (sizeof(old_memory_object_behave_info_data_t)/sizeof(int)))
275 #define OLD_MEMORY_OBJECT_ATTR_INFO_COUNT ((mach_msg_type_number_t) \
276 (sizeof(old_memory_object_attr_info_data_t)/sizeof(int)))
277
278 #ifdef KERNEL
279
280 __BEGIN_DECLS
281 extern void memory_object_reference(memory_object_t object);
282 extern void memory_object_deallocate(memory_object_t object);
283
284 extern void memory_object_default_reference(memory_object_default_t);
285 extern void memory_object_default_deallocate(memory_object_default_t);
286
287 extern void memory_object_control_reference(memory_object_control_t control);
288 extern void memory_object_control_deallocate(memory_object_control_t control);
289 extern int memory_object_control_uiomove(memory_object_control_t, memory_object_offset_t, void *, int, int, int, int);
290 __END_DECLS
291
292 #endif /* KERNEL */
293
294 #endif /* PRIVATE */
295
296 struct memory_object_perf_info {
297 memory_object_cluster_size_t cluster_size;
298 boolean_t may_cache;
299 };
300
301 struct memory_object_attr_info {
302 memory_object_copy_strategy_t copy_strategy;
303 memory_object_cluster_size_t cluster_size;
304 boolean_t may_cache_object;
305 boolean_t temporary;
306 };
307
308 struct memory_object_behave_info {
309 memory_object_copy_strategy_t copy_strategy;
310 boolean_t temporary;
311 boolean_t invalidate;
312 boolean_t silent_overwrite;
313 boolean_t advisory_pageout;
314 };
315
316
317 typedef struct memory_object_behave_info *memory_object_behave_info_t;
318 typedef struct memory_object_behave_info memory_object_behave_info_data_t;
319
320 typedef struct memory_object_perf_info *memory_object_perf_info_t;
321 typedef struct memory_object_perf_info memory_object_perf_info_data_t;
322
323 typedef struct memory_object_attr_info *memory_object_attr_info_t;
324 typedef struct memory_object_attr_info memory_object_attr_info_data_t;
325
326 #define MEMORY_OBJECT_BEHAVE_INFO_COUNT ((mach_msg_type_number_t) \
327 (sizeof(memory_object_behave_info_data_t)/sizeof(int)))
328 #define MEMORY_OBJECT_PERF_INFO_COUNT ((mach_msg_type_number_t) \
329 (sizeof(memory_object_perf_info_data_t)/sizeof(int)))
330 #define MEMORY_OBJECT_ATTR_INFO_COUNT ((mach_msg_type_number_t) \
331 (sizeof(memory_object_attr_info_data_t)/sizeof(int)))
332
333 #define invalid_memory_object_flavor(f) \
334 (f != MEMORY_OBJECT_ATTRIBUTE_INFO && \
335 f != MEMORY_OBJECT_PERFORMANCE_INFO && \
336 f != OLD_MEMORY_OBJECT_BEHAVIOR_INFO && \
337 f != MEMORY_OBJECT_BEHAVIOR_INFO && \
338 f != OLD_MEMORY_OBJECT_ATTRIBUTE_INFO)
339
340
341 /*
342 * Used to support options on memory_object_release_name call
343 */
344 #define MEMORY_OBJECT_TERMINATE_IDLE 0x1
345 #define MEMORY_OBJECT_RESPECT_CACHE 0x2
346 #define MEMORY_OBJECT_RELEASE_NO_OP 0x4
347
348
349 /* named entry processor mapping options */
350 /* enumerated */
351 #define MAP_MEM_NOOP 0
352 #define MAP_MEM_COPYBACK 1
353 #define MAP_MEM_IO 2
354 #define MAP_MEM_WTHRU 3
355 #define MAP_MEM_WCOMB 4 /* Write combining mode */
356 /* aka store gather */
357
358 #define GET_MAP_MEM(flags) \
359 ((((unsigned int)(flags)) >> 24) & 0xFF)
360
361 #define SET_MAP_MEM(caching, flags) \
362 ((flags) = ((((unsigned int)(caching)) << 24) \
363 & 0xFF000000) | ((flags) & 0xFFFFFF));
364
365 /* leave room for vm_prot bits */
366 #define MAP_MEM_ONLY 0x10000 /* change processor caching */
367 #define MAP_MEM_NAMED_CREATE 0x20000 /* create extant object */
368 #define MAP_MEM_PURGABLE 0x40000 /* create a purgable VM object */
369 #define MAP_MEM_NAMED_REUSE 0x80000 /* reuse provided entry if identical */
370
371 #ifdef KERNEL
372
373 /*
374 * Universal Page List data structures
375 *
376 * A UPL describes a bounded set of physical pages
377 * associated with some range of an object or map
378 * and a snapshot of the attributes associated with
379 * each of those pages.
380 */
381 #ifdef PRIVATE
382 #define MAX_UPL_TRANSFER 256
383
384 struct upl_page_info {
385 ppnum_t phys_addr; /* physical page index number */
386 unsigned int
387 #ifdef XNU_KERNEL_PRIVATE
388 pageout:1, /* page is to be removed on commit */
389 absent:1, /* No valid data in this page */
390 dirty:1, /* Page must be cleaned (O) */
391 precious:1, /* must be cleaned, we have only copy */
392 device:1, /* no page data, mapped dev memory */
393 speculative:1, /* page is valid, but not yet accessed */
394 :0; /* force to long boundary */
395 #else
396 opaque; /* use upl_page_xxx() accessor funcs */
397 #endif /* XNU_KERNEL_PRIVATE */
398 };
399
400 #else
401
402 struct upl_page_info {
403 unsigned int opaque[2]; /* use upl_page_xxx() accessor funcs */
404 };
405
406 #endif /* PRIVATE */
407
408 typedef struct upl_page_info upl_page_info_t;
409 typedef upl_page_info_t *upl_page_info_array_t;
410 typedef upl_page_info_array_t upl_page_list_ptr_t;
411
412 typedef uint32_t upl_offset_t; /* page-aligned byte offset */
413 typedef uint32_t upl_size_t; /* page-aligned byte size */
414
415 /* upl invocation flags */
416 /* top nibble is used by super upl */
417
418 #define UPL_FLAGS_NONE 0x00000000
419 #define UPL_COPYOUT_FROM 0x00000001
420 #define UPL_PRECIOUS 0x00000002
421 #define UPL_NO_SYNC 0x00000004
422 #define UPL_CLEAN_IN_PLACE 0x00000008
423 #define UPL_NOBLOCK 0x00000010
424 #define UPL_RET_ONLY_DIRTY 0x00000020
425 #define UPL_SET_INTERNAL 0x00000040
426 #define UPL_QUERY_OBJECT_TYPE 0x00000080
427 #define UPL_RET_ONLY_ABSENT 0x00000100 /* used only for COPY_FROM = FALSE */
428 #define UPL_FILE_IO 0x00000200
429 #define UPL_SET_LITE 0x00000400
430 #define UPL_SET_INTERRUPTIBLE 0x00000800
431 #define UPL_SET_IO_WIRE 0x00001000
432 #define UPL_FOR_PAGEOUT 0x00002000
433 #define UPL_WILL_BE_DUMPED 0x00004000
434 #define UPL_FORCE_DATA_SYNC 0x00008000
435 /* continued after the ticket bits... */
436
437 #define UPL_PAGE_TICKET_MASK 0x000F0000
438 #define UPL_PAGE_TICKET_SHIFT 16
439
440 /* ... flags resume here */
441 #define UPL_BLOCK_ACCESS 0x00100000
442 #define UPL_ENCRYPT 0x00200000
443 #define UPL_NOZEROFILL 0x00400000
444 #define UPL_WILL_MODIFY 0x00800000 /* caller will modify the pages */
445
446 #define UPL_NEED_32BIT_ADDR 0x01000000
447
448 /* UPL flags known by this kernel */
449 #define UPL_VALID_FLAGS 0x01FFFFFF
450
451
452 /* upl abort error flags */
453 #define UPL_ABORT_RESTART 0x1
454 #define UPL_ABORT_UNAVAILABLE 0x2
455 #define UPL_ABORT_ERROR 0x4
456 #define UPL_ABORT_FREE_ON_EMPTY 0x8 /* only implemented in wrappers */
457 #define UPL_ABORT_DUMP_PAGES 0x10
458 #define UPL_ABORT_NOTIFY_EMPTY 0x20
459 #define UPL_ABORT_ALLOW_ACCESS 0x40
460 #define UPL_ABORT_REFERENCE 0x80
461
462 /* upl pages check flags */
463 #define UPL_CHECK_DIRTY 0x1
464
465
466 /*
467 * upl pagein/pageout flags
468 *
469 *
470 * when I/O is issued from this UPL it should be done synchronously
471 */
472 #define UPL_IOSYNC 0x1
473
474 /*
475 * the passed in UPL should not have either a commit or abort
476 * applied to it by the underlying layers... the site that
477 * created the UPL is responsible for cleaning it up.
478 */
479 #define UPL_NOCOMMIT 0x2
480
481 /*
482 * turn off any speculative read-ahead applied at the I/O layer
483 */
484 #define UPL_NORDAHEAD 0x4
485
486 /*
487 * pageout request is targeting a real file
488 * as opposed to a swap file.
489 */
490
491 #define UPL_VNODE_PAGER 0x8
492 /*
493 * this pageout is being originated as part of an explicit
494 * memory synchronization operation... no speculative clustering
495 * should be applied, only the range specified should be pushed.
496 */
497 #define UPL_MSYNC 0x10
498
499 /*
500 *
501 */
502 #ifdef MACH_KERNEL_PRIVATE
503 #define UPL_PAGING_ENCRYPTED 0x20
504 #endif /* MACH_KERNEL_PRIVATE */
505
506 /*
507 * this pageout is being originated as part of an explicit
508 * memory synchronization operation that is checking for I/O
509 * errors and taking it's own action... if an error occurs,
510 * just abort the pages back into the cache unchanged
511 */
512 #define UPL_KEEPCACHED 0x40
513
514 /*
515 * this pageout originated from within cluster_io to deal
516 * with a dirty page that hasn't yet been seen by the FS
517 * that backs it... tag it so that the FS can take the
518 * appropriate action w/r to its locking model since the
519 * pageout will reenter the FS for the same file currently
520 * being handled in this context.
521 */
522
523 #define UPL_NESTED_PAGEOUT 0x80
524
525
526
527 /* upl commit flags */
528 #define UPL_COMMIT_FREE_ON_EMPTY 0x1 /* only implemented in wrappers */
529 #define UPL_COMMIT_CLEAR_DIRTY 0x2
530 #define UPL_COMMIT_SET_DIRTY 0x4
531 #define UPL_COMMIT_INACTIVATE 0x8
532 #define UPL_COMMIT_NOTIFY_EMPTY 0x10
533 #define UPL_COMMIT_ALLOW_ACCESS 0x20
534
535 /* flags for return of state from vm_map_get_upl, vm_upl address space */
536 /* based call */
537 #define UPL_DEV_MEMORY 0x1
538 #define UPL_PHYS_CONTIG 0x2
539
540
541 /*
542 * Flags for the UPL page ops routine. This routine is not exported
543 * out of the kernel at the moment and so the defs live here.
544 */
545 #define UPL_POP_DIRTY 0x1
546 #define UPL_POP_PAGEOUT 0x2
547 #define UPL_POP_PRECIOUS 0x4
548 #define UPL_POP_ABSENT 0x8
549 #define UPL_POP_BUSY 0x10
550
551 #define UPL_POP_PHYSICAL 0x10000000
552 #define UPL_POP_DUMP 0x20000000
553 #define UPL_POP_SET 0x40000000
554 #define UPL_POP_CLR 0x80000000
555
556 /*
557 * Flags for the UPL range op routine. This routine is not exported
558 * out of the kernel at the moemet and so the defs live here.
559 */
560 /*
561 * UPL_ROP_ABSENT: Returns the extent of the range presented which
562 * is absent, starting with the start address presented
563 */
564 #define UPL_ROP_ABSENT 0x01
565 /*
566 * UPL_ROP_PRESENT: Returns the extent of the range presented which
567 * is present (i.e. resident), starting with the start address presented
568 */
569 #define UPL_ROP_PRESENT 0x02
570 /*
571 * UPL_ROP_DUMP: Dump the pages which are found in the target object
572 * for the target range.
573 */
574 #define UPL_ROP_DUMP 0x04
575
576 #ifdef PRIVATE
577
578 /* access macros for upl_t */
579
580 #define UPL_DEVICE_PAGE(upl) \
581 (((upl)[0].phys_addr != 0) ? ((upl)[0].device) : FALSE)
582
583 #define UPL_PAGE_PRESENT(upl, index) \
584 ((upl)[(index)].phys_addr != 0)
585
586 #define UPL_PHYS_PAGE(upl, index) \
587 ((upl)[(index)].phys_addr)
588
589 #define UPL_SPECULATIVE_PAGE(upl, index) \
590 (((upl)[(index)].phys_addr != 0) ? ((upl)[(index)].speculative) : FALSE)
591
592 #define UPL_DIRTY_PAGE(upl, index) \
593 (((upl)[(index)].phys_addr != 0) ? ((upl)[(index)].dirty) : FALSE)
594
595 #define UPL_PRECIOUS_PAGE(upl, index) \
596 (((upl)[(index)].phys_addr != 0) ? ((upl)[(index)].precious) : FALSE)
597
598 #define UPL_VALID_PAGE(upl, index) \
599 (((upl)[(index)].phys_addr != 0) ? (!((upl)[(index)].absent)) : FALSE)
600
601 #define UPL_PAGEOUT_PAGE(upl, index) \
602 (((upl)[(index)].phys_addr != 0) ? ((upl)[(index)].pageout) : FALSE)
603
604 #define UPL_SET_PAGE_FREE_ON_COMMIT(upl, index) \
605 (((upl)[(index)].phys_addr != 0) ? \
606 ((upl)[(index)].pageout = TRUE) : FALSE)
607
608 #define UPL_CLR_PAGE_FREE_ON_COMMIT(upl, index) \
609 (((upl)[(index)].phys_addr != 0) ? \
610 ((upl)[(index)].pageout = FALSE) : FALSE)
611
612 /* The call prototyped below is used strictly by UPL_GET_INTERNAL_PAGE_LIST */
613
614 extern vm_size_t upl_offset_to_pagelist;
615 extern vm_size_t upl_get_internal_pagelist_offset(void);
616
617 /* UPL_GET_INTERNAL_PAGE_LIST is only valid on internal objects where the */
618 /* list request was made with the UPL_INTERNAL flag */
619
620 #define UPL_GET_INTERNAL_PAGE_LIST(upl) \
621 ((upl_page_info_t *)((upl_offset_to_pagelist == 0) ? \
622 (unsigned int)upl + (unsigned int)(upl_offset_to_pagelist = upl_get_internal_pagelist_offset()): \
623 (unsigned int)upl + (unsigned int)upl_offset_to_pagelist))
624
625 __BEGIN_DECLS
626
627 extern ppnum_t upl_phys_page(upl_page_info_t *upl, int index);
628 extern boolean_t upl_device_page(upl_page_info_t *upl);
629 extern boolean_t upl_speculative_page(upl_page_info_t *upl, int index);
630 extern void upl_clear_dirty(upl_t upl, boolean_t value);
631
632 __END_DECLS
633
634 #endif /* PRIVATE */
635
636 __BEGIN_DECLS
637
638 extern boolean_t upl_page_present(upl_page_info_t *upl, int index);
639 extern boolean_t upl_dirty_page(upl_page_info_t *upl, int index);
640 extern boolean_t upl_valid_page(upl_page_info_t *upl, int index);
641 extern void upl_deallocate(upl_t upl);
642
643 __END_DECLS
644
645 #endif /* KERNEL */
646
647 #endif /* _MACH_MEMORY_OBJECT_TYPES_H_ */