X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/fe8ab488e9161c46dd9885d58fc52996dc0249ff..e8c3f78193f1895ea514044358b93b1add9322f3:/iokit/Kernel/IOFilterInterruptEventSource.cpp diff --git a/iokit/Kernel/IOFilterInterruptEventSource.cpp b/iokit/Kernel/IOFilterInterruptEventSource.cpp index 83b6ed6e0..f3c61367b 100644 --- a/iokit/Kernel/IOFilterInterruptEventSource.cpp +++ b/iokit/Kernel/IOFilterInterruptEventSource.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #if IOKITSTATS @@ -123,6 +124,39 @@ IOFilterInterruptEventSource *IOFilterInterruptEventSource return me; } + +IOFilterInterruptEventSource *IOFilterInterruptEventSource +::filterInterruptEventSource(OSObject *inOwner, + IOService *inProvider, + int inIntIndex, + ActionBlock inAction, + FilterBlock inFilterAction) +{ + IOFilterInterruptEventSource *me = new IOFilterInterruptEventSource; + + FilterBlock filter = Block_copy(inFilterAction); + if (!filter) return 0; + + if (me + && !me->init(inOwner, (Action) NULL, (Filter) filter, inProvider, inIntIndex)) { + me->release(); + Block_release(filter); + return 0; + } + me->flags |= kFilterBlock; + me->setActionBlock((IOEventSource::ActionBlock) inAction); + + return me; +} + + +void IOFilterInterruptEventSource::free( void ) +{ + if ((kFilterBlock & flags) && filterActionBlock) Block_release(filterActionBlock); + + super::free(); +} + void IOFilterInterruptEventSource::signalInterrupt() { bool trace = (gIOKitTrace & kIOTraceIntEventSource) ? true : false; @@ -131,12 +165,12 @@ void IOFilterInterruptEventSource::signalInterrupt() producerCount++; if (trace) - IOTimeStampStartConstant(IODBG_INTES(IOINTES_SEMA), (uintptr_t) this, (uintptr_t) owner); + IOTimeStampStartConstant(IODBG_INTES(IOINTES_SEMA), VM_KERNEL_ADDRHIDE(this), VM_KERNEL_ADDRHIDE(owner)); signalWorkAvailable(); if (trace) - IOTimeStampEndConstant(IODBG_INTES(IOINTES_SEMA), (uintptr_t) this, (uintptr_t) owner); + IOTimeStampEndConstant(IODBG_INTES(IOINTES_SEMA), VM_KERNEL_ADDRHIDE(this), VM_KERNEL_ADDRHIDE(owner)); } @@ -144,11 +178,16 @@ void IOFilterInterruptEventSource::signalInterrupt() IOFilterInterruptEventSource::Filter IOFilterInterruptEventSource::getFilterAction() const { + if (kFilterBlock & flags) return NULL; return filterAction; } - - +IOFilterInterruptEventSource::FilterBlock +IOFilterInterruptEventSource::getFilterActionBlock() const +{ + if (kFilterBlock & flags) return filterActionBlock; + return (NULL); +} void IOFilterInterruptEventSource::normalInterruptOccurred (void */*refcon*/, IOService */*prov*/, int /*source*/) @@ -160,7 +199,7 @@ void IOFilterInterruptEventSource::normalInterruptOccurred if (trace) IOTimeStampStartConstant(IODBG_INTES(IOINTES_FILTER), - VM_KERNEL_UNSLIDE(filterAction), (uintptr_t) owner, (uintptr_t) this, (uintptr_t) workLoop); + VM_KERNEL_UNSLIDE(filterAction), VM_KERNEL_ADDRHIDE(owner), VM_KERNEL_ADDRHIDE(this), VM_KERNEL_ADDRHIDE(workLoop)); if (IOInterruptEventSource::reserved->statistics) { if (IA_GET_STATISTIC_ENABLED(kInterruptAccountingFirstLevelTimeIndex)) { @@ -169,7 +208,8 @@ void IOFilterInterruptEventSource::normalInterruptOccurred } // Call the filter. - filterRes = (*filterAction)(owner, this); + if (kFilterBlock & flags) filterRes = (filterActionBlock)(this); + else filterRes = (*filterAction)(owner, this); if (IOInterruptEventSource::reserved->statistics) { if (IA_GET_STATISTIC_ENABLED(kInterruptAccountingFirstLevelCountIndex)) { @@ -184,7 +224,8 @@ void IOFilterInterruptEventSource::normalInterruptOccurred if (trace) IOTimeStampEndConstant(IODBG_INTES(IOINTES_FILTER), - VM_KERNEL_UNSLIDE(filterAction), (uintptr_t) owner, (uintptr_t) this, (uintptr_t) workLoop); + VM_KERNEL_ADDRHIDE(filterAction), VM_KERNEL_ADDRHIDE(owner), + VM_KERNEL_ADDRHIDE(this), VM_KERNEL_ADDRHIDE(workLoop)); if (filterRes) signalInterrupt(); @@ -200,7 +241,7 @@ void IOFilterInterruptEventSource::disableInterruptOccurred if (trace) IOTimeStampStartConstant(IODBG_INTES(IOINTES_FILTER), - VM_KERNEL_UNSLIDE(filterAction), (uintptr_t) owner, (uintptr_t) this, (uintptr_t) workLoop); + VM_KERNEL_UNSLIDE(filterAction), VM_KERNEL_ADDRHIDE(owner), VM_KERNEL_ADDRHIDE(this), VM_KERNEL_ADDRHIDE(workLoop)); if (IOInterruptEventSource::reserved->statistics) { if (IA_GET_STATISTIC_ENABLED(kInterruptAccountingFirstLevelTimeIndex)) { @@ -209,7 +250,8 @@ void IOFilterInterruptEventSource::disableInterruptOccurred } // Call the filter. - filterRes = (*filterAction)(owner, this); + if (kFilterBlock & flags) filterRes = (filterActionBlock)(this); + else filterRes = (*filterAction)(owner, this); if (IOInterruptEventSource::reserved->statistics) { if (IA_GET_STATISTIC_ENABLED(kInterruptAccountingFirstLevelCountIndex)) { @@ -224,7 +266,7 @@ void IOFilterInterruptEventSource::disableInterruptOccurred if (trace) IOTimeStampEndConstant(IODBG_INTES(IOINTES_FILTER), - VM_KERNEL_UNSLIDE(filterAction), (uintptr_t) owner, (uintptr_t) this, (uintptr_t) workLoop); + VM_KERNEL_UNSLIDE(filterAction), VM_KERNEL_ADDRHIDE(owner), VM_KERNEL_ADDRHIDE(this), VM_KERNEL_ADDRHIDE(workLoop)); if (filterRes) { prov->disableInterrupt(source); /* disable the interrupt */