Newer
Older
AMI-Aptio-BIOS-Reversed / EarlyVideoPei / VgaModeDetect.c
@Ajax Dong Ajax Dong 2 days ago 988 bytes Init
int __thiscall VgaModeDetect(int *this)
{
  int v1; // eax
  int v2; // ecx
  unsigned int v3; // ebx
  unsigned int i; // esi
  unsigned int j; // edi
  int v6; // ecx
  int v7; // ecx
  int v9; // [esp+8h] [ebp-18h]
  int n255_1; // [esp+10h] [ebp-10h]
  int n255; // [esp+14h] [ebp-Ch]
  unsigned int v13; // [esp+18h] [ebp-8h]
  unsigned int v14; // [esp+1Ch] [ebp-4h]

  v9 = *this;
  v1 = PciRegRead(*this, 510525464);
  v13 = 0;
  v14 = 0;
  v3 = v1 & 0xFFFFFFE0;
  n255 = 255;
  n255_1 = 255;
  for ( i = 0; i < 2; ++i )
  {
    for ( j = 0; j < 0x10; ++j )
    {
      PciRegWrite(v2, 510525464, v3 | j | (16 * i));
      PciRegWrite(v6, 510525552, 0);
      PciRegWrite(v7, 510525556, 4095);
      if ( PciRegVerifyWrite(this) )
      {
        ++*(&v13 + i);
        if ( *(&n255_1 + i) > j )
          *(&n255_1 + i) = j;
      }
      v2 = v9;
    }
  }
  if ( (!n255_1 || !n255) && !n255 && (v13 < v14 || n255_1) )
    v3 |= 0x10u;
  return PciRegWrite(v9, 510525464, v3);
}