HalpAcpiSetupPmRegister

NTSTATUS __fastcall HalpAcpiSetupPmRegister(UINT64 NumberOfBytes, UINT64 a2, INT64 a3, INT64 a4){
  UINT64 v5; 
  NTSTATUS v7; 
  unsigned __int8 v8; 
  unsigned int v9; 
  unsigned int v10; 
  unsigned int v11; 
  void *v12; 
  int v14; 

  v5 = (unsigned int)NumberOfBytes;
  v7 = 0;
  *(_DWORD *)(a4 + 24) = a2;
  v8 = *(_BYTE *)(a3 + 3);
  if( v8 <= 1u )
  {
    v9 = 1;
  }
  else
  {
    v9 = 2;
    if( v8 != 2 )
    {
      v9 = 4;
      if( v8 != 3 )
      {
        if( v8 != 4 )
          return -1073741823;
        v9 = 8;
      }
    }
  }
  v10 = *(unsigned __int8 *)(a3 + 1);
  if( (_BYTE)v10 )
    v11 = v10 >> 3;
  else
    v11 = v9;
  if( v9 < (unsigned int)a2 )
    return -1073741823;
  *(_DWORD *)(a4 + 28) = v11;
  if( !*(_QWORD *)(a3 + 4) )
    return -1073741823;
  switch( *(_BYTE *)a3 )
  {
    case 0:
      *(_QWORD *)(a4 + 8) = HalMapIoSpace(*(_LARGE_INTEGER *)(a3 + 4), v5, MmNonCached, a3);
      *(_QWORD *)(a4 + 32) = HalpAcpiPmRegisterReadRegister;
      v12 = HalpAcpiPmRegisterWriteRegister;
      goto LABEL_10;
    case 1:
      *(_QWORD *)(a4 + 8) = *(unsigned int *)(a3 + 4);
      *(_QWORD *)(a4 + 32) = HalpAcpiPmRegisterReadPort;
      v12 = HalpAcpiPmRegisterWritePort;
LABEL_10:
      *(_QWORD *)(a4 + 40) = v12;
      goto LABEL_11;
    case 2:
      *(_DWORD *)(a4 + 16) = 0;
      v14 = *(_DWORD *)(a3 + 8) & 0x1F;
      *(_DWORD *)(a4 + 16) = v14;
      *(_DWORD *)(a4 + 16) = v14 | (*(_DWORD *)(a3 + 4) >> 11) & 0xE0;
      *(_WORD *)(a4 + 20) = *(_WORD *)(a3 + 4);
      *(_WORD *)(a4 + 22) = *(_WORD *)(a3 + 10);
      *(_QWORD *)(a4 + 32) = HalSystemVectorDispatchEntry;
      v12 = HalSystemVectorDispatchEntry;
      *(_QWORD *)(a4 + 8) = a4 + 16;
      goto LABEL_10;
  }
  v7 = -1073741637;
LABEL_11:
  if( *(_QWORD *)(a4 + 8) )
    *(_BYTE *)a4 = 1;
  return v7;
}

Referenced by:

HalpAcpiInitializePmRegisters
HalpAcpiSetupPmRegisterLegacy