]> git.saurik.com Git - apple/xnu.git/blobdiff - iokit/Kernel/IOCommandGate.cpp
xnu-2782.20.48.tar.gz
[apple/xnu.git] / iokit / Kernel / IOCommandGate.cpp
index 0b823d2b69eaff02a7ecd8363201f29b101ad1c9..9b19d70eefeb5e7dd63bfb88997f44401ed9c654 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1998-2000, 2009-2010 Apple Inc. All rights reserved.
  *
  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  * 
  *
  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  * 
@@ -49,11 +49,33 @@ OSMetaClassDefineReservedUnused(IOCommandGate, 5);
 OSMetaClassDefineReservedUnused(IOCommandGate, 6);
 OSMetaClassDefineReservedUnused(IOCommandGate, 7);
 
 OSMetaClassDefineReservedUnused(IOCommandGate, 6);
 OSMetaClassDefineReservedUnused(IOCommandGate, 7);
 
-bool IOCommandGate::checkForWork() { return false; }
+#if IOKITSTATS
+
+#define IOStatisticsInitializeCounter() \
+do { \
+       IOStatistics::setCounterType(IOEventSource::reserved->counter, kIOStatisticsCommandGateCounter); \
+} while (0)
+
+#define IOStatisticsActionCall() \
+do { \
+       IOStatistics::countCommandGateActionCall(IOEventSource::reserved->counter); \
+} while (0)
+
+#else
+
+#define IOStatisticsInitializeCounter()
+#define IOStatisticsActionCall()
+
+#endif /* IOKITSTATS */
 
 bool IOCommandGate::init(OSObject *inOwner, Action inAction)
 {
 
 bool IOCommandGate::init(OSObject *inOwner, Action inAction)
 {
-    return super::init(inOwner, (IOEventSource::Action) inAction);
+    bool res = super::init(inOwner, (IOEventSource::Action) inAction);
+    if (res) {
+        IOStatisticsInitializeCounter();
+    }
+
+    return res;
 }
 
 IOCommandGate *
 }
 
 IOCommandGate *
@@ -160,17 +182,19 @@ IOReturn IOCommandGate::runAction(Action inAction,
        
        if (trace)
                IOTimeStampStartConstant(IODBG_CMDQ(IOCMDQ_ACTION),
        
        if (trace)
                IOTimeStampStartConstant(IODBG_CMDQ(IOCMDQ_ACTION),
-                                                                (uintptr_t) inAction, (uintptr_t) owner);
+                                        VM_KERNEL_UNSLIDE(inAction), (uintptr_t) owner);
+       
+    IOStatisticsActionCall();
        
     // Must be gated and on the work loop or enabled
     res = (*inAction)(owner, arg0, arg1, arg2, arg3);
        
        if (trace)
                IOTimeStampEndConstant(IODBG_CMDQ(IOCMDQ_ACTION),
        
     // Must be gated and on the work loop or enabled
     res = (*inAction)(owner, arg0, arg1, arg2, arg3);
        
        if (trace)
                IOTimeStampEndConstant(IODBG_CMDQ(IOCMDQ_ACTION),
-                                                          (uintptr_t) inAction, (uintptr_t) owner);
+                                      VM_KERNEL_UNSLIDE(inAction), (uintptr_t) owner);
     
     openGate();
     
     openGate();
-
+       
     return res;
 }
 
     return res;
 }
 
@@ -196,13 +220,15 @@ IOReturn IOCommandGate::attemptAction(Action inAction,
                
         if (trace)
             IOTimeStampStartConstant(IODBG_CMDQ(IOCMDQ_ACTION),
                
         if (trace)
             IOTimeStampStartConstant(IODBG_CMDQ(IOCMDQ_ACTION),
-                           (uintptr_t) inAction, (uintptr_t) owner);
-
-       res = (*inAction)(owner, arg0, arg1, arg2, arg3);
+                                    VM_KERNEL_UNSLIDE(inAction), (uintptr_t) owner);
+        
+        IOStatisticsActionCall();
+        
+        res = (*inAction)(owner, arg0, arg1, arg2, arg3);
                
         if (trace)
             IOTimeStampEndConstant(IODBG_CMDQ(IOCMDQ_ACTION),
                
         if (trace)
             IOTimeStampEndConstant(IODBG_CMDQ(IOCMDQ_ACTION),
-                                                                  (uintptr_t) inAction, (uintptr_t) owner);
+                                  VM_KERNEL_UNSLIDE(inAction), (uintptr_t) owner);
     }
 
     openGate();
     }
 
     openGate();