Newer
Older
AMI-Aptio-BIOS-Reversed / PlatformInfo / PlatformInfo.c
@Ajax Dong Ajax Dong 2 days ago 42 KB Init
/*
 *PlatformInfo - Decompiled PlatformInfo
 *Source: Auto-generated from IDA Pro decompilation
 *
 *Decompiled from port 13363
 */

#include "PlatformInfo.h"

/*
 *InternalZeroMem at 0xffde7fd8
 */
void *InternalZeroMem(void *buf, unsigned int this)
{
 memset(buf, 0, this); /*0xffde7fef*/
 return buf; /*0xffde7ff6*/
}

/*
 *InternalCopyMem at 0xffde7ff8
 */
char *InternalCopyMem(char *dst, char *src, unsigned int n4102)
{
 unsigned int n4102_1; // edx char *dst_1; // edi char *src_1; // esi n4102_1 = n4102; /*0xffde8002*/
 if ( src < dst && &src[n4102 - 1] >= dst ) /*0xffde8010*/
 {
 src_1 = &src[n4102 - 1]; /*0xffde8024*/
 dst_1 = &dst[n4102 - 1]; /*0xffde8026*/
 }
 else
 {
 n4102_1 = n4102 & 3; /*0xffde8014*/
 qmemcpy(dst, src, 4 * (n4102 >> 2)); /*0xffde801d*/
 src_1 = &src[4 * (n4102 >> 2)]; /*0xffde801d*/
 dst_1 = &dst[4 * (n4102 >> 2)]; /*0xffde801d*/
 }
 qmemcpy(dst_1, src_1, n4102_1); /*0xffde802d*/
 return dst; /*0xffde8034*/
}

/*
 *SetMem at 0xffde8038
 */
void *SetMem(void *buf, unsigned int count, char value)
{
 memset(buf, value, count); /*0xffde8045*/
 return buf; /*0xffde804b*/
}

/*
 *SetMem32_Repeated at 0xffde8058
 */
int SetMem32_Repeated(int a1, int a2, int a3, int a4)
{
 do /*0xffde8071*/
 {
 *(_DWORD *)(a1 + 8 *a2 - 8) = a3; /*0xffde8069*/
 *(_DWORD *)(a1 + 8 *a2-- - 4) = a4; /*0xffde806d*/
 }
 while ( a2 ); /*0xffde8071*/
 return a1; /*0xffde8075*/
}

/*
 *SetMem32 at 0xffde8078
 */
void *SetMem32(void *buf, unsigned int count, int value)
{
 memset32(buf, value, count); /*0xffde8085*/
 return buf; /*0xffde808b*/
}

/*
 *_ModuleEntryPoint at 0xffde808d
 */
