PoFxStartDevicePowerManagement

VOID __stdcall PoFxStartDevicePowerManagement(POHANDLE *Handle){
  POHANDLE v1; 
  POHANDLE v3; 
  unsigned int v4; 
  KIRQL v5; 
  unsigned int v6; 
  unsigned __int64 v7; 
  unsigned int v8; 
  __int64 v9; 
  unsigned int i; 
  _ETHREAD *CurrentThread; 
  char v12; 
  DEVICE_OBJECT *v13; 
  POHANDLE v14; 
  v1 = Handle[6];
  PopPepDeviceStarted((INT64)Handle[7]);
  v3 = Handle[8];
  v4 = 0;
  if( v3 )
  {
    v14 = Handle[9];
    (*((void(__fastcall **)(__int64, POHANDLE *))v3 + 12))(18i64, &v14);
  }
  if( v1 )
  {
    v5 = ExAcquireSpinLockExclusive((PEX_SPIN_LOCK)v1 + 22);
    v6 = *((_DWORD *)v1 + 30);
    v7 = v5;
    if( ((_DWORD)Handle[103] & 1) != 0 )
    {
      if( !v6 )
      {
LABEL_10:
        _InterlockedOr((volatile signed __int32 *)v1 + 74, 4u);
        ExReleaseSpinLockExclusiveFromDpcLevel((INT64 *)v1 + 11);
        __writecr8(v7);
        PopDiagTraceFxDeviceStartPowerManagement(v1);
        goto LABEL_11;
      }
      v6 = 0;
      *((_DWORD *)v1 + 30) = 0;
    }
    if( v6 )
    {
      v8 = *((_DWORD *)Handle + 207);
      v9 = v6;
      do
      {
        for( i = 0; i < v8; ++i )
        {
          PoFxActivateComponent(Handle, i, 2ui64);
          v8 = *((_DWORD *)Handle + 207);
        }
        --v9;
      }
      while( v9 );
    }
    goto LABEL_10;
  }
LABEL_11:
  CurrentThread = (_ETHREAD *)KeGetCurrentThread();
  --*((_WORD *)CurrentThread + 242);
  ExAcquirePushLockSharedEx((UINT64)&PopFxDeviceListLock, 0i64);
  v12 = PopFxEnableShutdownActiveBias;
  if( _InterlockedCompareExchange64((volatile signed __int64 *)&PopFxDeviceListLock, 0i64, 17i64) != 17 )
    ExfReleasePushLockShared((INT64 *)&PopFxDeviceListLock);
  KeAbPostRelease(&PopFxDeviceListLock);
  KeLeaveCriticalRegionThread((__int64)KeGetCurrentThread());
  if( v12 )
  {
    v13 = (DEVICE_OBJECT *)*((_QWORD *)v1 + 4);
    PopFxActivateDevice(v13, 0);
    PopFxIncrementDeviceSleepCount(v13);
  }
  if( *((_DWORD *)Handle + 207) )
  {
    do
      PoFxIdleComponent(Handle, v4++, 1ui64);
    while( v4 < *((_DWORD *)Handle + 207) );
  }
}

Referenced by:

HalpDmaInitPowerManagement
HalpInterruptInitPowerManagement
HalpTimerInitPowerManagement
PoFxEnableDStateReporting
PoFxRegisterDebugger