]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/vm/vm_object.h
xnu-344.49.tar.gz
[apple/xnu.git] / osfmk / vm / vm_object.h
index 92044ab016d7a794fec6c7fdc461f912da8883e6..dbfc2a85ec3a91b82acbe68be64bb57b0e8b16a8 100644 (file)
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * 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. 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 OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * 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_LICENSE_HEADER_END@
  */
@@ -275,6 +278,10 @@ struct vm_object {
                                                 * put in current object
                                                 */
 #endif
+                                       /* hold object lock when altering */
+       unsigned        int                     /* cache WIMG bits         */           
+                       wimg_bits:8,            /* wimg plus some expansion*/
+                       not_in_use:24;
 #ifdef UBC_DEBUG
        queue_head_t            uplq;           /* List of outstanding upls */
 #endif /* UBC_DEBUG */
@@ -519,17 +526,21 @@ __private_extern__ vm_object_t    vm_object_enter(
 #define        VM_OBJECT_EVENT_CACHING                 7
 
 #define        vm_object_assert_wait(object, event, interruptible)             \
-       MACRO_BEGIN                                                     \
-       (object)->all_wanted |= 1 << (event);                           \
-       assert_wait((event_t)((vm_offset_t)(object)+(event)),(interruptible)); \
-       MACRO_END
+       (((object)->all_wanted |= 1 << (event)),                        \
+        assert_wait((event_t)((vm_offset_t)(object)+(event)),(interruptible)))
 
 #define        vm_object_wait(object, event, interruptible)                    \
-       MACRO_BEGIN                                                     \
-       vm_object_assert_wait((object),(event),(interruptible));        \
-       vm_object_unlock(object);                                       \
-       thread_block((void (*)(void)) 0);                               \
-       MACRO_END
+       (vm_object_assert_wait((object),(event),(interruptible)),       \
+       vm_object_unlock(object),                                       \
+       thread_block(THREAD_CONTINUE_NULL))                             \
+
+#define thread_sleep_vm_object(object, event, interruptible)           \
+       thread_sleep_mutex((event_t)(event), &(object)->Lock, (interruptible))
+
+#define vm_object_sleep(object, event, interruptible)                  \
+       (((object)->all_wanted |= 1 << (event)),                        \
+        thread_sleep_vm_object((object),                               \
+               ((vm_offset_t)(object)+(event)), (interruptible)))
 
 #define        vm_object_wakeup(object, event)                                 \
        MACRO_BEGIN                                                     \
@@ -567,13 +578,13 @@ __private_extern__ vm_object_t    vm_object_enter(
 #define                vm_object_paging_wait(object, interruptible)            \
        MACRO_BEGIN                                                     \
        while ((object)->paging_in_progress != 0) {                     \
-               vm_object_wait( (object),                               \
+               wait_result_t  _wr;                                     \
+                                                                       \
+               _wr = vm_object_sleep((object),                         \
                                VM_OBJECT_EVENT_PAGING_IN_PROGRESS,     \
                                (interruptible));                       \
-               vm_object_lock(object);                                 \
                                                                        \
-               /*XXX if ((interruptible) &&    */                      \
-                   /*XXX (current_thread()->wait_result != THREAD_AWAKENED))*/ \
+               /*XXX if ((interruptible) && (_wr != THREAD_AWAKENED))*/\
                        /*XXX break; */                                 \
        }                                                               \
        MACRO_END