//
// TcgPeiplatform.efi - Full Decompilation
// Source: IDA Pro MCP port 13381
// Functions: 14
//
#include <Uefi.h>
#include <PiPei.h>
{"addr":"0xffe2cd34","code":"void *InternalMemSetMem(void *buf, unsigned int count, char value)\n{\n memset(buf, value, count); /*0xffe2cd41*/\n return buf; /*0xffe2cd47*/\n}"}
{"addr":"0xffe2cd54","code":"int InternalMemSetMem32(int a1, int a2, int a3, int a4)\n{\n do /*0xffe2cd6d*/\n {\n *(_DWORD *)(a1 + 8 *a2 - 8) = a3; /*0xffe2cd65*/\n *(_DWORD *)(a1 + 8 *a2-- - 4) = a4; /*0xffe2cd69*/\n }\n while ( a2 ); /*0xffe2cd6d*/\n return a1; /*0xffe2cd71*/\n}"}
{"addr":"0xffe2cd74","code":"void *InternalMemZeroMem(void *buf, unsigned int count, int value)\n{\n memset32(buf, value, count); /*0xffe2cd81*/\n return buf; /*0xffe2cd87*/\n}"}
{"addr":"0xffe2cd94","code":"char *InternalMemCopyMem(char *dst, char *src, unsigned int count)\n{\n unsigned int count_1; // edx\n char *dst_1; // edi\n char *src_1; // esi\n\n count_1 = count; /*0xffe2cd9e*/\n if ( src < dst && &src[count - 1] >= dst ) /*0xffe2cdac*/\n {\n src_1 = &src[count - 1]; /*0xffe2cdc0*/\n dst_1 = &dst[count - 1]; /*0xffe2cdc2*/\n }\n else\n {\n count_1 = count & 3; /*0xffe2cdb0*/\n qmemcpy(dst, src, 4 * (count >> 2)); /*0xffe2cdb9*/\n src_1 = &src[4 * (count >> 2)]; /*0xffe2cdb9*/\n dst_1 = &dst[4 * (count >> 2)]; /*0xffe2cdb9*/\n }\n qmemcpy(dst_1, src_1, count_1); /*0xffe2cdc9*/\n return dst; /*0xffe2cdd0*/\n}"}
{"addr":"0xffe2cdf4","code":"EFI_STATUS ModuleEntryPoint(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)\n{\n int v2; // ebp\n int PcdPpi; // eax\n int Signature; // eax\n EFI_STATUS result; // eax\n void ( **ImageHandle_1)(EFI_SYSTEM_TABLE *); // [esp-8h] [ebp-Ch] BYREF\n _DWORD v7[2]; // [esp-4h] [ebp-8h] BYREF\n\n if ( *(char *)(GetPcdPpi() + 1024068) >= 0 ) /*0xffe2ce05*/\n {\n PcdSetSku(); /*0xffe2ce07*/\n PcdPpi = GetPcdPpi(); /*0xffe2ce0c*/\n *(_BYTE *)(PcdPpi + 1024068) |= 0x80u; /*0xffe2ce18*/\n }\n v7[1] = v2; /*0xffe2cedb*/\n v7[0] = ImageHandle; /*0xffe2cede*/\n ImageHandle_1 = (void ( **)(EFI_SYSTEM_TABLE *))ImageHandle; /*0xffe2cedf*/\n Signature = SystemTable->Hdr.Signature; /*0xffe2ceed*/\n ImageHandle_1 = 0; /*0xffe2cef6*/\n if ( (*(int ( **)(EFI_SYSTEM_TABLE *, void *, _DWORD, _DWORD, void ( ***)(EFI_SYSTEM_TABLE *)))(Signature + 32))( /*0xffe2cf01*/\n SystemTable,\n &unk_FFE2D4A4,\n 0,\n 0,\n &ImageHandle_1) < 0 )\n return 0; /*0xffe2cf03*/\n (*ImageHandle_1)(SystemTable); /*0xffe2cf0b*/\n result = (*(int ( **)(EFI_SYSTEM_TABLE *, int, _DWORD *))(LODWORD(SystemTable->Hdr.Signature) + 76))( /*0xffe2cf16*/\n SystemTable,\n 16,\n v7);\n if ( (result & 0x80000000) == 0 ) /*0xffe2cf1e*/\n {\n *(_DWORD *)v7[0] = -2147483616; /*0xffe2cf23*/\n *(_DWORD *)(v7[0] + 4) = &unk_FFE2D494; /*0xffe2cf2c*/\n *(_DWORD *)(v7[0] + 8) = &loc_FFE2CE28; /*0xffe2cf36*/\n *(_DWORD *)(v7[0] + 12) = ImageHandle; /*0xffe2cf40*/\n return (*(int ( **)(EFI_SYSTEM_TABLE *, _DWORD))(LODWORD(SystemTable->Hdr.Signature) + 36))( /*0xffe2cf49*/\n SystemTable,\n v7[0]);\n }\n return result; /*0xffe2cf53*/\n}","refs":[{"addr":"0xffe2d0ca","name":"PcdSetSku"},{"addr":"0xffe2d0be","name":"GetPcdPpi"},{"addr":"0xffe2d4a4","name":"unk_FFE2D4A4"},{"addr":"0xffe2d494","name":"unk_FFE2D494"},{"addr":"0xffe2ce28","name":"loc_FFE2CE28"}]}
{"addr":"0xffe2cf54","code":"int GetDebugOutput()\n{\n int PeiServicesTable; // eax\n _BYTE v2[4]; // [esp+0h] [ebp-8h] BYREF\n int v3; // [esp+4h] [ebp-4h] BYREF\n\n PeiServicesTable = GetPeiServicesTable(); /*0xffe2cf59*/\n if ( (*(int ( **)(int, void *, _DWORD, _BYTE *, int *))(*(_DWORD *)PeiServicesTable + 32))( /*0xffe2cf78*/\n PeiServicesTable,\n &unk_FFE2D474,\n 0,\n v2,\n &v3) >= 0 )\n return v3; /*0xffe2cf7e*/\n else\n return 0; /*0xffe2cf7a*/\n}","refs":[{"addr":"0xffe2d069","name":"GetPeiServicesTable"},{"addr":"0xffe2d474","name":"unk_FFE2D474"}]}
{"addr":"0xffe2cf85","code":"int DebugPrint(int a1, int _nASSERT_EFI_ERROR_(Status___%r)_n, ...)\n{\n int result; // eax\n int ( **v3)(int, int, char *); // esi\n va_list va; // [esp+10h] [ebp+Ch] BYREF\n\n va_start(va, _nASSERT_EFI_ERROR_(Status___%r)_n);\n result = GetDebugOutput(); /*0xffe2cf86*/\n v3 = (int ( **)(int, int, char *))result; /*0xffe2cf8b*/\n if ( result ) /*0xffe2cf8f*/\n {\n result = TpmIsPresent(); /*0xffe2cf91*/\n if ( (result & a1) != 0 ) /*0xffe2cf9c*/\n return (*v3)(a1, _nASSERT_EFI_ERROR_(Status___%r)_n, (char *)va); /*0xffe2cfa8*/\n }\n return result; /*0xffe2cfad*/\n}","refs":[{"addr":"0xffe2cf54","name":"GetDebugOutput"},{"addr":"0xffe2cfcd","name":"TpmIsPresent"}]}
{"addr":"0xffe2cfaf","code":"int DebugAssert(\n int e:__hs__MdePkg__Library__PeiServicesTablePointerLibIdt__PeiServ,\n int n48,\n int PeiServices____((void__)_0))\n{\n int result; // eax\n\n result = GetDebugOutput(); /*0xffe2cfb5*/\n if ( result ) /*0xffe2cfbc*/\n return (*(int ( **)(int, int, int))(result + 4))( /*0xffe2cfc4*/\n e:__hs__MdePkg__Library__PeiServicesTablePointerLibIdt__PeiServ,\n n48,\n PeiServices____((void__)_0));\n return result; /*0xffe2cfca*/\n}","refs":[{"addr":"0xffe2cf54","name":"GetDebugOutput"}]}
{"addr":"0xffe2cfcd","code":"int TpmIsPresent()\n{\n unsigned __int8 v0; // al\n char n3; // al\n char n3_1; // cl\n\n v0 = __inbyte(0x70u); /*0xffe2cfd3*/\n __outbyte(0x70u, v0 & 0x80 | 0x4A); /*0xffe2cfd8*/\n n3 = __inbyte(0x71u); /*0xffe2cfdf*/\n n3_1 = n3; /*0xffe2cfe0*/\n if ( (unsigned __int8)n3 <= 3u ) /*0xffe2cfe5*/\n {\nLABEL_4:\n if ( !n3_1 ) /*0xffe2d000*/\n return 0; /*0xffe2d000*/\n goto LABEL_5; /*0xffe2d000*/\n }\n n3_1 = n3; /*0xffe2cfe7*/\n if ( !n3 ) /*0xffe2cfef*/\n {\n n3_1 = MEMORY[0xFDAF0490] & 2 | 1; /*0xffe2cffb*/\n goto LABEL_4; /*0xffe2cffb*/\n }\nLABEL_5:\n if ( n3_1 != -1 )\n return n3_1 != 1 ? -2147483578 : -2147483644;\n return 0; /*0xffe2d018*/\n}","refs":[{"addr":"0xffe2d4d0","name":"n3"}]}
{"addr":"0xffe2d069","code":"int GetPeiServicesTable()\n{\n int v0; // esi\n _BYTE v2[2]; // [esp+4h] [ebp-8h] BYREF\n int v3; // [esp+6h] [ebp-6h]\n\n AsmReadIdtr(v2); /*0xffe2d072*/\n v0 = *(_DWORD *)(v3 - 4); /*0xffe2d07a*/\n if ( !v0 ) /*0xffe2d07f*/\n DebugAssert( /*0xffe2d08e*/\n (int)\"e:\\\\hs\\\\MdePkg\\\\Library\\\\PeiServicesTablePointerLibIdt\\\\PeiServicesTablePointer.c\",\n 48,\n (int)\"PeiServices != ((void *) 0)\");\n return v0; /*0xffe2d096*/\n}","refs":[{"addr":"0xffe2d09b","name":"AsmReadIdtr"},{"addr":"0xffe2cfaf","name":"DebugAssert"},{"addr":"0xffe2d234","name":"aEHsMdepkgLibra","string":"e:\\hs\\MdePkg\\Library\\PeiServicesTablePointerLibIdt\\PeiServicesTablePointer.c"},{"addr":"0xffe2d214","name":"aPeiservicesVoi","string":"PeiServices != ((void *) 0)"}]}
{"addr":"0xffe2d09b","code":"void *__thiscall AsmReadIdtr(void *this)\n{\n void *this_1; // eax\n\n if ( !this ) /*0xffe2d0a1*/\n DebugAssert((int)\"e:\\\\hs\\\\MdePkg\\\\Library\\\\BaseLib\\\\X86ReadIdtr.c\", 37, (int)\"Idtr != ((void *) 0)\"); /*0xffe2d0b0*/\n this_1 = this; /*0xffe2d0b6*/\n __sidt(this); /*0xffe2d0b9*/\n return this_1; /*0xffe2d0bd*/\n}","refs":[{"addr":"0xffe2cfaf","name":"DebugAssert"},{"addr":"0xffe2d29c","name":"aEHsMdepkgLibra_0","string":"e:\\hs\\MdePkg\\Library\\BaseLib\\X86ReadIdtr.c"},{"addr":"0xffe2d284","name":"aIdtrVoid0","string":"Idtr != ((void *) 0)"}]}
{"addr":"0xffe2d0be","code":"int __thiscall GetPcdPpi(void *this)\n{\n int ( **PcdProtocol)(int); // eax\n\n PcdProtocol = (int ( **)(int))GetPcdProtocol(this); /*0xffe2d0be*/\n return PcdProtocol[4](5); /*0xffe2d0c9*/\n}","refs":[{"addr":"0xffe2d0db","name":"GetPcdProtocol"}]}
{"addr":"0xffe2d0ca","code":"int __thiscall PcdSetSku(void *this)\n{\n int v1; // ebx\n int DebugOutput; // eax\n\n v1 = GetPcdPpi(this) + 1024064; /*0xffe2d03a*/\n if ( (v1 & 1) != 0 ) /*0xffe2d03f*/\n {\n DebugOutput = GetDebugOutput(); /*0xffe2d041*/\n if ( DebugOutput ) /*0xffe2d048*/\n (*(void ( **)(const char *, int, const char *))(DebugOutput + 4))( /*0xffe2d059*/\n \"e:\\\\hs\\\\MdePkg\\\\Library\\\\BaseIoLibIntrinsic\\\\IoLib.c\",\n 183,\n \"(Address & 1) == 0\");\n }\n *(_WORD *)v1 = 1280; /*0xffe2d064*/\n return 1280; /*0xffe2d068*/\n}","refs":[{"addr":"0xffe2d0be","name":"GetPcdPpi"},{"addr":"0xffe2cf54","name":"GetDebugOutput"},{"addr":"0xffe2d1d0","name":"aEHsMdepkgLibra_1","string":"e:\\hs\\MdePkg\\Library\\BaseIoLibIntrinsic\\IoLib.c"},{"addr":"0xffe2d200","name":"aAddress10","string":"(Address & 1) == 0"}]}
{"addr":"0xffe2d0db","code":"void *__thiscall GetPcdProtocol(void *this)\n{\n int PeiServicesTable; // eax\n int v2; // eax\n int DebugOutput; // eax\n void *this_1; // [esp+0h] [ebp-4h]\n\n this_1 = this; /*0xffe2d0de*/\n PeiServicesTable = GetPeiServicesTable(); /*0xffe2d0df*/\n v2 = (*(int (__stdcall **)(int))(*(_DWORD *)PeiServicesTable + 32))(PeiServicesTable); /*0xffe2d0f4*/\n if ( v2 < 0 ) /*0xffe2d0fc*/\n {\n DebugPrint(0x80000000, (int)\"\\nASSERT_EFI_ERROR (Status = %r)\\n\", v2); /*0xffe2d109*/\n DebugOutput = GetDebugOutput(); /*0xffe2d111*/\n if ( DebugOutput ) /*0xffe2d118*/\n (*(void ( **)(const char *, int, const char *))(DebugOutput + 4))( /*0xffe2d126*/\n \"e:\\\\hs\\\\MdePkg\\\\Library\\\\PeiPcdLib\\\\PeiPcdLib.c\",\n 49,\n \"!EFI_ERROR (Status)\");\n }\n return this_1; /*0xffe2d131*/\n}","refs":[{"addr":"0xffe2d069","name":"GetPeiServicesTable"},{"addr":"0xffe2cf85","name":"DebugPrint"},{"addr":"0xffe2d134","name":"aAssertEfiError","string":"\nASSERT_EFI_ERROR (Status = %r)\n"},{"addr":"0xffe2cf54","name":"GetDebugOutput"},{"addr":"0xffe2d2c8","name":"aEHsMdepkgLibra_2","string":"e:\\hs\\MdePkg\\Library\\PeiPcdLib\\PeiPcdLib.c"},{"addr":"0xffe2d158","name":"aEfiErrorStatus","string":"!EFI_ERROR (Status)"}]}