]> git.saurik.com Git - apple/xnu.git/blobdiff - iokit/Kernel/IOInterruptEventSource.cpp
xnu-1699.24.23.tar.gz
[apple/xnu.git] / iokit / Kernel / IOInterruptEventSource.cpp
index 97d4c595761deb84c70f8a39341cc3b7e76d593b..8b49024a174488864b5b5c1c0281f1a95588cba4 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1998-2010 Apple Inc. All rights reserved.
  *
  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  * 
  *
  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  * 
  * 
  * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
  */
  * 
  * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
  */
-/*
-Copyright (c) 1998 Apple Computer, Inc.  All rights reserved.
 
 
-HISTORY
-    1998-7-13  Godfrey van der Linden(gvdl)
-        Created.
-*/
 #include <IOKit/IOInterruptEventSource.h>
 #include <IOKit/IOKitDebug.h>
 #include <IOKit/IOLib.h>
 #include <IOKit/IOInterruptEventSource.h>
 #include <IOKit/IOKitDebug.h>
 #include <IOKit/IOLib.h>
@@ -40,6 +34,31 @@ HISTORY
 #include <IOKit/IOTimeStamp.h>
 #include <IOKit/IOWorkLoop.h>
 
 #include <IOKit/IOTimeStamp.h>
 #include <IOKit/IOWorkLoop.h>
 
+#if IOKITSTATS
+
+#define IOStatisticsInitializeCounter() \
+do { \
+       IOStatistics::setCounterType(IOEventSource::reserved->counter, kIOStatisticsInterruptEventSourceCounter); \
+} while (0)
+
+#define IOStatisticsCheckForWork() \
+do { \
+       IOStatistics::countInterruptCheckForWork(IOEventSource::reserved->counter); \
+} while (0)
+
+#define IOStatisticsInterrupt() \
+do { \
+       IOStatistics::countInterrupt(IOEventSource::reserved->counter); \
+} while (0)
+
+#else
+
+#define IOStatisticsInitializeCounter()
+#define IOStatisticsCheckForWork()
+#define IOStatisticsInterrupt()
+
+#endif // IOKITSTATS
+
 #define super IOEventSource
 
 OSDefineMetaClassAndStructors(IOInterruptEventSource, IOEventSource)
 #define super IOEventSource
 
 OSDefineMetaClassAndStructors(IOInterruptEventSource, IOEventSource)
@@ -74,6 +93,8 @@ bool IOInterruptEventSource::init(OSObject *inOwner,
            intIndex = inIntIndex;
     }
 
            intIndex = inIntIndex;
     }
 
+    IOStatisticsInitializeCounter();
+
     return res;
 }
 
     return res;
 }
 
@@ -182,24 +203,26 @@ bool IOInterruptEventSource::checkForWork()
     int numInts = cacheProdCount - consumerCount;
     IOInterruptEventAction intAction = (IOInterruptEventAction) action;
        bool trace = (gIOKitTrace & kIOTraceIntEventSource) ? true : false;
     int numInts = cacheProdCount - consumerCount;
     IOInterruptEventAction intAction = (IOInterruptEventAction) action;
        bool trace = (gIOKitTrace & kIOTraceIntEventSource) ? true : false;
-
+       
+    IOStatisticsCheckForWork();
+       
        if ( numInts > 0 )
        {
                if (trace)
                        IOTimeStampStartConstant(IODBG_INTES(IOINTES_ACTION),
                                                                         (uintptr_t) intAction, (uintptr_t) owner, (uintptr_t) this, (uintptr_t) workLoop);
        if ( numInts > 0 )
        {
                if (trace)
                        IOTimeStampStartConstant(IODBG_INTES(IOINTES_ACTION),
                                                                         (uintptr_t) intAction, (uintptr_t) owner, (uintptr_t) this, (uintptr_t) workLoop);
-
+               
                // Call the handler
                // Call the handler
-        (*intAction)(owner, this,  numInts);
+               (*intAction)(owner, this, numInts);
                
                if (trace)
                        IOTimeStampEndConstant(IODBG_INTES(IOINTES_ACTION),
                                                                   (uintptr_t) intAction, (uintptr_t) owner, (uintptr_t) this, (uintptr_t) workLoop);
                
                if (trace)
                        IOTimeStampEndConstant(IODBG_INTES(IOINTES_ACTION),
                                                                   (uintptr_t) intAction, (uintptr_t) owner, (uintptr_t) this, (uintptr_t) workLoop);
-
-        consumerCount = cacheProdCount;
-        if (autoDisable && !explicitDisable)
-            enable();
-    }
+               
+               consumerCount = cacheProdCount;
+               if (autoDisable && !explicitDisable)
+                       enable();
+       }
        
        else if ( numInts < 0 )
        {
        
        else if ( numInts < 0 )
        {
@@ -208,17 +231,17 @@ bool IOInterruptEventSource::checkForWork()
                                                                         (uintptr_t) intAction, (uintptr_t) owner, (uintptr_t) this, (uintptr_t) workLoop);
                
                // Call the handler
                                                                         (uintptr_t) intAction, (uintptr_t) owner, (uintptr_t) this, (uintptr_t) workLoop);
                
                // Call the handler
