]> git.saurik.com Git - apple/xnu.git/blob - osfmk/vm/vm_object.h
d7a3433df084577c0d5f8dea559fd494144d91f8
[apple/xnu.git] / osfmk / vm / vm_object.h
1 /*
2 * Copyright (c) 2000-2005 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,1987 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: vm_object.h
60 * Author: Avadis Tevanian, Jr., Michael Wayne Young
61 * Date: 1985
62 *
63 * Virtual memory object module definitions.
64 */
65
66 #ifndef _VM_VM_OBJECT_H_
67 #define _VM_VM_OBJECT_H_
68
69 #include <mach_pagemap.h>
70 #include <task_swapper.h>
71
72 #include <mach/kern_return.h>
73 #include <mach/boolean.h>
74 #include <mach/memory_object_types.h>
75 #include <mach/port.h>
76 #include <mach/vm_prot.h>
77 #include <mach/vm_param.h>
78 #include <mach/machine/vm_types.h>
79 #include <kern/queue.h>
80 #include <kern/lock.h>
81 #include <kern/assert.h>
82 #include <kern/misc_protos.h>
83 #include <kern/macro_help.h>
84 #include <ipc/ipc_types.h>
85 #include <vm/pmap.h>
86
87 #if MACH_PAGEMAP
88 #include <vm/vm_external.h>
89 #endif /* MACH_PAGEMAP */
90
91 struct vm_page;
92
93 /*
94 * Types defined:
95 *
96 * vm_object_t Virtual memory object.
97 */
98
99 struct vm_object {
100 queue_head_t memq; /* Resident memory */
101 decl_mutex_data(, Lock) /* Synchronization */
102
103 vm_object_size_t size; /* Object size (only valid
104 * if internal)
105 */
106 struct vm_page *memq_hint;
107 int ref_count; /* Number of references */
108 #if TASK_SWAPPER
109 int res_count; /* Residency references (swap)*/
110 #endif /* TASK_SWAPPER */
111 unsigned int resident_page_count;
112 /* number of resident pages */
113
114 struct vm_object *copy; /* Object that should receive
115 * a copy of my changed pages,
116 * for copy_delay, or just the
117 * temporary object that
118 * shadows this object, for
119 * copy_call.
120 */
121 struct vm_object *shadow; /* My shadow */
122 vm_object_offset_t shadow_offset; /* Offset into shadow */
123
124 memory_object_t pager; /* Where to get data */
125 vm_object_offset_t paging_offset; /* Offset into memory object */
126 memory_object_control_t pager_control; /* Where data comes back */
127
128 memory_object_copy_strategy_t
129 copy_strategy; /* How to handle data copy */
130
131 unsigned int absent_count; /* The number of pages that
132 * have been requested but
133 * not filled. That is, the
134 * number of pages for which
135 * the "absent" attribute is
136 * asserted.
137 */
138
139 int paging_in_progress;
140 /* The memory object ports are
141 * being used (e.g., for pagein
142 * or pageout) -- don't change
143 * any of these fields (i.e.,
144 * don't collapse, destroy or
145 * terminate)
146 */
147 unsigned int
148 /* boolean_t array */ all_wanted:11, /* Bit array of "want to be
149 * awakened" notations. See
150 * VM_OBJECT_EVENT_* items
151 * below */
152 /* boolean_t */ pager_created:1, /* Has pager been created? */
153 /* boolean_t */ pager_initialized:1, /* Are fields ready to use? */
154 /* boolean_t */ pager_ready:1, /* Will pager take requests? */
155
156 /* boolean_t */ pager_trusted:1,/* The pager for this object
157 * is trusted. This is true for
158 * all internal objects (backed
159 * by the default pager)
160 */
161 /* boolean_t */ can_persist:1, /* The kernel may keep the data
162 * for this object (and rights
163 * to the memory object) after
164 * all address map references
165 * are deallocated?
166 */
167 /* boolean_t */ internal:1, /* Created by the kernel (and
168 * therefore, managed by the
169 * default memory manger)
170 */
171 /* boolean_t */ temporary:1, /* Permanent objects may be
172 * changed externally by the
173 * memory manager, and changes
174 * made in memory must be
175 * reflected back to the memory
176 * manager. Temporary objects
177 * lack both of these
178 * characteristics.
179 */
180 /* boolean_t */ private:1, /* magic device_pager object,
181 * holds private pages only */
182 /* boolean_t */ pageout:1, /* pageout object. contains
183 * private pages that refer to
184 * a real memory object. */
185 /* boolean_t */ alive:1, /* Not yet terminated */
186
187 /* boolean_t */ purgable:2, /* Purgable state. See
188 * VM_OBJECT_PURGABLE_*
189 * items below.
190 */
191 /* boolean_t */ shadowed:1, /* Shadow may exist */
192 /* boolean_t */ silent_overwrite:1,
193 /* Allow full page overwrite
194 * without data_request if
195 * page is absent */
196 /* boolean_t */ advisory_pageout:1,
197 /* Instead of sending page
198 * via OOL, just notify
199 * pager that the kernel
200 * wants to discard it, page
201 * remains in object */
202 /* boolean_t */ true_share:1,
203 /* This object is mapped
204 * in more than one place
205 * and hence cannot be
206 * coalesced */
207 /* boolean_t */ terminating:1,
208 /* Allows vm_object_lookup
209 * and vm_object_deallocate
210 * to special case their
211 * behavior when they are
212 * called as a result of
213 * page cleaning during
214 * object termination
215 */
216 /* boolean_t */ named:1, /* An enforces an internal
217 * naming convention, by
218 * calling the right routines
219 * for allocation and
220 * destruction, UBC references
221 * against the vm_object are
222 * checked.
223 */
224 /* boolean_t */ shadow_severed:1,
225 /* When a permanent object
226 * backing a COW goes away
227 * unexpectedly. This bit
228 * allows vm_fault to return
229 * an error rather than a
230 * zero filled page.
231 */
232 /* boolean_t */ phys_contiguous:1,
233 /* Memory is wired and
234 * guaranteed physically
235 * contiguous. However
236 * it is not device memory
237 * and obeys normal virtual
238 * memory rules w.r.t pmap
239 * access bits.
240 */
241 /* boolean_t */ nophyscache:1;
242 /* When mapped at the
243 * pmap level, don't allow
244 * primary caching. (for
245 * I/O)
246 */
247
248
249
250 queue_chain_t cached_list; /* Attachment point for the
251 * list of objects cached as a
252 * result of their can_persist
253 * value
254 */
255
256 queue_head_t msr_q; /* memory object synchronise
257 request queue */
258
259 vm_object_offset_t last_alloc; /* last allocation offset */
260 vm_object_offset_t sequential; /* sequential access size */
261 vm_size_t cluster_size; /* size of paging cluster */
262 #if MACH_PAGEMAP
263 vm_external_map_t existence_map; /* bitmap of pages written to
264 * backing storage */
265 #endif /* MACH_PAGEMAP */
266 vm_offset_t cow_hint; /* last page present in */
267 /* shadow but not in object */
268 #if MACH_ASSERT
269 struct vm_object *paging_object; /* object which pages to be
270 * swapped out are temporary
271 * put in current object
272 */
273 #endif
274 /* hold object lock when altering */
275 unsigned int /* cache WIMG bits */
276 wimg_bits:8, /* wimg plus some expansion*/
277 not_in_use:24;
278 #ifdef UPL_DEBUG
279 queue_head_t uplq; /* List of outstanding upls */
280 #ifdef VM_PIP_DEBUG
281 /*
282 * Keep track of the stack traces for the first holders
283 * of a "paging_in_progress" reference for this VM object.
284 */
285 #define VM_PIP_DEBUG_STACK_FRAMES 25 /* depth of each stack trace */
286 #define VM_PIP_DEBUG_MAX_REFS 10 /* track that many references */
287 struct __pip_backtrace {
288 void *pip_retaddr[VM_PIP_DEBUG_STACK_FRAMES];
289 } pip_holders[VM_PIP_DEBUG_MAX_REFS];
290 #endif /* VM_PIP_DEBUG */
291 #endif /* UPL_DEBUG */
292 };
293
294 #define VM_PAGE_REMOVE(page) \
295 MACRO_BEGIN \
296 vm_page_t __page = (page); \
297 vm_object_t __object = __page->object; \
298 if (__page == __object->memq_hint) { \
299 vm_page_t __new_hint; \
300 queue_entry_t __qe; \
301 __qe = queue_next(&__page->listq); \
302 if (queue_end(&__object->memq, __qe)) { \
303 __qe = queue_prev(&__page->listq); \
304 if (queue_end(&__object->memq, __qe)) { \
305 __qe = NULL; \
306 } \
307 } \
308 __new_hint = (vm_page_t) __qe; \
309 __object->memq_hint = __new_hint; \
310 } \
311 queue_remove(&__object->memq, __page, vm_page_t, listq); \
312 MACRO_END
313
314 #define VM_PAGE_INSERT(page, object) \
315 MACRO_BEGIN \
316 vm_page_t __page = (page); \
317 vm_object_t __object = (object); \
318 queue_enter(&__object->memq, __page, vm_page_t, listq); \
319 __object->memq_hint = __page; \
320 MACRO_END
321
322 __private_extern__
323 vm_object_t kernel_object; /* the single kernel object */
324
325 __private_extern__
326 unsigned int vm_object_absent_max; /* maximum number of absent pages
327 at a time for each object */
328
329 # define VM_MSYNC_INITIALIZED 0
330 # define VM_MSYNC_SYNCHRONIZING 1
331 # define VM_MSYNC_DONE 2
332
333 struct msync_req {
334 queue_chain_t msr_q; /* object request queue */
335 queue_chain_t req_q; /* vm_msync request queue */
336 unsigned int flag;
337 vm_object_offset_t offset;
338 vm_object_size_t length;
339 vm_object_t object; /* back pointer */
340 decl_mutex_data(, msync_req_lock) /* Lock for this structure */
341 };
342
343 typedef struct msync_req *msync_req_t;
344 #define MSYNC_REQ_NULL ((msync_req_t) 0)
345
346 /*
347 * Macros to allocate and free msync_reqs
348 */
349 #define msync_req_alloc(msr) \
350 MACRO_BEGIN \
351 (msr) = (msync_req_t)kalloc(sizeof(struct msync_req)); \
352 mutex_init(&(msr)->msync_req_lock, 0); \
353 msr->flag = VM_MSYNC_INITIALIZED; \
354 MACRO_END
355
356 #define msync_req_free(msr) \
357 (kfree((msr), sizeof(struct msync_req)))
358
359 #define msr_lock(msr) mutex_lock(&(msr)->msync_req_lock)
360 #define msr_unlock(msr) mutex_unlock(&(msr)->msync_req_lock)
361
362 /*
363 * Declare procedures that operate on VM objects.
364 */
365
366 __private_extern__ void vm_object_bootstrap(void);
367
368 __private_extern__ void vm_object_init(void);
369
370 __private_extern__ void vm_object_reaper_init(void);
371
372 __private_extern__ vm_object_t vm_object_allocate(
373 vm_object_size_t size);
374
375 __private_extern__ void _vm_object_allocate(vm_object_size_t size,
376 vm_object_t object);
377
378 #if TASK_SWAPPER
379
380 __private_extern__ void vm_object_res_reference(
381 vm_object_t object);
382 __private_extern__ void vm_object_res_deallocate(
383 vm_object_t object);
384 #define VM_OBJ_RES_INCR(object) (object)->res_count++
385 #define VM_OBJ_RES_DECR(object) (object)->res_count--
386
387 #else /* TASK_SWAPPER */
388
389 #define VM_OBJ_RES_INCR(object)
390 #define VM_OBJ_RES_DECR(object)
391 #define vm_object_res_reference(object)
392 #define vm_object_res_deallocate(object)
393
394 #endif /* TASK_SWAPPER */
395
396 #define vm_object_reference_locked(object) \
397 MACRO_BEGIN \
398 vm_object_t RLObject = (object); \
399 assert((RLObject)->ref_count > 0); \
400 (RLObject)->ref_count++; \
401 vm_object_res_reference(RLObject); \
402 MACRO_END
403
404
405 __private_extern__ void vm_object_reference(
406 vm_object_t object);
407
408 #if !MACH_ASSERT
409
410 #define vm_object_reference(object) \
411 MACRO_BEGIN \
412 vm_object_t RObject = (object); \
413 if (RObject) { \
414 vm_object_lock(RObject); \
415 vm_object_reference_locked(RObject); \
416 vm_object_unlock(RObject); \
417 } \
418 MACRO_END
419
420 #endif /* MACH_ASSERT */
421
422 __private_extern__ void vm_object_deallocate(
423 vm_object_t object);
424
425 __private_extern__ kern_return_t vm_object_release_name(
426 vm_object_t object,
427 int flags);
428
429 __private_extern__ void vm_object_pmap_protect(
430 vm_object_t object,
431 vm_object_offset_t offset,
432 vm_object_size_t size,
433 pmap_t pmap,
434 vm_map_offset_t pmap_start,
435 vm_prot_t prot);
436
437 __private_extern__ void vm_object_page_remove(
438 vm_object_t object,
439 vm_object_offset_t start,
440 vm_object_offset_t end);
441
442 __private_extern__ void vm_object_deactivate_pages(
443 vm_object_t object,
444 vm_object_offset_t offset,
445 vm_object_size_t size,
446 boolean_t kill_page);
447
448 __private_extern__ unsigned int vm_object_purge(
449 vm_object_t object);
450
451 __private_extern__ kern_return_t vm_object_purgable_control(
452 vm_object_t object,
453 vm_purgable_t control,
454 int *state);
455
456 __private_extern__ boolean_t vm_object_coalesce(
457 vm_object_t prev_object,
458 vm_object_t next_object,
459 vm_object_offset_t prev_offset,
460 vm_object_offset_t next_offset,
461 vm_object_size_t prev_size,
462 vm_object_size_t next_size);
463
464 __private_extern__ boolean_t vm_object_shadow(
465 vm_object_t *object,
466 vm_object_offset_t *offset,
467 vm_object_size_t length);
468
469 __private_extern__ void vm_object_collapse(
470 vm_object_t object,
471 vm_object_offset_t offset,
472 boolean_t can_bypass);
473
474 __private_extern__ boolean_t vm_object_copy_quickly(
475 vm_object_t *_object,
476 vm_object_offset_t src_offset,
477 vm_object_size_t size,
478 boolean_t *_src_needs_copy,
479 boolean_t *_dst_needs_copy);
480
481 __private_extern__ kern_return_t vm_object_copy_strategically(
482 vm_object_t src_object,
483 vm_object_offset_t src_offset,
484 vm_object_size_t size,
485 vm_object_t *dst_object,
486 vm_object_offset_t *dst_offset,
487 boolean_t *dst_needs_copy);
488
489 __private_extern__ kern_return_t vm_object_copy_slowly(
490 vm_object_t src_object,
491 vm_object_offset_t src_offset,
492 vm_object_size_t size,
493 int interruptible,
494 vm_object_t *_result_object);
495
496 __private_extern__ vm_object_t vm_object_copy_delayed(
497 vm_object_t src_object,
498 vm_object_offset_t src_offset,
499 vm_object_size_t size);
500
501
502
503 __private_extern__ kern_return_t vm_object_destroy(
504 vm_object_t object,
505 kern_return_t reason);
506
507 __private_extern__ void vm_object_pager_create(
508 vm_object_t object);
509
510 __private_extern__ void vm_object_page_map(
511 vm_object_t object,
512 vm_object_offset_t offset,
513 vm_object_size_t size,
514 vm_object_offset_t (*map_fn)
515 (void *, vm_object_offset_t),
516 void *map_fn_data);
517
518 __private_extern__ kern_return_t vm_object_upl_request(
519 vm_object_t object,
520 vm_object_offset_t offset,
521 upl_size_t size,
522 upl_t *upl,
523 upl_page_info_t *page_info,
524 unsigned int *count,
525 int flags);
526
527 __private_extern__ kern_return_t vm_object_transpose(
528 vm_object_t object1,
529 vm_object_t object2,
530 vm_object_size_t transpose_size);
531
532 __private_extern__ boolean_t vm_object_sync(
533 vm_object_t object,
534 vm_object_offset_t offset,
535 vm_object_size_t size,
536 boolean_t should_flush,
537 boolean_t should_return,
538 boolean_t should_iosync);
539
540 __private_extern__ kern_return_t vm_object_update(
541 vm_object_t object,
542 vm_object_offset_t offset,
543 vm_object_size_t size,
544 vm_object_offset_t *error_offset,
545 int *io_errno,
546 memory_object_return_t should_return,
547 int flags,
548 vm_prot_t prot);
549
550 __private_extern__ kern_return_t vm_object_lock_request(
551 vm_object_t object,
552 vm_object_offset_t offset,
553 vm_object_size_t size,
554 memory_object_return_t should_return,
555 int flags,
556 vm_prot_t prot);
557
558
559
560 __private_extern__ vm_object_t vm_object_enter(
561 memory_object_t pager,
562 vm_object_size_t size,
563 boolean_t internal,
564 boolean_t init,
565 boolean_t check_named);
566
567
568 /*
569 * Purgable object state.
570 */
571
572 #define VM_OBJECT_NONPURGABLE 0 /* not a purgable object */
573 #define VM_OBJECT_PURGABLE_NONVOLATILE 1 /* non-volatile purgable object */
574 #define VM_OBJECT_PURGABLE_VOLATILE 2 /* volatile (but intact) purgable object */
575 #define VM_OBJECT_PURGABLE_EMPTY 3 /* volatile purgable object that has been emptied */
576
577 __private_extern__ kern_return_t vm_object_populate_with_private(
578 vm_object_t object,
579 vm_object_offset_t offset,
580 ppnum_t phys_page,
581 vm_size_t size);
582
583 extern kern_return_t adjust_vm_object_cache(
584 vm_size_t oval,
585 vm_size_t nval);
586
587 extern kern_return_t vm_object_page_op(
588 vm_object_t object,
589 vm_object_offset_t offset,
590 int ops,
591 ppnum_t *phys_entry,
592 int *flags);
593
594 extern kern_return_t vm_object_range_op(
595 vm_object_t object,
596 vm_object_offset_t offset_beg,
597 vm_object_offset_t offset_end,
598 int ops,
599 int *range);
600
601 /*
602 * Event waiting handling
603 */
604
605 #define VM_OBJECT_EVENT_INITIALIZED 0
606 #define VM_OBJECT_EVENT_PAGER_READY 1
607 #define VM_OBJECT_EVENT_PAGING_IN_PROGRESS 2
608 #define VM_OBJECT_EVENT_ABSENT_COUNT 3
609 #define VM_OBJECT_EVENT_LOCK_IN_PROGRESS 4
610 #define VM_OBJECT_EVENT_UNCACHING 5
611 #define VM_OBJECT_EVENT_COPY_CALL 6
612 #define VM_OBJECT_EVENT_CACHING 7
613
614 #define vm_object_assert_wait(object, event, interruptible) \
615 (((object)->all_wanted |= 1 << (event)), \
616 assert_wait((event_t)((vm_offset_t)(object)+(event)),(interruptible)))
617
618 #define vm_object_wait(object, event, interruptible) \
619 (vm_object_assert_wait((object),(event),(interruptible)), \
620 vm_object_unlock(object), \
621 thread_block(THREAD_CONTINUE_NULL)) \
622
623 #define thread_sleep_vm_object(object, event, interruptible) \
624 thread_sleep_mutex((event_t)(event), &(object)->Lock, (interruptible))
625
626 #define vm_object_sleep(object, event, interruptible) \
627 (((object)->all_wanted |= 1 << (event)), \
628 thread_sleep_vm_object((object), \
629 ((vm_offset_t)(object)+(event)), (interruptible)))
630
631 #define vm_object_wakeup(object, event) \
632 MACRO_BEGIN \
633 if ((object)->all_wanted & (1 << (event))) \
634 thread_wakeup((event_t)((vm_offset_t)(object) + (event))); \
635 (object)->all_wanted &= ~(1 << (event)); \
636 MACRO_END
637
638 #define vm_object_set_wanted(object, event) \
639 MACRO_BEGIN \
640 ((object)->all_wanted |= (1 << (event))); \
641 MACRO_END
642
643 #define vm_object_wanted(object, event) \
644 ((object)->all_wanted & (1 << (event)))
645
646 /*
647 * Routines implemented as macros
648 */
649 #ifdef VM_PIP_DEBUG
650 extern unsigned OSBacktrace(void **bt, unsigned maxAddrs);
651 #define VM_PIP_DEBUG_BEGIN(object) \
652 MACRO_BEGIN \
653 if ((object)->paging_in_progress < VM_PIP_DEBUG_MAX_REFS) { \
654 int pip = (object)->paging_in_progress; \
655 (void) OSBacktrace(&(object)->pip_holders[pip].retaddr[0], \
656 VM_PIP_DEBUG_STACK_FRAMES); \
657 } \
658 MACRO_END
659 #else /* VM_PIP_DEBUG */
660 #define VM_PIP_DEBUG_BEGIN(object)
661 #endif /* VM_PIP_DEBUG */
662
663 #define vm_object_paging_begin(object) \
664 MACRO_BEGIN \
665 assert((object)->paging_in_progress >= 0); \
666 VM_PIP_DEBUG_BEGIN((object)); \
667 (object)->paging_in_progress++; \
668 MACRO_END
669
670 #define vm_object_paging_end(object) \
671 MACRO_BEGIN \
672 assert((object)->paging_in_progress > 0); \
673 if (--(object)->paging_in_progress == 0) { \
674 vm_object_wakeup(object, \
675 VM_OBJECT_EVENT_PAGING_IN_PROGRESS); \
676 } \
677 MACRO_END
678
679 #define vm_object_paging_wait(object, interruptible) \
680 MACRO_BEGIN \
681 while ((object)->paging_in_progress != 0) { \
682 wait_result_t _wr; \
683 \
684 _wr = vm_object_sleep((object), \
685 VM_OBJECT_EVENT_PAGING_IN_PROGRESS, \
686 (interruptible)); \
687 \
688 /*XXX if ((interruptible) && (_wr != THREAD_AWAKENED))*/\
689 /*XXX break; */ \
690 } \
691 MACRO_END
692
693 #define vm_object_absent_assert_wait(object, interruptible) \
694 MACRO_BEGIN \
695 vm_object_assert_wait( (object), \
696 VM_OBJECT_EVENT_ABSENT_COUNT, \
697 (interruptible)); \
698 MACRO_END
699
700
701 #define vm_object_absent_release(object) \
702 MACRO_BEGIN \
703 (object)->absent_count--; \
704 vm_object_wakeup((object), \
705 VM_OBJECT_EVENT_ABSENT_COUNT); \
706 MACRO_END
707
708 /*
709 * Object locking macros
710 */
711
712 #define vm_object_lock_init(object) mutex_init(&(object)->Lock, 0)
713 #define vm_object_lock(object) mutex_lock(&(object)->Lock)
714 #define vm_object_unlock(object) mutex_unlock(&(object)->Lock)
715 #define vm_object_lock_try(object) mutex_try(&(object)->Lock)
716
717 #define vm_object_round_page(x) (((vm_object_offset_t)(x) + PAGE_MASK) & ~((signed)PAGE_MASK))
718 #define vm_object_trunc_page(x) ((vm_object_offset_t)(x) & ~((signed)PAGE_MASK))
719
720 #endif /* _VM_VM_OBJECT_H_ */