X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/060df5ea7c632b1ac8cc8aac1fb59758165c2084..e2d2fc5c71f7d145cba7267989251af45e3bb5ba:/iokit/Kernel/IOInterruptEventSource.cpp diff --git a/iokit/Kernel/IOInterruptEventSource.cpp b/iokit/Kernel/IOInterruptEventSource.cpp index 97d4c5957..8b49024a1 100644 --- a/iokit/Kernel/IOInterruptEventSource.cpp +++ b/iokit/Kernel/IOInterruptEventSource.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1998-2010 Apple Inc. All rights reserved. * * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ * @@ -25,13 +25,7 @@ * * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ */ -/* -Copyright (c) 1998 Apple Computer, Inc. All rights reserved. -HISTORY - 1998-7-13 Godfrey van der Linden(gvdl) - Created. -*/ #include #include #include @@ -40,6 +34,31 @@ HISTORY #include #include +#if IOKITSTATS + +#define IOStatisticsInitializeCounter() \ +do { \ + IOStatistics::setCounterType(IOEventSource::reserved->counter, kIOStatisticsInterruptEventSourceCounter); \ +} while (0) + +#define IOStatisticsCheckForWork() \ +do { \ + IOStatistics::countInterruptCheckForWork(IOEventSource::reserved->counter); \ +} while (0) + +#define IOStatisticsInterrupt() \ +do { \ + IOStatistics::countInterrupt(IOEventSource::reserved->counter); \ +} while (0) + +#else + +#define IOStatisticsInitializeCounter() +#define IOStatisticsCheckForWork() +#define IOStatisticsInterrupt() + +#endif // IOKITSTATS + #define super IOEventSource OSDefineMetaClassAndStructors(IOInterruptEventSource, IOEventSource) @@ -74,6 +93,8 @@ bool IOInterruptEventSource::init(OSObject *inOwner, intIndex = inIntIndex; } + IOStatisticsInitializeCounter(); + return res; } @@ -182,24 +203,26 @@ bool IOInterruptEventSource::checkForWork() int numInts = cacheProdCount - consumerCount; IOInterruptEventAction intAction = (IOInterruptEventAction) action; bool trace = (gIOKitTrace & kIOTraceIntEventSource) ? true : false; - + + IOStatisticsCheckForWork(); + if ( numInts > 0 ) { if (trace) IOTimeStampStartConstant(IODBG_INTES(IOINTES_ACTION), (uintptr_t) intAction, (uintptr_t) owner, (uintptr_t) this, (uintptr_t) workLoop); - + // Call the handler - (*intAction)(owner, this, numInts); + (*intAction)(owner, this, numInts); if (trace) IOTimeStampEndConstant(IODBG_INTES(IOINTES_ACTION), (uintptr_t) intAction, (uintptr_t) owner, (uintptr_t) this, (uintptr_t) workLoop); - - consumerCount = cacheProdCount; - if (autoDisable && !explicitDisable) - enable(); - } + + consumerCount = cacheProdCount; + if (autoDisable && !explicitDisable) + enable(); + } else if ( numInts < 0 ) { @@ -208,17 +231,17 @@ bool IOInterruptEventSource::checkForWork() (uintptr_t) intAction, (uintptr_t) owner, (uintptr_t) this, (uintptr_t) workLoop); // Call the handler - (*intAction)(owner, this, -numInts); + (*intAction)(owner, this, -numInts); if (trace) IOTimeStampEndConstant(IODBG_INTES(IOINTES_ACTION), (uintptr_t) intAction, (uintptr_t) owner, (uintptr_t) this, (uintptr_t) workLoop); - - consumerCount = cacheProdCount; - if (autoDisable && !explicitDisable) - enable(); - } - + + consumerCount = cacheProdCount; + if (autoDisable && !explicitDisable) + enable(); + } + return false; } @@ -226,14 +249,15 @@ void IOInterruptEventSource::normalInterruptOccurred (void */*refcon*/, IOService */*prov*/, int /*source*/) { bool trace = (gIOKitTrace & kIOTraceIntEventSource) ? true : false; - + + IOStatisticsInterrupt(); producerCount++; - + if (trace) IOTimeStampStartConstant(IODBG_INTES(IOINTES_SEMA), (uintptr_t) this, (uintptr_t) owner); signalWorkAvailable(); - + if (trace) IOTimeStampEndConstant(IODBG_INTES(IOINTES_SEMA), (uintptr_t) this, (uintptr_t) owner); } @@ -242,16 +266,17 @@ void IOInterruptEventSource::disableInterruptOccurred (void */*refcon*/, IOService *prov, int source) { bool trace = (gIOKitTrace & kIOTraceIntEventSource) ? true : false; - + prov->disableInterrupt(source); /* disable the interrupt */ - + + IOStatisticsInterrupt(); producerCount++; - + if (trace) IOTimeStampStartConstant(IODBG_INTES(IOINTES_SEMA), (uintptr_t) this, (uintptr_t) owner); signalWorkAvailable(); - + if (trace) IOTimeStampEndConstant(IODBG_INTES(IOINTES_SEMA), (uintptr_t) this, (uintptr_t) owner); } @@ -264,3 +289,10 @@ void IOInterruptEventSource::interruptOccurred else normalInterruptOccurred(refcon, prov, source); } + +IOReturn IOInterruptEventSource::warmCPU + (uint64_t abstime) +{ + + return ml_interrupt_prewarm(abstime); +}