HalpShutdown

VOID __stdcall HalpShutdown(){
  __int16 v0; 
  __int16 v1; 
  __int16 v2; 
  v2 = 0;
  v0 = 0;
  v1 = 0;
  if( _InterlockedCompareExchange(&HalpShutdownActive, 1, 0) )
  {
    while( 1 )
      ;
  }
  (*(void(__fastcall **)(_QWORD))(PmAcpiDispatchTable + 8))(0i64);
  if( PmRegisters[0] )
  {
    HalpAcpiPmRegisterRead(0, 0, (__int64)&v2, 2u, 0i64);
    v1 = v2;
    if( byte_140C48E50 )
    {
      HalpAcpiPmRegisterRead(3, 0, (__int64)&v2, 2u, 0i64);
      v1 |= v2;
    }
    HalpAcpiPmRegisterWrite(0, 0, (__int64)&v1, 2u, 0i64);
    if( byte_140C48E50 )
      HalpAcpiPmRegisterWrite(3, 0, (__int64)&v1, 2u, 0i64);
  }
  if( HalpShutdownContext && byte_140C48DF0 )
  {
    if( HalpHvSleepEnlightenedCpuManager )
      HalpHvEnterSleepState();
    HalpAcpiPmRegisterRead(1, 0, (__int64)&v0, 2u, 0i64);
    v0 = v0 & 0x203 | ((HalpShutdownContext & 7 | 8) << 10);
    HalpAcpiPmRegisterWrite(1, 0, (__int64)&v0, 2u, 0i64);
    if( byte_140C48E80 )
    {
      HalpAcpiPmRegisterRead(4, 0, (__int64)&v0, 2u, 0i64);
      v0 = v0 & 0x203 | ((((unsigned int)HalpShutdownContext >> 4) & 7 | 8) << 10);
      HalpAcpiPmRegisterWrite(4, 0, (__int64)&v0, 2u, 0i64);
    }
  }
  if( HalFirmwareTypeEfi )
    HalEfiResetSystem(2i64);
}

Referenced by:

HalReturnToFirmware
HaliHaltSystem
HalpCheckPowerButton