EFI_STATUS ModuleEntryPoint(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
{
 return sub_FFDE870D(ImageHandle, SystemTable);
}

/*
 *ReadBoardIdFromIoPorts at 0xffde8096
 */
int ReadBoardIdFromIoPorts()
{
 unsigned __int8 Result; // bl int n40; // ecx int n40_1; // esi int n40_2; // esi int n40_3; // esi unsigned __int8 n2; // al int n40_4; // esi unsigned __int8 n3; // al Result = 0; /*0xffde809a*/
 __outbyte(0x2Eu, 0x5Au); /*0xffde80a4*/
 n40 = 40; /*0xffde80a7*/
 n40_1 = 40; /*0xffde80aa*/
 do /*0xffde80b4*/
 {
 __inbyte(0x61u); /*0xffde80b0*/
 --n40_1; /*0xffde80b1*/
 }
 while ( n40_1 ); /*0xffde80b4*/
 __outbyte(0x2Eu, 7u); /*0xffde80bb*/
 n40_2 = 40; /*0xffde80bc*/
 do /*0xffde80c5*/
 {
 __inbyte(0x61u); /*0xffde80c1*/
 --n40_2; /*0xffde80c2*/
 }
 while ( n40_2 ); /*0xffde80c5*/
 __outbyte(0x2Fu, 2u); /*0xffde80cf*/
 n40_3 = 40; /*0xffde80d0*/
 do /*0xffde80d9*/
 {
 __inbyte(0x61u); /*0xffde80d5*/
 --n40_3; /*0xffde80d6*/
 }
 while ( n40_3 ); /*0xffde80d9*/
 n2 = __inbyte(0x2Fu); /*0xffde80e1*/
 if ( n2 == 2 ) /*0xffde80e4*/
 Result = 1; /*0xffde80e6*/
 n40_4 = 40; /*0xffde80e8*/
 do /*0xffde80f1*/
 {
 __inbyte(0x61u); /*0xffde80ed*/
 --n40_4; /*0xffde80ee*/
 }
 while ( n40_4 ); /*0xffde80f1*/
 __outbyte(0x2Eu, 0xA5u); /*0xffde80f8*/
 do /*0xffde8100*/
 {
 __inbyte(0x61u); /*0xffde80fc*/
 --n40; /*0xffde80fd*/
 }
 while ( n40 ); /*0xffde8100*/
 __outbyte(0x2Eu, 7u); /*0xffde8107*/
 __outbyte(0x2Fu, 3u); /*0xffde8110*/
 n3 = __inbyte(0x2Fu); /*0xffde8111*/
 if ( n3 == 3 ) /*0xffde8114*/
 Result |= 2u; /*0xffde8116*/
 return Result; /*0xffde8119*/
}

/*
 *GetPlatformInfoFromPdr at 0xffde8121
 */
int GetPlatformInfoFromPdr(int a1, int a2)
{
 int Status; // eax int Result; // esi int Protocol; // eax int Status; // eax int ReportStatusCodeProtocol; // eax unsigned __int8 n0x17; // al int v10; // [esp+8h] [ebp-4h] BYREF Status = (*(int ( **)(int, void *, _DWORD, _DWORD, int *))(*(_DWORD *)a1 + 32))(a1, &unk_FFDEA9E8, 0, 0, &v10); /*0xffde8139*/
 Result = Status; /*0xffde813c*/
 if ( Status >= 0 )
 {
 Status = (*(int ( **)(int, int, _DWORD, int, int))(v10 + 4))(v10, 4, 0, 4102, a2); /*0xffde8187*/
 Result = Status; /*0xffde818a*/
 if ( Status >= 0 )
 {
 n0x17 = *(_BYTE *)(a2 + 37); /*0xffde81c0*/
 if ( n0x17 > 0x17u )
 {
 ReportStatusCode( /*0xffde81e1*/
 0x80000000,
 (int)"PIT from SPI PDR reports Platform ID as %x. This is unknown ID. Assuming Greencity Platform!\n",
 n0x17);
 *(_BYTE *)(a2 + 37) = -1; /*0xffde81e6*/
 return -2147483623; /*0xffde81ea*/
 }
 else
 {
 ReportStatusCode(0x80000000, (int)"Platform Info from PDR: Type = %x\n", n0x17);
 }
 }
 else
 {
 ReportStatusCode(0x80000000, (int)"\nASSERT_EFI_ERROR (Status = %r)\n", Status); /*0xffde819e*/
 ReportStatusCodeProtocol = GetReportStatusCodeProtocol(); /*0xffde81a6*/
 if ( ReportStatusCodeProtocol ) /*0xffde81ad*/
 (*(void ( **)(const char *, int, const char *))(ReportStatusCodeProtocol + 4))( /*0xffde81b9*/
 "e:\\hs\\PurleyRpPkg\\Platform\\Pei\\PlatformInfo\\PlatformInfo.c",
 279,
 "!EFI_ERROR (Status)");
 }
 }
 else
 {
 ReportStatusCode(0x80000000, (int)"\nASSERT_EFI_ERROR (Status = %r)\n", Status); /*0xffde8150*/
 Protocol = GetReportStatusCodeProtocol(); /*0xffde8158*/
 if ( Protocol ) /*0xffde815f*/
 (*(void ( **)(const char *, int, const char *))(Protocol + 4))( /*0xffde8174*/
 "e:\\hs\\PurleyRpPkg\\Platform\\Pei\\PlatformInfo\\PlatformInfo.c",
 263,
 "!EFI_ERROR (Status)");
 }
 return Result; /*0xffde81f2*/
}

/*
 *PciCfgInitPciBridge at 0xffde81fa
 */
unsigned int PciCfgInitPciBridge()
{
 int n1120; // esi int n2; // edi int n1120_1; // edx _DWORD *v3; // ecx unsigned int result; // eax n1120 = 1120; /*0xffde81ff*/
 n2 = 2; /*0xffde8209*/
 do /*0xffde8236*/
 {
 n1120_1 = (unsigned __int16)n1120; /*0xffde820a*/
 n1120 += 8; /*0xffde820d*/
 *(_DWORD *)(n1120_1 | 0xFDAE0000) = *(_DWORD *)(n1120_1 | 0xFDAE0000) & 0x3F61E0FE | 0x80000101; /*0xffde8220*/
 v3 = (_DWORD *)((unsigned __int16)(n1120_1 + 4) | 0xFDAE0000); /*0xffde8228*/
 result = *v3 & 0xFFFFC3FF; /*0xffde822c*/
 *v3 = result; /*0xffde8231*/
 --n2; /*0xffde8233*/
 }
 while ( n2 ); /*0xffde8236*/
 return result; /*0xffde8238*/
}

/*
 *GetBoardIdFromGpio at 0xffde823c
 */
int GetBoardIdFromGpio(int a1, int a2)
{
 int ReportStatusCodeProtocol; // eax int n1120; // edi int n5; // ebx int n1120_1; // edx int result; // eax unsigned __int8 v8; // al unsigned int n14; // edi void *v10; // ecx unsigned __int8 v11; // al int v12; // ebx int v13; // eax int v14; // eax int v15; // esi int v16; // eax void *v17; // ecx int Ptr; // eax int v19; // eax int v20; // eax void *v21; // ecx int v22; // eax int v23; // eax int v24; // eax char v25; // [esp+17h] [ebp-5h]
 unsigned __int8 v26; // [esp+17h] [ebp-5h]
 int v27; // [esp+18h] [ebp-4h] BYREF if ( !*(_DWORD *)(*(_DWORD *)a1 + 100) ) /*0xffde8241*/
 {
 ReportStatusCodeProtocol = GetReportStatusCodeProtocol(); /*0xffde824d*/
 if ( ReportStatusCodeProtocol ) /*0xffde8254*/
 (*(void ( **)(const char *, int, const char *))(ReportStatusCodeProtocol + 4))( /*0xffde8265*/
 "e:\\hs\\PurleyRpPkg\\Platform\\Pei\\PlatformInfo\\PlatformInf... [13054 chars total]

/*
 *ReadClx64LCapIdAndSetPcd at 0xffde869c
 */
int __thiscall ReadClx64LCapIdAndSetPcd(void *this)
{
 int MmioAddr; // eax int Offset; // ecx int Offset; // eax int Ptr; // eax MmioAddr = PciCfgReadMmioAddr((unsigned __int16)__readmsr(0x300u) >> 8, 30, 3); /*0xffde86b3*/
 Offset = *(_DWORD *)(MmioAddr + 132); /*0xffde86b9*/
 Offset = *(_DWORD *)(MmioAddr + 152); /*0xffde86bf*/
 if ( (Offset & 0x38) == 0x10 && (Offset & 0x600) == 0x600 )
 {
 Ptr = PeiPcdGetPtr((void *)0x600); /*0xffde86d8*/
 (*(void ( **)(int, int, void *))(Ptr + 60))(35, 17, this); /*0xffde86e1*/
 ReportStatusCode(0x80000000, (int)"ReadClx64LCapIdandSetPcd(): PcdCLX64LCpuValue = CLX64L_CPU_PRESENT\n");
 }
 else
 {
 ReportStatusCode(0x80000000, (int)"ReadClx64LCapIdandSetPcd(): PcdCLX64LCpuValue = 0\n");
 }
 return 0; /*0xffde870c*/
}

/*
 *PlatformInfoInit at 0xffde870d
 */
int PlatformInfoInit(int a1, int *a2)
{
 int Protocol; // eax int Protocol; // eax int v6; // eax int v7; // ecx int n40; // ecx int n40_1; // esi int n40_2; // esi int n40_3; // esi int v12; // edi void ( **v13)(int, _DWORD, int, int, _DWORD, __int16 *); // ebx int MatchingSetupGuid; // eax int Variable; // eax int PlatformInfoFromPdr; // eax bool v17; // al char BoardIdFromIoPorts; // al int v19; // ecx int Protocol; // ecx int NextGuidHob; // eax int NextGuidHob_1; // ebx int Status; // eax int ReportStatusCodeProtocol; // eax char v25; // [esp+12h] [ebp-2026h] BYREF unsigned __int8 v26; // [esp+13h] [ebp-2025h] BYREF unsigned int v27; // [esp+14h] [ebp-2024h] BYREF __int16 v28; // [esp+18h] [ebp-2020h] BYREF int v29; // [esp+1Ch] [ebp-201Ch]
 int *v30; // [esp+20h] [ebp-2018h]
 char v31[4]; // [esp+24h] [ebp-2014h] BYREF _BYTE Protocol[28]; // [esp+28h] [ebp-2010h] BYREF unsigned int v33; // [esp+44h] [ebp-1FF4h]
 char v34; // [esp+48h] [ebp-1FF0h]
 int v35; // [esp+49h] [ebp-1FEFh]
 unsigned __int8 v36; // [esp+4Dh] [ebp-1FEBh]
 __int16 v37; // [esp+50h] [ebp-1FE8h]
 __int16 v38; // [esp+52h] [ebp-1FE6h]
 __int16 v39; // [esp+54h] [ebp-1FE4h]
 __int16 v40; // [esp+56h] [ebp-1FE2h]
 char BoardIdFromIoPorts_1; // [esp+AAh] [ebp-1F8Eh]
 char v42; // [esp+ABh] [ebp-1F8Dh]
 __int16 v43; // [esp+B6h] [ebp-1F82h]
 bool v44; // [esp+B8h] [ebp-1F80h]
 bool v45; // [esp+B9h] [ebp-1F7Fh]
 char PchSku; // [esp+BAh] [ebp-1F7Eh]
 char v47; // [esp+BCh] [ebp-1F7Ch]
 char v48; // [esp+BDh] [ebp-1F7Bh]
 char v49[33]; // [esp+1030h] [ebp-1008h] BYREF int v50; // [esp+1051h] [ebp-FE7h]
 unsigned __int8 v51; // [esp+1055h] [ebp-FE3h]

 v30 = a2; /*0xffde871f*/
 Protocol = *a2; /*0xffde8723*/
 v27 = *(_DWORD *)(*a2 + 100); /*0xffde8728*/
 if ( v27 ) /*0xffde872e*/
 {
 v6 = (*(int ( **)(int *, void *, _DWORD, _DWORD, char *))(Protocol + 32))(a2, &unk_FFDEA9C8, 0, 0, v31); /*0xffde8786*/
 v7 = *a2; /*0xffde8789*/
 v29 = v6; /*0xffde878e*/
 (*(void ( **)(_BYTE *, int, _DWORD))(v7 + 84))(Protocol, 4102, 0); /*0xffde879d*/
 __outbyte(0x2Eu, 0x5Au); /*0xffde87ab*/
 n40 = 40; /*0xffde87ae*/
 n40_1 = 40; /*0xffde87b1*/
 do /*0xffde87bb*/
 {
 __inbyte(0x61u); /*0xffde87b7*/
 --n40_1; /*0xffde87b8*/
 }
 while ( n40_1 ); /*0xffde87bb*/
 __outbyte(0x2Eu, 0x20u); /*0xffde87c5*/
 n40_2 = 40; /*0xffde87c8*/
 do /*0xffde87d2*/
 {
 __inbyte(0x61u); /*0xffde87ce*/
 --n40_2; /*0xffde87cf*/
 }
 while ( n40_2 ); /*0xffde87d2*/
 __inbyte(0x2Fu); /*0xffde87da*/
 n40_3 = 40; /*0xffde87df*/
 do /*0xffde87eb*/
 {
 __inbyte(0x61u); /*0xffde87e7*/
 --n40_3; /*0xffde87e8*/
 }
 while ( n40_3 ); /*0xffde87eb*/
 __outbyte(0x2Eu, 0xA5u); /*0xffde87f5*/
 v12 = (int)v30; /*0xffde87f6*/
 do /*0xffde8804*/
 {
 __inbyte(0x61u); /*0xffde8800*/
 --n40; /*0xffde8801*/
 }
 while ( n40 ); /*0xffde8804*/
 v13 = (void ( **)(int, _DWORD, int, int, _DWORD, __int16 *))v27; /*0xffde8806*/
 if ( v29 < 0 ) /*0xffde8811*/
 ReportStatusCode(0x80000000, (int)"LocatePpi Error in PlatformInfo.c !\n"); /*0xffde8819*/
 MatchingSetupGuid = FindMatchingSetupGuid(); /*0xffde8820*/
 if ( MatchingSetupGuid == -1 || (Variable = PeiSetupGetVariable(dword_FFDEADE0[3 *MatchingSetupGuid])) == 0 ) /*0xffde8841*/
 {
 v42 = 1; /*0xffde885f*/
 }
 else
 {
 CopyMem((int)&v25, Variable + 8, 1); /*0xffde884c*/
 v42 = v25; /*0xffde8856*/
 }
 (*v13)(v12, v13, 1, 2031618, 0, &v28); /*0xffde8877*/
 v38 = v28; /*0xffde887e*/
 v40 = 0; /*0xffde8885*/
 (*v13)(v12, v13, 0, 2031624, 0, (__int16 *)&v26); /*0xffde889a*/
 v39 = v26; /*0xffde88a8*/
 if ( GetBoardIdFromGpio(v12, (int)Protocol) < 0 ) /*0xffde88b6*/
 {
 PlatformInfoFromPdr = GetPlatformInfoFromPdr(v12, (int)v49); /*0xffde88c1*/
 v36 = v51; /*0xffde88cd*/
 v35 = v50; /*0xffde88d8*/
 if ( PlatformInfoFromPdr < 0 ) /*0xffde88de*/
 v36 = -1; /*0xffde88e0*/
 }
 v37 = 0; /*0xffde88e7*/
 v17 = IsGbeEnabled(); /*0xffde88ec*/
 v43 = -256; /*0xffde88f3*/
 v44 = !v17; /*0xffde8901*/
 HIBYTE(v43) = GetGbePortNumber(); /*0xffde890d*/
 v45 = IsGbePhyPresent(); /*0xffde8919*/
 PchSku = GetPchSku(); /*0xffde8925*/
 BoardIdFromIoPorts = ReadBoardIdFromIoPorts(); /*0xffde892c*/
 v27 = 0; /*0xffde8931*/
 BoardIdFromIoPorts_1 = BoardIdFromIoPorts; /*0xffde893d*/
 CpuGetStepping(v19, &v27); /*0xffde8944*/
 Protocol = v27; /*0xffde8949*/
 LOBYTE(Protocol) = v27 & 0xF; /*0xffde895a*/
 v33 = v27 >> 4; /*0xffde895d*/
 v34 = v27 & 0xF; /*0xffde8961*/
 NextGuidHob = GetNextGuidHob(Protocol, 4126); /*0xffde8965*/
 NextGuidHob_1 = NextGuidHob; /*0xffde896a*/
 if ( NextGuidHob ) /*0xffde896e*/
 {
 SetBoardDefaultSku((void *)(NextGuidHob + 8)); /*0xffde8973*/
 if ( NextGuidHob_1 != -24 ) /*0xffde897d*/
 CopyMem(NextGuidHob_1 + 24, (int)Protocol, 4102); /*0xffde8988*/
 }
 Status = (*(int ( **)(int, void *))(*(_DWORD *)v12 + 24))(v12, &unk_FFDEAAA8); /*0xffde8996*/
 if ( Status < 0 ) /*0xffde899d*/
 {
 ReportStatusCode(0x80000000, (int)"\nASSERT_EFI_ERROR (Status = %r)\n", Status); /*0xffde89a6*/
 ReportStatusCodeProtocol = GetReportStatusCodeProtocol(); /*0xffde89ae*/
 if ( ReportStatusCodeProtocol ) /*0xffde89b5*/
 (*(void ( **)(const char *, int, const char *))(ReportStatusCodeProtocol + 4))( /*0xffde89c6*/
 "e:\\hs\\PurleyRpPkg\\Platform\\Pei\\PlatformInfo\\PlatformInfo.c",
 897,
 "!EFI_ERROR (Status)");
 }
 __outbyte(0x72u, 0x18u); /*0xffde89d4*/
 __outbyte(0x73u, v36); /*0xffde89df*/
 __outbyte(0x72u, 0x19u); /*0xffde89e5*/
 __outbyte(0x73u, v47 + 16 *v48); /*0xffde89fa*/
 ReadClx64LCapIdAndSetPcd((void *)0x72); /*0xffde89fb*/
 return 0; /*0xffde8a00*/
 }
 else
 {
 ReportStatusCode(0x80000000, (int)"\nError! PlatformInfoInit() - PeiServices is a NULL Pointer!!!\n"); /*0xffde873b*/
 ReportStatusCode(0x80000000, (int)"\nASSERT_EFI_ERROR (Status = %r)\n", -2147483646); /*0xffde874a*/
 Protocol = GetReportStatusCodeProtocol(); /*0xffde8752*/
 if ( Protocol ) /*0xffde8759*/
 (*(void ( **)(const char *, int, const char *))(Protocol + 4))( /*0xffde876a*/
 "e:\\hs\\PurleyRpPkg\\Platform\\Pei\\PlatformInfo\\PlatformInfo.c",
 771,
 "!EFI_ERROR (((RETURN_STATUS)(0x80000000 | (2))))");
 return -2147483646; /*0xffde8770*/
 }
}

/*
 *GetPchSku at 0xffde8a0a
 */
int GetPchSku()
{
 int Result; // eax int MmioAddr; // eax char Offset; // bl unsigned __int16 n0xA1C0; // ax int ReportStatusCodeProtocol; // eax double v5; // [esp-4h] [ebp-10h]
 int n35_1; // [esp-4h] [ebp-10h]

 Result = Result; /*0xffde8a0a*/
 if ( Result == 54 ) /*0xffde8a17*/
 {
 MmioAddr = PciCfgReadMmioAddr(0, 31, 0); /*0xffde8a25*/
 Offset = *(_BYTE *)(MmioAddr + 8); /*0xffde8a2b*/
 n0xA1C0 = IoRead16((unsigned __int16 *)(MmioAddr + 2)); /*0xffde8a31*/
 if ( n0xA1C0 != 0xA142 /*0xffde8af9*/
 && n0xA1C0 != 0xA143
 && n0xA1C0 != 0xA144
 && n0xA1C0 != 0xA145
 && n0xA1C0 != 0xA146
 && n0xA1C0 != 0xA147
 && n0xA1C0 != 0xA148
 && n0xA1C0 != 0xA140
 && n0xA1C0 != 0xA141
 && n0xA1C0 != 0xA14D
 && n0xA1C0 != 0xA14E
 && n0xA1C0 != 0xA14F
 && n0xA1C0 != 0xA149
 && n0xA1C0 != 0xA14A
 && n0xA1C0 != 0xA150
 && n0xA1C0 != 0xA14B )
 {
 if ( n0xA1C0 != 0x9D40 /*0xffde8b43*/
 && n0xA1C0 != 0x9D41
 && n0xA1C0 != 0x9D42
 && n0xA1C0 != 0x9D43
 && n0xA1C0 != 0x9D46
 && n0xA1C0 != 0x9D48 )
 {
 if ( (n0xA1C0 < 0xA1C0u || n0xA1C0 > 0xA1CFu) && n0xA1C0 != 0xA243 && (n0xA1C0 < 0xA240u || n0xA1C0 > 0xA24Fu) ) /*0xffde8b89*/
 return 54; /*0xffde8b89*/
 if ( *(_BYTE *)(GetPchSeriesFromPcd((void *)n0xA1C0) + 252) == 4 && !Offset || !Offset ) /*0xffde8baf*/
 return 48; /*0xffde8ba2*/
 switch ( Offset ) /*0xffde8bb5*/
 {
 case 2: /*0xffde8bb5*/
 return 49; /*0xffde8c13*/
 case 3: /*0xffde8bb5*/
 return 50; /*0xffde8c0f*/
 case 4: /*0xffde8bb5*/
 return 51; /*0xffde8c0b*/
 case 8: /*0xffde8bb5*/
 return 52; /*0xffde8c07*/
 }
 if ( Offset != 9 ) /*0xffde8bc9*/
 {
 ReportStatusCode( /*0xffde8bda*/
 0x80000000,
 (int)"Unsupported PCH Stepping. Supporting PCH stepping starting from %s and above\n",
 "LbgA0");
 ReportStatusCodeProtocol = GetReportStatusCodeProtocol(); /*0xffde8be2*/
 if ( ReportStatusCodeProtocol ) /*0xffde8be9*/
 (*(void ( **)(const char *, int, const char *))(ReportStatusCodeProtocol + 4))( /*0xffde8bfe*/
 "e:\\hs\\PurleySktPkg\\SouthClusterLbg\\Library\\PeiDxeSmmPchInfoLib\\PchInfoLib.c",
 167,
 "((BOOLEAN)(0==1))");
 return 54; /*0xffde8c01*/
 }
 return 53; /*0xffde8ba5*/
 }
 switch ( Offset ) /*0xffde8c1d*/
 {
 case 16: /*0xffde8c1d*/
 n35_1 = 35; /*0xffde8c41*/
 break;
 case 17: /*0xffde8c1d*/
 n35_1 = 36; /*0xffde8c3d*/
 break;
 case 32: /*0xffde8c1d*/
 n35_1 = 37; /*0xffde8c39*/
 break;
 case 33: /*0xffde8c1d*/
 n35_1 = 38; /*0xffde8c35*/
 break;
 default:
 LODWORD(v5) = "PchLpB0"; /*0xffde8c2e*/
LABEL_61:
 ReportStatusCode( /*0xffde8c65*/
 0x80000000,
 (int)"Unsupported PCH Stepping. Supporting PCH stepping starting from %a and above\n",
 v5);
 return 54; /*0xffde8c79*/
 }
 goto LABEL_66; /*0xffde8c37*/
 }
 if ( Offset ) /*0xffde8c4a*/
 {
 switch ( Offset ) /*0xffde8c4f*/
 {
 case 16: /*0xffde8c4f*/
 Result = 1; /*0xffde8c8a*/
 goto LABEL_68; /*0xffde8c8a*/
 case 32: /*0xffde8c4f*/
 n35_1 = 2; /*0xffde8c83*/
 break;
 case 48: /*0xffde8c4f*/
 n35_1 = 3; /*0xffde8c7f*/
 break;
 case 49: /*0xffde8c4f*/
 n35_1 = 4; /*0xffde8c7b*/
 break;
 default:
 LODWORD(v5) = "PchHA0"; /*0xffde8c60*/
 goto LABEL_61; /*0xffde8c60*/
 }
LABEL_66:
 Result = n35_1; /*0xffde8c85*/
LABEL_68:
 Result = Result; /*0xffde8c8b*/
 return Result; /*0xffde8c90*/
 }
 Result = 0; /*0xffde8c92*/
 return 0; /*0xffde8c98*/
 }
 return Result; /*0xffde8c9a*/
}

/*
 *GetPchSeries at 0xffde8c9e
 */
int GetPchSeries()
{
 int Result; // eax int n3_1; // esi int MmioAddr; // eax unsigned __int16 n0xA1C0; // ax int ReportStatusCodeProtocol; // eax Result = n3_0; /*0xffde8c9e*/
 n3_1 = 3; /*0xffde8ca6*/
 if ( n3_0 == 3 )
 {
 MmioAddr = PciCfgReadMmioAddr(0, 31, 0); /*0xffde8cb6*/
 n0xA1C0 = IoRead16((unsigned __int16 *)(MmioAddr + 2)); /*0xffde8cc4*/
 if ( n0xA1C0 >= 0xA1C0u && n0xA1C0 <= 0xA1CFu || n0xA1C0 == 0xA243 || n0xA1C0 >= 0xA240u && n0xA1C0 <= 0xA24Fu )
 {
 n3_1 = 1; /*0xffde8d7f*/
 }
 else if ( n0xA1C0 == 0x9D40
 || n0xA1C0 == 0x9D41
 || n0xA1C0 == 0x9D42
 || n0xA1C0 == 0x9D43
 || n0xA1C0 == 0x9D46
 || n0xA1C0 == 0x9D48 )
 {
 n3_1 = 2; /*0xffde8d7a*/
 }
 else
 {
 ReportStatusCode(0x80000000, (int)"Unsupported PCH SKU, LpcDeviceId: 0x%04x!\n", n0xA1C0);
 ReportStatusCodeProtocol = GetReportStatusCodeProtocol(); /*0xffde8d58*/
 if ( ReportStatusCodeProtocol ) /*0xffde8d5f*/
 (*(void ( **)(const char *, int, const char *))(ReportStatusCodeProtocol + 4))( /*0xffde8d70*/
 "e:\\hs\\PurleySktPkg\\SouthClusterLbg\\Library\\PeiDxeSmmPchInfoLib\\PchInfoLib.c",
 252,
 "((BOOLEAN)(0==1))");
 }
 n3_0 = n3_1; /*0xffde8d80*/
 return n3_1; /*0xffde8d86*/
 }
 return Result; /*0xffde8d88*/
}

/*
 *IsPchLbg at 0xffde8d8a
 */
int IsPchLbg()
{
 int Result; // eax int n2_1; // esi int MmioAddr; // eax unsigned __int16 n0xA1C0; // ax int ReportStatusCodeProtocol; // eax Result = Result; /*0xffde8d8a*/
 n2_1 = 2; /*0xffde8d92*/
 if ( Result == 2 )
 {
 MmioAddr = PciCfgReadMmioAddr(0, 31, 0); /*0xffde8da2*/
 n0xA1C0 = IoRead16((unsigned __int16 *)(MmioAddr + 2)); /*0xffde8db0*/
 if ( n0xA1C0 >= 0xA1C0u && n0xA1C0 <= 0xA1CFu || n0xA1C0 == 0xA243 || n0xA1C0 >= 0xA240u && n0xA1C0 <= 0xA24Fu )
 {
 n2_1 = 1; /*0xffde8e28*/
 }
 else
 {
 ReportStatusCode(0x80000000, (int)"Unsupported PCH SKU, LpcDeviceId: 0x%04x!\n", n0xA1C0);
 ReportStatusCodeProtocol = GetReportStatusCodeProtocol(); /*0xffde8e06*/
 if ( ReportStatusCodeProtocol ) /*0xffde8e0d*/
 (*(void ( **)(const char *, int, const char *))(ReportStatusCodeProtocol + 4))( /*0xffde8e1e*/
 "e:\\hs\\PurleySktPkg\\SouthClusterLbg\\Library\\PeiDxeSmmPchInfoLib\\PchInfoLib.c",
 290,
 "((BOOLEAN)(0==1))");
 }
 Result = n2_1; /*0xffde8e29*/
 return n2_1; /*0xffde8e2f*/
 }
 return Result; /*0xffde8e31*/
}

/*
 *PciCfgReadMmioAddr at 0xffde8e33
 */
int PciCfgReadMmioAddr(unsigned __int8 a1, char a2, int a3)
{
 _DWORD Device[5]; // [esp+8h] [ebp-14h] BYREF Device[2] = 512; /*0xffde8e4a*/
 Device[3] = 0; /*0xffde8e63*/
 Device[1] = 0; /*0xffde8e69*/
 Device[0] = (a3 & 7 | (8 * (a2 & 0x1F | (32 *a1)))) << 12; /*0xffde8e6c*/
 PciCfgAddrEncode(0, 0, Device, &a3); /*0xffde8e6f*/
 return a3; /*0xffde8e7a*/
}

/*
 *CpuGetStepping at 0xffde8e7f
 */
int CpuGetStepping(int a1, _DWORD *a2)
{
 _EAX = 1; /*0xffde8e9b*/
 __asm { cpuid } /*0xffde8e9e*/
 if ( a2 ) /*0xffde8ea4*/
 *a2 = _EAX; /*0xffde8ea6*/
 return 1; /*0xffde8ec1*/
}

/*
 *GpioGetPadOutputState at 0xffde8ec6
 */
int GpioGetPadOutputState(int a1, int a2, int *a3)
{
 int v3; // ecx int v4; // ebx unsigned int Ptr; // esi unsigned int Ptr; // edi _DWORD *GroupInfo; // ebp unsigned int Index; // [esp+10h] [ebp-8h] BYREF unsigned int v10; // [esp+14h] [ebp-4h] BYREF v4 = v3; /*0xffde8ec9*/
 Ptr = BYTE2(v3); /*0xffde8ed3*/
 Ptr = (unsigned __int16)v3; /*0xffde8ed6*/
 if ( !GpioIsPadValidForChipset(v3) )
 {
 ReportStatusCode(
 0x80000000,
 (int)"GPIO ERROR: Incorrect GpioPad define used on this chipset (Group=%d, Pad=%d)!\n",
 Ptr,
 Ptr);
 return -2147483645; /*0xffde8efb*/
 }
 GroupInfo = GpioGetGroupInfo(&Index); /*0xffde8f09*/
 if ( Ptr >= Index )
 {
 ReportStatusCode(0x80000000, (int)"GPIO ERROR: Group argument (%d) exceeds GPIO group range\n", Ptr);
 return -2147483646; /*0xffde8f29*/
 }
 Index = 60 *Ptr; /*0xffde8f2e*/
 if ( Ptr >= GroupInfo[15 *Ptr + 14] )
 {
 ReportStatusCode(0x80000000, (int)"GPIO ERROR: Pin number (%d) exceeds possible range for this group\n", Ptr);
 return -2147483646; /*0xffde8f3e*/
 }
 GpioGetPadOwnership(v4, &v10); /*0xffde8f46*/
 if ( v10 )
 {
 ReportStatusCode(0x80000000, (int)"GPIO ERROR: Accessing pad not owned by host (Group=%d, Pad=%d)!\n", Ptr, Ptr);
 return -2147483645; /*0xffde8f59*/
 }
 *a3 = *(_DWORD *)((unsigned __int16)(GroupInfo[Index / 4 + 13] + 8 *Ptr) /*0xffde8f81*/
 | ((LOBYTE(GroupInfo[Index / 4]) | 0xFFFFFD00) << 16))
 & 2;
 return 0; /*0xffde8f85*/
}

/*
 *GpioGetInputValue at 0xffde8f8c
 */
int GpioGetInputValue(int a1, int *a2)
{
 int PadOutputState; // eax int PadOutputState_1; // edi int ReportStatusCodeProtocol; // eax PadOutputState = GpioGetPadOutputState(a1, a1, a2); /*0xffde8f94*/
 PadOutputState_1 = PadOutputState; /*0xffde8f99*/
 if ( PadOutputState < 0 ) /*0xffde8fa0*/
 {
 ReportStatusCode(0x80000000, (int)"\nASSERT_EFI_ERROR (Status = %r)\n", PadOutputState); /*0xffde8fad*/
 ReportStatusCodeProtocol = GetReportStatusCodeProtocol(); /*0xffde8fb5*/
 if ( ReportStatusCodeProtocol ) /*0xffde8fbc*/
 (*(void ( **)(const char *, int, const char *))(ReportStatusCodeProtocol + 4))( /*0xffde8fcd*/
 "e:\\hs\\PurleySktPkg\\SouthClusterLbg\\Library\\PeiDxeSmmGpioLib\\GpioLib.c",
 935,
 "!EFI_ERROR (Status)");
 }
 *a2 = (unsigned int)*a2 >> 1; /*0xffde8fd3*/
 return PadOutputState_1; /*0xffde8fd7*/
}

/*
 *GpioGetPadOwnership at 0xffde8fdb
 */
int GpioGetPadOwnership(int a1, unsigned int *a2)
{
 unsigned int ErrorLevel; // esi unsigned int Ptr; // edi _DWORD *GroupInfo; // eax int ReportStatusCodeProtocol; // eax int Protocol; // eax unsigned int v9; // edx unsigned int v10; // [esp+10h] [ebp-4h] BYREF ErrorLevel = (unsigned __int16)a1; /*0xffde8fe6*/
 Ptr = BYTE2(a1); /*0xffde8fee*/
 GroupInfo = GpioGetGroupInfo(&v10); /*0xffde8ff1*/
 if ( Ptr >= v10 )
 {
 ReportStatusCode(0x80000000, (int)"GPIO ERROR: Group argument (%d) exceeds GPIO group range\n", Ptr);
 ReportStatusCodeProtocol = GetReportStatusCodeProtocol(); /*0xffde9011*/
 if ( ReportStatusCodeProtocol ) /*0xffde9018*/
 (*(void ( **)(const char *, int, const char *))(ReportStatusCodeProtocol + 4))( /*0xffde9029*/
 "e:\\hs\\PurleySktPkg\\SouthClusterLbg\\Library\\PeiDxeSmmGpioLib\\GpioLib.c",
 1389,
 "((BOOLEAN)(0==1))");
 return -2147483646; /*0xffde9034*/
 }
 if ( ErrorLevel >= GroupInfo[15 *Ptr + 14] )
 {
 ReportStatusCode(0x80000000, (int)"GPIO ERROR: Pin number (%d) exceeds possible range for this group\n", ErrorLevel);
 Protocol = GetReportStatusCodeProtocol(); /*0xffde9052*/
 if ( Protocol ) /*0xffde9059*/
 (*(void ( **)(const char *, int, const char *))(Protocol + 4))( /*0xffde9065*/
 "e:\\hs\\PurleySktPkg\\SouthClusterLbg\\Library\\PeiDxeSmmGpioLib\\GpioLib.c",
 1398,
 "((BOOLEAN)(0==1))");
 return -2147483646; /*0xffde9065*/
 }
 v9 = (*(_DWORD *)((unsigned __int16)(GroupInfo[15 *Ptr + 1] + 4 * (ErrorLevel >> 3)) /*0xffde9096*/
 | ((LOBYTE(GroupInfo[15 *Ptr]) | 0xFFFFFD00) << 16))
 & (unsigned int)(3 << (4 * (ErrorLevel & 7)))) >> (4 * (ErrorLevel & 7));
 *a2 = v9; /*0xffde909a*/
 return 0; /*0xffde909d*/
}

/*
 *GpioGetGroupInfo at 0xffde90a3
 */
void *__thiscall GpioGetGroupInfo(_DWORD *this)
{
 if ( IsPchLbg() == 1 ) /*0xffde90ae*/
 {
 *this = 13; /*0xffde90b0*/
 return &unk_FFDEAAC0; /*0xffde90b6*/
 }
 else
 {
 *this = 0; /*0xffde90bd*/
 return 0; /*0xffde90c0*/
 }
}

/*
 *GpioIsPadValidForChipset at 0xffde90c4
 */
bool GpioIsPadValidForChipset(int a1)
{
 int PchSeries; // eax PchSeries = GetPchSeries(); /*0xffde90c7*/
 if ( PchSeries == 1 ) /*0xffde90cf*/
 return (a1 & 0xFF000000) == 0x1000000; /*0xffde90d7*/
 if ( PchSeries != 2 ) /*0xffde90e6*/
 return 0; /*0xffde90e6*/
 return (a1 & 0xFF000000) == 0x2000000; /*0xffde90e1*/
}

/*
 *IoRead16 at 0xffde90fa
 */
int IoRead16(unsigned __int16 *MmioAddr)
{
 int ReportStatusCodeProtocol; // eax if ( ((unsigned __int8)MmioAddr & 1) != 0 ) /*0xffde9100*/
 {
 ReportStatusCodeProtocol = GetReportStatusCodeProtocol(); /*0xffde9102*/
 if ( ReportStatusCodeProtocol ) /*0xffde9109*/
 (*(void ( **)(const char *, int, const char *))(ReportStatusCodeProtocol + 4))( /*0xffde911a*/
 "e:\\hs\\MdePkg\\Library\\BaseIoLibIntrinsic\\IoLib.c",
 151,
 "(Address & 1) == 0");
 }
 return *MmioAddr; /*0xffde9126*/
}

/*
 *GetNextGuidHob at 0xffde9128
 */
int GetNextGuidHob(int a1, int n4126)
{
 int PeiServicesTablePointer; // eax int ReportStatusCodeProtocol; // eax int Result; // [esp+4h] [ebp-4h] BYREF PeiServicesTablePointer = GetPeiServicesTablePointer(); /*0xffde912f*/
 if ( (*(int ( **)(int, int, int, int *))(*(_DWORD *)PeiServicesTablePointer + 52))( /*0xffde9147*/
 PeiServicesTablePointer,
 4,
 n4126,
 &Result) < 0 )
 Result = 0; /*0xffde9149*/
 if ( !Result ) /*0xffde9151*/
 {
 ReportStatusCodeProtocol = GetReportStatusCodeProtocol(); /*0xffde9153*/
 if ( ReportStatusCodeProtocol ) /*0xffde915a*/
 (*(void ( **)(const char *, int, const char *))(ReportStatusCodeProtocol + 4))( /*0xffde916b*/
 "e:\\hs\\MdePkg\\Library\\PeiHobLib\\HobLib.c",
 250,
 "Hob != ((void *) 0)");
 }
 return Result; /*0xffde9144*/
}

/*
 *GetReportStatusCodeProtocol at 0xffde9178
 */
int GetReportStatusCodeProtocol()
{
 int PeiServicesTablePointer; // eax _BYTE v2[4]; // [esp+0h] [ebp-8h] BYREF int Result; // [esp+4h] [ebp-4h] BYREF PeiServicesTablePointer = GetPeiServicesTablePointer(); /*0xffde917d*/
 if ( (*(int ( **)(int, void *, _DWORD, _BYTE *, int *))(*(_DWORD *)PeiServicesTablePointer + 32))( /*0xffde919c*/
 PeiServicesTablePointer,
 &unk_FFDEA9D8,
 0,
 v2,
 &Result) >= 0 )
 return Result; /*0xffde91a2*/
 else return 0; /*0xffde919e*/
}

/*
 *ReportStatusCode at 0xffde91a9
 */
int ReportStatusCode(int a1, int a2, ...)
{
 int result; // eax int ( **v3)(int, int, char *); // esi va_list va; // [esp+10h] [ebp+Ch] BYREF va_start(va, a2);
 result = GetReportStatusCodeProtocol(); /*0xffde91aa*/
 v3 = (int ( **)(int, int, char *))result; /*0xffde91af*/
 if ( result ) /*0xffde91b3*/
 {
 result = GetReportMode(); /*0xffde91b5*/
 if ( (result & a1) != 0 ) /*0xffde91c0*/
 return (*v3)(a1, a2, (char *)va); /*0xffde91cc*/
 }
 return result; /*0xffde91d1*/
}

/*
 *ReportDebugAssert at 0xffde91d3
 */
int ReportDebugAssert(
 int e:__hs__MdePkg__Library__PeiServicesTablePointerLibIdt__PeiServ,
 int n48,
 int PeiServices____((void__)_0))
{
 int result; // eax result = GetReportStatusCodeProtocol(); /*0xffde91d9*/
 if ( result ) /*0xffde91e0*/
 return (*(int ( **)(int, int, int))(result + 4))( /*0xffde91e8*/
 e:__hs__MdePkg__Library__PeiServicesTablePointerLibIdt__PeiServ,
 n48,
 PeiServices____((void__)_0));
 return result; /*0xffde91ee*/
}

/*
 *PeiPcdGetPtr at 0xffde91f1
 */
void *__thiscall PeiPcdGetPtr(void *this)
{
 int PeiServicesTablePointer; // eax int Status; // eax int ReportStatusCodeProtocol; // eax void *this_1; // [esp+0h] [ebp-4h]

 this_1 = this; /*0xffde91f4*/
 PeiServicesTablePointer = GetPeiServicesTablePointer(); /*0xffde91f5*/
 Status = (*(int (__stdcall **)(int))(*(_DWORD *)PeiServicesTablePointer + 32))(PeiServicesTablePointer); /*0xffde920a*/
 if ( Status < 0 ) /*0xffde9212*/
 {
 ReportStatusCode(0x80000000, (int)"\nASSERT_EFI_ERROR (Status = %r)\n", Status); /*0xffde921f*/
 ReportStatusCodeProtocol = GetReportStatusCodeProtocol(); /*0xffde9227*/
 if ( ReportStatusCodeProtocol ) /*0xffde922e*/
 (*(void ( **)(const char *, int, const char *))(ReportStatusCodeProtocol + 4))( /*0xffde923c*/
 "e:\\hs\\MdePkg\\Library\\PeiPcdLib\\PeiPcdLib.c",
 49,
 "!EFI_ERROR (Status)");
 }
 return this_1; /*0xffde9247*/
}

/*
 *PcdGet32 at 0xffde9249
 */
int __thiscall PcdGet32(void *this)
{
 int ( **Ptr)(void *); // eax Ptr = (int ( **)(void *))PeiPcdGetPtr(this); /*0xffde924c*/
 return Ptr[4](this); /*0xffde9256*/
}

/*
 *PcdGet64 at 0xffde9258
 */
int __thiscall PcdGet64(void *this)
{
 int ( **Ptr)(void *); // eax Ptr = (int ( **)(void *))PeiPcdGetPtr(this); /*0xffde925b*/
 return Ptr[5](this); /*0xffde9265*/
}

/*
 *PeiSetupGetVariable at 0xffde9267
 */
int PeiSetupGetVariable(void *a1)
{
 int v1; // ecx int Result; // edi int PeiServicesTablePointer; // eax int result; // eax int Result; // esi int Status; // eax int ReportStatusCodeProtocol; // eax int ( **v8)(_DWORD, int, void *, _DWORD, void **, int); // [esp+8h] [ebp-4h] BYREF Result = v1; /*0xffde926d*/
 PeiServicesTablePointer = GetPeiServicesTablePointer(); /*0xffde926f*/
 (*(void ( **)(int, void *, _DWORD, _DWORD, int ( ***)(_DWORD, int, void *, _DWORD, void **, int)))(*(_DWORD *)PeiServicesTablePointer + 32))( /*0xffde9284*/
 PeiServicesTablePointer,
 &unk_FFDEA9C8,
 0,
 0,
 &v8);
 result = InternalPeiZeroMem(a1); /*0xffde928d*/
 Result = result; /*0xffde9292*/
 if ( result ) /*0xffde9296*/
 {
 Status = (*v8)(v8, Result, &unk_FFDEAA88, 0, &a1, result); /*0xffde92a9*/
 if ( Status < 0 ) /*0xffde92b0*/
 {
 ReportStatusCode(0x80000000, (int)"\nASSERT_EFI_ERROR (Status = %r)\n", Status); /*0xffde92bd*/
 ReportStatusCodeProtocol = GetReportStatusCodeProtocol(); /*0xffde92c5*/
 if ( ReportStatusCodeProtocol ) /*0xffde92cc*/
 (*(void ( **)(const char *, int, const char *))(ReportStatusCodeProtocol + 4))( /*0xffde92da*/
 "e:\\hs\\PurleyRpPkg\\Library\\SetupLib\\PeiSetupLib.c",
 80,
 "!EFI_ERROR (Status)");
 }
 return Result; /*0xffde92e0*/
 }
 return result; /*0xffde92e2*/
}

/*
 *FindMatchingSetupGuid at 0xffde92e8
 */
int FindMatchingSetupGuid()
{
 int Index; // esi char **v1; // eax Index = 0; /*0xffde92e9*/
 if ( off_FFDEADD8 ) /*0xffde92f1*/
 {
 v1 = (char **)&off_FFDEADD8; /*0xffde92f3*/
 do /*0xffde930d*/
 {
 if ( IsGuidMatch(*v1) ) /*0xffde92fa*/
 break; /*0xffde9301*/
 ++Index; /*0xffde9303*/
 v1 = (char **)(&off_FFDEADD8 + 3 *Index); /*0xffde9307*/
 }
 while ( *v1 ); /*0xffde930d*/
 }
 if ( *(&off_FFDEADD8 + 3 *Index) ) /*0xffde9315*/
 return Index; /*0xffde9323*/
 else return -1; /*0xffde931e*/
}

/*
 *IsGbeEnabled at 0xffde9327
 */
bool IsGbeEnabled()
{
 unsigned int Device; // esi int ReportStatusCodeProtocol; // eax Device = *(_DWORD *)(PciCfgReadMmioAddr(0, 31, 5) + 16) & 0xFFFFF000; /*0xffde9338*/
 if ( !Device ) /*0xffde933e*/
 {
 ReportStatusCodeProtocol = GetReportStatusCodeProtocol(); /*0xffde9340*/
 if ( ReportStatusCodeProtocol ) /*0xffde9347*/
 (*(void ( **)(const char *, int, const char *))(ReportStatusCodeProtocol + 4))( /*0xffde9355*/
 "e:\\hs\\PurleySktPkg\\SouthClusterLbg\\Library\\PeiDxeSmmPchGbeLib\\PchGbeLib.c",
 58,
 "SpiBar != 0");
 }
 return *(_DWORD *)(Device + 96) != 0x7FFF; /*0xffde9363*/
}

/*
 *GetGbePortNumber at 0xffde9368
 */
int GetGbePortNumber()
{
 int v1; // eax int v2; // eax int v3; // eax int v4; // eax int ReportStatusCodeProtocol; // eax if ( MEMORY[0xFD130200] >= 0 ) /*0xffde9376*/
 return 0; /*0xffde9376*/
 v1 = (MEMORY[0xFD130200] >> 28) & 7; /*0xffde937e*/
 if ( !v1 ) /*0xffde9384*/
 return 4; /*0xffde93d6*/
 v2 = v1 - 1; /*0xffde9386*/
 if ( !v2 ) /*0xffde9389*/
 return 5; /*0xffde93d2*/
 v3 = v2 - 1; /*0xffde938b*/
 if ( !v3 ) /*0xffde938e*/
 return 6; /*0xffde93ce*/
 v4 = v3 - 1; /*0xffde9390*/
 if ( !v4 ) /*0xffde9393*/
 return 9; /*0xffde93ca*/
 if ( v4 != 1 ) /*0xffde9398*/
 {
 ReportStatusCode(0x80000000, (int)"Invalid GbE port\n"); /*0xffde93a0*/
 ReportStatusCodeProtocol = GetReportStatusCodeProtocol(); /*0xffde93a7*/
 if ( ReportStatusCodeProtocol ) /*0xffde93ae*/
 (*(void ( **)(const char *, int, const char *))(ReportStatusCodeProtocol + 4))( /*0xffde93bc*/
 "e:\\hs\\PurleySktPkg\\SouthClusterLbg\\Library\\PeiDxeSmmPchGbeLib\\PchGbeLib.c",
 94,
 "((BOOLEAN)(0==1))");
 return 0; /*0xffde937a*/
 }
 return 12; /*0xffde937a*/
}

/*
 *IsGbePhyPresent at 0xffde93d8
 */
bool IsGbePhyPresent()
{
 int ReportStatusCodeProtocol; // eax _DWORD *MmioAddr; // esi int PeiServicesTablePointer; // eax int Status; // eax int Protocol; // eax int v6; // [esp+Ch] [ebp-Ch] BYREF int v7; // [esp+10h] [ebp-8h] BYREF unsigned int v8; // [esp+14h] [ebp-4h] BYREF v7 = 0; /*0xffde93e5*/
 v8 = 0; /*0xffde93e8*/
 PchPwrmBaseGet(&v8); /*0xffde93eb*/
 if ( v8 ) /*0xffde93f5*/
 {
 if ( (*(_DWORD *)(v8 + 300) & 0x8000) != 0 ) /*0xffde94c3*/
 return 0; /*0xffde94c3*/
 }
 else
 {
 ReportStatusCodeProtocol = GetReportStatusCodeProtocol(); /*0xffde93fb*/
 if ( ReportStatusCodeProtocol ) /*0xffde9402*/
 (*(void ( **)(const char *, int, const char *))(ReportStatusCodeProtocol + 4))( /*0xffde9413*/
 "e:\\hs\\PurleySktPkg\\SouthClusterLbg\\Library\\PeiDxeSmmPchPmcLib\\PchPmcLib.c",
 162,
 "PchPwrmBase != 0");
 }
 MmioAddr = (_DWORD *)PciCfgReadMmioAddr(0, 31, 6); /*0xffde9426*/
 PeiServicesTablePointer = GetPeiServicesTablePointer(); /*0xffde9428*/
 Status = (*(int ( **)(int, void *, _DWORD, _DWORD, int *))(*(_DWORD *)PeiServicesTablePointer + 32))( /*0xffde943b*/
 PeiServicesTablePointer,
 &unk_FFDEA9E8,
 0,
 0,
 &v7);
 if ( Status < 0 ) /*0xffde9443*/
 {
 ReportStatusCode(0x80000000, (int)"\nASSERT_EFI_ERROR (Status = %r)\n", Status); /*0xffde9450*/
 Protocol = GetReportStatusCodeProtocol(); /*0xffde9458*/
 if ( Protocol ) /*0xffde945f*/
 (*(void ( **)(const char *, int, const char *))(Protocol + 4))( /*0xffde9470*/
 "e:\\hs\\PurleySktPkg\\SouthClusterLbg\\Library\\PeiDxeSmmPchGbeLib\\PchGbeLib.c",
 134,
 "!EFI_ERROR (Status)");
 }
 if ( ((*(int ( **)(int, int, int, int *))(v7 + 36))(v7, 476, 4, &v6) < 0 || (v6 & 0x4000) == 0) /*0xffde94a1*/
 && GetGbePortNumber()
 && IsGbeEnabled() )
 {
 return *MmioAddr != -1; /*0xffde94b7*/
 }
 return 0; /*0xffde94b2*/
}

/*
 *GetReportMode at 0xffde94cd
 */
int GetReportMode()
{
 unsigned __int8 v0; // al char Result; // al char n3_1; // cl v0 = __inbyte(0x70u); /*0xffde94d3*/
 __outbyte(0x70u, v0 & 0x80 | 0x4A); /*0xffde94d8*/
 Result = __inbyte(0x71u); /*0xffde94df*/
 n3_1 = Result; /*0xffde94e0*/
 if ( (unsigned __int8)Result <= 3u ) /*0xffde94e5*/
 {
LABEL_4:
 if ( !n3_1 ) /*0xffde9500*/
 return 0; /*0xffde9500*/
 goto LABEL_5; /*0xffde9500*/
 }
 n3_1 = Result; /*0xffde94e7*/
 if ( !Result ) /*0xffde94ef*/
 {
 n3_1 = MEMORY[0xFDAF0490] & 2 | 1; /*0xffde94fb*/
 goto LABEL_4; /*0xffde94fb*/
 }
LABEL_5:
 if ( n3_1 != -1 )
 return n3_1 != 1 ? -2147483578 : -2147483644;
 return 0; /*0xffde9518*/
}

/*
 *GetPeiServicesTablePointer at 0xffde951c
 */
int GetPeiServicesTablePointer()
{
 int Result; // esi _BYTE v2[2]; // [esp+4h] [ebp-8h] BYREF int v3; // [esp+6h] [ebp-6h]

 ReadIdtr(v2); /*0xffde9525*/
 Result = *(_DWORD *)(v3 - 4); /*0xffde952d*/
 if ( !Result ) /*0xffde9532*/
 ReportDebugAssert( /*0xffde9541*/
 (int)"e:\\hs\\MdePkg\\Library\\PeiServicesTablePointerLibIdt\\PeiServicesTablePointer.c",
 48,
 (int)"PeiServices != ((void *) 0)");
 return Result; /*0xffde9549*/
}

/*
 *PeiPcdGetPtrByToken at 0xffde954e
 */
int __thiscall PeiPcdGetPtrByToken(void *this)
{
 int PeiServicesTablePointer; // eax int Result; // [esp+4h] [ebp-4h] BYREF PeiServicesTablePointer = GetPeiServicesTablePointer(); /*0xffde9555*/
 if ( (*(int ( **)(int, void *, int *))(*(_DWORD *)PeiServicesTablePointer + 76))( /*0xffde956b*/
 PeiServicesTablePointer,
 this,
 &Result) >= 0 )
 return Result; /*0xffde9571*/
 else return 0; /*0xffde956d*/
}

/*
 *InternalPeiZeroMem at 0xffde9578
 */
int __thiscall InternalPeiZeroMem(void *this)
{
 int buf_1; // eax void *this_1; // edx unsigned int this_2; // edi void *buf; // esi int ReportStatusCodeProtocol; // eax buf_1 = PeiPcdGetPtrByToken(this); /*0xffde957b*/
 if ( buf_1 ) /*0xffde9582*/
 {
 this_1 = this; /*0xffde9584*/
 this_2 = (unsigned int)this; /*0xffde9644*/
 buf = (void *)buf_1; /*0xffde9646*/
 if ( this_1 ) /*0xffde964a*/
 {
 if ( this_2 > -buf_1 ) /*0xffde9677*/
 {
 ReportStatusCodeProtocol = GetReportStatusCodeProtocol(); /*0xffde9679*/
 if ( ReportStatusCodeProtocol ) /*0xffde9680*/
 (*(void ( **)(const char *, int, const char *))(ReportStatusCodeProtocol + 4))( /*0xffde968a*/
 "e:\\hs\\MdePkg\\Library\\BaseMemoryLibRepStr\\ZeroMemWrapper.c",
 54,
 "Length <= (0xFFFFFFFF - (UINTN)Buffer + 1)");
 }
 return (int)InternalZeroMem(buf, this_2); /*0xffde9692*/
 }
 }
 return buf_1; /*0xffde958e*/
}

/*
 *PciCfgAddrEncode at 0xffde9590
 */
int *PciCfgAddrEncode(int a1, int a2, _DWORD *a3, int *a4)
{
 int Device; // ecx Device = PciCfgAddrDecode((int)a3) + (*a3 & 0xFFFFFFF); /*0xffde95a4*/
 *a4 = Device; /*0xffde95ab*/
 return a4; /*0xffde95aa*/
}

/*
 *PchPwrmBaseGet at 0xffde95ae
 */
int __thiscall PchPwrmBaseGet(unsigned int *this)
{
 int Protocol; // eax int MmioAddr; // edi int ReportStatusCodeProtocol; // eax if ( this ) /*0xffde95b5*/
 {
 MmioAddr = PciCfgReadMmioAddr(0, 31, 2); /*0xffde95fa*/
 if ( (unsigned __int16)IoRead16((unsigned __int16 *)MmioAddr) == 0xFFFF ) /*0xffde960b*/
 {
 ReportStatusCodeProtocol = GetReportStatusCodeProtocol(); /*0xffde960d*/
 if ( ReportStatusCodeProtocol ) /*0xffde9614*/
 (*(void ( **)(const char *, int, const char *))(ReportStatusCodeProtocol + 4))( /*0xffde9625*/
 "e:\\hs\\PurleySktPkg\\SouthClusterLbg\\Library\\PeiDxeSmmPchCycleDecodingLib\\PchCycleDecodingLib.c",
 303,
 "((BOOLEAN)(0==1))");
 return -2147483645; /*0xffde962b*/
 }
 else
 {
 *this = *(_DWORD *)(MmioAddr + 72) & 0xFFFF0000; /*0xffde963a*/
 return 0; /*0xffde963c*/
 }
 }
 else
 {
 ReportStatusCode(0x80000000, (int)"PchPwrmBaseGet Error. Invalid pointer.\n"); /*0xffde95c1*/
 Protocol = GetReportStatusCodeProtocol(); /*0xffde95c8*/
 if ( Protocol ) /*0xffde95cf*/
 (*(void ( **)(const char *, int, const char *))(Protocol + 4))( /*0xffde95e0*/
 "e:\\hs\\PurleySktPkg\\SouthClusterLbg\\Library\\PeiDxeSmmPchCycleDecodingLib\\PchCycleDecodingLib.c",
 293,
 "((BOOLEAN)(0==1))");
 return -2147483646; /*0xffde95e6*/
 }
}

/*
 *SetBoardDefaultSku at 0xffde969d
 */
void *__thiscall SetBoardDefaultSku(void *this)
{
 __int64 Unaligned64; // rax __int64 Unaligned64_1; // rax Unaligned64 = ReadUnaligned64(&unk_FFDEAA28); /*0xffde96a5*/
 WriteUnaligned64(Unaligned64, SHIDWORD(Unaligned64)); /*0xffde96ae*/
 Unaligned64_1 = ReadUnaligned64(&unk_FFDEAA30); /*0xffde96b8*/
 WriteUnaligned64(Unaligned64_1, SHIDWORD(Unaligned64_1)); /*0xffde96c2*/
 return this; /*0xffde96cc*/
}

/*
 *IsGuidMatch at 0xffde96ce
 */
bool __thiscall IsGuidMatch(char *this)
{
 __int64 Unaligned64; // rax int Unaligned64_1; // ebx __int64 Unaligned64_3; // rax int Unaligned64_2; // edi __int64 v6; // kr00_8 __int64 v7; // rax int v9; // [esp+10h] [ebp-8h]
 int v10; // [esp+14h] [ebp-4h]

 Unaligned64 = ReadUnaligned64(this); /*0xffde96d6*/
 v10 = HIDWORD(Unaligned64); /*0xffde96e0*/
 Unaligned64_1 = Unaligned64; /*0xffde96e4*/
 Unaligned64_3 = ReadUnaligned64(&unk_FFDEAA88); /*0xffde96e6*/
 v9 = HIDWORD(Unaligned64_3); /*0xffde96ee*/
 Unaligned64_2 = Unaligned64_3; /*0xffde96f2*/
 v6 = ReadUnaligned64(this + 8); /*0xffde9700*/
 v7 = ReadUnaligned64(&unk_FFDEAA90); /*0xffde9702*/
 return Unaligned64_1 == Unaligned64_2 && v10 == v9 && v6 == v7; /*0xffde9723*/
}

/*
 *CopyMem at 0xffde972a
 */
char *CopyMem(char *dst, char *src, unsigned int n4102)
{
 int ReportStatusCodeProtocol; // eax int Protocol; // eax if ( n4102 - 1 > -1 - (int)dst ) /*0xffde9740*/
 {
 ReportStatusCodeProtocol = GetReportStatusCodeProtocol(); /*0xffde9742*/
 if ( ReportStatusCodeProtocol ) /*0xffde9749*/
 (*(void ( **)(const char *, int, const char *))(ReportStatusCodeProtocol + 4))( /*0xffde9757*/
 "e:\\hs\\MdePkg\\Library\\BaseMemoryLibRepStr\\CopyMemWrapper.c",
 56,
 "(Length - 1) <= (0xFFFFFFFF - (UINTN)DestinationBuffer)");
 }
 if ( n4102 - 1 > -1 - (int)src ) /*0xffde9761*/
 {
 Protocol = GetReportStatusCodeProtocol(); /*0xffde9763*/
 if ( Protocol ) /*0xffde976a*/
 (*(void ( **)(const char *, int, const char *))(Protocol + 4))( /*0xffde9778*/
 "e:\\hs\\MdePkg\\Library\\BaseMemoryLibRepStr\\CopyMemWrapper.c",
 57,
 "(Length - 1) <= (0xFFFFFFFF - (UINTN)SourceBuffer)");
 }
 if ( dst == src ) /*0xffde9780*/
 return dst; /*0xffde9782*/
 else return InternalCopyMem(dst, src, n4102); /*0xffde978c*/
}

/*
 *ReadIdtr at 0xffde9799
 */
void *__thiscall ReadIdtr(void *this)
{
 void *this_1; // eax if ( !this ) /*0xffde979f*/
 ReportDebugAssert((int)"e:\\hs\\MdePkg\\Library\\BaseLib\\X86ReadIdtr.c", 37, (int)"Idtr != ((void *) 0)"); /*0xffde97ae*/
 this_1 = this; /*0xffde97b4*/
 __sidt(this); /*0xffde97b7*/
 return this_1; /*0xffde97bb*/
}

/*
 *ReadUnaligned64 at 0xffde97bc
 */
__int64 __thiscall ReadUnaligned64(void *this)
{
 int ReportStatusCodeProtocol; // eax if ( !this ) /*0xffde97c1*/
 {
 ReportStatusCodeProtocol = GetReportStatusCodeProtocol(); /*0xffde97c3*/
 if ( ReportStatusCodeProtocol ) /*0xffde97ca*/
 (*(void ( **)(const char *, int, const char *))(ReportStatusCodeProtocol + 4))( /*0xffde97db*/
 "e:\\hs\\MdePkg\\Library\\BaseLib\\Unaligned.c",
 192,
 "Buffer != ((void *) 0)");
 }
 return *(_QWORD *)this; /*0xffde97e6*/
}

/*
 *WriteUnaligned64 at 0xffde97e8
 */
int WriteUnaligned64(int Unaligned64, int a2)
{
 _DWORD *v2; // ecx _DWORD *v3; // esi int ReportStatusCodeProtocol; // eax v3 = v2; /*0xffde97e9*/
 if ( !v2 ) /*0xffde97ed*/
 {
 ReportStatusCodeProtocol = GetReportStatusCodeProtocol(); /*0xffde97ef*/
 if ( ReportStatusCodeProtocol ) /*0xffde97f6*/
 (*(void ( **)(const char *, int, const char *))(ReportStatusCodeProtocol + 4))( /*0xffde9807*/
 "e:\\hs\\MdePkg\\Library\\BaseLib\\Unaligned.c",
 219,
 "Buffer != ((void *) 0)");
 }
 *v3 = Unaligned64; /*0xffde9815*/
 v3[1] = a2; /*0xffde9817*/
 return Unaligned64; /*0xffde981a*/
}

/*
 *PciCfgSegmentInit at 0xffde981c
 */
int PciCfgSegmentInit(_DWORD *a1, int n8)
{
 int v3; // [esp+Ch] [ebp-4h]

 v3 = PcdGet64((void *)6); /*0xffde984c*/
 a1[1] = 16 *n8 + 16; /*0xffde9855*/
 if ( !a1[4] && !a1[5] ) /*0xffde9871*/
 {
 *(_DWORD *)(v3 + 16) = PcdGet32((void *)5); /*0xffde9896*/
 *(_DWORD *)(v3 + 20) = 0; /*0xffde98ad*/
 }
 return 0; /*0xffde98b3*/
}

/*
 *PciCfgAddrDecode at 0xffde98b7
 */
int PciCfgAddrDecode(int a1)
{
 int v2; // [esp+Ch] [ebp-Ch]
 int v3; // [esp+10h] [ebp-8h]
 int Result; // [esp+14h] [ebp-4h]

 if ( *(_DWORD *)(a1 + 12) ) /*0xffde98cc*/
 {
 v3 = *(_DWORD *)(*(_DWORD *)(a1 + 12) + 4 * (unsigned __int16)*(_DWORD *)(a1 + 4) + 255544); /*0xffde99c2*/
 Result = *(_DWORD *)(*(_DWORD *)(a1 + 12) + 4 * (unsigned __int16)*(_DWORD *)(a1 + 4) + 255560); /*0xffde99de*/
 }
 else
 {
 v2 = PcdGet64((void *)6); /*0xffde98df*/
 if ( *(_DWORD *)(v2 + 4) ) /*0xffde98e5*/
 {
 v3 = *(_DWORD *)(v2 + 16 * (unsigned __int16)*(_DWORD *)(a1 + 4) + 20); /*0xffde9900*/
 Result = *(_DWORD *)(v2 + 16 * (unsigned __int16)*(_DWORD *)(a1 + 4) + 16); /*0xffde9918*/
 }
 else
 {
 PciCfgSegmentInit(dword_FFDEAE5C, 8); /*0xffde992b*/
 v3 = dword_FFDEAE70[4 * (unsigned __int16)*(_DWORD *)(a1 + 4)]; /*0xffde9946*/
 Result = dword_FFDEAE6C[4 * (unsigned __int16)*(_DWORD *)(a1 + 4)]; /*0xffde995d*/
 if ( !Result && !v3 ) /*0xffde996a*/
 {
 Result = PcdGet32((void *)5); /*0xffde9997*/
 v3 = 0; /*0xffde99a4*/
 }
 }
 }
 if ( !Result && !v3 ) /*0xffde99eb*/
 return PcdGet32((void *)5); /*0xffde9a18*/
 return Result; /*0xffde9a31*/
}

/*
 *GetPchSeriesFromPcd at 0xffde9a35
 */
int __thiscall GetPchSeriesFromPcd(void *this)
{
 int ( **Ptr)(int); // eax Ptr = (int ( **)(int))PeiPcdGetPtr(this); /*0xffde9a35*/
 return Ptr[4](5); /*0xffde9a40*/
}