Loading...
iokit/Kernel/IOInterruptController.cpp xnu-3248.50.21 xnu-1504.15.3
--- xnu/xnu-3248.50.21/iokit/Kernel/IOInterruptController.cpp
+++ xnu/xnu-1504.15.3/iokit/Kernel/IOInterruptController.cpp
@@ -1,6 +1,5 @@
 /*
- * Copyright (c) 2007-2012 Apple Inc. All rights reserved.
- * Copyright (c) 1998-2006 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1998-2011 Apple Inc. All rights reserved.
  *
  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  * 
@@ -26,6 +25,11 @@
  * 
  * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
  */
+
+
+#if __ppc__
+#include <ppc/proc_reg.h> 
+#endif
 
 #include <IOKit/IOLib.h>
 #include <IOKit/IOService.h>
@@ -291,13 +295,17 @@
   
   if (vector->interruptDisabledSoft) {
     vector->interruptDisabledSoft = 0;
-#if !defined(__i386__) && !defined(__x86_64__)
-    OSMemoryBarrier();
-#endif
-
+#if __ppc__
+    sync();
+    isync();
+#endif
+    
     if (!getPlatform()->atInterruptLevel()) {
       while (vector->interruptActive)
 	{}
+#if __ppc__
+      isync();
+#endif
     }
     if (vector->interruptDisabledHard) {
       vector->interruptDisabledHard = 0;
@@ -322,13 +330,17 @@
   vector = &vectors[vectorNumber];
   
   vector->interruptDisabledSoft = 1;
-#if !defined(__i386__) && !defined(__x86_64__)
-  OSMemoryBarrier();
+#if __ppc__
+  sync();
+  isync();
 #endif
   
   if (!getPlatform()->atInterruptLevel()) {
     while (vector->interruptActive)
 	{}
+#if __ppc__
+    isync();
+#endif
   }
   
   return kIOReturnSuccess;
@@ -418,8 +430,6 @@
 {
   int      cnt, interruptType;
   IOReturn error;
-
-  reserved = NULL;
   
   if (!super::init())
     return kIOReturnNoResources;
@@ -653,10 +663,10 @@
   interruptState = IOSimpleLockLockDisableInterrupt(controllerLock); 
   if (!vector->interruptDisabledSoft) {
     vector->interruptDisabledSoft = 1;
-#if !defined(__i386__) && !defined(__x86_64__)
-    OSMemoryBarrier();
-#endif
-
+#if __ppc__
+    sync();
+    isync();
+#endif
     vectorsEnabled--;
   }
   IOSimpleLockUnlockEnableInterrupt(controllerLock, interruptState);
@@ -664,6 +674,9 @@
   if (!getPlatform()->atInterruptLevel()) {
     while (vector->interruptActive)
 	{}
+#if __ppc__
+    isync();
+#endif
   }
   
   return kIOReturnSuccess;
@@ -686,30 +699,48 @@
     vector = &vectors[vectorNumber];
     
     vector->interruptActive = 1;
-#if !defined(__i386__) && !defined(__x86_64__)
-    OSMemoryBarrier();
-#endif
-
-	if (!vector->interruptDisabledSoft) {
-	  
-	  // Call the handler if it exists.
-	  if (vector->interruptRegistered) {
-		  
-		  bool	trace = (gIOKitTrace & kIOTraceInterrupts) ? true : false;
+#if __ppc__
+    sync();
+    isync();
+#endif
+    if (!vector->interruptDisabledSoft) {
+#if __ppc__
+      isync();
+#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 (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;
   }