HalpApicDiscover

INT64 __stdcall HalpApicDiscover(){
  LARGE_INTEGER *AcpiTable; 
  INT64 result; 
  LARGE_INTEGER v2; 
  char *v3; 
  unsigned __int64 v4; 
  __int64 v5; 
  char *v6; 
  HalpLocalApicPhysical.QuadPart = 0i64;
  AcpiTable = HalSocGetAcpiTable(0x43495041ui64);
  if( !AcpiTable )
    return 3221225858i64;
  result = HalpApicSetupRegisterAccess();
  if( (int)result >= 0 )
  {
    v2.QuadPart = (unsigned int)AcpiTable[4].HighPart;
    HalpLocalApicPhysical = v2;
    LODWORD(result) = HalRegisterPermanentAddressUsage(v2, 0x400u);
    if( (int)result >= 0 )
    {
      v3 = (char *)&AcpiTable[5].QuadPart + 4;
      v4 = (unsigned __int64)AcpiTable + (unsigned int)AcpiTable->HighPart;
      while( (unsigned __int64)(v3 + 2) <= v4 )
      {
        v5 = (unsigned __int8)v3[1];
        if( (unsigned __int8)v5 < 2u || (unsigned __int64)&v3[v5] > v4 )
          break;
        v6 = v3;
        v3 += v5;
        if( *v6 == 1 && (_BYTE)v5 == 12 )
          HalpApicRegisterIoUnit((LARGE_INTEGER)*((unsigned int *)v6 + 1));
      }
      return 0i64;
    }
  }
  return result;
}

Referenced by:

HalpInitializeInterrupts