Loading...
--- xnu/xnu-7195.141.2/iokit/Kernel/IOStateReporter.cpp
+++ xnu/xnu-8019.41.5/iokit/Kernel/IOStateReporter.cpp
@@ -99,11 +99,11 @@
{
if (_currentStates) {
PREFL_MEMOP_PANIC(_nChannels, int);
- IOFree(_currentStates, (size_t)_nChannels * sizeof(int));
+ IOFreeData(_currentStates, (size_t)_nChannels * sizeof(int));
}
if (_lastUpdateTimes) {
PREFL_MEMOP_PANIC(_nChannels, uint64_t);
- IOFree(_lastUpdateTimes, (size_t)_nChannels * sizeof(uint64_t));
+ IOFreeData(_lastUpdateTimes, (size_t)_nChannels * sizeof(uint64_t));
}
super::free();
@@ -127,7 +127,7 @@
// new currentStates buffer
PREFL_MEMOP_FAIL(newNChannels, int);
newCurStatesSize = (size_t)newNChannels * sizeof(int);
- _swapCurrentStates = (int*)IOMalloc(newCurStatesSize);
+ _swapCurrentStates = (int*)IOMallocData(newCurStatesSize);
if (_swapCurrentStates == NULL) {
res = kIOReturnNoMemory; goto finish;
}
@@ -136,22 +136,21 @@
// new timestamps buffer
PREFL_MEMOP_FAIL(newNChannels, uint64_t);
newTSSize = (size_t)newNChannels * sizeof(uint64_t);
- _swapLastUpdateTimes = (uint64_t *)IOMalloc(newTSSize);
+ _swapLastUpdateTimes = (uint64_t *)IOMallocZeroData(newTSSize);
if (_swapLastUpdateTimes == NULL) {
res = kIOReturnNoMemory; goto finish;
}
- memset(_swapLastUpdateTimes, 0, newTSSize);
res = super::handleSwapPrepare(newNChannels);
finish:
if (res) {
if (_swapCurrentStates) {
- IOFree(_swapCurrentStates, newCurStatesSize);
+ IOFreeData(_swapCurrentStates, newCurStatesSize);
_swapCurrentStates = NULL;
}
if (_swapLastUpdateTimes) {
- IOFree(_swapLastUpdateTimes, newTSSize);
+ IOFreeData(_swapLastUpdateTimes, newTSSize);
_swapLastUpdateTimes = NULL;
}
}
@@ -243,12 +242,12 @@
if (_swapCurrentStates) {
PREFL_MEMOP_PANIC(swapNChannels, int);
- IOFree(_swapCurrentStates, (size_t)swapNChannels * sizeof(int));
+ IOFreeData(_swapCurrentStates, (size_t)swapNChannels * sizeof(int));
_swapCurrentStates = NULL;
}
if (_swapLastUpdateTimes) {
PREFL_MEMOP_PANIC(swapNChannels, uint64_t);
- IOFree(_swapLastUpdateTimes, (size_t)swapNChannels * sizeof(uint64_t));
+ IOFreeData(_swapLastUpdateTimes, (size_t)swapNChannels * sizeof(uint64_t));
_swapLastUpdateTimes = NULL;
}
}
@@ -345,7 +344,7 @@
if (_getStateIndices(channel_id, state_id, &channel_index, &state_index) == kIOReturnSuccess) {
if (_lastUpdateTimes[channel_index]) {
- panic("overrideChannelState() cannot be used after setChannelState()!\n");
+ panic("overrideChannelState() cannot be used after setChannelState()!");
}
res = handleOverrideChannelStateByIndices(channel_index, state_index,
@@ -421,7 +420,7 @@
if (_getStateIndices(channel_id, state_id, &channel_index, &state_index) == kIOReturnSuccess) {
if (_lastUpdateTimes[channel_index]) {
- panic("incrementChannelState() cannot be used after setChannelState()!\n");
+ panic("incrementChannelState() cannot be used after setChannelState()!");
}
res = handleIncrementChannelStateByIndices(channel_index, state_index,
@@ -872,3 +871,21 @@
finish:
return result;
}
+
+/* static */ OSPtr<IOReportLegendEntry>
+IOStateReporter::createLegend(const uint64_t *channelIDs,
+ const char **channelNames,
+ int channelCount,
+ int nstates,
+ IOReportCategories categories,
+ IOReportUnit unit)
+{
+ IOReportChannelType channelType = {
+ .categories = categories,
+ .report_format = kIOReportFormatState,
+ .nelements = static_cast<uint16_t>(nstates),
+ .element_idx = 0
+ };
+
+ return IOReporter::legendWith(channelIDs, channelNames, channelCount, channelType, unit);
+}