//
// TCMPEI.efi - cleaned decompilation
//
#include <Uefi.h>
#include <PiPei.h>
#define TcmBaseRegister ((volatile UINT8 *)(UINTN)0xFFE2ECDC)
#define TcmEntryContext ((void *)(UINTN)0xFFE2ECD0)
char *internal_memcpy(char *dst, char *src, unsigned int count)
{
unsigned int count_1;
char *dst_1;
char *src_1;
count_1 = count;
if (src < dst && &src[count - 1] >= dst) {
src_1 = &src[count - 1];
dst_1 = &dst[count - 1];
} else {
count_1 = count & 3;
qmemcpy(dst, src, 4 * (count >> 2));
src_1 = &src[4 * (count >> 2)];
dst_1 = &dst[4 * (count >> 2)];
}
qmemcpy(dst_1, src_1, count_1);
return dst;
}
void *internal_memset(void *buf, unsigned int count, char value)
{
memset(buf, value, count);
return buf;
}
int fn_addr(int a1, int a2, int a3, int a4)
{
do {
*(_DWORD *)(a1 + 8 * a2 - 8) = a3;
*(_DWORD *)(a1 + 8 * a2-- - 4) = a4;
} while (a2);
return a1;
}
void *internal_memset32(void *buf, unsigned int count, int value)
{
memset32(buf, value, count);
return buf;
}
EFI_STATUS ModuleEntryPoint(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
{
void *v2;
void *v3;
int v4;
if (*(char *)(TcmGetPcdBaseAddress(v2) + 1024068) >= 0) {
TcmSetLocality();
v4 = TcmGetPcdBaseAddress(v3);
*(_BYTE *)(v4 + 1024068) |= 0x80u;
}
if (*(_WORD *)(TcmBaseRegister + 3840) == 6990)
return (*(int (**)(EFI_SYSTEM_TABLE *, void *))(LODWORD(SystemTable->Hdr.Signature) + 24))(SystemTable, TcmEntryContext);
return -1610612735;
}
int TcmStartup(int this, __int16 n2)
{
int v2;
__int16 v4;
int n201326592;
int v6;
__int16 v7;
_WORD v8[8];
v4 = -16128;
n201326592 = 201326592;
v6 = -1719664640;
v7 = __ROL2__(n2, 8);
v2 = TcmFifoTransmit((int)TcmBaseRegister, (int)&v4, 0xCu, (int)v8, 10);
return TcmCheckResponse(v2, v8);
}
int TcmContinueSelfTest()
{
int v0;
_WORD v2[6];
__int16 v3;
int n167772160;
int n1400897536;
n167772160 = 167772160;
v3 = -16128;
n1400897536 = 1400897536;
v0 = TcmFifoTransmit((int)TcmBaseRegister, (int)&v3, 0xAu, (int)v2, 10);
return TcmCheckResponse(v0, v2);
}
int TcmSetDeactivated()
{
int v0;
_WORD v2[6];
__int16 v3;
int n167772160;
int n1887436800;
n167772160 = 167772160;
v3 = -16128;
n1887436800 = 1887436800;
v0 = TcmFifoTransmit((int)TcmBaseRegister, (int)&v3, 0xAu, (int)v2, 10);
return TcmCheckResponse(v0, v2);
}
int TcmSetPhysicalPresence(int this, char a2)
{
int v2;
__int16 v4;
int n184549376;
int n1920991232;
char v7;
_WORD v8[8];
n184549376 = 184549376;
v4 = -16128;
n1920991232 = 1920991232;
v7 = a2;
v2 = TcmFifoTransmit((int)TcmBaseRegister, (int)&v4, 0xBu, (int)v8, 10);
return TcmCheckResponse(v2, v8);
}
int __usercall TcmBuildCommandPacket@<eax>(unsigned int n4@<edx>, unsigned int n0x108, int n17, int a4)
{
int n17_1;
int v5;
_BYTE *v6;
_WORD v8[7];
_BYTE v9[22];
__int16 v10;
int n369098752;
int n1702887424;
unsigned __int32 v13;
int n0x4000000;
unsigned __int32 v15;
n17_1 = n17;
v10 = -16128;
v15 = _byteswap_ulong(n0x108);
n369098752 = 369098752;
n1702887424 = 1702887424;
v13 = _byteswap_ulong(n4);
n0x4000000 = 0x4000000;
v5 = TcmFifoTransmit((int)TcmBaseRegister, (int)&v10, 0x16u, (int)v8, n17 + 14);
v6 = (_BYTE *)(n17 + a4);
do {
--v6;
*v6 = v9[(_DWORD)v6 - a4];
--n17_1;
} while (n17_1);
return TcmCheckResponse(v5, v8);
}
int __thiscall TcmStartupClear(void *this)
{
int v1;
int v2;
int v3;
v1 = TcmStartup((int)this, 1);
v2 = v1;
if (v1) {
TcmDebugPrint(0x80000000, "Tcm StartUp Clear error, returned %r\n", v1);
} else {
v3 = TcmContinueSelfTest();
v2 = v3;
if (v3)
TcmDebugPrint(0x80000000, "Tcm ContinueSelfTest error, returned %r\n", v3);
}
return v2;
}
int __thiscall TcmStartupState(void *this)
{
int v1;
int v2;
int v3;
v1 = TcmStartup((int)this, 2);
v2 = v1;
if (v1) {
TcmDebugPrint(0x80000000, "Tcm Startup state error, returned %r\n", v1);
} else {
v3 = TcmContinueSelfTest();
v2 = v3;
if (v3)
TcmDebugPrint(0x80000000, "Tcm ContinueSelfTest error, returned %r\n", v3);
}
return v2;
}
int TcmPhysicalEnable()
{
int v0;
int v1;
int v2;
int v3;
int v5;
_WORD v6[6];
__int16 v7;
int n167772160;
int n1870659584;
n167772160 = 167772160;
v7 = -16128;
n1870659584 = 1870659584;
v0 = TcmFifoTransmit((int)TcmBaseRegister, (int)&v7, 0xAu, (int)v6, 10);
v1 = TcmCheckResponse(v0, v6);
v2 = v1;
if (v1) {
TcmDebugPrint(0x80000000, "Tcm Physical enable error, returned %r\n", v1);
} else {
v3 = TcmSetPhysicalPresence(v5, 0);
v2 = v3;
if (v3)
TcmDebugPrint(0x80000000, "Tcm Set activate error, returned %r\n", v3);
}
return v2;
}
int __thiscall TcmPhysicalSetDeactivated(void *this)
{
int v1;
int v2;
int v3;
v1 = TcmSetPhysicalPresence((int)this, 1);
v2 = v1;
if (v1) {
TcmDebugPrint(0x80000000, "Tcm Set deactivate error, returned %r\n", v1);
} else {
v3 = TcmSetDeactivated();
v2 = v3;
if (v3)
TcmDebugPrint(0x80000000, "Tcm Physical disable error, returned %r\n", v3);
}
return v2;
}
int TcmForceClear()
{
int v0;
int v1;
int v2;
_WORD v4[6];
__int16 v5;
int n167772160;
int n1568669696;
n167772160 = 167772160;
v5 = -16128;
n1568669696 = 1568669696;
v0 = TcmFifoTransmit((int)TcmBaseRegister, (int)&v5, 0xAu, (int)v4, 10);
v1 = TcmCheckResponse(v0, v4);
v2 = v1;
if (v1)
TcmDebugPrint(0x80000000, "Tcm Force clear error, returned %r\n", v1);
return v2;
}
int TcmGetFlags(bool *a1, bool *a2, bool *a3)
{
int v3;
int v4;
bool v6;
int v7;
_BYTE v8[23];
char v9;
v3 = TcmBuildCommandPacket(4u, 0x108u, 17, (int)v8);
v4 = v3;
if (v3) {
TcmDebugPrint(0x80000000, "Tcm Get Pflag error, returned %r\n", v3);
return v4;
}
v6 = v8[4] == 0;
*a1 = v8[2] == 0;
*a2 = v6;
v7 = TcmBuildCommandPacket(5u, 0x111u, 1, (int)&v9);
v4 = v7;
if (v7) {
TcmDebugPrint(0x80000000, "Tcm Get Vflag error, returned %r\n", v7);
return v4;
}
*a3 = v9 != 0;
return 0;
}
int TcmCheckResponse(int a1, _WORD *a2)
{
if (!a1 && *a2 != 0xC400) {
TcmDebugPrint(0x80000000, "Tcm no response.\n");
return -2147483632;
}
return a1;
}
int TcmSm3CompressionFunction(_DWORD *dst, _DWORD *a2, int *this)
{
int n2043430169;
int v4;
int v5;
int v6;
int v7;
int n16;
int v9;
int v10;
int v11;
int v12;
_DWORD *v13;
int v14;
int v15;
int v16;
_DWORD *v17;
int v18;
int v19;
int v20;
int v22;
int v23;
int v24;
int v27;
int n16_1;
int v29;
int v30;
int v31;
int v32;
n2043430169 = 2043430169;
v4 = *this;
v5 = *(this + 2);
v6 = *(this + 4);
v31 = *(this + 3);
v23 = *(this + 5);
v24 = *(this + 6);
v7 = *(this + 1);
v32 = *(this + 7);
n16 = 0;
v22 = *this;
v27 = v5;
n16_1 = 0;
while (1) {
if (n16)
n2043430169 = n16 == 16 ? -1651869049 : __ROL4__(n2043430169, 1);
else
n2043430169 = 2043430169;
v9 = __ROL4__(v4, 12);
v10 = __ROL4__(n2043430169 + v9 + v6, 7);
v11 = v10 ^ v9;
v29 = v10;
if (n16 > 15) {
v12 = v5 & v7 | v22 & (v5 | v7);
n16 = n16_1;
} else {
v12 = v5 ^ v7 ^ v22;
}
v13 = a2++;
v14 = v31 + v11 + v12 + *v13;
if (n16 > 15) {
v16 = v23 & v6 | v24 & ~v6;
v15 = v24;
} else {
v15 = v24;
v16 = v24 ^ v23 ^ v6;
}
v17 = dst++;
v18 = v32 + v29 + v16 + *v17;
v32 = v15;
v24 = __ROR4__(v23, 13);
v23 = v6;
v31 = v27;
v19 = v7;
v7 = v22;
v6 = v18 ^ __ROL4__(v18, 9) ^ __ROR4__(v18, 15);
v20 = __ROL4__(v19, 9);
v4 = v14;
n16 = n16_1 + 1;
v27 = v20;
v30 = v22;
v22 = v14;
n16_1 = n16;
if (n16 > 63)
break;
v5 = v20;
}
*this ^= v14;
*(this + 1) ^= v30;
*(this + 5) ^= v23;
*(this + 2) ^= v20;
*(this + 4) ^= v6;
*(this + 3) ^= v31;
*(this + 6) ^= v24;
*(this + 7) ^= v32;
return v24;
}
char TcmSm3WordSwap(int this, unsigned int n0x40, int thisa)
{
unsigned int v3;
char *v4;
char *v5;
char v6;
char result;
char v8;
v3 = n0x40 >> 2;
if (v3) {
v4 = (char *)(thisa + 1);
v5 = (char *)(this + 3);
do {
v6 = *(v4 - 1);
*(v4 - 1) = *v5;
result = *(v5 - 1);
*v5 = v6;
v5 += 4;
v8 = *v4;
*v4 = result;
v4 += 4;
*(v4 - 3) = v8;
--v3;
} while (v3);
}
return result;
}
int __thiscall TcmSm3ProcessBlock(int *this)
{
int *dst_1;
int n64;
_DWORD *dst_2;
int n52;
int v6;
int v7;
int v8;
int v9;
_DWORD dst[68];
_DWORD v13[64];
dst_1 = this + 10;
n64 = 64;
TcmSm3WordSwap((int)(this + 10), 0x40u, (int)(this + 10));
qmemcpy(dst, dst_1, 0x40u);
dst_2 = dst;
n52 = 52;
do {
v6 = dst_2[3];
v7 = *dst_2 ^ dst_2[7] ^ __ROL4__(dst_2[13], 15);
++dst_2;
dst_2[15] = v7 ^ dst_2[9] ^ __ROR4__(v7, 9) ^ __ROL4__(v7, 15) ^ __ROL4__(v6, 7);
--n52;
} while (n52);
v8 = 0;
do {
v9 = dst[v8 + 4];
++v8;
dst[v8 + 67] = dst[v8 - 1] ^ v9;
--n64;
} while (n64);
return TcmSm3CompressionFunction(dst, v13, this);
}
char __thiscall TcmSm3Finalize(int this)
{
int v2;
unsigned int n0x40;
v2 = *(_DWORD *)(this + 36);
*(_DWORD *)(this + 32) += 8 * v2;
*(_BYTE *)(v2 + this + 40) = 0x80;
n0x40 = ++*(_DWORD *)(this + 36);
if (n0x40 > 0x38) {
while (n0x40 < 0x40) {
*(_BYTE *)(this + n0x40 + 40) = 0;
n0x40 = ++*(_DWORD *)(this + 36);
}
TcmSm3ProcessBlock((int *)this);
*(_DWORD *)(this + 36) = 0;
}
while (*(_DWORD *)(this + 36) < 0x38u)
*(_BYTE *)(this + (*(_DWORD *)(this + 36))++ + 40) = 0;
*(_DWORD *)(this + 96) = 0;
*(_BYTE *)(this + 103) = *(_BYTE *)(this + 32);
*(_BYTE *)(this + 102) = BYTE1(*(_DWORD *)(this + 32));
*(_BYTE *)(this + 101) = *(_BYTE *)(this + 34);
*(_BYTE *)(this + 100) = *(_BYTE *)(this + 35);
TcmSm3ProcessBlock((int *)this);
return TcmSm3WordSwap(this, 0x20u, this);
}
char TcmSm3(_BYTE *a1, int a2)
{
int n64;
int v6[8];
int v7;
int n64_1;
_BYTE v9[64];
v7 = 0;
v6[0] = 1937774191;
v6[1] = 1226093241;
v6[2] = 388252375;
v6[3] = -628488704;
v6[4] = -1452330820;
v6[5] = 372324522;
v6[6] = -477237683;
v6[7] = -1325724082;
LABEL_4:
n64 = 0;
n64_1 = 0;
while (a2) {
--a2;
v9[n64] = *a1++;
n64 = n64_1 + 1;
n64_1 = n64;
if (n64 == 64) {
TcmSm3ProcessBlock(v6);
v7 += 512;
goto LABEL_4;
}
}
return TcmSm3Finalize((int)v6);
}
int TcmPcrExtend(int a1, _BYTE *a2, int a3, char *src, __int16 a5)
{
int v5;
__int16 v7;
int n738197504;
int n343932928;
__int16 v10;
char dst[32];
_WORD v12[6];
TcmSm3(a2, a3);
n738197504 = 738197504;
v7 = -16128;
n343932928 = 343932928;
v10 = a5;
TcmMemoryCopy(dst, src, 0x20u);
v5 = TcmFifoTransmit(a1, (int)&v7, 0x2Cu, (int)v12, 10);
return TcmCheckResponse(v5, v12);
}
int __thiscall TcmMicroDelay(void *this)
{
unsigned __int64 v1;
__int64 v3;
v3 = TcmGetTimeConstant();
LODWORD(v1) = v3;
HIDWORD(v1) = HIDWORD(v3) % 0xF4240;
return TcmDelayCycles(v1 / 0xF4240);
}
int TcmWaitForStatusBits(_BYTE *a1, unsigned __int8 n0x40, unsigned __int8 n8)
{
int v5;
v5 = 0;
while ((n0x40 & *a1) != n0x40 || (*a1 & n8) != 0) {
TcmMicroDelay(a1);
if ((unsigned int)++v5 >= 0xC350)
return 1;
}
return 0;
}
int TcmReadStatusRegister(unsigned __int8 a1, _WORD *p_i)
{
int v4;
int v5;
unsigned __int8 v6;
bool v7;
void *v8;
if (!p_i)
return 2;
v4 = 0;
v5 = a1 << 12;
while (1) {
v6 = *(_BYTE *)(v5 - 19660775);
v8 = (void *)(*(unsigned __int8 *)(v5 - 19660774) << 8);
v7 = v6 + (_WORD)v8 == 0;
LOWORD(v8) = v6 + (_WORD)v8;
*p_i = (_WORD)v8;
if (!v7)
break;
TcmMicroDelay(v8);
if ((unsigned int)++v4 >= 0xC350)
return 1;
}
return 0;
}
int TcmSetCommandReady(unsigned __int8 a1)
{
_BYTE *v2;
v2 = (_BYTE *)((a1 << 12) - 19660776);
*v2 = 64;
return TcmWaitForStatusBits(v2, 0x40u, 0);
}
int TcmFifoIO(unsigned __int8 a1, int a2, unsigned int a3, int a4, unsigned int *a5)
{
int result;
int v6;
_BYTE *v7;
char v8;
unsigned __int8 v9;
unsigned int v10;
int i;
char v12;
int n4_1;
unsigned int n0xA;
int i_2;
unsigned int n0xA_1;
int n4;
int i_1;
int v20;
unsigned int dst_;
int v22;
_BYTE *v23;
v20 = a2;
if (MEMORY[0xFED40000] == 0xFF)
return 3;
v6 = a1 << 12;
v22 = v6;
v7 = (_BYTE *)(v6 - 19660800);
v8 = *(_BYTE *)(v6 - 19660800);
v23 = (_BYTE *)(v6 - 19660800);
if (v8 == -1)
return 6;
*v7 = 2;
result = TcmWaitForStatusBits(v7, 0xA0u, 0);
if (!result) {
v9 = a1;
result = TcmSetCommandReady(a1);
if (!result) {
v10 = 0;
if (a3) {
while (!TcmReadStatusRegister(a1, &i_1)) {
for (i = i_1; (_WORD)i; i_1 = i) {
if (v10 >= a3)
goto LABEL_14;
v12 = *(_BYTE *)(v10 + v20);
++v10;
i += 0xFFFF;
*(_BYTE *)(v6 - 19660764) = v12;
}
if (v10 >= a3)
goto LABEL_14;
}
goto LABEL_36;
}
LABEL_14:
if (TcmWaitForStatusBits((_BYTE *)(v6 - 19660776), 0x80u, 8u)) {
n4 = 4;
} else {
*(_BYTE *)(v6 - 19660776) = 32;
if (TcmWaitForStatusBits((_BYTE *)(v6 - 19660776), 0x90u, 0))
goto LABEL_36;
n0xA = 0;
i_1 = 0;
while (2) {
n4_1 = TcmReadStatusRegister(v9, &i_1);
if (n4_1) {
LABEL_36:
n4_1 = 1;
goto LABEL_37;
}
LOWORD(i_2) = i_1;
while ((_WORD)i_2) {
i_2 = i_1;
*(_BYTE *)(n0xA + a4) = *(_BYTE *)(v6 - 19660764);
if (++n0xA == 10)
goto LABEL_26;
i_2 += 0xFFFF;
i_1 = i_2;
}
if (n0xA < 0xA) {
v9 = a1;
continue;
}
break;
}
LABEL_26:
TcmMemoryCopy((char *)&dst_, (char *)(a4 + 2), 4u);
n0xA_1 = (((dst_ << 16) | dst_ & 0xFF00) << 8) | ((HIWORD(dst_) | dst_ & 0xFF0000) >> 8);
if (*a5 >= n0xA_1) {
*a5 = n0xA_1;
if (n0xA < n0xA_1) {
while (!(_WORD)i_2) {
LABEL_32:
n4_1 = TcmReadStatusRegister(a1, &i_1);
if (n4_1)
goto LABEL_36;
if (n0xA >= n0xA_1)
goto LABEL_37;
LOWORD(i_2) = i_1;
}
while (1) {
*(_BYTE *)(n0xA + a4) = *(_BYTE *)(v22 - 19660764);
if (++n0xA == n0xA_1)
break;
i_1 += 0xFFFF;
if (!(_WORD)i_1)
goto LABEL_32;
}
n4_1 = 0;
}
goto LABEL_37;
}
n4 = 5;
}
n4_1 = n4;
LABEL_37:
TcmSetCommandReady(a1);
*v23 = 32;
return n4_1;
}
}
return result;
}
int TcmFifoTransmit(int a1, int a2, unsigned int a3, int a4, int a5)
{
return TcmFifoIO((unsigned int)(a1 + 19660800) >> 12, a2, a3, a4, (unsigned int *)&a5);
}
char *TcmMemoryCopy(char *dst, char *src, unsigned int n32)
{
int v5;
int v6;
if (n32 - 1 > -1 - (int)dst) {
v5 = TcmGetPeiServices();
if (v5)
(*(void (**)(const char *, int, const char *))(v5 + 4))("e:\\hs\\MdePkg\\Library\\BaseMemoryLibRepStr\\CopyMemWrapper.c", 56, "(Length - 1) <= (0xFFFFFFFF - (UINTN)DestinationBuffer)");
}
if (n32 - 1 > -1 - (int)src) {
v6 = TcmGetPeiServices();
if (v6)
(*(void (**)(const char *, int, const char *))(v6 + 4))("e:\\hs\\MdePkg\\Library\\BaseMemoryLibRepStr\\CopyMemWrapper.c", 57, "(Length - 1) <= (0xFFFFFFFF - (UINTN)SourceBuffer)");
}
if (dst == src)
return dst;
return internal_memcpy(dst, src, n32);
}
int TcmGetPeiServices()
{
int v0;
_BYTE v2[4];
int v3;
v0 = TcmGetPeiServicesFromTable();
if ((*(int (**)(int, void *, _DWORD, _BYTE *, int *))(*(_DWORD *)v0 + 32))(v0, &unk_FFE2EC80, 0, v2, &v3) >= 0)
return v3;
return 0;
}
int TcmDebugPrint(int a1, const char *a2, ...)
{
int result;
int (**v3)(int, const char *, char *);
va_list va;
va_start(va, a2);
result = TcmGetPeiServices();
v3 = (int (**)(int, const char *, char *))result;
if (result) {
result = TcmGetTpmDebugLevel();
if ((result & a1) != 0)
return (*v3)(a1, a2, (char *)va);
}
return result;
}
int TcmPeiServicesAssert(int e, int n48, int PeiServices)
{
int result;
result = TcmGetPeiServices();
if (result)
return (*(int (**)(int, int, int))(result + 4))(e, n48, PeiServices);
return result;
}
unsigned int TcmDelayCycles(unsigned int a1)
{
unsigned int v1;
unsigned int n0x400000;
unsigned __int32 v3;
unsigned int result;
v1 = a1 >> 22;
n0x400000 = a1 & 0x3FFFFF;
do {
v3 = n0x400000 + (TcmIoRead32(0x508u) & 0xFFFFFF);
n0x400000 = 0x400000;
while (((v3 - TcmIoRead32(0x508u)) & 0x800000) == 0)
_mm_pause();
result = v1--;
} while (result);
return result;
}
int TcmGetTpmDebugLevel()
{
unsigned __int8 v0;
char n3;
char n3_1;
v0 = __inbyte(0x70u);
__outbyte(0x70u, v0 & 0x80 | 0x4A);
n3 = __inbyte(0x71u);
n3_1 = n3;
if ((unsigned __int8)n3 <= 3u) {
LABEL_4:
if (!n3_1)
return 0;
goto LABEL_5;
}
n3_1 = n3;
if (!n3) {
n3_1 = MEMORY[0xFDAF0490] & 2 | 1;
goto LABEL_4;
}
LABEL_5:
if (n3_1 != -1)
return n3_1 != 1 ? -2147483578 : -2147483644;
return 0;
}
unsigned __int32 __thiscall TcmIoRead32(unsigned __int16 n1288)
{
int v2;
if ((n1288 & 3) != 0) {
v2 = TcmGetPeiServices();
if (v2)
(*(void (**)(const char *, int, const char *))(v2 + 4))("e:\\hs\\MdePkg\\Library\\BaseIoLibIntrinsic\\IoLibMsc.c", 193, "(Port & 3) == 0");
}
return __indword(n1288);
}
__int64 TcmGetTimeConstant()
{
return 107386350;
}
int TcmGetPeiServicesFromTable()
{
int v0;
_BYTE v2[2];
int v3;
TcmReadIdtr(v2);
v0 = *(_DWORD *)(v3 - 4);
if (!v0)
TcmPeiServicesAssert((int)"e:\\hs\\MdePkg\\Library\\PeiServicesTablePointerLibIdt\\PeiServicesTablePointer.c", 48, (int)"PeiServices != ((void *) 0)");
return v0;
}
void *__thiscall TcmReadIdtr(void *this)
{
void *this_1;
if (!this)
TcmPeiServicesAssert((int)"e:\\hs\\MdePkg\\Library\\BaseLib\\X86ReadIdtr.c", 37, (int)"Idtr != ((void *) 0)");
this_1 = this;
__sidt(this);
return this_1;
}
int __thiscall TcmGetPcdBaseAddress(void *this)
{
int (**v1)(int);
v1 = (int (**)(int))TcmGetPcdInterface(this);
return v1[4](5);
}
int __thiscall TcmSetLocality(void *this)
{
int v1;
int v2;
v1 = TcmGetPcdBaseAddress(this) + 1024064;
if ((v1 & 1) != 0) {
v2 = TcmGetPeiServices();
if (v2)
(*(void (**)(const char *, int, const char *))(v2 + 4))("e:\\hs\\MdePkg\\Library\\BaseIoLibIntrinsic\\IoLib.c", 183, "(Address & 1) == 0");
}
*(_WORD *)v1 = 1280;
return 1280;
}
void *__thiscall TcmGetPcdInterface(void *this)
{
int v1;
int v2;
int v3;
void *this_1;
this_1 = this;
v1 = TcmGetPeiServicesFromTable();
v2 = (*(int (__stdcall **)(int))(*(_DWORD *)v1 + 32))(v1);
if (v2 < 0) {
TcmDebugPrint(0x80000000, "\nASSERT_EFI_ERROR (Status = %r)\n", v2);
v3 = TcmGetPeiServices();
if (v3)
(*(void (**)(const char *, int, const char *))(v3 + 4))("e:\\hs\\MdePkg\\Library\\PeiPcdLib\\PeiPcdLib.c", 49, "!EFI_ERROR (Status)");
}
return this_1;
}