Loading...
--- xnu/xnu-12377.101.15/iokit/Kernel/IOInterruptEventSource.cpp
+++ xnu/xnu-6153.121.1/iokit/Kernel/IOInterruptEventSource.cpp
@@ -26,9 +26,6 @@
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
-#define IOKIT_ENABLE_SHARED_PTR
-
-#include <ptrauth.h>
#include <IOKit/IOInterruptEventSource.h>
#include <IOKit/IOKitDebug.h>
#include <IOKit/IOLib.h>
@@ -37,7 +34,6 @@
#include <IOKit/IOTimeStamp.h>
#include <IOKit/IOWorkLoop.h>
#include <IOKit/IOInterruptAccountingPrivate.h>
-#include <libkern/Block_private.h>
#if IOKITSTATS
@@ -84,15 +80,17 @@
{
bool res = true;
- if (inIntIndex < 0) {
- return false;
- }
-
if (!super::init(inOwner, (IOEventSourceAction) inAction)) {
return false;
}
- reserved = IOMallocType(ExpansionData);
+ reserved = IONew(ExpansionData, 1);
+
+ if (!reserved) {
+ return false;
+ }
+
+ bzero(reserved, sizeof(ExpansionData));
provider = inProvider;
producerCount = consumerCount = 0;
@@ -111,7 +109,17 @@
* We also avoid try to avoid interrupt accounting overhead if none of
* the statistics are enabled.
*/
- reserved->statistics = IOMallocType(IOInterruptAccountingData);
+ reserved->statistics = IONew(IOInterruptAccountingData, 1);
+
+ if (!reserved->statistics) {
+ /*
+ * We rely on the free() routine to clean up after us if init fails
+ * midway.
+ */
+ return false;
+ }
+
+ bzero(reserved->statistics, sizeof(IOInterruptAccountingData));
reserved->statistics->owner = this;
}
@@ -200,28 +208,29 @@
}
-OSSharedPtr<IOInterruptEventSource>
+IOInterruptEventSource *
IOInterruptEventSource::interruptEventSource(OSObject *inOwner,
Action inAction,
IOService *inProvider,
int inIntIndex)
{
- OSSharedPtr<IOInterruptEventSource> me = OSMakeShared<IOInterruptEventSource>();
+ IOInterruptEventSource *me = new IOInterruptEventSource;
if (me && !me->init(inOwner, inAction, inProvider, inIntIndex)) {
- return nullptr;
+ me->release();
+ return NULL;
}
return me;
}
-OSSharedPtr<IOInterruptEventSource>
+IOInterruptEventSource *
IOInterruptEventSource::interruptEventSource(OSObject *inOwner,
IOService *inProvider,
int inIntIndex,
ActionBlock inAction)
{
- OSSharedPtr<IOInterruptEventSource> ies;
+ IOInterruptEventSource * ies;
ies = IOInterruptEventSource::interruptEventSource(inOwner, (Action) NULL, inProvider, inIntIndex);
if (ies) {
ies->setActionBlock((IOEventSource::ActionBlock) inAction);
@@ -239,10 +248,10 @@
if (reserved) {
if (reserved->statistics) {
- IOFreeType(reserved->statistics, IOInterruptAccountingData);
- }
-
- IOFreeType(reserved, ExpansionData);
+ IODelete(reserved->statistics, IOInterruptAccountingData, 1);
+ }
+
+ IODelete(reserved, ExpansionData, 1);
}
super::free();
@@ -322,24 +331,16 @@
uint64_t endCPUTime = 0;
unsigned int cacheProdCount = producerCount;
int numInts = cacheProdCount - consumerCount;
- IOEventSource::Action intAction = action;
+ IOInterruptEventAction intAction = (IOInterruptEventAction) action;
ActionBlock intActionBlock = (ActionBlock) actionBlock;
- void *address;
bool trace = (gIOKitTrace & kIOTraceIntEventSource) ? true : false;
-
- if (kActionBlock & flags) {
- address = ptrauth_nop_cast(void *, _Block_get_invoke_fn((struct Block_layout *)intActionBlock));
- } else {
- address = ptrauth_nop_cast(void *, intAction);
- }
IOStatisticsCheckForWork();
if (numInts > 0) {
if (trace) {
IOTimeStampStartConstant(IODBG_INTES(IOINTES_ACTION),
- VM_KERNEL_ADDRHIDE(address),
- VM_KERNEL_ADDRHIDE(owner),
+ VM_KERNEL_ADDRHIDE(intAction), VM_KERNEL_ADDRHIDE(owner),
VM_KERNEL_ADDRHIDE(this), VM_KERNEL_ADDRHIDE(workLoop));
}
@@ -357,7 +358,7 @@
if (kActionBlock & flags) {
(intActionBlock)(this, numInts);
} else {
- ((IOInterruptEventAction)intAction)(owner, this, numInts);
+ (*intAction)(owner, this, numInts);
}
if (reserved->statistics) {
@@ -378,8 +379,7 @@
if (trace) {
IOTimeStampEndConstant(IODBG_INTES(IOINTES_ACTION),
- VM_KERNEL_ADDRHIDE(address),
- VM_KERNEL_ADDRHIDE(owner),
+ VM_KERNEL_ADDRHIDE(intAction), VM_KERNEL_ADDRHIDE(owner),
VM_KERNEL_ADDRHIDE(this), VM_KERNEL_ADDRHIDE(workLoop));
}
@@ -390,8 +390,7 @@
} else if (numInts < 0) {
if (trace) {
IOTimeStampStartConstant(IODBG_INTES(IOINTES_ACTION),
- VM_KERNEL_ADDRHIDE(address),
- VM_KERNEL_ADDRHIDE(owner),
+ VM_KERNEL_ADDRHIDE(intAction), VM_KERNEL_ADDRHIDE(owner),
VM_KERNEL_ADDRHIDE(this), VM_KERNEL_ADDRHIDE(workLoop));
}
@@ -409,29 +408,28 @@
if (kActionBlock & flags) {
(intActionBlock)(this, numInts);
} else {
- ((IOInterruptEventAction)intAction)(owner, this, numInts);
+ (*intAction)(owner, this, numInts);
}
if (reserved->statistics) {
+ if (IA_GET_STATISTIC_ENABLED(kInterruptAccountingSecondLevelCountIndex)) {
+ IA_ADD_VALUE(&reserved->statistics->interruptStatistics[kInterruptAccountingSecondLevelCountIndex], 1);
+ }
+
+ if (IA_GET_STATISTIC_ENABLED(kInterruptAccountingSecondLevelCPUTimeIndex)) {
+ endCPUTime = thread_get_runtime_self();
+ IA_ADD_VALUE(&reserved->statistics->interruptStatistics[kInterruptAccountingSecondLevelCPUTimeIndex], endCPUTime - startCPUTime);
+ }
+
if (IA_GET_STATISTIC_ENABLED(kInterruptAccountingSecondLevelSystemTimeIndex)) {
endSystemTime = mach_absolute_time();
IA_ADD_VALUE(&reserved->statistics->interruptStatistics[kInterruptAccountingSecondLevelSystemTimeIndex], endSystemTime - startSystemTime);
}
-
- if (IA_GET_STATISTIC_ENABLED(kInterruptAccountingSecondLevelCPUTimeIndex)) {
- endCPUTime = thread_get_runtime_self();
- IA_ADD_VALUE(&reserved->statistics->interruptStatistics[kInterruptAccountingSecondLevelCPUTimeIndex], endCPUTime - startCPUTime);
- }
-
- if (IA_GET_STATISTIC_ENABLED(kInterruptAccountingSecondLevelCountIndex)) {
- IA_ADD_VALUE(&reserved->statistics->interruptStatistics[kInterruptAccountingSecondLevelCountIndex], 1);
- }
}
if (trace) {
IOTimeStampEndConstant(IODBG_INTES(IOINTES_ACTION),
- VM_KERNEL_ADDRHIDE(address),
- VM_KERNEL_ADDRHIDE(owner),
+ VM_KERNEL_ADDRHIDE(intAction), VM_KERNEL_ADDRHIDE(owner),
VM_KERNEL_ADDRHIDE(this), VM_KERNEL_ADDRHIDE(workLoop));
}
@@ -531,7 +529,7 @@
}
uint64_t
-IOInterruptEventSource::getPrimaryInterruptTimestamp()
+IOInterruptEventSource::getPimaryInterruptTimestamp()
{
if (reserved->statistics && reserved->statistics->enablePrimaryTimestamp) {
return reserved->statistics->primaryTimestamp;