]> git.saurik.com Git - apple/xnu.git/blobdiff - iokit/Kernel/IOCommandGate.cpp
xnu-1699.32.7.tar.gz
[apple/xnu.git] / iokit / Kernel / IOCommandGate.cpp
index 0b823d2b69eaff02a7ecd8363201f29b101ad1c9..29ecd859e07820f9f648b3d8eec46067e680bbbe 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@
  * 
@@ -49,11 +49,33 @@ OSMetaClassDefineReservedUnused(IOCommandGate, 5);
 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)
 {
-    return super::init(inOwner, (IOEventSource::Action) inAction);
+    bool res = super::init(inOwner, (IOEventSource::Action) inAction);
+    if (res) {
+        IOStatisticsInitializeCounter();
+    }
+
+    return res;
 }
 
 IOCommandGate *
@@ -162,6 +184,8 @@ IOReturn IOCommandGate::runAction(Action inAction,
                IOTimeStampStartConstant(IODBG_CMDQ(IOCMDQ_ACTION),
                                                                 (uintptr_t) inAction, (uintptr_t) owner);
        
+    IOStatisticsActionCall();
+       
     // Must be gated and on the work loop or enabled
     res = (*inAction)(owner, arg0, arg1, arg2, arg3);
        
@@ -170,7 +194,7 @@ IOReturn IOCommandGate::runAction(Action inAction,
                                                           (uintptr_t) inAction, (uintptr_t) owner);
     
     openGate();
-
+       
     return res;
 }
 
@@ -196,9 +220,11 @@ IOReturn IOCommandGate::attemptAction(Action inAction,
                
         if (trace)
             IOTimeStampStartConstant(IODBG_CMDQ(IOCMDQ_ACTION),
-                           (uintptr_t) inAction, (uintptr_t) owner);
-
-       res = (*inAction)(owner, arg0, arg1, arg2, arg3);
+                                                                        (uintptr_t) inAction, (uintptr_t) owner);
+        
+        IOStatisticsActionCall();
+        
+        res = (*inAction)(owner, arg0, arg1, arg2, arg3);
                
         if (trace)
             IOTimeStampEndConstant(IODBG_CMDQ(IOCMDQ_ACTION),