Newer
Older
AMI-Aptio-BIOS-Reversed / Platform / SetupConfigExtract.c
@Ajax Dong Ajax Dong 2 days ago 2 KB Init
// SetupConfigExtract - decompiled from Platform.efi
__int64 __fastcall SetupConfigExtract(int n4, unsigned int n2)
{
  unsigned int n2_1; // ebx
  unsigned int v5; // esi
  __int64 v6; // rcx
  __int64 CpuPciCfg; // rax
  __int64 v8; // rcx
  __int64 v9; // rcx

  n2_1 = n2; /*0xb1b3*/
  if ( n2 != 2 ) /*0xb1ba*/
  {
    DebugPrint(0x40u, "[ME Policy] Not Auto-configuration (%d) passed for device %d\n", n2, n4); /*0xb1ce*/
    return n2_1; /*0xb1d5*/
  }
  if ( (unsigned int)GetManufacturingMode() == 15 ) /*0xb1df*/
    return 1; /*0xb1e6*/
  v5 = 0; /*0xb1e8*/
  if ( !n4 ) /*0xb1ec*/
  {
    n2_1 = 1; /*0xb297*/
    if ( (unsigned int)GetManufacturingMode() == 1 ) /*0xb29e*/
      return n2_1; /*0xb29e*/
    if ( (unsigned int)GetManufacturingMode() == 255 ) /*0xb2ae*/
    {
      LOBYTE(v5) = (*(_DWORD *)(ReadCpuPciCfg(v9, 22, 0) + 64) & 0xF0000) == 458752; /*0xb2ce*/
      return v5; /*0xb2d2*/
    }
    goto LABEL_12; /*0xb2ae*/
  }
  n2_1 = 1; /*0xb1f2*/
  if ( n4 == 1 ) /*0xb1f7*/
  {
    if ( (unsigned int)GetManufacturingMode() == 1 ) /*0xb26b*/
    {
      if ( (unsigned int)GetManufacturingMode() == 1 && *(_DWORD *)(ReadCpuPciCfg(v8, 22, 1) + 64) >= 0x80000000 ) /*0xb28b*/
        return n2_1; /*0xb28b*/
      return 0; /*0xb28b*/
    }
    goto LABEL_12; /*0xb26b*/
  }
  if ( n4 <= 1 )
  {
LABEL_18:
    DebugPrint(2u, "[ME Policy] WARNING: Auto-configuration passed for unrecognised device %d\n", (unsigned int)n4);
    return 0; /*0xb262*/
  }
  if ( n4 > 3 ) /*0xb1fe*/
  {
    if ( n4 == 4 ) /*0xb203*/
    {
      if ( (unsigned int)GetManufacturingMode() == 1 ) /*0xb20c*/
        return n2_1; /*0xb20c*/
      goto LABEL_12; /*0xb20c*/
    }
    goto LABEL_18; /*0xb203*/
  }
  if ( (unsigned int)GetManufacturingMode() != 1 )
  {
LABEL_12:
    if ( (unsigned int)GetManufacturingMode() != 255 )
    {
      CpuPciCfg = ReadCpuPciCfg(v6, 22, 0); /*0xb221*/
      DebugPrint(2u, "[ME Policy] WARNING: Unexpected ME type (MEFS1: %08X)\n", *(unsigned int *)(CpuPciCfg + 64));
    }
  }
  return 0; /*0xb247*/
}