-       (*intAction)(owner, this, -numInts);
+               (*intAction)(owner, this, -numInts);
                
                if (trace)
                        IOTimeStampEndConstant(IODBG_INTES(IOINTES_ACTION),
                                                                   (uintptr_t) intAction, (uintptr_t) owner, (uintptr_t) this, (uintptr_t) workLoop);
                
                if (trace)
                        IOTimeStampEndConstant(IODBG_INTES(IOINTES_ACTION),
                                                                   (uintptr_t) intAction, (uintptr_t) owner, (uintptr_t) this, (uintptr_t) workLoop);
-    
-        consumerCount = cacheProdCount;
-        if (autoDisable && !explicitDisable)
-            enable();
-    }
-
+               
+               consumerCount = cacheProdCount;
+               if (autoDisable && !explicitDisable)
+                       enable();
+       }
+       
     return false;
 }
 
     return false;
 }
 
@@ -226,14 +249,15 @@ void IOInterruptEventSource::normalInterruptOccurred
     (void */*refcon*/, IOService */*prov*/, int /*source*/)
 {
        bool trace = (gIOKitTrace & kIOTraceIntEventSource) ? true : false;
     (void */*refcon*/, IOService */*prov*/, int /*source*/)
 {
        bool trace = (gIOKitTrace & kIOTraceIntEventSource) ? true : false;
-
+       
+    IOStatisticsInterrupt();
     producerCount++;
     producerCount++;
-
+       
        if (trace)
            IOTimeStampStartConstant(IODBG_INTES(IOINTES_SEMA), (uintptr_t) this, (uintptr_t) owner);
        
     signalWorkAvailable();
        if (trace)
            IOTimeStampStartConstant(IODBG_INTES(IOINTES_SEMA), (uintptr_t) this, (uintptr_t) owner);
        
     signalWorkAvailable();
-
+       
        if (trace)
            IOTimeStampEndConstant(IODBG_INTES(IOINTES_SEMA), (uintptr_t) this, (uintptr_t) owner);
 }
        if (trace)
            IOTimeStampEndConstant(IODBG_INTES(IOINTES_SEMA), (uintptr_t) this, (uintptr_t) owner);
 }
@@ -242,16 +266,17 @@ void IOInterruptEventSource::disableInterruptOccurred
     (void */*refcon*/, IOService *prov, int source)
 {
        bool trace = (gIOKitTrace & kIOTraceIntEventSource) ? true : false;
     (void */*refcon*/, IOService *prov, int source)
 {
        bool trace = (gIOKitTrace & kIOTraceIntEventSource) ? true : false;
-
+       
     prov->disableInterrupt(source);    /* disable the interrupt */
     prov->disableInterrupt(source);    /* disable the interrupt */
-
+       
+    IOStatisticsInterrupt();
     producerCount++;
     producerCount++;
-
+       
        if (trace)
            IOTimeStampStartConstant(IODBG_INTES(IOINTES_SEMA), (uintptr_t) this, (uintptr_t) owner);
     
     signalWorkAvailable();
        if (trace)
            IOTimeStampStartConstant(IODBG_INTES(IOINTES_SEMA), (uintptr_t) this, (uintptr_t) owner);
     
     signalWorkAvailable();
-
+       
        if (trace)
            IOTimeStampEndConstant(IODBG_INTES(IOINTES_SEMA), (uintptr_t) this, (uintptr_t) owner);
 }
        if (trace)
            IOTimeStampEndConstant(IODBG_INTES(IOINTES_SEMA), (uintptr_t) this, (uintptr_t) owner);
 }
@@ -264,3 +289,10 @@ void IOInterruptEventSource::interruptOccurred
     else
         normalInterruptOccurred(refcon, prov, source);
 }
     else
         normalInterruptOccurred(refcon, prov, source);
 }
+
+IOReturn IOInterruptEventSource::warmCPU
+    (uint64_t abstime)
+{
+
+       return ml_interrupt_prewarm(abstime);
+}