]> git.saurik.com Git - apple/xnu.git/blobdiff - iokit/Kernel/IOInterruptController.cpp
xnu-3789.31.2.tar.gz
[apple/xnu.git] / iokit / Kernel / IOInterruptController.cpp
index a8e04bddd28deb711e851fd8b40c818a20890c24..fb0aa23b014cc0a600c9cdbac730dd8d03a83f32 100644 (file)
@@ -1,5 +1,6 @@
 /*
- * Copyright (c) 1998-2011 Apple Inc. All rights reserved.
+ * Copyright (c) 2007-2012 Apple Inc. All rights reserved.
+ * Copyright (c) 1998-2006 Apple Computer, Inc. All rights reserved.
  *
  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  * 
  * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
  */
 
-
-#if __ppc__
-#include <ppc/proc_reg.h> 
-#endif
-
 #include <IOKit/IOLib.h>
 #include <IOKit/IOService.h>
 #include <IOKit/IOPlatformExpert.h>
@@ -295,17 +291,13 @@ IOReturn IOInterruptController::enableInterrupt(IOService *nub, int source)
   
   if (vector->interruptDisabledSoft) {
     vector->interruptDisabledSoft = 0;
-#if __ppc__
-    sync();
-    isync();
+#if !defined(__i386__) && !defined(__x86_64__)
+    OSMemoryBarrier();
 #endif
-    
+
     if (!getPlatform()->atInterruptLevel()) {
       while (vector->interruptActive)
        {}
-#if __ppc__
-      isync();
-#endif
     }
     if (vector->interruptDisabledHard) {
       vector->interruptDisabledHard = 0;
@@ -330,17 +322,13 @@ IOReturn IOInterruptController::disableInterrupt(IOService *nub, int source)
   vector = &vectors[vectorNumber];
   
   vector->interruptDisabledSoft = 1;
-#if __ppc__
-  sync();
-  isync();
+#if !defined(__i386__) && !defined(__x86_64__)
+  OSMemoryBarrier();
 #endif
   
   if (!getPlatform()->atInterruptLevel()) {
     while (vector->interruptActive)
        {}
-#if __ppc__
-    isync();
-#endif
   }
   
   return kIOReturnSuccess;
@@ -430,6 +418,8 @@ IOReturn IOSharedInterruptController::initInterruptController(IOInterruptControl
 {
   int      cnt, interruptType;
   IOReturn error;
+
+  reserved = NULL;
   
   if (!super::init())
     return kIOReturnNoResources;
@@ -529,6 +519,7 @@ IOReturn IOSharedInterruptController::registerInterrupt(IOService *nub,
   // Create the vectorData for the IOInterruptSource.
   vectorData = OSData::withBytes(&vectorNumber, sizeof(vectorNumber));
   if (vectorData == 0) {
+    IOLockUnlock(vector->interruptLock);
     return kIOReturnNoMemory;
   }
   
@@ -663,10 +654,10 @@ IOReturn IOSharedInterruptController::disableInterrupt(IOService *nub,
   interruptState = IOSimpleLockLockDisableInterrupt(controllerLock); 
   if (!vector->interruptDisabledSoft) {
     vector->interruptDisabledSoft = 1;
-#if __ppc__
-    sync();
-    isync();
+#if !defined(__i386__) && !defined(__x86_64__)
+    OSMemoryBarrier();
 #endif
+
     vectorsEnabled--;
   }
   IOSimpleLockUnlockEnableInterrupt(controllerLock, interruptState);
@@ -674,9 +665,6 @@ IOReturn IOSharedInterruptController::disableInterrupt(IOService *nub,
   if (!getPlatform()->atInterruptLevel()) {
     while (vector->interruptActive)
        {}
-#if __ppc__
-    isync();
-#endif
   }
   
   return kIOReturnSuccess;
@@ -699,48 +687,30 @@ IOReturn IOSharedInterruptController::handleInterrupt(void * /*refCon*/,
     vector = &vectors[vectorNumber];
     
     vector->interruptActive = 1;
-#if __ppc__
-    sync();
-    isync();
-#endif
-    if (!vector->interruptDisabledSoft) {
-#if __ppc__
-      isync();
+#if !defined(__i386__) && !defined(__x86_64__)
+    OSMemoryBarrier();
 #endif
-      
-      // Call the handler if it exists.
-      if (vector->interruptRegistered) {
-      
-                 bool          trace           = (gIOKitTrace & kIOTraceInterrupts) ? true : false;
-                 bool          timeHandler     = gIOInterruptThresholdNS ? true : false;
-                 uint64_t      startTime       = 0;
-                 uint64_t      endTime         = 0;
+
+       if (!vector->interruptDisabledSoft) {
+         
+         // Call the handler if it exists.
+         if (vector->interruptRegistered) {
+                 
+                 bool  trace = (gIOKitTrace & kIOTraceInterrupts) ? true : false;
                  
                  if (trace)
                          IOTimeStampStartConstant(IODBG_INTC(IOINTC_HANDLER),
                                                                           (uintptr_t) vectorNumber, (uintptr_t) vector->handler, (uintptr_t)vector->target);
                  
-                 if (timeHandler)
-                         startTime = mach_absolute_time();
-                 
                  // Call handler.
                  vector->handler(vector->target, vector->refCon, vector->nub, vector->source);
-
-                 if (timeHandler)
-                 {
-                         endTime = mach_absolute_time();
-                         if ((endTime - startTime) > gIOInterruptThresholdNS)
-                                 panic("IOSIC::handleInterrupt: interrupt exceeded threshold, handlerTime = %qd, vectorNumber = %d, handler = %p, target = %p\n",
-                                               endTime - startTime, (int)vectorNumber, vector->handler, vector->target);
-                 }
                  
                  if (trace)
                          IOTimeStampEndConstant(IODBG_INTC(IOINTC_HANDLER),
                                                                         (uintptr_t) vectorNumber, (uintptr_t) vector->handler, (uintptr_t)vector->target);
                  
-      }
-      
-    }
+               }
+       }
     
     vector->interruptActive = 0;
   }