Loading...
iokit/Kernel/IOInterruptController.cpp xnu-12377.101.15 xnu-4903.270.47
--- xnu/xnu-12377.101.15/iokit/Kernel/IOInterruptController.cpp
+++ xnu/xnu-4903.270.47/iokit/Kernel/IOInterruptController.cpp
@@ -43,9 +43,9 @@
 
 OSDefineMetaClassAndAbstractStructors(IOInterruptController, IOService);
 
-OSMetaClassDefineReservedUsedX86(IOInterruptController, 0);
-OSMetaClassDefineReservedUsedX86(IOInterruptController, 1);
-OSMetaClassDefineReservedUsedX86(IOInterruptController, 2);
+OSMetaClassDefineReservedUnused(IOInterruptController, 0);
+OSMetaClassDefineReservedUnused(IOInterruptController, 1);
+OSMetaClassDefineReservedUnused(IOInterruptController, 2);
 OSMetaClassDefineReservedUnused(IOInterruptController, 3);
 OSMetaClassDefineReservedUnused(IOInterruptController, 4);
 OSMetaClassDefineReservedUnused(IOInterruptController, 5);
@@ -104,10 +104,10 @@
 	// register as a shared interrupt.
 	if (wasAlreadyRegisterd || shouldBeShared) {
 		// If this vector is not already shared, break it out.
-		if (vector->sharedController == NULL) {
+		if (vector->sharedController == 0) {
 			// Make the IOShareInterruptController instance
 			vector->sharedController = new IOSharedInterruptController;
-			if (vector->sharedController == NULL) {
+			if (vector->sharedController == 0) {
 				IOLockUnlock(vector->interruptLock);
 				return kIOReturnNoMemory;
 			}
@@ -133,7 +133,7 @@
 					enableInterrupt(originalNub, originalSource);
 				}
 				vector->sharedController->release();
-				vector->sharedController = NULL;
+				vector->sharedController = 0;
 				IOLockUnlock(vector->interruptLock);
 				return error;
 			}
@@ -163,7 +163,7 @@
 					enableInterrupt(originalNub, originalSource);
 
 					vector->sharedController->release();
-					vector->sharedController = NULL;
+					vector->sharedController = 0;
 					IOLockUnlock(vector->interruptLock);
 					return error;
 				}
@@ -174,7 +174,7 @@
 			vector->nub     = vector->sharedController;
 			vector->source  = 0;
 			vector->target  = vector->sharedController;
-			vector->refCon  = NULL;
+			vector->refCon  = 0;
 
 			// If the interrupt was already registered,
 			// save the driver's interrupt enablement state.
@@ -259,11 +259,11 @@
 	vector->interruptDisabledSoft = 0;
 	vector->interruptDisabledHard = 0;
 	vector->interruptRegistered = 0;
-	vector->nub = NULL;
+	vector->nub = 0;
 	vector->source = 0;
-	vector->handler = NULL;
-	vector->target = NULL;
-	vector->refCon = NULL;
+	vector->handler = 0;
+	vector->target = 0;
+	vector->refCon = 0;
 
 	IOLockUnlock(vector->interruptLock);
 	return kIOReturnSuccess;
@@ -278,7 +278,7 @@
 	IOInterruptVector *vector;
 	OSData            *vectorData;
 
-	if (interruptType == NULL) {
+	if (interruptType == 0) {
 		return kIOReturnBadArgument;
 	}
 
@@ -318,14 +318,6 @@
 		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);
 		}
 	}
@@ -380,7 +372,7 @@
 IOInterruptAction
 IOInterruptController::getInterruptHandlerAddress(void)
 {
-	return NULL;
+	return 0;
 }
 
 IOReturn
@@ -432,21 +424,6 @@
 }
 
 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)
 {
 	uint64_t providerID = 0;
@@ -479,17 +456,11 @@
 
 
 	if (isStart) {
-#if SCHED_HYGIENE_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 SCHED_HYGIENE_DEBUG
-		ml_irq_debug_end();
-#endif
 	}
 }
 
@@ -535,8 +506,8 @@
 	provider = this;
 
 	// Allocate the IOInterruptSource so this can act like a nub.
-	_interruptSources = IONew(IOInterruptSource, 1);
-	if (_interruptSources == NULL) {
+	_interruptSources = (IOInterruptSource *)IOMalloc(sizeof(IOInterruptSource));
+	if (_interruptSources == 0) {
 		return kIOReturnNoMemory;
 	}
 	_numInterruptSources = 1;
@@ -557,15 +528,16 @@
 
 	// Allocate the memory for the vectors
 	numVectors = kIOSharedInterruptControllerDefaultVectors; // For now a constant number.
-	vectors = IONewZero(IOInterruptVector, numVectors);
+	vectors = (IOInterruptVector *)IOMalloc(numVectors * sizeof(IOInterruptVector));
 	if (vectors == NULL) {
-		IODelete(_interruptSources, IOInterruptSource, 1);
+		IOFree(_interruptSources, sizeof(IOInterruptSource));
 		return kIOReturnNoMemory;
 	}
+	bzero(vectors, numVectors * sizeof(IOInterruptVector));
 
 	// Allocate the lock for the controller.
 	controllerLock = IOSimpleLockAlloc();
-	if (controllerLock == NULL) {
+	if (controllerLock == 0) {
 		return kIOReturnNoResources;
 	}
 
@@ -599,7 +571,7 @@
 {
 	IOInterruptSource *interruptSources;
 	IOInterruptVectorNumber vectorNumber;
-	IOInterruptVector *vector = NULL;
+	IOInterruptVector *vector = 0;
 	OSData            *vectorData;
 	IOInterruptState  interruptState;
 
@@ -634,8 +606,8 @@
 	}
 
 	// Create the vectorData for the IOInterruptSource.
-	vectorData = OSData::withValue(vectorNumber);
-	if (vectorData == NULL) {
+	vectorData = OSData::withBytes(&vectorNumber, sizeof(vectorNumber));
+	if (vectorData == 0) {
 		IOLockUnlock(vector->interruptLock);
 		return kIOReturnNoMemory;
 	}
@@ -690,20 +662,16 @@
 		// Soft disable the source and the controller too.
 		disableInterrupt(nub, source);
 
-		// Free vectorData
-		IOInterruptSource *interruptSources = nub->_interruptSources;
-		OSSafeReleaseNULL(interruptSources[source].vectorData);
-
 		// Clear all the storage for the vector except for interruptLock.
 		vector->interruptActive = 0;
 		vector->interruptDisabledSoft = 0;
 		vector->interruptDisabledHard = 0;
 		vector->interruptRegistered = 0;
-		vector->nub = NULL;
+		vector->nub = 0;
 		vector->source = 0;
-		vector->handler = NULL;
-		vector->target = NULL;
-		vector->refCon = NULL;
+		vector->handler = 0;
+		vector->target = 0;
+		vector->refCon = 0;
 
 		interruptState = IOSimpleLockLockDisableInterrupt(controllerLock);
 		vectorsRegistered--;