PopPepUpdateIdleStateRefCount
VOID __stdcall PopPepUpdateIdleStateRefCount(
UINT64 OldMask,
UINT64 NewMask,
POP_PEP_REFERENCE_COUNTER_UPDATE_TYPE Type){
int v4;
int v5;
char v6;
__int64 v7;
unsigned __int8 CurrentIrql;
int v9;
int v10;
bool v11;
__int64 v12;
__int64 v13;
signed int v14;
signed __int32 v15;
__int64 v16;
__int64 v17;
signed __int32 v18;
unsigned int StateIndex;
UINT64 SpinCount;
__int64 P2[32];
LODWORD(SpinCount) = 0;
v4 = NewMask;
v5 = OldMask;
memset(P2, 0i64, sizeof(P2));
v6 = 0;
v7 = 0i64;
CurrentIrql = 0;
v9 = v5;
if( Type )
v9 = v4;
v10 = (v5 ^ v4) & v9;
v11 = !_BitScanForward((unsigned int *)&v12, v10);
StateIndex = v12;
if( v11 )
return;
do
{
v13 = PopPepPlatformState + 384 * v12;
v10 &= v10 - 1;
if( Type )
{
v15 = *(_DWORD *)(v13 + 320);
if( v15 <= 0 || v15 != _InterlockedCompareExchange((volatile signed __int32 *)(v13 + 320), v15 + 1, v15) )
{
P2[v7] = v13;
v7 = (unsigned int)(v7 + 1);
}
}
else
{
v14 = _InterlockedDecrement((volatile signed __int32 *)(v13 + 320));
if( v14 < 0x40000000 )
PopFxBugCheck(0x668u, v13, v14, v10);
if( v14 == 0x40000000 )
{
if( !v6 )
{
CurrentIrql = KeGetCurrentIrql();
__writecr8(2ui64);
v6 = 1;
}
if( _InterlockedCompareExchange((volatile signed __int32 *)(v13 + 320), -1, 0x40000000) == 0x40000000 )
{
PopFxPlatformStateAvailable(StateIndex, 1u);
if( *(_DWORD *)(v13 + 320) != -1 )
PopFxBugCheck(0x669u, v13, *(_DWORD *)(v13 + 320), 0);
*(_DWORD *)(v13 + 320) = 0;
}
}
}
v11 = !_BitScanForward((unsigned int *)&v12, v10);
StateIndex = v12;
}
while( !v11 );
if( (_DWORD)v7 )
{
CurrentIrql = KeGetCurrentIrql();
__writecr8(2ui64);
while( 1 )
{
KeYieldProcessorEx(&SpinCount);
v16 = 0i64;
do
{
v17 = P2[v16];
v18 = *(_DWORD *)(v17 + 320);
if( v18 <= 0 )
{
if( !v18 && !_InterlockedCompareExchange((volatile signed __int32 *)(v17 + 320), -1, 0) )
{
PopFxPlatformStateAvailable((v17 - PopPepPlatformState) / 384, 0);
if( *(_DWORD *)(v17 + 320) != -1 )
PopFxBugCheck(0x669u, v17, *(_DWORD *)(v17 + 320), 0);
*(_DWORD *)(v17 + 320) = 1073741825;
v7 = (unsigned int)(v7 - 1);
goto LABEL_26;
}
}
else if( v18 == _InterlockedCompareExchange((volatile signed __int32 *)(v17 + 320), v18 + 1, v18) )
{
v7 = (unsigned int)(v7 - 1);
LABEL_26:
P2[v16] = P2[v7];
continue;
}
v16 = (unsigned int)(v16 + 1);
}
while( (unsigned int)v16 < (unsigned int)v7 );
if( !(_DWORD)v7 )
{
LABEL_36:
__writecr8(CurrentIrql);
return;
}
}
}
if( v6 )
goto LABEL_36;
}Referenced by:
PopPepClearDripsDeviceVetoMask
PopPepCompleteComponentIdleStateChangeActivity
PopPepDeviceDState
PopPepInitializeVetoMasks
PopPepPlatformStateRegistered
PopPepStartComponentIdleStateChangeActivity
PopPepUnregisterDevice
PopPepUpdateDripsDeviceVetoMask