void *SetMem(void *buf, unsigned __int64 count, char value)
{
memset(buf, value, count); /*0x2aa*/
return buf; /*0x2af*/
}
void CpuPause()
{
_mm_pause(); /*0x300*/
}
unsigned __int64 AsmReadTsc()
{
return __rdtsc(); /*0x319*/
}
void EnableInterrupts()
{
_enable(); /*0x320*/
}
void DisableInterrupts()
{
_disable(); /*0x330*/
}
unsigned __int64 AsmReadEflags()
{
return __getcallerseflags(); /*0x342*/
}
char *__fastcall CopyMem(char *dst, char *src, unsigned __int64 count)
{
char *dst_2; // rax
unsigned __int64 count_1; // rcx
char *dst_1; // rdi
char *src_1; // rsi
dst_2 = dst; /*0x360*/
if ( src < dst && &src[count - 1] >= dst ) /*0x368*/
{
src_1 = &src[count - 1]; /*0x380*/
dst_1 = &dst[count - 1]; /*0x383*/
}
else
{
count_1 = count; /*0x36a*/
count &= 7u; /*0x36d*/
count_1 >>= 3; /*0x374*/
qmemcpy(dst, src, 8 * count_1); /*0x378*/
src_1 = &src[8 * count_1]; /*0x378*/
dst_1 = &dst[8 * count_1]; /*0x378*/
}
qmemcpy(dst_1, src_1, count); /*0x38c*/
return dst_2; /*0x38f*/
}
__int64 GetDebugPrintProtocol()
{
__int64 result; // rax
unsigned __int64 n0x10; // rbx
__int64 v2; // rax
__int64 v3; // rcx
result = qword_7948; /*0x5392*/
if ( !qword_7948 ) /*0x539e*/
{
n0x10 = (*(__int64 (__fastcall **)(__int64))(qword_7930 + 24))(31); /*0x53b7*/
(*(void (__fastcall **)(unsigned __int64))(qword_7930 + 32))(n0x10); /*0x53ba*/
if ( n0x10 <= 0x10 ) /*0x53c1*/
{
v2 = (*(__int64 (__fastcall **)(void *, _QWORD, __int64 *))(qword_7930 + 320))(&unk_73A0, 0, &qword_7948); /*0x53de*/
v3 = qword_7948; /*0x53e4*/
if ( v2 < 0 ) /*0x53ee*/
v3 = 0; /*0x53ee*/
qword_7948 = v3; /*0x53f2*/
return v3; /*0x53f9*/
}
else
{
return 0; /*0x53c3*/
}
}
return result; /*0x5401*/
}
__int64 DebugPrint(__int64 a1, const char *a2, ...)
{
__int64 result; // rax
__int64 (__fastcall **v4)(__int64, const char *, __int64 *); // r10
va_list va; // [rsp+40h] [rbp+18h] BYREF
va_start(va, a2);
result = GetDebugPrintProtocol(); /*0x541f*/
if ( result ) /*0x542a*/
{
result = GetPchRevision(); /*0x542c*/
if ( ((unsigned int)result & (unsigned int)a1) != 0 ) /*0x5437*/
return (*v4)(a1, a2, (__int64 *)va); /*0x5446*/
}
return result; /*0x5449*/
}
__int64 __fastcall DebugAssert(__int64 a1, __int64 a2, __int64 a3)
{
__int64 result; // rax
result = GetDebugPrintProtocol(); /*0x5468*/
if ( result ) /*0x5470*/
return (*(__int64 (__fastcall **)(__int64, __int64, __int64))(result + 8))(a1, a2, a3); /*0x547b*/
return result; /*0x5488*/
}
void *__fastcall SetMemZero(char *p_n2, unsigned __int64 n256)
{
if ( n256 - 1 > -1 - (__int64)p_n2 ) /*0x54ae*/
DebugAssert( /*0x54c3*/
(__int64)"e:\\hs\\MdePkg\\Library\\BaseMemoryLibRepStr\\SetMemWrapper.c",
54,
(__int64)"(Length - 1) <= (0xFFFFFFFFFFFFFFFFULL - (UINTN)Buffer)");
return SetMem(p_n2, n256, 0); /*0x54d6*/
}
unsigned __int64 __fastcall LocateConfigurationTable(__int64 a1, _QWORD *a2)
{
__int64 v4; // rdi
__int64 v5; // rbx
__int64 i; // r14
if ( !a1 ) /*0x5502*/
DebugAssert((__int64)"e:\\hs\\MdePkg\\Library\\UefiLib\\UefiLib.c", 97, (__int64)"TableGuid != ((void *) 0)"); /*0x5515*/
if ( !a2 ) /*0x551d*/
DebugAssert((__int64)"e:\\hs\\MdePkg\\Library\\UefiLib\\UefiLib.c", 98, (__int64)"Table != ((void *) 0)"); /*0x5530*/
v4 = qword_7928; /*0x5535*/
v5 = 0; /*0x553c*/
*a2 = 0; /*0x553e*/
if ( !*(_QWORD *)(v4 + 104) ) /*0x5542*/
return 0x800000000000000EuLL; /*0x556b*/
for ( i = 0; !(unsigned __int8)CompareGuid(a1, i + *(_QWORD *)(v4 + 112)); i += 24 ) /*0x5548*/
{
if ( (unsigned __int64)++v5 >= *(_QWORD *)(v4 + 104) ) /*0x5569*/
return 0x800000000000000EuLL; /*0x5569*/
}
*a2 = *(_QWORD *)(*(_QWORD *)(v4 + 112) + 24 * v5 + 16); /*0x559f*/
return 0; /*0x5589*/
}
__int64 GetLpcDeviceId()
{
_DWORD v1[6]; // [rsp+20h] [rbp-18h] BYREF
v1[3] = 0; /*0x55ab*/
v1[1] = 0; /*0x55b3*/
v1[2] = 512; /*0x55b7*/
v1[0] = 1015808; /*0x55be*/
return (*(__int64 (__fastcall **)(_DWORD *))(qword_7958 + 24))(v1); /*0x55cf*/
}
__int64 GetHobList()
{
__int64 result; // rax
signed __int64 v1; // rax
result = qword_7960; /*0x55d8*/
if ( !qword_7960 ) /*0x55e2*/
{
v1 = LocateConfigurationTable((__int64)&unk_7480, &qword_7960); /*0x55f2*/
if ( v1 < 0 ) /*0x55fa*/
{
DebugPrint(0x80000000LL, "\nASSERT_EFI_ERROR (Status = %r)\n", v1); /*0x560b*/
DebugAssert((__int64)"e:\\hs\\MdePkg\\Library\\DxeHobLib\\HobLib.c", 54, (__int64)"!EFI_ERROR (Status)"); /*0x5623*/
}
result = qword_7960; /*0x5628*/
if ( !qword_7960 ) /*0x5632*/
{
DebugAssert((__int64)"e:\\hs\\MdePkg\\Library\\DxeHobLib\\HobLib.c", 55, (__int64)"mHobList != ((void *) 0)"); /*0x5645*/
return qword_7960; /*0x564a*/
}
}
return result; /*0x5651*/
}
__int64 __fastcall PciExpressAddress(__int64 n1024064)
{
if ( (n1024064 & 0xFFFFFFFFF0000000uLL) != 0 ) /*0x5668*/
DebugAssert( /*0x567d*/
(__int64)"e:\\hs\\MdePkg\\Library\\SmmPciExpressLib\\PciExpressLib.c",
118,
(__int64)"((Address) & ~0xfffffff) == 0");
return n1024064 + qword_7968; /*0x568c*/
}
__int64 __fastcall CompareMemPattern(unsigned __int64 a1)
{
_BYTE *v1; // rdx
unsigned __int64 v2; // r9
unsigned __int64 n8; // r10
unsigned __int64 v4; // r8
v1 = &unk_75F0; /*0x5697*/
v2 = a1 + 16; /*0x569e*/
n8 = a1 & 7; /*0x56a2*/
if ( (a1 & 7) != 0 && n8 == ((unsigned __int64)&unk_75F0 & 7) ) /*0x56b1*/
{
v4 = 8 - n8; /*0x56b9*/
if ( n8 != 8 ) /*0x56bc*/
{
do /*0x56ce*/
{
if ( *(_BYTE *)a1 != *v1 ) /*0x56c2*/
break; /*0x56c2*/
++a1; /*0x56c4*/
++v1; /*0x56c7*/
--v4; /*0x56ca*/
}
while ( v4 ); /*0x56ce*/
}
}
while ( a1 <= v2 - 8 && *(_QWORD *)a1 == *(_QWORD *)v1 ) /*0x56dc*/
{
a1 += 8LL; /*0x56de*/
v1 += 8; /*0x56e2*/
}
while ( 1 ) /*0x56f9*/
{
if ( a1 >= v2 ) /*0x56fc*/
return 0; /*0x5700*/
if ( *(_BYTE *)a1 != *v1 ) /*0x56f1*/
break; /*0x56f1*/
++a1; /*0x56f3*/
++v1; /*0x56f6*/
}
return *(char *)a1 - (char)*v1; /*0x5700*/
}
__int64 GetCurrentPchSku()
{
__int64 v0; // r11
__int64 v1; // rbx
unsigned __int64 v2; // rdi
__int64 v3; // rax
v0 = 0; /*0x5721*/
v1 = *(_QWORD *)(SystemTable + 104); /*0x5724*/
v2 = *(_QWORD *)(SystemTable + 112); /*0x5728*/
if ( v1 ) /*0x572f*/
{
while ( CompareMemPattern(v2) ) /*0x573c*/
{
v2 += 24LL; /*0x573e*/
if ( !--v1 ) /*0x5746*/
goto LABEL_4; /*0x5746*/
}
v3 = *(_QWORD *)(v2 + 16); /*0x5762*/
}
else
{
LABEL_4:
v3 = v0; /*0x5748*/
}
if ( v3 ) /*0x574e*/
LODWORD(v0) = *(_DWORD *)(v3 + 12); /*0x5750*/
return (unsigned int)v0; /*0x575c*/
}
__int64 __fastcall DetectInterposerCardInstall(_BYTE *a1, _BYTE *a2)
{
__int64 result; // rax
int v5; // [rsp+30h] [rbp+8h] BYREF
*a1 = 0; /*0x5775*/
*a2 = 0; /*0x577b*/
v5 = 1; /*0x5783*/
GetGpioPadConfig(16842767, &v5); /*0x5790*/
if ( !v5 ) /*0x579a*/
*a1 = 1; /*0x579c*/
result = GetGpioPadConfig(16842768, &v5); /*0x57a9*/
if ( !v5 ) /*0x57b3*/
*a2 = 1; /*0x57b5*/
return result; /*0x57bd*/
}
__int64 __fastcall ReadUnalignedQword(__int64 a1)
{
if ( !a1 ) /*0x5e88*/
DebugAssert((__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\Unaligned.c", 192, (__int64)"Buffer != ((void *) 0)"); /*0x5e9d*/
return *(_QWORD *)a1; /*0x5ea5*/
}
char *__fastcall CopyMemS(__int64 a1, char *src, unsigned __int64 count)
{
unsigned __int64 v6; // rbp
if ( !count ) /*0x5ec9*/
return dst; /*0x5ecb*/
v6 = count - 1; /*0x5ee2*/
if ( count - 1 > -1 - (__int64)dst ) /*0x5ee9*/
DebugAssert( /*0x5efe*/
(__int64)"e:\\hs\\MdePkg\\Library\\BaseMemoryLibRepStr\\CopyMemWrapper.c",
56,
(__int64)"(Length - 1) <= (0xFFFFFFFFFFFFFFFFULL - (UINTN)DestinationBuffer)");
if ( v6 > ~(unsigned __int64)src ) /*0x5f0c*/
DebugAssert( /*0x5f21*/
(__int64)"e:\\hs\\MdePkg\\Library\\BaseMemoryLibRepStr\\CopyMemWrapper.c",
57,
(__int64)"(Length - 1) <= (0xFFFFFFFFFFFFFFFFULL - (UINTN)SourceBuffer)");
if ( dst == src ) /*0x5f29*/
return dst; /*0x5f2b*/
else
return CopyMem(dst, src, count); /*0x5f39*/
}
bool __fastcall CompareGuid(__int64 a1, __int64 a2)
{
__int64 v4; // rsi
__int64 v5; // rbx
__int64 v6; // rdi
__int64 v7; // rax
v4 = ((__int64 (*)(void))ReadUnalignedQword)(); /*0x5f76*/
v5 = ReadUnalignedQword(a2); /*0x5f82*/
v6 = ReadUnalignedQword(a1 + 8); /*0x5f8e*/
v7 = ReadUnalignedQword(a2 + 8); /*0x5f91*/
return v4 == v5 && v6 == v7; /*0x5fb5*/
}
__int64 GetPchSku()
{
__int64 n3_1; // rax
unsigned int n3; // ebx
__int64 v2; // rax
unsigned __int16 v3; // ax
int v4; // edx
int n335; // eax
n3_1 = (unsigned int)n3_0; /*0x5fc2*/
n3 = 3; /*0x5fc8*/
if ( n3_0 == 3 )
{
v2 = GetLpcDeviceId(); /*0x5fd1*/
v3 = ReadUnaligned16(v2 + 2); /*0x5fda*/
v4 = v3; /*0x5fdf*/
if ( ((v3 + 24128) & 0xFF70) != 0 )
{
if ( (unsigned __int16)(v3 + 25280) <= 8u && (n335 = 335, _bittest(&n335, v4 + 25280)) )
{
n3 = 2; /*0x600a*/
}
else
{
DebugPrint(0x80000000LL, "Unsupported PCH SKU, LpcDeviceId: 0x%04x!\n", (unsigned __int16)v4);
DebugAssert( /*0x6039*/
(__int64)"e:\\hs\\PurleySktPkg\\SouthClusterLbg\\Library\\PeiDxeSmmPchInfoLib\\PchInfoLib.c",
252,
(__int64)"((BOOLEAN)(0==1))");
}
}
else
{
n3 = 1; /*0x6040*/
}
n3_0 = n3; /*0x6045*/
return n3; /*0x604b*/
}
return n3_1; /*0x604d*/
}
__int64 __fastcall Cpuid(unsigned int _RAX_1, _DWORD *a2, _DWORD *a3, _DWORD *a4, _DWORD *a5)
{
__int64 result; // rax
_RAX = _RAX_1; /*0x606f*/
__asm { cpuid } /*0x6074*/
if ( a2 ) /*0x6079*/
*a2 = result; /*0x607b*/
if ( a3 ) /*0x6081*/
*a3 = _RBX; /*0x6083*/
if ( a4 ) /*0x6089*/
*a4 = _RCX; /*0x608b*/
if ( a5 ) /*0x6091*/
*a5 = _RDX; /*0x6093*/
return result; /*0x6096*/
}
int *__fastcall SetMem32(int *buf_1, int value_2, unsigned __int64 n4)
{
int *buf; // rdi
int value_1; // eax
unsigned __int64 count; // rcx
__int16 value; // bx
int v7; // eax
__int64 v8; // rdx
char count_1; // dl
unsigned __int64 i; // rcx
buf = buf_1; /*0x60a3*/
value_1 = value_2; /*0x60a6*/
count = n4; /*0x60a9*/
BYTE1(value_1) = value_2; /*0x60ba*/
value = value_1; /*0x60bc*/
v7 = value_1 << 16; /*0x60bf*/
LOWORD(v7) = value; /*0x60c3*/
if ( n4 >= 4 ) /*0x60ca*/
{
v8 = (unsigned __int8)buf & 3; /*0x60cf*/
if ( ((unsigned __int8)buf & 3) != 0 ) /*0x60d3*/
{
memset(buf, value, 4 - v8); /*0x60e2*/
buf = (int *)((char *)buf + 4 - v8); /*0x60e2*/
count = n4 - (4 - v8); /*0x60e4*/
}
count_1 = count; /*0x60e7*/
for ( i = count >> 2; i; --i ) /*0x60ea*/
*buf++ = v7; /*0x60ee*/
count = count_1 & 3; /*0x60f4*/
}
memset(buf, value, count); /*0x60f7*/
return buf_1; /*0x60fa*/
}
char *__fastcall CopyMemPreserveFlags(char *dst_1, char *src, unsigned __int64 n8)
{
char *dst; // rdi
unsigned __int64 count_2; // rcx
char v10; // dl
unsigned __int64 n8_1; // rax
unsigned __int64 count; // rax
__int64 count_1; // rbx
char count_3; // al
unsigned __int64 v15; // rcx
unsigned __int64 count_4; // rax
__asm { pushf } /*0x6103*/
dst = dst_1; /*0x6109*/
count_2 = n8; /*0x610c*/
v10 = 0; /*0x610f*/
n8_1 = src - dst; /*0x6114*/
if ( src < dst ) /*0x6117*/
{
n8_1 = dst - src; /*0x611d*/
if ( &src[n8] >= dst ) /*0x6123*/
{
src += n8; /*0x6125*/
dst += n8; /*0x6128*/
v10 = 1; /*0x612c*/
}
}
if ( n8 < 8 || n8_1 < 8 ) /*0x6139*/
goto LABEL_19; /*0x6139*/
count = (unsigned __int8)src & 7; /*0x6141*/
count_1 = (unsigned __int8)dst & 7; /*0x6145*/
if ( v10 ) /*0x614b*/
{
--src; /*0x614d*/
--dst; /*0x6150*/
}
if ( count == count_1 && count ) /*0x615b*/
{
if ( !v10 ) /*0x615f*/
count = 8 - count; /*0x6164*/
qmemcpy(dst, src, count); /*0x616d*/
src += count; /*0x616d*/
dst += count; /*0x616d*/
count_2 = n8 - count; /*0x616f*/
}
if ( v10 ) /*0x6174*/
{
src -= 7; /*0x6176*/
dst -= 7; /*0x617a*/
}
count_3 = count_2; /*0x617e*/
v15 = count_2 >> 3; /*0x6181*/
qmemcpy(dst, src, 8 * v15); /*0x6185*/
src += 8 * v15; /*0x6185*/
dst += 8 * v15; /*0x6185*/
count_4 = count_3 & 7; /*0x6188*/
if ( count_4 ) /*0x618c*/
{
if ( v10 ) /*0x6190*/
{
src += 8; /*0x6192*/
dst += 8; /*0x6196*/
}
count_2 = count_4; /*0x619a*/
LABEL_19:
if ( v10 ) /*0x619f*/
{
--src; /*0x61a1*/
--dst; /*0x61a4*/
}
qmemcpy(dst, src, count_2); /*0x61a7*/
}
__asm { popf } /*0x61a9*/
return dst_1; /*0x61ac*/
}
unsigned __int32 __fastcall IoRead32(unsigned __int16 n1288)
{
if ( (n1288 & 3) != 0 ) /*0x5364*/
DebugAssert((__int64)"e:\\hs\\MdePkg\\Library\\BaseIoLibIntrinsic\\IoLibMsc.c", 193, (__int64)"(Port & 3) == 0"); /*0x5379*/
return __indword(n1288); /*0x5382*/
}