]> git.saurik.com Git - apple/xnu.git/blobdiff - iokit/Kernel/IOInterruptController.cpp
xnu-7195.101.1.tar.gz
[apple/xnu.git] / iokit / Kernel / IOInterruptController.cpp
index f84357e38d0bbcc2f5f93db8ce68d68d71be13c3..6dc591963572288f996f8e3c894678140665edc6 100644 (file)
@@ -43,9 +43,9 @@
 
 OSDefineMetaClassAndAbstractStructors(IOInterruptController, IOService);
 
-OSMetaClassDefineReservedUnused(IOInterruptController, 0);
-OSMetaClassDefineReservedUnused(IOInterruptController, 1);
-OSMetaClassDefineReservedUnused(IOInterruptController, 2);
+OSMetaClassDefineReservedUsedX86(IOInterruptController, 0);
+OSMetaClassDefineReservedUsedX86(IOInterruptController, 1);
+OSMetaClassDefineReservedUsedX86(IOInterruptController, 2);
 OSMetaClassDefineReservedUnused(IOInterruptController, 3);
 OSMetaClassDefineReservedUnused(IOInterruptController, 4);
 OSMetaClassDefineReservedUnused(IOInterruptController, 5);
@@ -104,10 +104,10 @@ IOInterruptController::registerInterrupt(IOService *nub, int source,
        // register as a shared interrupt.
        if (wasAlreadyRegisterd || shouldBeShared) {
                // If this vector is not already shared, break it out.
-               if (vector->sharedController == 0) {
+               if (vector->sharedController == NULL) {
                        // Make the IOShareInterruptController instance
                        vector->sharedController = new IOSharedInterruptController;
-                       if (vector->sharedController == 0) {
+                       if (vector->sharedController == NULL) {
                                IOLockUnlock(vector->interruptLock);
                                return kIOReturnNoMemory;
                        }
@@ -133,7 +133,7 @@ IOInterruptController::registerInterrupt(IOService *nub, int source,
                                        enableInterrupt(originalNub, originalSource);
                                }
                                vector->sharedController->release();
-                               vector->sharedController = 0;
+                               vector->sharedController = NULL;
                                IOLockUnlock(vector->interruptLock);
                                return error;
                        }
@@ -163,7 +163,7 @@ IOInterruptController::registerInterrupt(IOService *nub, int source,
                                        enableInterrupt(originalNub, originalSource);
 
                                        vector->sharedController->release();
-                                       vector->sharedController = 0;
+                                       vector->sharedController = NULL;
                                        IOLockUnlock(vector->interruptLock);
                                        return error;
                                }
@@ -174,7 +174,7 @@ IOInterruptController::registerInterrupt(IOService *nub, int source,
                        vector->nub     = vector->sharedController;
                        vector->source  = 0;
                        vector->target  = vector->sharedController;
-                       vector->refCon  = 0;
+                       vector->refCon  = NULL;
 
                        // If the interrupt was already registered,
                        // save the driver's interrupt enablement state.
@@ -259,11 +259,11 @@ IOInterruptController::unregisterInterrupt(IOService *nub, int source)
        vector->interruptDisabledSoft = 0;
        vector->interruptDisabledHard = 0;
        vector->interruptRegistered = 0;
-       vector->nub = 0;
+       vector->nub = NULL;
        vector->source = 0;
-       vector->handler = 0;
-       vector->target = 0;
-       vector->refCon = 0;
+       vector->handler = NULL;
+       vector->target = NULL;
+       vector->refCon = NULL;
 
        IOLockUnlock(vector->interruptLock);
        return kIOReturnSuccess;
@@ -278,7 +278,7 @@ IOInterruptController::getInterruptType(IOService *nub, int source,
        IOInterruptVector *vector;
        OSData            *vectorData;
 
-       if (interruptType == 0) {
+       if (interruptType == NULL) {
                return kIOReturnBadArgument;
        }
 
@@ -318,6 +318,14 @@ IOInterruptController::enableInterrupt(IOService *nub, int source)
                if (vector->interruptDisabledHard) {
                        vector->interruptDisabledHard = 0;
 
+                       // A DSB ISH on ARM is needed to make sure the vector data are
+                       // properly initialized before the MMIO enabling the interrupts
+                       // in hardware. OSMemoryBarrier(), which maps to DMB, is not
+                       // sufficient here as the CPUs are not consumers of the device
+                       // write. Hence, the DMB does not guarantee the CPUs won't see an
+                       // interrupt before it initalizes the vector data properly.
+                       OSSynchronizeIO();
+
                        enableVector(vectorNumber, vector);
                }
        }
@@ -372,7 +380,7 @@ IOInterruptController::causeInterrupt(IOService *nub, int source)
 IOInterruptAction
 IOInterruptController::getInterruptHandlerAddress(void)
 {
-       return 0;
+       return NULL;
 }
 
 IOReturn
@@ -423,6 +431,21 @@ IOInterruptController::causeVector(IOInterruptVectorNumber /*vectorNumber*/,
 {
 }
 
+void
+IOInterruptController::setCPUInterruptProperties(IOService */*service*/)
+{
+}
+
+void
+IOInterruptController::sendIPI(unsigned int /*cpu_id*/, bool /*deferred*/)
+{
+}
+
+void
+IOInterruptController::cancelDeferredIPI(unsigned int /*cpu_id*/)
+{
+}
+
 void
 IOInterruptController::timeStampSpuriousInterrupt(void)
 {
@@ -456,11 +479,17 @@ IOInterruptController::timeStampInterruptHandlerInternal(bool isStart, IOInterru
 
 
        if (isStart) {
+#if INTERRUPT_MASKED_DEBUG
+               ml_irq_debug_start((uintptr_t)vector->handler, (uintptr_t)vector);
+#endif
                IOTimeStampStartConstant(IODBG_INTC(IOINTC_HANDLER), (uintptr_t)vectorNumber, (uintptr_t)unslidHandler,
                    (uintptr_t)unslidTarget, (uintptr_t)providerID);
        } else {
                IOTimeStampEndConstant(IODBG_INTC(IOINTC_HANDLER), (uintptr_t)vectorNumber, (uintptr_t)unslidHandler,
                    (uintptr_t)unslidTarget, (uintptr_t)providerID);
+#if INTERRUPT_MASKED_DEBUG
+               ml_irq_debug_end();
+#endif
        }
 }
 
@@ -507,7 +536,7 @@ IOSharedInterruptController::initInterruptController(IOInterruptController *pare
 
        // Allocate the IOInterruptSource so this can act like a nub.
        _interruptSources = (IOInterruptSource *)IOMalloc(sizeof(IOInterruptSource));
-       if (_interruptSources == 0) {
+       if (_interruptSources == NULL) {
                return kIOReturnNoMemory;
        }
        _numInterruptSources = 1;
@@ -537,7 +566,7 @@ IOSharedInterruptController::initInterruptController(IOInterruptController *pare
 
        // Allocate the lock for the controller.
        controllerLock = IOSimpleLockAlloc();
-       if (controllerLock == 0) {
+       if (controllerLock == NULL) {
                return kIOReturnNoResources;
        }
 
@@ -571,7 +600,7 @@ IOSharedInterruptController::registerInterrupt(IOService *nub,
 {
        IOInterruptSource *interruptSources;
        IOInterruptVectorNumber vectorNumber;
-       IOInterruptVector *vector = 0;
+       IOInterruptVector *vector = NULL;
        OSData            *vectorData;
        IOInterruptState  interruptState;
 
@@ -607,7 +636,7 @@ IOSharedInterruptController::registerInterrupt(IOService *nub,
 
        // Create the vectorData for the IOInterruptSource.
        vectorData = OSData::withBytes(&vectorNumber, sizeof(vectorNumber));
-       if (vectorData == 0) {
+       if (vectorData == NULL) {
                IOLockUnlock(vector->interruptLock);
                return kIOReturnNoMemory;
        }
@@ -667,11 +696,11 @@ IOSharedInterruptController::unregisterInterrupt(IOService *nub,
                vector->interruptDisabledSoft = 0;
                vector->interruptDisabledHard = 0;
                vector->interruptRegistered = 0;
-               vector->nub = 0;
+               vector->nub = NULL;
                vector->source = 0;
-               vector->handler = 0;
-               vector->target = 0;
-               vector->refCon = 0;
+               vector->handler = NULL;
+               vector->target = NULL;
+               vector->refCon = NULL;
 
                interruptState = IOSimpleLockLockDisableInterrupt(controllerLock);
                vectorsRegistered--;