Loading...
iokit/Kernel/IOInterruptController.cpp xnu-2422.100.13 xnu-1504.3.12
--- xnu/xnu-2422.100.13/iokit/Kernel/IOInterruptController.cpp
+++ xnu/xnu-1504.3.12/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-2008 Apple Computer, Inc. All rights reserved.
  *
  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  * 
@@ -26,6 +25,17 @@
  * 
  * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
  */
+/*
+ * Copyright (c) 1999 Apple Computer, Inc.  All rights reserved. 
+ *
+ *  DRI: Josh de Cesare
+ *
+ */
+
+
+#if __ppc__
+#include <ppc/proc_reg.h> 
+#endif
 
 #include <IOKit/IOLib.h>
 #include <IOKit/IOService.h>
@@ -33,9 +43,6 @@
 #include <IOKit/IODeviceTreeSupport.h>
 #include <IOKit/IOInterrupts.h>
 #include <IOKit/IOInterruptController.h>
-#include <IOKit/IOKitDebug.h>
-#include <IOKit/IOTimeStamp.h>
-
 
 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
 
@@ -76,7 +83,7 @@
   vector = &vectors[vectorNumber];
   
   // Get the lock for this vector.
-  IOLockLock(vector->interruptLock);
+  IOTakeLock(vector->interruptLock);
   
   // Check if the interrupt source can/should be shared.
   canBeShared = vectorCanBeShared(vectorNumber, vector);
@@ -95,7 +102,7 @@
   
   // If the vector is registered and can not be shared return error.
   if (wasAlreadyRegisterd && !canBeShared) {
-    IOLockUnlock(vector->interruptLock);
+    IOUnlock(vector->interruptLock);
     return kIOReturnNoResources;
   }
   
@@ -108,7 +115,7 @@
       // Make the IOShareInterruptController instance
       vector->sharedController = new IOSharedInterruptController;
       if (vector->sharedController == 0) {
-        IOLockUnlock(vector->interruptLock);
+        IOUnlock(vector->interruptLock);
         return kIOReturnNoMemory;
       }
       
@@ -132,7 +139,7 @@
 	if (wasAlreadyRegisterd) enableInterrupt(originalNub, originalSource);
         vector->sharedController->release();
         vector->sharedController = 0;
-        IOLockUnlock(vector->interruptLock);
+        IOUnlock(vector->interruptLock);
         return error;
       }
       
@@ -160,7 +167,7 @@
 	  
 	  vector->sharedController->release();
 	  vector->sharedController = 0;
-	  IOLockUnlock(vector->interruptLock);
+	  IOUnlock(vector->interruptLock);
 	  return error;
 	}
       }
@@ -192,7 +199,7 @@
     
     error = vector->sharedController->registerInterrupt(nub, source, target,
                                                         handler, refCon);
-    IOLockUnlock(vector->interruptLock);
+    IOUnlock(vector->interruptLock);
     return error;
   }
   
@@ -211,7 +218,7 @@
   vector->interruptDisabledSoft = 1;
   vector->interruptRegistered   = 1;
   
-  IOLockUnlock(vector->interruptLock);
+  IOUnlock(vector->interruptLock);
   return kIOReturnSuccess;
 }
 
@@ -228,11 +235,11 @@
   vector = &vectors[vectorNumber];
   
   // Get the lock for this vector.
-  IOLockLock(vector->interruptLock);
+  IOTakeLock(vector->interruptLock);
   
   // Return success if it is not already registered
   if (!vector->interruptRegistered) {
-    IOLockUnlock(vector->interruptLock);
+    IOUnlock(vector->interruptLock);
     return kIOReturnSuccess;
   }
   
@@ -253,7 +260,7 @@
   vector->target = 0;
   vector->refCon = 0;
   
-  IOLockUnlock(vector->interruptLock);
+  IOUnlock(vector->interruptLock);
   return kIOReturnSuccess;
 }
 
@@ -291,13 +298,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 +333,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 +433,6 @@
 {
   int      cnt, interruptType;
   IOReturn error;
-
-  reserved = NULL;
   
   if (!super::init())
     return kIOReturnNoResources;
@@ -499,13 +512,13 @@
       vector = &vectors[vectorNumber];
       
       // Get the lock for this vector.
-      IOLockLock(vector->interruptLock);
+      IOTakeLock(vector->interruptLock);
       
       // Is it unregistered?
       if (!vector->interruptRegistered) break;
       
       // Move along to the next one.
-      IOLockUnlock(vector->interruptLock);
+      IOUnlock(vector->interruptLock);
     }
     
     if (vectorNumber != kIOSharedInterruptControllerDefaultVectors) break;
@@ -542,7 +555,7 @@
   if (++vectorsRegistered > numVectors) numVectors = vectorsRegistered;
   IOSimpleLockUnlockEnableInterrupt(controllerLock, interruptState);
   
-  IOLockUnlock(vector->interruptLock);
+  IOUnlock(vector->interruptLock);
   return kIOReturnSuccess;
 }
 
@@ -557,12 +570,12 @@
     vector = &vectors[vectorNumber];
 
     // Get the lock for this vector.
-    IOLockLock(vector->interruptLock);
+    IOTakeLock(vector->interruptLock);
 
     // Return success if it is not already registered
     if (!vector->interruptRegistered
      || (vector->nub != nub) || (vector->source != source)) {
-        IOLockUnlock(vector->interruptLock);
+        IOUnlock(vector->interruptLock);
         continue;
     }
 
@@ -585,7 +598,7 @@
     IOSimpleLockUnlockEnableInterrupt(controllerLock, interruptState);
 
     // Move along to the next one.
-    IOLockUnlock(vector->interruptLock);
+    IOUnlock(vector->interruptLock);
   }
 
   // Re-enable the controller if all vectors are enabled.
@@ -653,10 +666,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 +677,9 @@
   if (!getPlatform()->atInterruptLevel()) {
     while (vector->interruptActive)
 	{}
+#if __ppc__
+    isync();
+#endif
   }
   
   return kIOReturnSuccess;
@@ -686,30 +702,21 @@
     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 (trace)
-			  IOTimeStampStartConstant(IODBG_INTC(IOINTC_HANDLER),
-									   (uintptr_t) vectorNumber, (uintptr_t) vector->handler, (uintptr_t)vector->target);
-		  
-		  // Call handler.
-		  vector->handler(vector->target, vector->refCon, vector->nub, vector->source);
-		  
-		  if (trace)
-			  IOTimeStampEndConstant(IODBG_INTC(IOINTC_HANDLER),
-									 (uintptr_t) vectorNumber, (uintptr_t) vector->handler, (uintptr_t)vector->target);
-		  
-		}
-	}
+#if __ppc__
+    sync();
+    isync();
+#endif
+    if (!vector->interruptDisabledSoft) {
+#if __ppc__
+      isync();
+#endif
+      
+      // Call the handler if it exists.
+      if (vector->interruptRegistered) {
+	vector->handler(vector->target, vector->refCon,
+			vector->nub, vector->source);
+      }
+    }
     
     vector->interruptActive = 0;
   }