/*
- * Copyright (c) 1998-2008 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1998-2010 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
*
* @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>
#include <IOKit/IODeviceTreeSupport.h>
#include <IOKit/IOInterrupts.h>
#include <IOKit/IOInterruptController.h>
+#include <IOKit/IOKitDebug.h>
+#include <IOKit/IOTimeStamp.h>
+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
vector = &vectors[vectorNumber];
// Get the lock for this vector.
- IOTakeLock(vector->interruptLock);
+ IOLockLock(vector->interruptLock);
// Check if the interrupt source can/should be shared.
canBeShared = vectorCanBeShared(vectorNumber, vector);
// If the vector is registered and can not be shared return error.
if (wasAlreadyRegisterd && !canBeShared) {
- IOUnlock(vector->interruptLock);
+ IOLockUnlock(vector->interruptLock);
return kIOReturnNoResources;
}
// Make the IOShareInterruptController instance
vector->sharedController = new IOSharedInterruptController;
if (vector->sharedController == 0) {
- IOUnlock(vector->interruptLock);
+ IOLockUnlock(vector->interruptLock);
return kIOReturnNoMemory;
}
if (wasAlreadyRegisterd) enableInterrupt(originalNub, originalSource);
vector->sharedController->release();
vector->sharedController = 0;
- IOUnlock(vector->interruptLock);
+ IOLockUnlock(vector->interruptLock);
return error;
}
vector->sharedController->release();
vector->sharedController = 0;
- IOUnlock(vector->interruptLock);
+ IOLockUnlock(vector->interruptLock);
return error;
}
}
error = vector->sharedController->registerInterrupt(nub, source, target,
handler, refCon);
- IOUnlock(vector->interruptLock);
+ IOLockUnlock(vector->interruptLock);
return error;
}
vector->interruptDisabledSoft = 1;
vector->interruptRegistered = 1;
- IOUnlock(vector->interruptLock);
+ IOLockUnlock(vector->interruptLock);
return kIOReturnSuccess;
}
vector = &vectors[vectorNumber];
// Get the lock for this vector.
- IOTakeLock(vector->interruptLock);
+ IOLockLock(vector->interruptLock);
// Return success if it is not already registered
if (!vector->interruptRegistered) {
- IOUnlock(vector->interruptLock);
+ IOLockUnlock(vector->interruptLock);
return kIOReturnSuccess;
}
vector->target = 0;
vector->refCon = 0;
- IOUnlock(vector->interruptLock);
+ IOLockUnlock(vector->interruptLock);
return kIOReturnSuccess;
}
if (vector->interruptDisabledSoft) {
vector->interruptDisabledSoft = 0;
-#if __ppc__
- sync();
- isync();
-#endif
if (!getPlatform()->atInterruptLevel()) {
while (vector->interruptActive)
{}
-#if __ppc__
- isync();
-#endif
}
if (vector->interruptDisabledHard) {
vector->interruptDisabledHard = 0;
vector = &vectors[vectorNumber];
vector->interruptDisabledSoft = 1;
-#if __ppc__
- sync();
- isync();
-#endif
if (!getPlatform()->atInterruptLevel()) {
while (vector->interruptActive)
{}
-#if __ppc__
- isync();
-#endif
}
return kIOReturnSuccess;
vector = &vectors[vectorNumber];
// Get the lock for this vector.
- IOTakeLock(vector->interruptLock);
+ IOLockLock(vector->interruptLock);
// Is it unregistered?
if (!vector->interruptRegistered) break;
// Move along to the next one.
- IOUnlock(vector->interruptLock);
+ IOLockUnlock(vector->interruptLock);
}
if (vectorNumber != kIOSharedInterruptControllerDefaultVectors) break;
if (++vectorsRegistered > numVectors) numVectors = vectorsRegistered;
IOSimpleLockUnlockEnableInterrupt(controllerLock, interruptState);
- IOUnlock(vector->interruptLock);
+ IOLockUnlock(vector->interruptLock);
return kIOReturnSuccess;
}
vector = &vectors[vectorNumber];
// Get the lock for this vector.
- IOTakeLock(vector->interruptLock);
+ IOLockLock(vector->interruptLock);
// Return success if it is not already registered
if (!vector->interruptRegistered
|| (vector->nub != nub) || (vector->source != source)) {
- IOUnlock(vector->interruptLock);
+ IOLockUnlock(vector->interruptLock);
continue;
}
IOSimpleLockUnlockEnableInterrupt(controllerLock, interruptState);
// Move along to the next one.
- IOUnlock(vector->interruptLock);
+ IOLockUnlock(vector->interruptLock);
}
// Re-enable the controller if all vectors are enabled.
interruptState = IOSimpleLockLockDisableInterrupt(controllerLock);
if (!vector->interruptDisabledSoft) {
vector->interruptDisabledSoft = 1;
-#if __ppc__
- sync();
- isync();
-#endif
vectorsEnabled--;
}
IOSimpleLockUnlockEnableInterrupt(controllerLock, interruptState);
if (!getPlatform()->atInterruptLevel()) {
while (vector->interruptActive)
{}
-#if __ppc__
- isync();
-#endif
}
return kIOReturnSuccess;
vector = &vectors[vectorNumber];
vector->interruptActive = 1;
-#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);
- }
- }
+ 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);
+
+ }
+ }
vector->interruptActive = 0;
}