Newer
Older
AMI-Aptio-BIOS-Reversed / ServerCommonPkg / Universal / GetSec / Pei / TxtPei / LtPeiLibInitialize.c
@Ajax Dong Ajax Dong 2 days ago 3 KB Restructure the repo
// Decompiled: 0xffe06c07
// Function: LtPeiLibInitialize
// Module: TxtPei.efi (TXTPEI)

int __thiscall LtPeiLibInitialize(_DWORD *this)
{
  int v2; // eax
  int v3; // eax
  char v4; // bl
  unsigned int n4_3; // ecx
  char v6; // dl
  unsigned int n4_2; // ecx
  int v8; // eax
  __int16 v9; // dx
  unsigned int n4; // ecx
  int v11; // esi
  unsigned int n4_1; // [esp+10h] [ebp-3Ch] BYREF
  int v14; // [esp+14h] [ebp-38h] BYREF
  int v15; // [esp+18h] [ebp-34h] BYREF
  char v16[4]; // [esp+1Ch] [ebp-30h] BYREF
  _BYTE v17[16]; // [esp+20h] [ebp-2Ch] BYREF
  _WORD v18[14]; // [esp+30h] [ebp-1Ch] BYREF

  HobGetType(v17, 16); /*0xffe06c17*/
  if ( (*(int (__cdecl **)(_DWORD, _DWORD, int *, char *))*(this + 4))(*this, *(this + 4), &v15, v16) < 0 ) /*0xffe06c42*/
  {
    DebugPrint(0x80000000, "\nASSERT_EFI_ERROR (Status = %r)\n"); /*0xffe06c4b*/
    v2 = DebugPrintProtocol(); /*0xffe06c53*/
    if ( v2 ) /*0xffe06c5a*/
      (*(void (__cdecl **)(const char *, int, const char *))(v2 + 4))( /*0xffe06c63*/
        "e:\\hs\\ServerCommonPkg\\Universal\\GetSec\\Pei\\TxtPeiLib.c",
        790,
        "!EFI_ERROR (Status)");
  }
  (*(void (__cdecl **)(_DWORD, _DWORD, unsigned int *))(*(this + 4) + 24))(*this, *(this + 4), &n4_1); /*0xffe06c74*/
  EndOfHobCheck(&v14); /*0xffe06c7c*/
  v14 &= 0x1Fu; /*0xffe06c90*/
  DebugPrint(64, "mNumofBitShift! %d\n"); /*0xffe06c94*/
  if ( (*(int (__cdecl **)(_DWORD, _DWORD, unsigned int, _WORD *))(*(this + 4) + 4))(*this, *(this + 4), n4_1, v18) < 0 ) /*0xffe06cb3*/
  {
    DebugPrint(0x80000000, "\nASSERT_EFI_ERROR (Status = %r)\n"); /*0xffe06cbc*/
    v3 = DebugPrintProtocol(); /*0xffe06cc4*/
    if ( v3 ) /*0xffe06ccb*/
      (*(void (__cdecl **)(const char *, int, const char *))(v3 + 4))( /*0xffe06cd4*/
        "e:\\hs\\ServerCommonPkg\\Universal\\GetSec\\Pei\\TxtPeiLib.c",
        810,
        "!EFI_ERROR (Status)");
  }
  v4 = LOBYTE(v18[0]) >> v14; /*0xffe06ce6*/
  n4_3 = 0; /*0xffe06ce8*/
  n4_1 = 0; /*0xffe06cea*/
  if ( v15 != -1 ) /*0xffe06cf1*/
  {
    do /*0xffe06d4c*/
    {
      (*(void (__cdecl **)(_DWORD, _DWORD, unsigned int, _WORD *))(*(this + 4) + 4))(*this, *(this + 4), n4_3, v18); /*0xffe06cff*/
      v6 = LOBYTE(v18[0]) >> v14; /*0xffe06d0d*/
      n4_2 = n4_1; /*0xffe06d0f*/
      if ( LOBYTE(v18[0]) >> v14 != v4 ) /*0xffe06d15*/
      {
        v8 = 0; /*0xffe06d17*/
        while ( v17[4 * v8 + 1] != v6 ) /*0xffe06d1d*/
        {
          if ( v17[4 * v8] == 0xFF ) /*0xffe06d24*/
          {
            v17[4 * v8 + 1] = v6; /*0xffe06d2e*/
            v9 = v18[0]; /*0xffe06d32*/
            v17[4 * v8] = n4_2; /*0xffe06d37*/
            *(_WORD *)&v17[4 * v8 + 2] = v9; /*0xffe06d3b*/
            break; /*0xffe06d3b*/
          }
          if ( (unsigned int)++v8 >= 4 ) /*0xffe06d2a*/
            break; /*0xffe06d2a*/
        }
      }
      n4_3 = n4_2 + 1; /*0xffe06d40*/
      n4_1 = n4_3; /*0xffe06d46*/
    }
    while ( n4_3 < v15 + 1 ); /*0xffe06d4c*/
  }
  ApicWriteIcr(804096, 0); /*0xffe06d55*/
  DebugPrint(64, "DoLockConfig for BSP\n"); /*0xffe06d63*/
  if ( *(_QWORD *)(*(this + 6) + 16) ) /*0xffe06d6d*/
    LtPeiLibLaunchBiosAcm((int)this, 6); /*0xffe06d7a*/
  DebugPrint(64, "Done! \n"); /*0xffe06d86*/
  n4 = 0; /*0xffe06d8d*/
  n4_1 = 0; /*0xffe06d8f*/
  do
  {
    if ( v17[4 * n4] == 0xFF ) /*0xffe06d99*/
      break; /*0xffe06d99*/
    DebugPrint(64, "DoLockConfig for Socket: %d AP: %d\n");
    v11 = (*(int (__cdecl **)(_DWORD, _DWORD, int (*)(), _DWORD, _DWORD, _DWORD *))(*(this + 4) + 12))( /*0xffe06dd0*/
            *this,
            *(this + 4),
            BitFieldRead32,
            (unsigned __int8)v17[4 * n4_1],
            0,
            this);
    ApicWriteIcr(17664, *(unsigned __int16 *)&v17[4 * n4_1 + 2]); /*0xffe06ddc*/
    DebugPrint(64, "Done! \n"); /*0xffe06de3*/
    if ( v11 < 0 ) /*0xffe06ded*/
      break; /*0xffe06ded*/
    n4 = n4_1 + 1; /*0xffe06df3*/
    n4_1 = n4; /*0xffe06df4*/
  }
  while ( n4 < 4 );
  return 0; /*0xffe06dfd*/
}