HalpAcpiPreSleep

VOID __fastcall HalpAcpiPreSleep(INT64 a1){
  __int16 v1; 
  INT64 v2; 
  INT64 v3; 
  INT64 v4; 
  UINT64 SavedPerformanceCounter; 
  __int16 v6; 
  __int16 v7; 
  __int16 v8; 
  __int16 v9; 
  v1 = a1;
  HalpSleepContext = a1;
  LOBYTE(a1) = 1;
  v8 = 0;
  v9 = 0;
  HalpTimerSwitchStallSource(a1);
  HalpTimerSavePerformanceCounter();
  if( (HalpPlatformFlags & 4) != 0 )
    HalpSetClockBeforeSleep(v3, v2, v4);
  SavedPerformanceCounter = HalpTimerGetSavedPerformanceCounter();
  KeSynchronizeTimeToQpc(SavedPerformanceCounter);
  HalpHiberInProgress = 1;
  if( (v1 & 0x4000) != 0 )
    HalpSaveDmaControllerState();
  if( (int)HalpAcpiPmRegisterAvailable(0) >= 0 )
  {
    HalpAcpiPmRegisterRead(0, (unsigned __int8)byte_140C49DD8 >> 1, (__int64)&v9, 2u, 0i64);
    v6 = v9;
    v8 = v9;
    if( (int)HalpAcpiPmRegisterAvailable(3) >= 0 )
    {
      HalpAcpiPmRegisterRead(3, (unsigned __int8)byte_140C49DD8 >> 1, (__int64)&v9, 2u, 0i64);
      v6 = v9 | v8;
      v8 |= v9;
    }
    if( (dword_140C49DF0 & 0x40) == 0 )
    {
      if( HIBYTE(HalpWakeupState) )
        v7 = v6 | 0x400;
      else
        v7 = v6 & 0xFBFF;
      v8 = v7;
    }
    HalpAcpiPmRegisterWrite(0, (unsigned __int8)byte_140C49DD8 >> 1, (__int64)&v8, 2u, 0i64);
    if( (int)HalpAcpiPmRegisterAvailable(3) >= 0 )
      HalpAcpiPmRegisterWrite(3, (unsigned __int8)byte_140C49DD8 >> 1, (__int64)&v8, 2u, 0i64);
    HalpAcpiPmRegisterRead(0, 0, (__int64)&v9, 2u, 0i64);
    v8 = v9;
    if( (int)HalpAcpiPmRegisterAvailable(3) >= 0 )
    {
      HalpAcpiPmRegisterRead(3, 0, (__int64)&v9, 2u, 0i64);
      v8 |= v9;
    }
    HalpAcpiPmRegisterWrite(0, 0, (__int64)&v8, 2u, 0i64);
    if( (int)HalpAcpiPmRegisterAvailable(3) >= 0 )
      HalpAcpiPmRegisterWrite(3, 0, (__int64)&v8, 2u, 0i64);
  }
  if( (_BYTE)HalpWakeupState )
    (*(void(**)(void))(PmAcpiDispatchTable + 24))();
  else(*(void(__fastcall **)(_QWORD))(PmAcpiDispatchTable + 8))(0i64);
  HalpPreserveNvsArea();
  SystemPowerPhase = 2;
}

Referenced by:

HaliAcpiSleep