#include "CpuMpPei.h"
//
// CpuMpPei - UEFI Module (Regenerated from IDA)
// Total functions: 163
//
// Function: CopyMem @ 0xffe33ba4 (0x3f bytes)
// Index: 1/163
char *__cdecl CopyMem(char *dst, char *src, unsigned int count)
{
unsigned int count_1; // edx
char *dst_1; // edi
char *src_1; // esi
count_1 = count; /*0xffe33bae*/
if ( src < dst && &src[count - 1] >= dst ) /*0xffe33bbc*/
{
src_1 = &src[count - 1]; /*0xffe33bd0*/
dst_1 = &dst[count - 1]; /*0xffe33bd2*/
}
else
{
count_1 = count & 3; /*0xffe33bc0*/
qmemcpy(dst, src, 4 * (count >> 2)); /*0xffe33bc9*/
src_1 = &src[4 * (count >> 2)]; /*0xffe33bc9*/
dst_1 = &dst[4 * (count >> 2)]; /*0xffe33bc9*/
}
qmemcpy(dst_1, src_1, count_1); /*0xffe33bd9*/
return dst; /*0xffe33be0*/
}
// Function: AsmExceptionEntryDiv0 @ 0xffe33be4 (0xa bytes)
// Index: 2/163
// (too small: 0xa bytes)
// Function: AsmExceptionEntry0 @ 0xffe33d24 (0xa bytes)
// Index: 3/163
// (too small: 0xa bytes)
// Function: ExceptionContextSwitch @ 0xffe33d2e (0x208 bytes)
// Index: 4/163
// positive sp value has been detected, the output may be wrong!
void __usercall ExceptionContextSwitch(int ContextRecord@<edx>, __int32 ExceptionType@<ecx>, int StackFrame@<ebp>)
{
int ProcessorIndex; // eax
__int32 PreviousExceptionType; // ecx
__int32 SavedExceptionCode; // ecx
int ProcessorIndex2; // eax
unsigned int CpuIndex3; // ecx
__int32 ActiveExceptionCode; // ecx
unsigned __int32 Cr4Value; // eax
unsigned __int32 Cr3Value; // eax
unsigned __int32 Cr2Value; // eax
unsigned __int32 Cr0Value; // eax
unsigned __int32 Dr7Value; // eax
unsigned __int32 Dr6Value; // eax
unsigned __int32 Dr3Value; // eax
unsigned __int32 Dr2Value; // eax
unsigned __int32 Dr1Value; // eax
unsigned __int32 Dr0Value; // eax
__int32 NestedExceptionCode_1; // [esp-240h] [ebp-2BCh] BYREF
_DWORD FxState[134]; // [esp-23Ch] [ebp-2B8h] BYREF
unsigned __int32 SavedCr0; // [esp-24h] [ebp-A0h]
int Cr0ProtectionMask; // [esp-20h] [ebp-9Ch]
unsigned __int32 SavedCr2; // [esp-1Ch] [ebp-98h]
unsigned __int32 SavedCr3; // [esp-18h] [ebp-94h]
unsigned __int32 SavedCr4; // [esp-14h] [ebp-90h]
int SavedCpuIndex; // [esp-10h] [ebp-8Ch]
int LocalDescTableReg; // [esp-Ch] [ebp-88h]
int TaskRegister; // [esp-8h] [ebp-84h]
_BYTE GdtSaveBuffer[2]; // [esp-4h] [ebp-80h] BYREF
_BYTE GdtBuffer2[6]; // [esp-2h] [ebp-7Eh]
_BYTE IdtHighBuffer[2]; // [esp+4h] [ebp-78h] BYREF
_BYTE IdtBuffer2[6]; // [esp+6h] [ebp-76h]
__int32 IdtSaveBuffer; // [esp+Ch] [ebp-70h]
int GsSegment; // [esp+10h] [ebp-6Ch]
int FsSegment; // [esp+14h] [ebp-68h]
int EsSegment; // [esp+18h] [ebp-64h]
int DsSegment; // [esp+1Ch] [ebp-60h]
int SavedSs; // [esp+20h] [ebp-5Ch]
int SsSegment; // [esp+24h] [ebp-58h]
int SavedFramePointer; // [esp+30h] [ebp-4Ch]
_BYTE *ReturnAddressPtr; // [esp+34h] [ebp-48h]
int SavedContextRecord; // [esp+3Ch] [ebp-40h]
__int32 CurrentExceptionCode; // [esp+40h] [ebp-3Ch]
int CpuIdx; // [esp+44h] [ebp-38h]
int JumpType; // [esp+48h] [ebp-34h]
int JumpFlags; // [esp+4Ch] [ebp-30h]
_DWORD JumpTarget[2]; // [esp+5Ch] [ebp-20h]
int CpuIndex; // [esp+68h] [ebp-14h]
__int32 NestedExceptionCode; // [esp+6Ch] [ebp-10h] BYREF
__int32 SavedReturnAddr; // [esp+70h] [ebp-Ch] BYREF
int SavedStackSeg; // [esp+74h] [ebp-8h]
int CpuIdx5; // [esp+78h] [ebp-4h]
_BYTE RetAddrArray[8]; // [esp+7Ch] [ebp+0h] BYREF
ProcessorIndex = CpuIdx5; /*0xffe33d2e*/
SavedReturnAddr = *(_DWORD *)RetAddrArray; /*0xffe33d35*/
PreviousExceptionType = _InterlockedExchange(&SavedReturnAddr, ExceptionType); /*0xffe33d39*/
if ( _bittest((const signed __int32 *)&dword_FFE3A214, PreviousExceptionType) ) /*0xffe33d3c*/
NestedExceptionCode = SavedReturnAddr; /*0xffe33d45*/
SavedExceptionCode = _InterlockedExchange(&NestedExceptionCode, PreviousExceptionType); /*0xffe33d48*/
CpuIndex = ProcessorIndex; /*0xffe33d4b*/
_disable(); /*0xffe33d4c*/
ProcessorIndex2 = CpuIndex; /*0xffe33d4d*/
CpuIndex3 = (unsigned __int8)_InterlockedExchange(&NestedExceptionCode, SavedExceptionCode); /*0xffe33d51*/
if ( CpuIndex3 < 0x20 && _bittest((const signed __int32 *)&dword_FFE3A214, CpuIndex3) ) /*0xffe33d66*/
{
ActiveExceptionCode = _InterlockedExchange(&NestedExceptionCode, CpuIndex3); /*0xffe33d74*/
}
else
{
CpuIndex = CpuIndex3; /*0xffe33d68*/
ActiveExceptionCode = _InterlockedExchange(&NestedExceptionCode, 0); /*0xffe33d6b*/
}
JumpFlags = 0; /*0xffe33d8c*/
JumpType = 0; /*0xffe33d91*/
CpuIdx = ProcessorIndex2; /*0xffe33d96*/
CurrentExceptionCode = ActiveExceptionCode; /*0xffe33d97*/
SavedContextRecord = ContextRecord; /*0xffe33d98*/
ReturnAddressPtr = RetAddrArray; /*0xffe33d9d*/
SavedFramePointer = StackFrame; /*0xffe33d9e*/
SsSegment = __SS__; /*0xffe33da5*/
SavedSs = (unsigned __int16)SavedStackSeg; /*0xffe33daa*/
DsSegment = __DS__; /*0xffe33dad*/
EsSegment = __ES__; /*0xffe33db0*/
FsSegment = __FS__; /*0xffe33db3*/
GsSegment = __GS__; /*0xffe33db6*/
IdtSaveBuffer = SavedReturnAddr; /*0xffe33dba*/
__sidt(IdtHighBuffer); /*0xffe33dc1*/
*(_DWORD *)&IdtBuffer2[2] = (unsigned __int16)_InterlockedExchange( /*0xffe33dd1*/
(volatile __int32 *)IdtHighBuffer,
*(__int32 *)IdtBuffer2);
__sgdt(GdtSaveBuffer); /*0xffe33ddb*/
*(_DWORD *)&GdtBuffer2[2] = (unsigned __int16)_InterlockedExchange( /*0xffe33deb*/
(volatile __int32 *)GdtSaveBuffer,
*(__int32 *)GdtBuffer2);
__asm { str ax } /*0xffe33df1*/
TaskRegister = _AX; /*0xffe33df5*/
__asm { sldt ax } /*0xffe33df6*/
LocalDescTableReg = _AX; /*0xffe33dfa*/
SavedCpuIndex = CpuIdx5; /*0xffe33dfe*/
_EAX = 1; /*0xffe33dff*/
__asm { cpuid } /*0xffe33e05*/
Cr4Value = __readcr4(); /*0xffe33e08*/
SavedCr4 = Cr4Value; /*0xffe33e0b*/
if ( (_EDX & 0x1000000) != 0 ) /*0xffe33e12*/
Cr4Value |= 0x200u; /*0xffe33e14*/
if ( (_EDX & 4) != 0 ) /*0xffe33e1f*/
Cr4Value |= 8u; /*0xffe33e21*/
__writecr4(Cr4Value); /*0xffe33e26*/
Cr3Value = __readcr3(); /*0xffe33e29*/
SavedCr3 = Cr3Value; /*0xffe33e2c*/
Cr2Value = __readcr2(); /*0xffe33e2d*/
SavedCr2 = Cr2Value; /*0xffe33e30*/
Cr0ProtectionMask = 0; /*0xffe33e33*/
Cr0Value = __readcr0(); /*0xffe33e34*/
SavedCr0 = Cr0Value; /*0xffe33e37*/
Dr7Value = __readdr(7u); /*0xffe33e38*/
FxState[133] = Dr7Value; /*0xffe33e3b*/
Dr6Value = __readdr(6u); /*0xffe33e3c*/
FxState[132] = Dr6Value; /*0xffe33e3f*/
Dr3Value = __readdr(3u); /*0xffe33e40*/
FxState[131] = Dr3Value; /*0xffe33e43*/
Dr2Value = __readdr(2u); /*0xffe33e44*/
FxState[130] = Dr2Value; /*0xffe33e47*/
Dr1Value = __readdr(1u); /*0xffe33e48*/
FxState[129] = Dr1Value; /*0xffe33e4b*/
Dr0Value = __readdr(0); /*0xffe33e4c*/
FxState[128] = Dr0Value; /*0xffe33e4f*/
if ( (_EDX & 0x1000000) != 0 ) /*0xffe33e5e*/
_fxsave(FxState); /*0xffe33e60*/
NestedExceptionCode_1 = NestedExceptionCode; /*0xffe33e64*/
InitializeDebugAgent((int)FxState, CpuIndex, &NestedExceptionCode_1); /*0xffe33e73*/
_disable(); /*0xffe33e7b*/
_EAX = 1; /*0xffe33e84*/
__asm { cpuid } /*0xffe33e89*/
if ( (_EDX & 0x1000000) != 0 ) /*0xffe33e91*/
_fxrstor(FxState); /*0xffe33e93*/
__writecr0(SavedCr0); /*0xffe33ea3*/
__writecr2(SavedCr2); /*0xffe33ead*/
__writecr3(SavedCr3); /*0xffe33eb1*/
__writecr4(SavedCr4); /*0xffe33eb5*/
CpuIdx5 = SavedCpuIndex; /*0xffe33eb8*/
SavedReturnAddr = IdtSaveBuffer; /*0xffe33ec1*/
SavedStackSeg = SavedSs; /*0xffe33eca*/
*MK_FP(SsSegment, JumpTarget) = JumpType; /*0xffe33ee0*/
JumpTarget[1] = JumpFlags; /*0xffe33ee3*/
if ( JumpFlags ) /*0xffe33ef7*/
{
if ( JumpType != 1 ) /*0xffe33f01*/
__asm { jmp [esp+1Ch+JumpTarget2] } /*0xffe33f03*/
__asm { jmp [esp+20h+JumpTarget2] } /*0xffe33f0d*/
}
__asm { iret } /*0xffe33f35*/
}
// Function: CpuPause @ 0xffe33f36 (0x1e bytes)
// Index: 5/163
void __cdecl CpuPause(_DWORD *ExceptionTable)
{
*ExceptionTable = AsmExceptionEntryDiv0; /*0xffe33f3d*/
ExceptionTable[1] = 10; /*0xffe33f43*/
ExceptionTable[2] = AsmExceptionEntry0; /*0xffe33f4a*/
}
// Function: CpuSfence @ 0xffe33f54 (0xc bytes)
// Index: 6/163
// (too small: 0xc bytes)
// Function: CpuDeepSleep @ 0xffe340eb (0x33 bytes)
// Index: 7/163
// positive sp value has been detected, the output may be wrong!
void __cdecl __noreturn CpuDeepSleep(int MonitorAddr, int a2, volatile signed __int32 *SyncCount)
{
char MonitorVar; // [esp-8h] [ebp-8h] BYREF
_UNKNOWN *retaddr; // [esp+0h] [ebp+0h]
_InterlockedDecrement(SyncCount); /*0xffe340fe*/
if ( MonitorVar == 1 ) /*0xffe34104*/
{
while ( 1 ) /*0xffe3410c*/
{
_mm_monitor(&MonitorVar, 0, 0); /*0xffe3410c*/
_mm_mwait(0, 16 * (_DWORD)retaddr); /*0xffe34114*/
}
}
_disable(); /*0xffe3411c*/
__halt(); /*0xffe3411d*/
}
// Function: AsmReadMsr64 @ 0xffe34123 (0x2a bytes)
// Index: 8/163
void __cdecl AsmReadMsr64(_DWORD *src)
{
*src = dword_FFE33F64; /*0xffe34129*/
src[1] = 99; /*0xffe3412f*/
src[2] = 391; /*0xffe34136*/
src[3] = CpuDeepSleep; /*0xffe3413d*/
src[4] = 56; /*0xffe34144*/
}
// Function: AsmWriteMsr64 @ 0xffe3414d (0x51 bytes)
// Index: 9/163
void __usercall AsmWriteMsr64(int MsrLow@<eax>, int MsrHigh@<edx>, int MsrIndex@<ecx>, int SyncData, _BYTE *SyncAck)
{
unsigned int EflagsSave; // kr00_4
unsigned __int32 SavedCr4_1; // eax
unsigned __int32 SavedCr0_1; // eax
unsigned __int32 SavedCr0; // [esp-2Ch] [ebp-2Ch] BYREF
unsigned __int32 SavedCr4; // [esp-28h] [ebp-28h]
unsigned int EflagsSave_1; // [esp-24h] [ebp-24h]
int MsrLow_1; // [esp-20h] [ebp-20h]
int MsrHigh_1; // [esp-1Ch] [ebp-1Ch]
int MsrIndex_1; // [esp-18h] [ebp-18h]
_UNKNOWN **StackFramePtr; // [esp-10h] [ebp-10h]
_UNKNOWN *retaddr; // [esp+0h] [ebp+0h] BYREF
StackFramePtr = &retaddr; /*0xffe3414d*/
MsrIndex_1 = MsrIndex; /*0xffe3414d*/
MsrHigh_1 = MsrHigh; /*0xffe3414d*/
MsrLow_1 = MsrLow; /*0xffe3414d*/
EflagsSave = __readeflags(); /*0xffe34156*/
EflagsSave_1 = EflagsSave; /*0xffe34156*/
SavedCr4_1 = __readcr4(); /*0xffe34157*/
SavedCr4 = SavedCr4_1; /*0xffe3415a*/
SavedCr0_1 = __readcr0(); /*0xffe3415b*/
SavedCr0 = SavedCr0_1; /*0xffe3415e*/
__sgdt((void *)(SyncData + 8)); /*0xffe3415f*/
__sidt((void *)(SyncData + 14)); /*0xffe34163*/
*(_DWORD *)(SyncData + 4) = &SavedCr0; /*0xffe34167*/
*(_BYTE *)SyncData = 1; /*0xffe3416a*/
while ( *SyncAck != 1 ) /*0xffe34170*/
_mm_pause(); /*0xffe34172*/
__lgdt(SyncAck + 8); /*0xffe34179*/
__lidt(SyncAck + 14); /*0xffe3417d*/
*SyncAck = 2; /*0xffe34184*/
while ( *(_BYTE *)SyncData != 2 ) /*0xffe3418a*/
_mm_pause(); /*0xffe3418c*/
__writecr0(SavedCr0); /*0xffe34194*/
__writecr4(SavedCr4); /*0xffe34198*/
__writeeflags(EflagsSave_1); /*0xffe3419b*/
}
// Function: SetMem @ 0xffe341a4 (0x20 bytes)
// Index: 10/163
void *__cdecl SetMem(void *buf, unsigned int count)
{
memset(buf, 0, count); /*0xffe341bb*/
return buf; /*0xffe341c2*/
}
// Function: SetMem16 @ 0xffe341c4 (0x15 bytes)
// Index: 11/163
void *__cdecl SetMem16(void *buf, unsigned int count, char value)
{
memset(buf, value, count); /*0xffe341d1*/
return buf; /*0xffe341d7*/
}
// Function: AsmCpuid @ 0xffe341e4 (0x1f bytes)
// Index: 12/163
int __cdecl AsmCpuid(int a1, int a2, int a3, int a4)
{
do /*0xffe341fd*/
{
*(_DWORD *)(a1 + 8 * a2 - 8) = a3; /*0xffe341f5*/
*(_DWORD *)(a1 + 8 * a2-- - 4) = a4; /*0xffe341f9*/
}
while ( a2 ); /*0xffe341fd*/
return a1; /*0xffe34201*/
}
// Function: SetMem32 @ 0xffe34204 (0x15 bytes)
// Index: 13/163
void *__cdecl SetMem32(void *buf, unsigned int count, int value)
{
memset32(buf, value, count); /*0xffe34211*/
return buf; /*0xffe34217*/
}
// Function: BitFieldRead32 @ 0xffe34224 (0x7c bytes)
// Index: 14/163
int __cdecl BitFieldRead32(unsigned __int64 a1, __int64 a2, int a3)
{
unsigned int v3; // ecx
unsigned __int64 v5; // rax
unsigned int v6; // ebx
unsigned int v7; // ebx
bool v8; // cf
unsigned __int64 v9; // rax
v3 = HIDWORD(a2); /*0xffe34224*/
if ( HIDWORD(a2) ) /*0xffe3422a*/
{
v5 = a1; /*0xffe34249*/
v6 = a2; /*0xffe34251*/
do /*0xffe3425f*/
{
v5 >>= 1; /*0xffe34255*/
v6 = __PAIR64__(v3, v6) >> 1; /*0xffe34259*/
v3 >>= 1; /*0xffe3425d*/
}
while ( v3 ); /*0xffe3425f*/
v7 = v5 / v6; /*0xffe34263*/
v9 = (unsigned int)a2 * (unsigned __int64)v7; /*0xffe34269*/
v8 = __CFADD__(v7 * HIDWORD(a2), HIDWORD(v9)); /*0xffe34270*/
HIDWORD(v9) = (a2 * (unsigned __int64)v7) >> 32; /*0xffe34270*/
if ( v8 || a1 < v9 ) /*0xffe34280*/
{
--v7; /*0xffe34282*/
if ( !a3 ) /*0xffe34283*/
return v7; /*0xffe34298*/
v9 -= a2; /*0xffe34289*/
}
if ( a3 ) /*0xffe3428d*/
*(_QWORD *)a3 = a1 - v9; /*0xffe34293*/
return v7; /*0xffe34293*/
}
if ( a3 ) /*0xffe34230*/
{
*(_DWORD *)(a3 + 4) = 0; /*0xffe34232*/
HIDWORD(a2) = a3; /*0xffe34239*/
}
return InitializeCpuExceptionHandlers(a1, HIDWORD(a1), a2, (_DWORD *)HIDWORD(a2)); /*0xffe3429f*/
}
// Function: AsmReadCr0 @ 0xffe342a4 (0x2b bytes)
// Index: 15/163
unsigned __int32 AsmReadCr0()
{
unsigned __int32 result; // eax
unsigned __int32 v5; // eax
__asm { finit } /*0xffe342a5*/
_EAX = 1; /*0xffe342ae*/
__asm { cpuid } /*0xffe342b3*/
if ( (_EDX & 0x2000000) != 0 ) /*0xffe342b9*/
{
v5 = __readcr4(); /*0xffe342bb*/
result = v5 | 0x200; /*0xffe342be*/
__writecr4(result); /*0xffe342c3*/
_mm_setcsr(0x1F80u); /*0xffe342c6*/
}
return result; /*0xffe342cd*/
}
// Function: _ModuleEntryPoint @ 0xffe342cf (0x1a2 bytes)
// Index: 16/163
EFI_STATUS __cdecl ModuleEntryPoint(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
{
EFI_PEI_SERVICES **PeiServices; // edi
EFI_SYSTEM_TABLE *SystemTable_4; // ecx
void *v4; // ecx
_BYTE *v5; // eax
EFI_SYSTEM_TABLE *SystemTable_2; // esi
_DWORD *Signature; // esi
int Ppi; // eax
int v9; // eax
int Service; // eax
int inited; // eax
int v12; // eax
int v13; // eax
int v14; // eax
EFI_STATUS v15; // esi
int v16; // eax
EFI_SYSTEM_TABLE *SystemTable_1; // [esp-Ch] [ebp-10h]
EFI_SYSTEM_TABLE *SystemTable_3; // [esp+0h] [ebp-4h] BYREF
if ( ReadModuleConfig(0xFA044u) >= 0 ) /*0xffe342de*/
{
WriteModuleConfig(SystemTable_4); /*0xffe342e0*/
v5 = (_BYTE *)(GetModuleParameter(v4) + 1024068); /*0xffe342ea*/
LOBYTE(SystemTable_4) = *v5 | 0x80; /*0xffe342ee*/
*v5 = (_BYTE)SystemTable_4; /*0xffe342f1*/
}
SystemTable_2 = SystemTable_3; /*0xffe342f7*/
SystemTable_3 = SystemTable_4; /*0xffe34387*/
SystemTable_1 = SystemTable_2; /*0xffe3438a*/
Signature = 0; /*0xffe3438e*/
Ppi = PeiServicesGetPpi(); /*0xffe34390*/
if ( !(*(int (__cdecl **)(int, struct EFI_GUID *, _DWORD, _DWORD, EFI_SYSTEM_TABLE **))(*(_DWORD *)Ppi + 32))( /*0xffe343a4*/
Ppi,
&stru_FFE3B8D4,
0,
0,
&SystemTable_3) )
Signature = (_DWORD *)SystemTable_3->Hdr.Signature; /*0xffe343b2*/
v9 = InitializeDebugAgent_0(Signature); /*0xffe343b6*/
if ( v9 < 0 ) /*0xffe343cc*/
{
DebugPrint(0x80000000, "\nASSERT_EFI_ERROR (Status = %r)\n", v9); /*0xffe343d5*/
Service = DebugPrintGetService(); /*0xffe343dd*/
if ( Service ) /*0xffe343e4*/
(*(void (__cdecl **)(const char *, int, const char *))(Service + 4))( /*0xffe343ed*/
"e:\\hs\\UefiCpuPkg\\CpuMpPei\\CpuMpPei.c",
448,
"!EFI_ERROR (Status)");
}
inited = MpInitLibInitialize(); /*0xffe343f3*/
if ( inited < 0 ) /*0xffe343fa*/
{
DebugPrint(0x80000000, "\nASSERT_EFI_ERROR (Status = %r)\n", inited); /*0xffe34403*/
v12 = DebugPrintGetService(); /*0xffe3440b*/
if ( v12 ) /*0xffe34412*/
(*(void (__cdecl **)(const char *, int, const char *))(v12 + 4))( /*0xffe3441b*/
"e:\\hs\\UefiCpuPkg\\CpuMpPei\\CpuMpPei.c",
454,
"!EFI_ERROR (Status)");
}
CpuBistCollect(PeiServices, SystemTable_1); /*0xffe34423*/
v13 = PeiServicesGetPpi(); /*0xffe34428*/
v14 = (*(int (__cdecl **)(int, struct EFI_GUID *))(*(_DWORD *)v13 + 24))(v13, &stru_FFE3B914); /*0xffe34435*/
v15 = v14; /*0xffe34438*/
if ( v14 < 0 ) /*0xffe3443e*/
{
DebugPrint(0x80000000, "\nASSERT_EFI_ERROR (Status = %r)\n", v14); /*0xffe3444b*/
v16 = DebugPrintGetService(); /*0xffe34453*/
if ( v16 ) /*0xffe3445a*/
(*(void (__cdecl **)(const char *, int, const char *))(v16 + 4))( /*0xffe34463*/
"e:\\hs\\UefiCpuPkg\\CpuMpPei\\CpuMpPei.c",
465,
"!EFI_ERROR (Status)");
}
return v15; /*0xffe34470*/
}
// Function: CpuMpPeiInit @ 0xffe34471 (0x5d bytes)
// Index: 17/163
int __cdecl CpuMpPeiInit(EFI_PEI_SERVICES **PeiServices, UINT32 *BufferSize, CHAR8 *Buffer)
{
char *v3; // eax
UINT32 count; // ecx
v3 = (char *)PpiFind((char *)&Guid_); /*0xffe34476*/
if ( v3 ) /*0xffe3447f*/
{
count = (unsigned __int16)(*((_WORD *)v3 + 1) - 24); /*0xffe34494*/
if ( *(_QWORD *)BufferSize < (unsigned __int64)(unsigned __int16)(*((_WORD *)v3 + 1) - 24) ) /*0xffe344a5*/
{
BufferSize[1] = 0; /*0xffe344a7*/
*BufferSize = count; /*0xffe344ab*/
return -2147483643; /*0xffe344b2*/
}
BufferSize[1] = 0; /*0xffe344b3*/
*BufferSize = count; /*0xffe344b7*/
if ( count ) /*0xffe344bb*/
CopyMemWrapper(Buffer, v3 + 24, count); /*0xffe344c5*/
}
else
{
*BufferSize = 0; /*0xffe34485*/
BufferSize[1] = 0; /*0xffe34487*/
}
return 0; /*0xffe344b2*/
}
// Function: HobListRead @ 0xffe344ce (0x8e bytes)
// Index: 18/163
EFI_STATUS __stdcall HobListRead(EFI_PEI_SERVICES **PeiServices, UINT32 *NumberOfProcessors)
{
int v2; // ecx
int v3; // edi
int v4; // eax
int v6; // esi
int Ppi; // eax
_DWORD v8[2]; // [esp+4h] [ebp-10h] BYREF
int (__cdecl **v9)(int, _DWORD *, UINT32); // [esp+Ch] [ebp-8h] BYREF
UINT32 v10; // [esp+10h] [ebp-4h] BYREF
v3 = v2; /*0xffe344dc*/
v4 = PpiGuidCheck((int)PeiServices, (int)&v9); /*0xffe344e0*/
if ( v4 == -2147483634 ) /*0xffe344ee*/
return -2147483634; /*0xffe344f0*/
if ( v4 ) /*0xffe344f6*/
return -2147483641; /*0xffe344f6*/
v8[0] = 0; /*0xffe344f9*/
v8[1] = 0; /*0xffe344fc*/
v10 = 0; /*0xffe344ff*/
if ( (*v9)(v3, v8, 0) != -2147483643 ) /*0xffe34514*/
return -2147483641; /*0xffe34514*/
v6 = v8[0]; /*0xffe34517*/
Ppi = PeiServicesGetPpi(); /*0xffe3451a*/
if ( (*(int (__cdecl **)(int, int, UINT32 *))(*(_DWORD *)Ppi + 76))(Ppi, v6, &v10) || (*v9)(v3, v8, v10) ) /*0xffe3453d*/
return -2147483641; /*0xffe34552*/
*NumberOfProcessors = v10; /*0xffe3454c*/
return 0; /*0xffe34557*/
}
// Function: CpuBistCollect @ 0xffe3455c (0x28d bytes)
// Index: 19/163
EFI_STATUS __stdcall CpuBistCollect(EFI_PEI_SERVICES **PeiServices, EFI_SYSTEM_TABLE *SystemTable)
{
unsigned int ProcessorCount_1; // ebx
unsigned int BufferSize_1; // ebp
int PpiDescriptor; // eax
int Status; // eax
int Service; // eax
unsigned int BistTablea_1; // edi
_DWORD *CpuBistTable; // eax
void *Index; // ecx
unsigned int ProcessorCount_2; // eax
_DWORD *BistTable_1; // ebp
_DWORD *ApicId; // esi
int RemainingCount; // ecx
unsigned int BistTablea_2; // eax
_DWORD *BistTable_2; // ebx
int Offset; // eax
int BufferPtr; // ecx
char *src_1; // eax
EFI_PEI_SERVICES *PpiStatus; // esi
int Ppi; // eax
EFI_STATUS result; // eax
int v22; // eax
_DWORD *BistTable; // [esp+14h] [ebp-7Ch]
unsigned int BistTablea; // [esp+14h] [ebp-7Ch]
_DWORD *BistResult; // [esp+18h] [ebp-78h] BYREF
char *src; // [esp+1Ch] [ebp-74h] BYREF
unsigned int *CpuInfo; // [esp+20h] [ebp-70h] BYREF
unsigned int ProcessorCount; // [esp+24h] [ebp-6Ch] BYREF
unsigned int CurrentProcessor; // [esp+28h] [ebp-68h]
int ByteOffset; // [esp+2Ch] [ebp-64h]
EFI_PEI_SERVICES *GuidHandle; // [esp+30h] [ebp-60h] BYREF
unsigned int BufferSize; // [esp+34h] [ebp-5Ch] BYREF
int SingleCpuInfo[6]; // [esp+38h] [ebp-58h] BYREF
_DWORD BistBuffer[16]; // [esp+50h] [ebp-40h] BYREF
GetSystemConfiguration(&ProcessorCount, (int *)&BufferSize); /*0xffe34576*/
ProcessorCount_1 = ProcessorCount; /*0xffe3457b*/
BufferSize_1 = (ProcessorCount << 6) + 72; /*0xffe34584*/
BufferSize = BufferSize_1; /*0xffe34587*/
PpiDescriptor = PeiServicesGetPpi(); /*0xffe3458b*/
Status = (*(int (__cdecl **)(int, unsigned int, char **))(*(_DWORD *)PpiDescriptor + 76))( /*0xffe34599*/
PpiDescriptor,
BufferSize_1,
&src);
if ( Status < 0 ) /*0xffe345a1*/
{
DebugPrint(0x80000000, "\nASSERT_EFI_ERROR (Status = %r)\n", Status); /*0xffe345ae*/
Service = DebugPrintGetService(); /*0xffe345b6*/
if ( Service ) /*0xffe345bd*/
(*(void (__cdecl **)(const char *, int, const char *))(Service + 4))( /*0xffe345ce*/
"e:\\hs\\UefiCpuPkg\\CpuMpPei\\CpuBist.c",
192,
"!EFI_ERROR (Status)");
}
CpuInfo = 0; /*0xffe345dd*/
BistTablea_1 = 0; /*0xffe345e2*/
BistResult = 0; /*0xffe345e4*/
*(_DWORD *)src = ProcessorCount_1; /*0xffe345ea*/
BistTable = 0; /*0xffe345f0*/
if ( !HobListRead(&GuidHandle, (UINT32 *)&CpuInfo) ) /*0xffe345fe*/
{
BistTablea_1 = *CpuInfo; /*0xffe3460e*/
CpuBistTable = CpuInfo + 2; /*0xffe34610*/
LABEL_8:
BistTable = CpuBistTable; /*0xffe3464d*/
goto LABEL_10; /*0xffe34651*/
}
if ( !HobListRead(&GuidHandle, (UINT32 *)&BistResult) ) /*0xffe34627*/
{
BistTablea_1 = 1; /*0xffe34635*/
BistBuffer[0] = GetCpuCount(Index); /*0xffe3463b*/
BistBuffer[2] = *BistResult; /*0xffe34645*/
CpuBistTable = BistBuffer; /*0xffe34649*/
goto LABEL_8; /*0xffe34649*/
}
DebugPrint(64, "Does not find any stored CPU BIST information from PPI!\n"); /*0xffe3465a*/
LABEL_10:
ProcessorCount_2 = 0; /*0xffe34661*/
CurrentProcessor = 0; /*0xffe34663*/
if ( ProcessorCount_1 ) /*0xffe34669*/
{
ByteOffset = 0; /*0xffe3466f*/
BistTable_1 = BistTable; /*0xffe34673*/
do /*0xffe34731*/
{
CollectBistData(ProcessorCount_2, SingleCpuInfo, &BistResult); /*0xffe34682*/
ApicId = BistResult; /*0xffe34687*/
if ( BistTablea_1 ) /*0xffe3468e*/
{
RemainingCount = SingleCpuInfo[0]; /*0xffe34690*/
BistTablea_2 = BistTablea_1; /*0xffe34694*/
BistTable_2 = BistTable_1; /*0xffe34696*/
BistTablea = BistTablea_1; /*0xffe34698*/
do /*0xffe346de*/
{
if ( !BistTable_1 ) /*0xffe3469e*/
{
Offset = DebugPrintGetService(); /*0xffe346a0*/
if ( Offset ) /*0xffe346a7*/
(*(void (__cdecl **)(const char *, int, const char *))(Offset + 4))( /*0xffe346b8*/
"e:\\hs\\UefiCpuPkg\\CpuMpPei\\CpuBist.c",
242,
"CpuInstance != ((void *) 0)");
RemainingCount = SingleCpuInfo[0]; /*0xffe346be*/
BistTablea_2 = BistTablea; /*0xffe346c2*/
}
if ( RemainingCount == *BistTable_2 && !SingleCpuInfo[1] ) /*0xffe346cf*/
ApicId = (_DWORD *)BistTable_2[2]; /*0xffe346d1*/
BistTable_2 += 16; /*0xffe346d4*/
BistTablea = --BistTablea_2; /*0xffe346da*/
}
while ( BistTablea_2 ); /*0xffe346de*/
ProcessorCount_1 = ProcessorCount; /*0xffe346e0*/
BistResult = ApicId; /*0xffe346e4*/
}
if ( ApicId ) /*0xffe346ea*/
CpuBistClear(); /*0xffe346ef*/
DebugPrint(64, " APICID - 0x%08x, BIST - 0x%08x\n", SingleCpuInfo[0], ApicId); /*0xffe34703*/
BufferPtr = ByteOffset; /*0xffe34708*/
src_1 = src; /*0xffe3470f*/
*(_DWORD *)&src[ByteOffset + 8] = SingleCpuInfo[0]; /*0xffe34717*/
*(_DWORD *)&src_1[BufferPtr + 16] = ApicId; /*0xffe3471b*/
ProcessorCount_2 = CurrentProcessor + 1; /*0xffe34726*/
ByteOffset = BufferPtr + 64; /*0xffe34727*/
CurrentProcessor = ProcessorCount_2; /*0xffe3472b*/
}
while ( ProcessorCount_2 < ProcessorCount_1 ); /*0xffe34731*/
BufferSize_1 = BufferSize; /*0xffe34737*/
}
MpSafeCopyBuffer((int)&Guid_, src, BufferSize_1); /*0xffe34745*/
if ( CpuInfo && BistTablea_1 < ProcessorCount_1 ) /*0xffe34754*/
{
PpiStatus = GuidHandle; /*0xffe34756*/
Ppi = PeiServicesGetPpi(); /*0xffe3475a*/
result = (*(int (__cdecl **)(int, EFI_PEI_SERVICES *, UINT8 *))(*(_DWORD *)Ppi + 28))( /*0xffe34768*/
Ppi,
PpiStatus,
&byte_FFE3B93C);
if ( (result & 0x80000000) != 0 ) /*0xffe34770*/
{
DebugPrint(0x80000000, "\nASSERT_EFI_ERROR (Status = %r)\n", result); /*0xffe3477d*/
result = DebugPrintGetService(); /*0xffe34785*/
if ( result ) /*0xffe3478c*/
return (*(EFI_STATUS (__cdecl **)(const char *, int, const char *))(result + 4))( /*0xffe34798*/
"e:\\hs\\UefiCpuPkg\\CpuMpPei\\CpuBist.c",
286,
"!EFI_ERROR (Status)");
}
}
else
{
v22 = PeiServicesGetPpi(); /*0xffe3479a*/
result = (*(int (__cdecl **)(int, UINT8 *))(*(_DWORD *)v22 + 24))(v22, &byte_FFE3B93C); /*0xffe347a7*/
if ( (result & 0x80000000) != 0 ) /*0xffe347ae*/
{
DebugPrint(0x80000000, "\nASSERT_EFI_ERROR (Status = %r)\n", result); /*0xffe347bb*/
result = DebugPrintGetService(); /*0xffe347c3*/
if ( result ) /*0xffe347ca*/
return (*(EFI_STATUS (__cdecl **)(const char *, int, const char *))(result + 4))( /*0xffe347db*/
"e:\\hs\\UefiCpuPkg\\CpuMpPei\\CpuBist.c",
292,
"!EFI_ERROR (Status)");
}
}
return result; /*0xffe347e1*/
}
// Function: CopyMemWrapper @ 0xffe347e9 (0x6f bytes)
// Index: 20/163
char *__fastcall CopyMemWrapper(char *dst, char *src, unsigned int count)
{
int Service; // eax
int v6; // eax
if ( count - 1 > -1 - (int)dst ) /*0xffe347ff*/
{
Service = DebugPrintGetService(); /*0xffe34801*/
if ( Service ) /*0xffe34808*/
(*(void (__cdecl **)(const char *, int, const char *))(Service + 4))( /*0xffe34816*/
"e:\\hs\\MdePkg\\Library\\BaseMemoryLibRepStr\\CopyMemWrapper.c",
56,
"(Length - 1) <= (0xFFFFFFFF - (UINTN)DestinationBuffer)");
}
if ( count - 1 > -1 - (int)src ) /*0xffe34820*/
{
v6 = DebugPrintGetService(); /*0xffe34822*/
if ( v6 ) /*0xffe34829*/
(*(void (__cdecl **)(const char *, int, const char *))(v6 + 4))( /*0xffe34837*/
"e:\\hs\\MdePkg\\Library\\BaseMemoryLibRepStr\\CopyMemWrapper.c",
57,
"(Length - 1) <= (0xFFFFFFFF - (UINTN)SourceBuffer)");
}
if ( dst == src ) /*0xffe3483f*/
return dst; /*0xffe34841*/
else
return CopyMem(dst, src, count); /*0xffe3484b*/
}
// Function: PpiGuidCheck @ 0xffe34858 (0x1e bytes)
// Index: 21/163
int __cdecl PpiGuidCheck(int p_PpiStatus, int a2)
{
int v2; // ecx
int v3; // esi
int Ppi; // eax
v3 = v2; /*0xffe34859*/
Ppi = PeiServicesGetPpi(); /*0xffe3485b*/
return (*(int (__cdecl **)(int, int, _DWORD, int, int))(*(_DWORD *)Ppi + 32))(Ppi, v3, 0, p_PpiStatus, a2); /*0xffe34874*/
}
// Function: PpiLocate @ 0xffe34876 (0x6e bytes)
// Index: 22/163
UINTN __stdcall PpiLocate(EFI_PEI_SERVICES **PeiServices)
{
int Ppi; // eax
int v2; // eax
int Service; // eax
int v4; // eax
UINTN v6; // [esp+4h] [ebp-4h] BYREF
Ppi = PeiServicesGetPpi(); /*0xffe3487b*/
v2 = (*(int (__cdecl **)(int, UINTN *))(*(_DWORD *)Ppi + 48))(Ppi, &v6); /*0xffe34887*/
if ( v2 < 0 ) /*0xffe34893*/
{
DebugPrint(0x80000000, "\nASSERT_EFI_ERROR (Status = %r)\n", v2); /*0xffe348a0*/
Service = DebugPrintGetService(); /*0xffe348a8*/
if ( Service ) /*0xffe348af*/
(*(void (__cdecl **)(const char *, int, const char *))(Service + 4))( /*0xffe348b9*/
"e:\\hs\\MdePkg\\Library\\PeiHobLib\\HobLib.c",
50,
"!EFI_ERROR (Status)");
}
if ( !v6 ) /*0xffe348c3*/
{
v4 = DebugPrintGetService(); /*0xffe348c5*/
if ( v4 ) /*0xffe348cc*/
(*(void (__cdecl **)(const char *, int, const char *))(v4 + 4))( /*0xffe348d6*/
"e:\\hs\\MdePkg\\Library\\PeiHobLib\\HobLib.c",
51,
"HobList != ((void *) 0)");
}
return v6; /*0xffe348df*/
}
// Function: PpiListSearch @ 0xffe348e4 (0x45 bytes)
// Index: 23/163
_WORD *__fastcall PpiListSearch(int a1, _WORD *i)
{
_WORD *i_1; // esi
int Service; // eax
i_1 = i; /*0xffe348e5*/
if ( !i ) /*0xffe348e9*/
{
Service = DebugPrintGetService(); /*0xffe348eb*/
if ( Service ) /*0xffe348f2*/
(*(void (__cdecl **)(const char *, int, const char *))(Service + 4))( /*0xffe34900*/
"e:\\hs\\MdePkg\\Library\\PeiHobLib\\HobLib.c",
82,
"HobStart != ((void *) 0)");
}
while ( 1 ) /*0xffe34919*/
{
if ( *i_1 == 0xFFFF ) /*0xffe3491f*/
return 0; /*0xffe34924*/
if ( *i_1 == 4 ) /*0xffe34911*/
break; /*0xffe34911*/
i_1 = (_WORD *)((char *)i_1 + (unsigned __int16)i_1[1]); /*0xffe34917*/
}
return i_1; /*0xffe34923*/
}
// Function: PpiFind @ 0xffe34929 (0x3a bytes)
// Index: 24/163
_WORD *__thiscall PpiFind(char *this)
{
_WORD *i; // edx
int v3; // ecx
_WORD *v4; // eax
_WORD *v5; // esi
EFI_PEI_SERVICES **PeiServices; // [esp+0h] [ebp-8h]
for ( i = (_WORD *)PpiLocate(PeiServices); ; i = (_WORD *)((char *)v5 + (unsigned __int16)v5[1]) ) /*0xffe34938*/
{
v4 = PpiListSearch(v3, i); /*0xffe34950*/
v5 = v4; /*0xffe34955*/
if ( !v4 || PcdGetBool(this, (int)(v4 + 4)) ) /*0xffe34941*/
break; /*0xffe34941*/
}
return v5; /*0xffe3495b*/
}
// Function: PpiFindByGuid @ 0xffe34963 (0x50 bytes)
// Index: 25/163
int __fastcall PpiFindByGuid(EFI_PEI_SERVICES **PeiServices, UINTN DataLength)
{
int Ppi; // eax
int Service; // eax
int v6; // [esp+4h] [ebp-4h] BYREF
Ppi = PeiServicesGetPpi(); /*0xffe3496a*/
if ( (*(int (__cdecl **)(int, int, UINTN, int *))(*(_DWORD *)Ppi + 52))(Ppi, 4, DataLength, &v6) < 0 ) /*0xffe34982*/
v6 = 0; /*0xffe34984*/
if ( !v6 ) /*0xffe3498c*/
{
Service = DebugPrintGetService(); /*0xffe3498e*/
if ( Service ) /*0xffe34995*/
(*(void (__cdecl **)(const char *, int, const char *))(Service + 4))( /*0xffe349a6*/
"e:\\hs\\MdePkg\\Library\\PeiHobLib\\HobLib.c",
250,
"Hob != ((void *) 0)");
}
return v6; /*0xffe3497f*/
}
// Function: InitializeFloatingPointUnits @ 0xffe349b3 (0x6b bytes)
// Index: 26/163
int __fastcall InitializeFloatingPointUnits(EFI_GUID *Guid, UINT16 DataLength)
{
unsigned int DataLength_1; // esi
int Service; // eax
int v5; // eax
int result; // eax
int v7; // esi
DataLength_1 = DataLength; /*0xffe349b8*/
if ( !Guid ) /*0xffe349c1*/
{
Service = DebugPrintGetService(); /*0xffe349c3*/
if ( Service ) /*0xffe349ca*/
(*(void (__cdecl **)(const char *, int, const char *))(Service + 4))( /*0xffe349d7*/
"e:\\hs\\MdePkg\\Library\\PeiHobLib\\HobLib.c",
416,
"Guid != ((void *) 0)");
}
if ( DataLength_1 > 0xFFE0 ) /*0xffe349e3*/
{
v5 = DebugPrintGetService(); /*0xffe349e5*/
if ( v5 ) /*0xffe349ec*/
(*(void (__cdecl **)(const char *, int, const char *))(v5 + 4))( /*0xffe349f9*/
"e:\\hs\\MdePkg\\Library\\PeiHobLib\\HobLib.c",
421,
"DataLength <= (0xFFF8 - sizeof (EFI_HOB_GUID_TYPE))");
}
result = PpiFindByGuid((EFI_PEI_SERVICES **)Guid, DataLength_1 + 24); /*0xffe34a02*/
v7 = result; /*0xffe34a07*/
if ( result ) /*0xffe34a0b*/
{
HobGetData(result + 8, (int)Guid); /*0xffe34a12*/
return v7 + 24; /*0xffe34a17*/
}
return result; /*0xffe34a1a*/
}
// Function: MpSafeCopyBuffer @ 0xffe34a1e (0x51 bytes)
// Index: 27/163
char *__fastcall MpSafeCopyBuffer(int Guid, char *Buffer, unsigned int BufferSize)
{
int Service; // eax
char *dst; // eax
if ( !Buffer ) /*0xffe34a2b*/
{
if ( BufferSize ) /*0xffe34a2f*/
{
Service = DebugPrintGetService(); /*0xffe34a31*/
if ( Service ) /*0xffe34a38*/
(*(void (__cdecl **)(const char *, int, const char *))(Service + 4))( /*0xffe34a49*/
"e:\\hs\\MdePkg\\Library\\PeiHobLib\\HobLib.c",
466,
"Data != ((void *) 0) || DataLength == 0");
}
}
dst = (char *)InitializeFloatingPointUnits((EFI_GUID *)Guid, BufferSize); /*0xffe34a53*/
if ( dst ) /*0xffe34a5a*/
{
if ( BufferSize ) /*0xffe34a5e*/
return CopyMemWrapper(dst, Buffer, BufferSize); /*0xffe34a65*/
}
return dst; /*0xffe34a6b*/
}
// Function: DebugPrintGetService @ 0xffe34a6f (0x31 bytes)
// Index: 28/163
int DebugPrintGetService()
{
int Ppi; // eax
_BYTE v2[4]; // [esp+0h] [ebp-8h] BYREF
int v3; // [esp+4h] [ebp-4h] BYREF
Ppi = PeiServicesGetPpi(); /*0xffe34a74*/
if ( (*(int (__cdecl **)(int, void *, _DWORD, _BYTE *, int *))(*(_DWORD *)Ppi + 32))(Ppi, &unk_FFE3B8B4, 0, v2, &v3) >= 0 ) /*0xffe34a93*/
return v3; /*0xffe34a99*/
else
return 0; /*0xffe34a95*/
}
// Function: DebugPrint @ 0xffe34aa0 (0x2a bytes)
// Index: 29/163
int DebugPrint(int a1, const char *a2, ...)
{
int result; // eax
int (__cdecl **v3)(int, const char *, char *); // esi
va_list va; // [esp+10h] [ebp+Ch] BYREF
va_start(va, a2);
result = DebugPrintGetService(); /*0xffe34aa1*/
v3 = (int (__cdecl **)(int, const char *, char *))result; /*0xffe34aa6*/
if ( result ) /*0xffe34aaa*/
{
result = DebugPrintLevelEnabled(); /*0xffe34aac*/
if ( (result & a1) != 0 ) /*0xffe34ab7*/
return (*v3)(a1, a2, (char *)va); /*0xffe34ac3*/
}
return result; /*0xffe34ac8*/
}
// Function: DebugAssert @ 0xffe34aca (0x1e bytes)
// Index: 30/163
int __fastcall DebugAssert(
int e:__hs__MdePkg__Library__BaseLib__X86ReadIdtr.c,
int n37,
const char *PeiServices____((void__)_0))
{
int result; // eax
result = DebugPrintGetService(); /*0xffe34ad0*/
if ( result ) /*0xffe34ad7*/
return (*(int (__cdecl **)(int, int, const char *))(result + 4))( /*0xffe34adf*/
e:__hs__MdePkg__Library__BaseLib__X86ReadIdtr.c,
n37,
PeiServices____((void__)_0));
return result; /*0xffe34ae5*/
}
// Function: SwitchStack @ 0xffe34ae8 (0x4b bytes)
// Index: 31/163
unsigned int __fastcall SwitchStack(unsigned int a1)
{
unsigned int v1; // esi
unsigned int n0x400000; // edi
unsigned int v3; // ebx
unsigned int result; // eax
v1 = a1 >> 22; /*0xffe34af5*/
n0x400000 = a1 & 0x3FFFFF; /*0xffe34af8*/
do /*0xffe34b2c*/
{
v3 = n0x400000 + LongJump((void *)0x508); /*0xffe34b06*/
n0x400000 = 0x400000; /*0xffe34b09*/
while ( ((v3 - LongJump((void *)0x508)) & 0x800000) == 0 ) /*0xffe34b25*/
_mm_pause(); /*0xffe34b10*/
result = v1--; /*0xffe34b27*/
}
while ( result ); /*0xffe34b2c*/
return result; /*0xffe34b2e*/
}
// Function: SwitchStackFinish @ 0xffe34b33 (0x37 bytes)
// Index: 32/163
unsigned int __fastcall SwitchStackFinish(unsigned int n0xA)
{
unsigned int v2; // eax
v2 = BitFieldRead64(3579545 * n0xA, (3579545 * (unsigned __int64)n0xA) >> 32); /*0xffe34b55*/
SwitchStack(v2); /*0xffe34b5e*/
return n0xA; /*0xffe34b65*/
}
// Function: ProcedureScope @ 0xffe34b6a (0x1e bytes)
// Index: 33/163
int __fastcall ProcedureScope(_DWORD *a1, _DWORD *a2)
{
if ( a1 ) /*0xffe34b6d*/
{
*a1 = 0; /*0xffe34b6f*/
a1[1] = 0; /*0xffe34b72*/
}
if ( a2 ) /*0xffe34b78*/
{
*a2 = -1; /*0xffe34b7a*/
a2[1] = -1; /*0xffe34b7d*/
}
return MpExchangeData(a1); /*0xffe34b87*/
}
// Function: MpExchangeData @ 0xffe34b88 (0x79 bytes)
// Index: 34/163
int __thiscall MpExchangeData(void *this)
{
__int16 v1; // kr00_2
int v2; // esi
unsigned __int64 v3; // rax
int v4; // edi
int result; // eax
v1 = __readeflags(); /*0xffe34b8f*/
_disable(); /*0xffe34b9a*/
v2 = LongJump((void *)0x508); /*0xffe34ba9*/
v3 = __rdtsc(); /*0xffe34bab*/
v4 = v3; /*0xffe34baf*/
while ( ((v2 + 357 - LongJump((void *)0x508)) & 0x800000) == 0 ) /*0xffe34bcc*/
_mm_pause(); /*0xffe34bb3*/
result = 10000 * (__rdtsc() - v4); /*0xffe34be8*/
if ( (v1 & 0x200) != 0 ) /*0xffe34bf3*/
_enable(); /*0xffe34bf5*/
else
_disable(); /*0xffe34bf8*/
return result; /*0xffe34bf9*/
}
// Function: ApStackCheck @ 0xffe34c01 (0x44 bytes)
// Index: 35/163
BOOL ApStackCheck()
{
int n1769238117; // [esp+0h] [ebp-Ch] BYREF
int n1145913699; // [esp+4h] [ebp-8h] BYREF
int n1752462657; // [esp+8h] [ebp-4h] BYREF
BitFieldFieldType(0, 0, &n1752462657, &n1145913699, &n1769238117); /*0xffe34c17*/
return n1752462657 == 1752462657 && n1145913699 == 1145913699 && n1769238117 == 1769238117; /*0xffe34c41*/
}
// Function: ApModeCheck @ 0xffe34c45 (0x38 bytes)
// Index: 36/163
bool __thiscall ApModeCheck(void *this)
{
unsigned int n4; // eax
int this_1; // [esp+0h] [ebp-4h] BYREF
this_1 = (int)this; /*0xffe34c48*/
BitFieldFieldType(1, &this_1, 0, 0, 0); /*0xffe34c54*/
n4 = UnalignedRead32(this_1, 8u, 0xBu); /*0xffe34c61*/
return n4 != 4 && n4 != 5; /*0xffe34c7b*/
}
// Function: ApInitCheck @ 0xffe34c7d (0x4a bytes)
// Index: 37/163
int __thiscall ApInitCheck(void *this)
{
if ( ApModeCheck(this) ) /*0xffe34c84*/
return __readmsr(0x1Bu) & 0xFFFFF000; /*0xffe34cc0*/
else
return -18874368; /*0xffe34c8d*/
}
// Function: SortCpuList @ 0xffe34cc7 (0x56 bytes)
// Index: 38/163
int __fastcall SortCpuList(unsigned int a1)
{
int Service; // eax
void *v3; // ecx
__int64 v4; // rax
if ( (a1 & 0xF) != 0 ) /*0xffe34cd3*/
{
Service = DebugPrintGetService(); /*0xffe34cd5*/
if ( Service ) /*0xffe34cdc*/
(*(void (__cdecl **)(const char *, int, const char *))(Service + 4))( /*0xffe34ced*/
"e:\\hs\\UefiCpuPkg\\Library\\BaseXApicX2ApicLib\\BaseXApicX2ApicLib.c",
167,
"(MmioOffset & 0xf) == 0");
}
if ( ReadCheck() == 1 ) /*0xffe34cfb*/
LODWORD(v4) = *(_DWORD *)(ApInitCheck(v3) + a1); /*0xffe34d02*/
else
return __readmsr((a1 >> 4) + 2048); /*0xffe34d16*/
return v4; /*0xffe34d18*/
}
// Function: FillCpuData @ 0xffe34d1d (0x67 bytes)
// Index: 39/163
int __fastcall FillCpuData(unsigned int a1, unsigned int a2)
{
int Service; // eax
void *v5; // ecx
int result; // eax
if ( (a1 & 0xF) != 0 ) /*0xffe34d2c*/
{
Service = DebugPrintGetService(); /*0xffe34d2e*/
if ( Service ) /*0xffe34d35*/
(*(void (__cdecl **)(const char *, int, const char *))(Service + 4))( /*0xffe34d46*/
"e:\\hs\\UefiCpuPkg\\Library\\BaseXApicX2ApicLib\\BaseXApicX2ApicLib.c",
210,
"(MmioOffset & 0xf) == 0");
}
if ( ReadCheck() == 1 ) /*0xffe34d54*/
{
result = ApInitCheck(v5); /*0xffe34d56*/
*(_DWORD *)(result + a1) = a2; /*0xffe34d5b*/
}
else
{
__writemsr((a1 >> 4) + 2048, a2); /*0xffe34d7c*/
return a2; /*0xffe34d76*/
}
return result; /*0xffe34d7e*/
}
// Function: InitPlatform @ 0xffe34d84 (0xcc bytes)
// Index: 40/163
int __fastcall InitPlatform(unsigned int a1, unsigned int n0xFF)
{
void *v4; // ecx
int Service; // eax
__int16 v6; // kr00_2
int v7; // ecx
int v8; // edx
__int64 v9; // rax
if ( ReadCheck() == 1 ) /*0xffe34d99*/
{
if ( n0xFF > 0xFF ) /*0xffe34da1*/
{
Service = DebugPrintGetService(); /*0xffe34da3*/
if ( Service ) /*0xffe34daa*/
(*(void (__cdecl **)(const char *, int, const char *))(Service + 4))( /*0xffe34dbb*/
"e:\\hs\\UefiCpuPkg\\Library\\BaseXApicX2ApicLib\\BaseXApicX2ApicLib.c",
260,
"ApicId <= 0xff");
}
v6 = __readeflags(); /*0xffe34dc1*/
_disable(); /*0xffe34dc3*/
v7 = ApInitCheck(v4); /*0xffe34dd1*/
v8 = *(_DWORD *)(v7 + 784); /*0xffe34dd8*/
while ( (*(_DWORD *)(v7 + 768) & 0x1000) != 0 ) /*0xffe34de6*/
; /*0xffe34dde*/
*(_DWORD *)(v7 + 784) = n0xFF << 24; /*0xffe34deb*/
*(_DWORD *)(v7 + 768) = a1; /*0xffe34df1*/
do /*0xffe34dff*/
LODWORD(v9) = *(_DWORD *)(v7 + 768); /*0xffe34df7*/
while ( (v9 & 0x1000) != 0 ); /*0xffe34dff*/
*(_DWORD *)(v7 + 784) = v8; /*0xffe34e05*/
if ( (v6 & 0x200) != 0 ) /*0xffe34e0b*/
_enable(); /*0xffe34e0d*/
else
_disable(); /*0xffe34e10*/
}
else
{
v9 = a1; /*0xffe34e3f*/
__writemsr(0x830u, a1); /*0xffe34e47*/
}
return v9; /*0xffe34e49*/
}
// Function: ReadCheck @ 0xffe34e50 (0x51 bytes)
// Index: 41/163
int __thiscall ReadCheck(void *this)
{
unsigned __int64 v2; // rax
__int16 v3; // si
int Service; // eax
if ( !ApModeCheck(this) ) /*0xffe34e52*/
return 1; /*0xffe34e5d*/
v2 = __readmsr(0x1Bu); /*0xffe34e66*/
v3 = v2; /*0xffe34e68*/
if ( (v2 & 0x800) == 0 ) /*0xffe34e70*/
{
Service = DebugPrintGetService(); /*0xffe34e72*/
if ( Service ) /*0xffe34e79*/
(*(void (__cdecl **)(const char *, int, const char *))(Service + 4))( /*0xffe34e8a*/
"e:\\hs\\UefiCpuPkg\\Library\\BaseXApicX2ApicLib\\BaseXApicX2ApicLib.c",
343,
"ApicBaseMsr.Bits.EN != 0");
}
return ((v3 & 0x400) != 0) + 1; /*0xffe34ea0*/
}
// Function: MpCheckDone @ 0xffe34ea1 (0x3b bytes)
// Index: 42/163
char __thiscall MpCheckDone(void *this)
{
unsigned __int64 v1; // rax
void *v2; // ecx
LOBYTE(v1) = ApModeCheck(this); /*0xffe34ea6*/
if ( (_BYTE)v1 ) /*0xffe34ead*/
{
LODWORD(v1) = ReadCheck(v2); /*0xffe34eaf*/
if ( (_DWORD)v1 == 1 ) /*0xffe34eb7*/
{
v1 = __readmsr(0x1Bu); /*0xffe34ebe*/
LODWORD(v1) = v1 | 0x400; /*0xffe34ec0*/
__writemsr(0x1Bu, v1); /*0xffe34ed6*/
}
}
return v1; /*0xffe34ed8*/
}
// Function: GetCpuCount @ 0xffe34edc (0x71 bytes)
// Index: 43/163
int __thiscall GetCpuCount(void *this)
{
int v2; // [esp+4h] [ebp-Ch] BYREF
unsigned int n0xB; // [esp+8h] [ebp-8h] BYREF
unsigned int v4; // [esp+Ch] [ebp-4h] BYREF
if ( ReadCheck(this) != 1 ) /*0xffe34eeb*/
return GetBistStatus(); /*0xffe34f43*/
BitFieldFieldType(0, &n0xB, 0, 0, 0); /*0xffe34ef7*/
if ( n0xB >= 0xB ) /*0xffe34f05*/
{
RclRead(0, &v4, 0, &v2); /*0xffe34f13*/
if ( (_WORD)v4 ) /*0xffe34f21*/
return v2; /*0xffe34f23*/
}
BitFieldFieldType(1, 0, &v4, 0, 0); /*0xffe34f33*/
return HIBYTE(v4); /*0xffe34f48*/
}
// Function: GetBistStatus @ 0xffe34f4d (0x2c bytes)
// Index: 44/163
unsigned int GetBistStatus()
{
unsigned int v0; // esi
void *v1; // ecx
void *v2; // ecx
unsigned int CpuCount; // eax
v0 = SortCpuList(0x20u); /*0xffe34f56*/
if ( ReadCheck(v1) == 1 ) /*0xffe34f60*/
{
CpuCount = GetCpuCount(v2); /*0xffe34f62*/
if ( CpuCount >= 0x100 ) /*0xffe34f6c*/
return CpuCount; /*0xffe34f73*/
else
v0 >>= 24; /*0xffe34f6e*/
}
return v0; /*0xffe34f77*/
}
// Function: ExecuteBistCommand @ 0xffe34f79 (0x92 bytes)
// Index: 45/163
int __fastcall ExecuteBistCommand(unsigned int n0xFF, unsigned int n0x100000)
{
int Service; // eax
int v5; // eax
unsigned int v6; // esi
if ( n0x100000 >= 0x100000 ) /*0xffe34f8b*/
{
Service = DebugPrintGetService(); /*0xffe34f8d*/
if ( Service ) /*0xffe34f94*/
(*(void (__cdecl **)(const char *, int, const char *))(Service + 4))( /*0xffe34fa1*/
"e:\\hs\\UefiCpuPkg\\Library\\BaseXApicX2ApicLib\\BaseXApicX2ApicLib.c",
642,
"StartupRoutine < 0x100000");
}
if ( (n0x100000 & 0xFFF) != 0 ) /*0xffe34fad*/
{
v5 = DebugPrintGetService(); /*0xffe34faf*/
if ( v5 ) /*0xffe34fb6*/
(*(void (__cdecl **)(const char *, int, const char *))(v5 + 4))( /*0xffe34fc3*/
"e:\\hs\\UefiCpuPkg\\Library\\BaseXApicX2ApicLib\\BaseXApicX2ApicLib.c",
643,
"(StartupRoutine & 0xfff) == 0");
}
InitPlatform(0x4500u, n0xFF); /*0xffe34fd0*/
SwitchStackFinish(0xAu); /*0xffe34fd8*/
v6 = (n0x100000 & 0xFF000 | 0x4600000) >> 12; /*0xffe34feb*/
InitPlatform(v6, n0xFF); /*0xffe34ff0*/
SwitchStackFinish(0xC8u); /*0xffe34ffa*/
return InitPlatform(v6, n0xFF); /*0xffe35003*/
}
// Function: MpSendApicCommand @ 0xffe3500b (0x91 bytes)
// Index: 46/163
int __fastcall MpSendApicCommand(unsigned int n0x100000)
{
int Service; // eax
int v3; // eax
unsigned int v4; // esi
if ( n0x100000 >= 0x100000 ) /*0xffe3501b*/
{
Service = DebugPrintGetService(); /*0xffe3501d*/
if ( Service ) /*0xffe35024*/
(*(void (__cdecl **)(const char *, int, const char *))(Service + 4))( /*0xffe35031*/
"e:\\hs\\UefiCpuPkg\\Library\\BaseXApicX2ApicLib\\BaseXApicX2ApicLib.c",
675,
"StartupRoutine < 0x100000");
}
if ( (n0x100000 & 0xFFF) != 0 ) /*0xffe3503d*/
{
v3 = DebugPrintGetService(); /*0xffe3503f*/
if ( v3 ) /*0xffe35046*/
(*(void (__cdecl **)(const char *, int, const char *))(v3 + 4))( /*0xffe35053*/
"e:\\hs\\UefiCpuPkg\\Library\\BaseXApicX2ApicLib\\BaseXApicX2ApicLib.c",
676,
"(StartupRoutine & 0xfff) == 0");
}
InitPlatform(0xC4500u, 0); /*0xffe35060*/
SwitchStackFinish(0xAu); /*0xffe35068*/
v4 = (n0x100000 & 0xFF000 | 0xC4600FFF) >> 12; /*0xffe3507b*/
InitPlatform(v4, 0); /*0xffe35080*/
SwitchStackFinish(0xC8u); /*0xffe3508a*/
return InitPlatform(v4, 0); /*0xffe35098*/
}
// Function: MpInitComplete @ 0xffe3509c (0x5d bytes)
// Index: 47/163
int MpInitComplete()
{
int v0; // eax
int v1; // eax
int v2; // eax
v0 = SortCpuList(0xF0u); /*0xffe350a4*/
FillCpuData(0xF0u, v0 & 0xFFFFFE00 | 0x10F); /*0xffe350b7*/
v1 = SortCpuList(0x350u); /*0xffe350c3*/
FillCpuData(0x350u, v1 & 0xFFFE58FF | 0x700); /*0xffe350d6*/
v2 = SortCpuList(0x360u); /*0xffe350e0*/
return FillCpuData(0x360u, v2 & 0xFFFE58FF | 0x400); /*0xffe350f3*/
}
// Function: SetApicTimer @ 0xffe350f9 (0xe9 bytes)
// Index: 48/163
int __fastcall SetApicTimer(unsigned int n0x80, unsigned int a2, char a3, unsigned __int8 a4)
{
int v6; // eax
int v7; // edx
int Service; // eax
int v9; // edx
int v10; // eax
char v11; // si
int v12; // eax
int v13; // eax
unsigned int v14; // eax
v6 = SortCpuList(0xF0u); /*0xffe35105*/
if ( (v6 & 0x100) == 0 ) /*0xffe35111*/
FillCpuData(0xF0u, v6 | 0x100); /*0xffe3511a*/
FillCpuData(0x380u, a2); /*0xffe35126*/
if ( n0x80 ) /*0xffe3512d*/
{
if ( n0x80 > 0x80 ) /*0xffe3513a*/
{
Service = DebugPrintGetService(); /*0xffe3513c*/
if ( Service ) /*0xffe35143*/
(*(void (__cdecl **)(const char *, int, const char *))(Service + 4))( /*0xffe35150*/
"e:\\hs\\UefiCpuPkg\\Library\\BaseXApicX2ApicLib\\BaseXApicX2ApicLib.c",
854,
"DivideValue <= 128");
}
if ( n0x80 != WriteMsr64(n0x80, v7) ) /*0xffe3515f*/
{
v10 = DebugPrintGetService(); /*0xffe35161*/
if ( v10 ) /*0xffe35168*/
(*(void (__cdecl **)(const char *, int, const char *))(v10 + 4))( /*0xffe35175*/
"e:\\hs\\UefiCpuPkg\\Library\\BaseXApicX2ApicLib\\BaseXApicX2ApicLib.c",
855,
"DivideValue == GetPowerOfTwo32((UINT32)DivideValue)");
}
v11 = (UnalignedRead16(n0x80, v9) - 1) & 7; /*0xffe3518c*/
v12 = SortCpuList(0x3E0u); /*0xffe3518f*/
FillCpuData(0x3E0u, v11 & 3 | v12 & 0xFFFFFFF4 | (2 * (v11 & 4))); /*0xffe351a7*/
}
v13 = SortCpuList(0x320u); /*0xffe351b3*/
if ( a3 ) /*0xffe351bd*/
v14 = v13 | 0x20000; /*0xffe351bf*/
else
v14 = v13 & 0xFFFDFFFF; /*0xffe351c6*/
return FillCpuData(0x320u, v14 & 0xFFFEFF00 | a4); /*0xffe351de*/
}
// Function: GetNextCpu @ 0xffe351e2 (0x88 bytes)
// Index: 49/163
int __fastcall GetNextCpu(int *a1, bool *a2, _BYTE *a3)
{
int result; // eax
unsigned int v6; // eax
result = SortCpuList(0xF0u); /*0xffe351ed*/
if ( (result & 0x100) == 0 ) /*0xffe351f7*/
{
result = DebugPrintGetService(); /*0xffe351f9*/
if ( result ) /*0xffe35200*/
result = (*(int (__cdecl **)(const char *, int, const char *))(result + 4))( /*0xffe35211*/
"e:\\hs\\UefiCpuPkg\\Library\\BaseXApicX2ApicLib\\BaseXApicX2ApicLib.c",
904,
"(ReadLocalApicReg(0x0f0) & 0x00000100) != 0");
}
if ( a1 ) /*0xffe35219*/
{
v6 = SortCpuList(0x3E0u); /*0xffe35220*/
result = 1 << ((((v6 >> 1) ^ (v6 ^ (v6 >> 1)) & 3) + 1) & 7); /*0xffe35239*/
*a1 = result; /*0xffe3523b*/
}
if ( a2 || a3 ) /*0xffe35247*/
{
result = SortCpuList(0x320u); /*0xffe3524e*/
if ( a2 ) /*0xffe35255*/
*a2 = (result & 0x20000) != 0; /*0xffe3525f*/
if ( a3 ) /*0xffe35263*/
*a3 = result; /*0xffe35265*/
}
return result; /*0xffe35267*/
}
// Function: GetApicBase @ 0xffe3526a (0x1e bytes)
// Index: 50/163
int GetApicBase()
{
int v0; // eax
v0 = SortCpuList(0x320u); /*0xffe35270*/
return FillCpuData(0x320u, v0 | 0x10000); /*0xffe35287*/
}
// Function: GetApicId @ 0xffe35288 (0x262 bytes)
// Index: 51/163
int *__fastcall GetApicId(unsigned int a1, int *a2, int *a3, unsigned int *a4)
{
char v4; // si
unsigned int v6; // edi
int *result; // eax
int Service; // eax
int v9; // ebp
unsigned int v10; // edi
unsigned int v11; // ebp
int v12; // edx
char v13; // al
int v14; // [esp+10h] [ebp-34h] BYREF
int v15; // [esp+14h] [ebp-30h] BYREF
unsigned int v16; // [esp+18h] [ebp-2Ch]
unsigned int n4; // [esp+1Ch] [ebp-28h] BYREF
unsigned int v18; // [esp+20h] [ebp-24h] BYREF
int v19; // [esp+24h] [ebp-20h] BYREF
int v20; // [esp+28h] [ebp-1Ch] BYREF
int v21; // [esp+2Ch] [ebp-18h] BYREF
unsigned int v22; // [esp+30h] [ebp-14h] BYREF
int v23; // [esp+34h] [ebp-10h] BYREF
unsigned int v24; // [esp+38h] [ebp-Ch] BYREF
int v25; // [esp+3Ch] [ebp-8h] BYREF
int *v26; // [esp+40h] [ebp-4h]
v4 = 0; /*0xffe35293*/
v6 = a1; /*0xffe3529a*/
v26 = a2; /*0xffe3529c*/
v16 = a1; /*0xffe352a2*/
BitFieldFieldType(1, 0, 0, 0, &v19); /*0xffe352ab*/
if ( (v19 & 0x10000000) != 0 ) /*0xffe352bb*/
{
BitFieldFieldType(0, &n4, 0, 0, 0); /*0xffe352ea*/
BitFieldFieldType(0x80000000, &v22, 0, 0, 0); /*0xffe352fb*/
if ( n4 >= 0xB && (RclRead(&v15, &v20, &v14, 0), v20) ) /*0xffe3532f*/
{
if ( (v14 & 0xFF00) != 0x100 ) /*0xffe35343*/
{
Service = DebugPrintGetService(); /*0xffe35345*/
if ( Service ) /*0xffe3534c*/
(*(void (__cdecl **)(const char *, int, const char *))(Service + 4))( /*0xffe3535d*/
"e:\\hs\\UefiCpuPkg\\Library\\BaseXApicX2ApicLib\\BaseXApicX2ApicLib.c",
1164,
"LevelType == 0x01");
}
LOBYTE(v9) = v15 & 0x1F; /*0xffe35369*/
v16 = 1; /*0xffe3536c*/
while ( 1 ) /*0xffe35381*/
{
RclRead(&v15, 0, &v14, 0); /*0xffe35381*/
if ( BYTE1(v14) == 2 ) /*0xffe35396*/
break; /*0xffe35396*/
++v16; /*0xffe3539d*/
if ( !BYTE1(v14) ) /*0xffe353a3*/
goto LABEL_26; /*0xffe353a3*/
}
v4 = (v15 & 0x1F) - v9; /*0xffe353b1*/
}
else
{
BitFieldFieldType(1, 0, &v21, 0, 0); /*0xffe353c3*/
v10 = 1; /*0xffe353d2*/
v11 = BYTE2(v21); /*0xffe353d4*/
if ( ApStackCheck() ) /*0xffe353d7*/
{
if ( v22 >= 0x8000001E ) /*0xffe353e8*/
{
BitFieldFieldType(-2147483647, 0, 0, &v23, 0); /*0xffe353fc*/
if ( (v23 & 0x400000) != 0 ) /*0xffe3540c*/
{
BitFieldFieldType(-2147483640, 0, 0, &v24, 0); /*0xffe3541c*/
v11 = 1 << ((v24 >> 12) & 0xF); /*0xffe35434*/
BitFieldFieldType(-2147483618, 0, &v25, 0, 0); /*0xffe3543d*/
v10 = v11 / ((unsigned int)BYTE1(v25) + 1); /*0xffe35456*/
}
}
}
else if ( n4 >= 4 ) /*0xffe35461*/
{
RclRead(&v18, 0, 0, 0); /*0xffe3546d*/
if ( v18 ) /*0xffe35479*/
v10 = ((v18 >> 14) & 0xFFF) + 1; /*0xffe35488*/
}
v9 = UnalignedRead16(v11 / v10 - 1, v11 % v10) + 1; /*0xffe3549a*/
v13 = UnalignedRead16(v10 - 1, v12); /*0xffe3549d*/
v6 = v16; /*0xffe354a2*/
v4 = v13 + 1; /*0xffe354a6*/
}
LABEL_26:
if ( a4 ) /*0xffe354af*/
*a4 = v6 & ((1 << v9) - 1); /*0xffe354ba*/
if ( a3 ) /*0xffe354c2*/
*a3 = ((1 << v4) - 1) & (v6 >> v9); /*0xffe354d1*/
result = v26; /*0xffe354d3*/
if ( v26 ) /*0xffe354d9*/
*v26 = v6 >> (v4 + v9); /*0xffe354e0*/
}
else
{
if ( a4 ) /*0xffe352c3*/
*a4 = 0; /*0xffe352c5*/
result = a3; /*0xffe352c7*/
if ( a3 ) /*0xffe352cd*/
*a3 = 0; /*0xffe352cf*/
if ( a2 ) /*0xffe352d3*/
*a2 = 0; /*0xffe352d9*/
}
return result; /*0xffe354e2*/
}
// Function: CpuBistClear @ 0xffe354ea (0x30 bytes)
// Index: 52/163
int CpuBistClear()
{
int Ppi; // eax
int v1; // eax
Ppi = PeiServicesGetPpi(); /*0xffe354ea*/
v1 = (*(int (__cdecl **)(int, int, int, _DWORD, void *, _DWORD))(*(_DWORD *)Ppi + 88))( /*0xffe35505*/
Ppi,
-2147483646,
69636,
0,
&unk_FFE3B8F4,
0);
return v1 != -1610612734 ? v1 : 0;
}
// Function: InitializeDebugAgent @ 0xffe3551a (0x2f bytes)
// Index: 53/163
void __usercall InitializeDebugAgent(int FxState@<edi>, int n0x20, _DWORD *p_NestedExceptionType)
{
ExceptionHandler(p_NestedExceptionType); /*0xffe35524*/
SendInitSipiSipi(p_NestedExceptionType[147], FxState); /*0xffe35533*/
while ( 1 ) /*0xffe3553f*/
; /*0xffe3553f*/
}
// Function: InitializeDebugAgent_0 @ 0xffe35549 (0xce bytes)
// Index: 54/163
int __thiscall InitializeDebugAgent_0(_DWORD *this)
{
unsigned int n2; // ecx
_DWORD *this_1; // edx
unsigned int n32; // esi
unsigned int n32_1; // edx
_DWORD *v6; // ebx
_WORD *v7; // ecx
int v8; // eax
unsigned __int16 v10; // [esp+8h] [ebp-614h] BYREF
int v11; // [esp+Ah] [ebp-612h]
_DWORD v12[3]; // [esp+10h] [ebp-60Ch] BYREF
_BYTE buf[8]; // [esp+1Ch] [ebp-600h] BYREF
_DWORD v14[382]; // [esp+24h] [ebp-5F8h] BYREF
if ( this ) /*0xffe35555*/
{
AllocatePool(buf, 0x600u); /*0xffe35560*/
n2 = *(this + 1); /*0xffe35565*/
this_1 = this; /*0xffe35568*/
while ( n2 != 0x80000000 ) /*0xffe35590*/
{
if ( n2 > 2 ) /*0xffe35574*/
return -2147483646; /*0xffe35610*/
if ( *this_1 < 0x20u ) /*0xffe3557f*/
v14[12 * *this_1] = n2; /*0xffe35584*/
n2 = this_1[7]; /*0xffe35588*/
this_1 += 6; /*0xffe3558b*/
}
}
AsmReadCr2(&v10); /*0xffe35596*/
n32 = ((unsigned int)v10 + 1) >> 3; /*0xffe355a1*/
if ( n32 > 0x20 ) /*0xffe355a7*/
n32 = 32; /*0xffe355ab*/
CpuPause(v12); /*0xffe355ba*/
n32_1 = 0; /*0xffe355bf*/
if ( n32 ) /*0xffe355c4*/
{
v6 = v14; /*0xffe355cb*/
v7 = (_WORD *)(v11 + 6); /*0xffe355cf*/
do /*0xffe35601*/
{
*(v7 - 2) = __CS__; /*0xffe355d2*/
if ( !this || *v6 ) /*0xffe355da*/
{
v8 = v12[0] + n32_1 * v12[1]; /*0xffe355e6*/
*(v7 - 3) = v8; /*0xffe355ea*/
*v7 = HIWORD(v8); /*0xffe355f1*/
*((_BYTE *)v7 - 1) = -114; /*0xffe355f4*/
}
++n32_1; /*0xffe355f8*/
v6 += 12; /*0xffe355f9*/
v7 += 4; /*0xffe355fc*/
}
while ( n32_1 < n32 ); /*0xffe35601*/
}
return 0; /*0xffe35607*/
}
// Function: ExceptionHandler @ 0xffe35617 (0x1f7 bytes)
// Index: 55/163
int __cdecl ExceptionHandler(_DWORD *p_NestedExceptionType)
{
unsigned int n0x15; // ecx
unsigned int n14; // esi
const char *Reserved; // edi
unsigned int BistStatus; // eax
int v6; // [esp+0h] [ebp-8h]
n14 = n0x15; /*0xffe3561b*/
if ( n0x15 >= 0x15 ) /*0xffe35621*/
Reserved = "Reserved"; /*0xffe3562c*/
else
Reserved = off_FFE3A474[n0x15]; // "#DE - Divide Error" /*0xffe35623*/
BistStatus = GetBistStatus(); /*0xffe35631*/
SendSipi( /*0xffe3563e*/
"!!!! IA32 Exception Type - %02x(%a) CPU Apic ID - %08x !!!!\n",
n14,
COERCE_DOUBLE(__PAIR64__(BistStatus, (unsigned int)Reserved)),
v6);
if ( ((1 << n14) & 0x27D00) != 0 ) /*0xffe35654*/
{
SendSipi("ExceptionData - %08x", *p_NestedExceptionType); /*0xffe35660*/
if ( n14 == 14 ) /*0xffe3566a*/
SendSipi( /*0xffe356a8*/
" I:%x R:%x U:%x W:%x P:%x PK:%x S:%x",
(*p_NestedExceptionType >> 4) & 1,
(*p_NestedExceptionType >> 3) & 1,
(*p_NestedExceptionType >> 2) & 1,
(*p_NestedExceptionType >> 1) & 1,
*p_NestedExceptionType & 1,
(*p_NestedExceptionType >> 5) & 1,
(*p_NestedExceptionType >> 15) & 1);
SendSipi("\n"); /*0xffe356b5*/
}
SendSipi( /*0xffe356d5*/
"EIP - %08x, CS - %08x, EFLAGS - %08x\n",
p_NestedExceptionType[147],
p_NestedExceptionType[152],
p_NestedExceptionType[140]);
SendSipi( /*0xffe356fa*/
"EAX - %08x, ECX - %08x, EDX - %08x, EBX - %08x\n",
p_NestedExceptionType[161],
p_NestedExceptionType[160],
p_NestedExceptionType[159],
p_NestedExceptionType[158]);
SendSipi( /*0xffe3571f*/
"ESP - %08x, EBP - %08x, ESI - %08x, EDI - %08x\n",
p_NestedExceptionType[157],
p_NestedExceptionType[156],
p_NestedExceptionType[155],
p_NestedExceptionType[154]);
SendSipi( /*0xffe3574a*/
"DS - %08x, ES - %08x, FS - %08x, GS - %08x, SS - %08x\n",
p_NestedExceptionType[151],
p_NestedExceptionType[150],
p_NestedExceptionType[149],
p_NestedExceptionType[148],
p_NestedExceptionType[153]);
SendSipi( /*0xffe35772*/
"CR0 - %08x, CR2 - %08x, CR3 - %08x, CR4 - %08x\n",
p_NestedExceptionType[135],
p_NestedExceptionType[137],
p_NestedExceptionType[138],
p_NestedExceptionType[139]);
SendSipi( /*0xffe35797*/
"DR0 - %08x, DR1 - %08x, DR2 - %08x, DR3 - %08x\n",
p_NestedExceptionType[129],
p_NestedExceptionType[130],
p_NestedExceptionType[131],
p_NestedExceptionType[132]);
SendSipi("DR6 - %08x, DR7 - %08x\n", p_NestedExceptionType[133], p_NestedExceptionType[134]); /*0xffe357b0*/
SendSipi( /*0xffe357d5*/
"GDTR - %08x %08x, IDTR - %08x %08x\n",
p_NestedExceptionType[143],
p_NestedExceptionType[144],
p_NestedExceptionType[145],
p_NestedExceptionType[146]);
SendSipi("LDTR - %08x, TR - %08x\n", p_NestedExceptionType[141], p_NestedExceptionType[142]); /*0xffe357f1*/
return SendSipi("FXSAVE_STATE - %08x\n", p_NestedExceptionType + 1); /*0xffe3580a*/
}
// Function: SendSipi @ 0xffe3580e (0x42 bytes)
// Index: 56/163
int SendSipi(unsigned __int8 *%02d_%02d_%04d__%02d:%02d, ...)
{
unsigned int Msr64; // eax
unsigned __int8 _r_n[256]; // [esp+0h] [ebp-100h] BYREF
va_list va; // [esp+10Ch] [ebp+Ch] BYREF
va_start(va, %02d_%02d_%04d__%02d:%02d);
PrintLibInternalWorker(_r_n, 0x100u, 0, %02d_%02d_%04d__%02d:%02d, (int)va); /*0xffe3582c*/
Msr64 = ReadMsr64(_r_n); /*0xffe3583a*/
return PpiGetBist(_r_n, Msr64); /*0xffe3584c*/
}
// Function: SendInitSipiSipi @ 0xffe35850 (0x77 bytes)
// Index: 57/163
int __usercall SendInitSipiSipi@<eax>(unsigned int a1@<ecx>, int FxState@<edi>)
{
char *FixedMtrr; // eax
char *FixedMtrr_1; // esi
int v5; // edi
char *MemoryAttributesInMtrr; // eax
double v7; // [esp-8h] [ebp-10h]
int v8; // [esp+4h] [ebp-4h] BYREF
FixedMtrr = (char *)MtrrGetFixedMtrr(a1); /*0xffe35855*/
FixedMtrr_1 = FixedMtrr; /*0xffe3585a*/
if ( !FixedMtrr ) /*0xffe3585e*/
return SendSipi("!!!! Can't find image information. !!!!\n"); /*0xffe35865*/
HIDWORD(v7) = FxState; /*0xffe3586d*/
if ( MtrrGetNumberOfVariableMtrrs(FixedMtrr, &v8) >= 0 ) /*0xffe3587a*/
v5 = v8; /*0xffe35880*/
else
v5 = 0; /*0xffe3587c*/
SendSipi("!!!! Find image "); /*0xffe35888*/
MemoryAttributesInMtrr = MtrrGetMemoryAttributesInMtrr(FixedMtrr_1); /*0xffe35890*/
if ( MemoryAttributesInMtrr ) /*0xffe35897*/
{
LODWORD(v7) = MemoryAttributesInMtrr; /*0xffe35899*/
SendSipi("%a", v7); /*0xffe3589f*/
}
else
{
SendSipi("(No PDB) "); /*0xffe358ac*/
}
return SendSipi(" (ImageBase=%016lp, EntryPoint=%016p) !!!!\n", FixedMtrr_1, v5); /*0xffe358c2*/
}
// Function: StartupAp @ 0xffe358c7 (0x37 bytes)
// Index: 58/163
int StartupAp()
{
int v0; // esi
_WORD *v1; // eax
int Service; // eax
v0 = 0; /*0xffe358cd*/
v1 = PpiFind(byte_FFE3B94C); /*0xffe358cf*/
if ( !v1 || (v0 = *((_DWORD *)v1 + 6)) == 0 ) /*0xffe358dd*/
{
Service = DebugPrintGetService(); /*0xffe358df*/
if ( Service ) /*0xffe358e6*/
(*(void (__cdecl **)(const char *, int, const char *))(Service + 4))( /*0xffe358f4*/
"e:\\hs\\PurleySktPkg\\Override\\UefiCpuPkg\\Library\\MpInitLib\\PeiMpLib.c",
41,
"CpuMpData != ((void *) 0)");
}
return v0; /*0xffe358fc*/
}
// Function: MpWakeupBuffer @ 0xffe358fe (0x133 bytes)
// Index: 59/163
unsigned int __thiscall MpWakeupBuffer(void *this)
{
unsigned int n0x100000_1; // ebp
UINTN v2; // esi
__int16 i; // ax
unsigned int n0x100000; // edi
unsigned int v5; // ebx
UINTN j; // eax
EFI_PEI_SERVICES **PeiServices; // [esp+0h] [ebp-1Ch]
EFI_PEI_SERVICES **PeiServices_1; // [esp+0h] [ebp-1Ch]
unsigned int n0x100000_2; // [esp+18h] [ebp-4h]
n0x100000_1 = ((unsigned int)this + 4095) & 0xFFFFF000; /*0xffe3590b*/
v2 = PpiLocate(PeiServices); /*0xffe35916*/
for ( i = *(_WORD *)v2; *(_WORD *)v2 != 0xFFFF; i = *(_WORD *)v2 ) /*0xffe35923*/
{
if ( i == 3 && *(_QWORD *)(v2 + 32) < 0x100000u && !*(_DWORD *)(v2 + 24) && (*(_DWORD *)(v2 + 28) & 0x380) == 0 ) /*0xffe35966*/
{
n0x100000 = *(_DWORD *)(v2 + 32) + *(_DWORD *)(v2 + 40); /*0xffe3596f*/
if ( n0x100000 > 0x100000 ) /*0xffe35978*/
n0x100000 = 0x100000; /*0xffe3597a*/
if ( n0x100000 > n0x100000_1 ) /*0xffe35981*/
{
do /*0xffe35a09*/
{
n0x100000_2 = n0x100000 - n0x100000_1; /*0xffe3598d*/
v5 = (n0x100000 - n0x100000_1) & 0xFFFFF000; /*0xffe35991*/
if ( (unsigned __int64)v5 < *(_QWORD *)(v2 + 32) ) /*0xffe359a1*/
break; /*0xffe359a1*/
for ( j = PpiLocate(PeiServices_1); ; j += *(unsigned __int16 *)(j + 2) ) /*0xffe359a3*/
{
if ( *(_WORD *)j == 0xFFFF ) /*0xffe359ec*/
{
DebugPrint( /*0xffe359f7*/
64,
"WakeupBufferStart = %x, WakeupBufferSize = %x\n",
(n0x100000 - n0x100000_1) & 0xFFFFF000,
n0x100000_1);
return (n0x100000 - n0x100000_1) & 0xFFFFF000; /*0xffe35a01*/
}
if ( *(_WORD *)j == 2 /*0xffe359d9*/
&& (unsigned __int64)v5 < *(_QWORD *)(j + 24) + *(_QWORD *)(j + 32)
&& (unsigned __int64)n0x100000 > *(_QWORD *)(j + 24) )
{
break; /*0xffe359d9*/
}
}
n0x100000 -= n0x100000_1; /*0xffe35a03*/
}
while ( n0x100000_2 > n0x100000_1 ); /*0xffe35a09*/
}
}
v2 += *(unsigned __int16 *)(v2 + 2); /*0xffe35a18*/
}
return -1; /*0xffe35a29*/
}
// Function: MpTimerInit @ 0xffe35a31 (0x4e bytes)
// Index: 60/163
void __thiscall MpTimerInit(unsigned int *this)
{
unsigned int v2; // eax
int v3; // ecx
if ( *(this + 12) == -1 ) /*0xffe35a38*/
{
v2 = MpWakeupBuffer((void *)(*(this + 9) + 76)); /*0xffe35a40*/
v3 = *(this + 9); /*0xffe35a45*/
*(this + 12) = v2; /*0xffe35a4a*/
*(this + 200) = v2 + v3; /*0xffe35a4d*/
}
if ( *(this + 14) ) /*0xffe35a53*/
CopyMemWrapper((char *)*(this + 13), (char *)*(this + 12), *(this + 14)); /*0xffe35a62*/
if ( *(this + 9) ) /*0xffe35a68*/
CopyMemWrapper((char *)*(this + 12), (char *)*(this + 7), *(this + 9)); /*0xffe35a77*/
}
// Function: MpTimerCheck @ 0xffe35a7f (0x1a bytes)
// Index: 61/163
void __usercall MpTimerCheck(int a1@<edx>, int a2)
{
AsmWriteMsr64(a2 + 160, a1, a2, a2 + 160, (_BYTE *)(a2 + 140)); /*0xffe35a91*/
}
// Function: ApSpinLock @ 0xffe35a99 (0x17 bytes)
// Index: 62/163
_DWORD *__fastcall ApSpinLock(_DWORD *a1, int a2)
{
AsmExchangeWithSpinlock(a1); /*0xffe35a9f*/
a1[5] = a2; /*0xffe35aa4*/
return ApExchangeFunction(a1); /*0xffe35aa9*/
}
// Function: ApInitConfig @ 0xffe35ab0 (0x45 bytes)
// Index: 63/163
bool __thiscall ApInitConfig(int this)
{
bool result; // al
GetNextCpu((int *)(this + 808), (bool *)(this + 813), (_BYTE *)(this + 812)); /*0xffe35ac6*/
*(_DWORD *)(this + 804) = SortCpuList(0x390u); /*0xffe35adb*/
result = (SortCpuList(0x320u) & 0x10000) == 0; /*0xffe35aeb*/
*(_BYTE *)(this + 814) = result; /*0xffe35aed*/
return result; /*0xffe35af3*/
}
// Function: SemaphoreInit @ 0xffe35af5 (0x65 bytes)
// Index: 64/163
int __thiscall SemaphoreInit(unsigned __int32 *this)
{
unsigned __int32 v1; // eax
unsigned __int32 v2; // eax
unsigned __int32 v3; // eax
unsigned __int32 *this_2; // ebx
int result; // eax
unsigned __int32 v6; // eax
unsigned __int32 v7; // eax
unsigned __int32 v8; // eax
unsigned __int32 v9; // eax
unsigned __int32 v10; // eax
int v11; // [esp+Ch] [ebp-8h] BYREF
unsigned __int32 *this_1; // [esp+10h] [ebp-4h]
this_1 = this; /*0xffe35afd*/
v1 = __readcr0(); /*0xffe35b00*/
*this = v1; /*0xffe35b03*/
v2 = __readcr3(); /*0xffe35b05*/
*(this + 1) = v2; /*0xffe35b08*/
v3 = __readcr4(); /*0xffe35b0b*/
this_2 = this_1; /*0xffe35b0e*/
this_1[2] = v3; /*0xffe35b16*/
result = BitFieldFieldType(1, 0, 0, 0, &v11); /*0xffe35b21*/
if ( (v11 & 4) != 0 ) /*0xffe35b2d*/
{
v6 = __readdr(0); /*0xffe35b2f*/
this_2[3] = v6; /*0xffe35b32*/
v7 = __readdr(1u); /*0xffe35b35*/
this_2[4] = v7; /*0xffe35b38*/
v8 = __readdr(2u); /*0xffe35b3b*/
this_2[5] = v8; /*0xffe35b3e*/
v9 = __readdr(3u); /*0xffe35b41*/
this_2[6] = v9; /*0xffe35b44*/
v10 = __readdr(6u); /*0xffe35b47*/
this_2[7] = v10; /*0xffe35b4a*/
result = __readdr(7u); /*0xffe35b4d*/
this_2[8] = result; /*0xffe35b50*/
}
return result; /*0xffe35b53*/
}
// Function: MpDataInit @ 0xffe35b5a (0xa5 bytes)
// Index: 65/163
unsigned __int32 __fastcall MpDataInit(unsigned __int32 *a1, char a2)
{
unsigned __int32 v2; // eax
unsigned __int32 result; // eax
unsigned __int32 *v4; // ecx
int v6; // [esp+10h] [ebp-Ch] BYREF
unsigned __int32 v7; // [esp+14h] [ebp-8h]
char v8; // [esp+1Bh] [ebp-1h]
v2 = *a1; /*0xffe35b60*/
v8 = a2; /*0xffe35b65*/
v7 = v2; /*0xffe35b6b*/
__writecr0(v2); /*0xffe35b71*/
v7 = a1[1]; /*0xffe35b77*/
__writecr3(v7); /*0xffe35b7d*/
v7 = a1[2]; /*0xffe35b83*/
result = v7; /*0xffe35b86*/
__writecr4(v7); /*0xffe35b89*/
if ( v8 ) /*0xffe35b90*/
{
result = BitFieldFieldType(1, 0, 0, 0, &v6); /*0xffe35b9f*/
if ( (v6 & 4) != 0 ) /*0xffe35bab*/
{
v4 = a1; /*0xffe35bad*/
__writedr(0, a1[3]); /*0xffe35bb9*/
__writedr(1u, v4[4]); /*0xffe35bc5*/
__writedr(2u, v4[5]); /*0xffe35bd1*/
__writedr(3u, v4[6]); /*0xffe35bdd*/
__writedr(6u, v4[7]); /*0xffe35be9*/
result = v4[8]; /*0xffe35bf2*/
__writedr(7u, result); /*0xffe35bf5*/
}
}
return result; /*0xffe35bf8*/
}
// Function: MpContextInit @ 0xffe35bff (0xdd bytes)
// Index: 66/163
void __thiscall MpContextInit(char **this)
{
char *src_1; // esi
char *v3; // edi
unsigned int v4; // eax
char *src_2; // ecx
unsigned int v6; // edx
unsigned int v7; // ebx
unsigned int *v8; // esi
char *v9; // ebx
int CpuCount; // eax
_DWORD *i; // ecx
char *src; // [esp+Ch] [ebp-28h]
char *v13; // [esp+10h] [ebp-24h]
unsigned int v14; // [esp+14h] [ebp-20h]
unsigned int v15; // [esp+18h] [ebp-1Ch]
char dst[20]; // [esp+20h] [ebp-14h] BYREF
src_1 = *this; /*0xffe35c0a*/
v13 = *this; /*0xffe35c0d*/
v3 = *(this + 2) - 1; /*0xffe35c11*/
if ( *(this + 2) != (char *)1 ) /*0xffe35c14*/
{
v4 = 0; /*0xffe35c1d*/
src_2 = *this; /*0xffe35c29*/
src = src_1; /*0xffe35c2b*/
do /*0xffe35cac*/
{
v6 = v4 + 1; /*0xffe35c36*/
v14 = v4; /*0xffe35c39*/
v15 = v4 + 1; /*0xffe35c3d*/
if ( v4 + 1 <= (unsigned int)v3 ) /*0xffe35c43*/
{
v7 = *((_DWORD *)src_2 + 1); /*0xffe35c45*/
v8 = (unsigned int *)(src_2 + 24); /*0xffe35c49*/
do /*0xffe35c5c*/
{
if ( v7 > *v8 ) /*0xffe35c4e*/
{
v7 = *v8; /*0xffe35c50*/
v14 = v6; /*0xffe35c52*/
}
++v6; /*0xffe35c56*/
v8 += 5; /*0xffe35c57*/
}
while ( v6 <= (unsigned int)v3 ); /*0xffe35c5c*/
if ( v14 != v4 ) /*0xffe35c68*/
{
CopyMemWrapper(dst, &v13[20 * v14], 0x14u); /*0xffe35c77*/
CopyMemWrapper(&v13[20 * v14], src, 0x14u); /*0xffe35c84*/
CopyMemWrapper(src, dst, 0x14u); /*0xffe35c93*/
src_2 = src; /*0xffe35c98*/
}
}
v4 = v15; /*0xffe35c9f*/
src_2 += 20; /*0xffe35ca3*/
src = src_2; /*0xffe35ca6*/
}
while ( v15 < (unsigned int)v3 ); /*0xffe35cac*/
v9 = 0; /*0xffe35cb2*/
CpuCount = GetCpuCount(src_2); /*0xffe35cb4*/
if ( *(this + 2) ) /*0xffe35cb9*/
{
for ( i = v13 + 4; *i != CpuCount; i += 5 ) /*0xffe35cbf*/
{
if ( ++v9 >= *(this + 2) ) /*0xffe35ccd*/
return; /*0xffe35ccd*/
}
*(this + 3) = v9; /*0xffe35cd1*/
}
}
}
// Function: ApEntryPoint @ 0xffe35cdc (0x5 bytes)
// Index: 67/163
// (too small: 0x5 bytes)
// Function: ApProcedure @ 0xffe35ce1 (0x73 bytes)
// Index: 68/163
int __cdecl ApProcedure(int a1)
{
_BYTE v2[8]; // [esp+10h] [ebp-8h] BYREF
if ( MtrrPrefetchCheck() ) /*0xffe35cf5*/
{
InternalSyncAnd(v2); /*0xffe35d02*/
MtrrGetMemoryAttributeInVariableMtrr((unsigned __int64 *)(a1 + 184)); /*0xffe35d09*/
BitFieldMsr((unsigned __int64 *)(a1 + 272)); /*0xffe35d11*/
__writemsr(0x2FFu, *(_QWORD *)(a1 + 784)); /*0xffe35d37*/
WriteRegister((int)v2); /*0xffe35d3d*/
MtrrSetAttribute(); /*0xffe35d42*/
}
return MicrocodeDetect((_DWORD *)a1); /*0xffe35d4e*/
}
// Function: WaitApDone @ 0xffe35d54 (0x36 bytes)
// Index: 69/163
int __fastcall WaitApDone(_DWORD *a1, _DWORD *this)
{
unsigned int v2; // ebx
int v3; // esi
_DWORD *i; // edi
v2 = a1[2]; /*0xffe35d55*/
v3 = 0; /*0xffe35d5a*/
if ( !v2 ) /*0xffe35d63*/
return -2147483634; /*0xffe35d79*/
for ( i = (_DWORD *)(*a1 + 4); *i != GetBistStatus(); i += 5 ) /*0xffe35d65*/
{
if ( ++v3 >= v2 ) /*0xffe35d77*/
return -2147483634; /*0xffe35d77*/
}
*this = v3; /*0xffe35d83*/
return 0; /*0xffe35d7e*/
}
// Function: MpInitUp @ 0xffe35d8a (0xff bytes)
// Index: 70/163
int __thiscall MpInitUp(int this)
{
unsigned int v1; // ebx
void *v3; // ecx
int Service; // eax
void *v5; // ecx
int v6; // edi
int v7; // eax
v1 = 0; /*0xffe35d8c*/
*(_DWORD *)(this + 128) = 1; /*0xffe35d96*/
*(_BYTE *)(this + 132) = 0; /*0xffe35da0*/
MpInitSleepLoop(this, 1, 0, 0, 0); /*0xffe35da6*/
*(_DWORD *)(this + 128) = 3; /*0xffe35dae*/
if ( *(_DWORD *)(this + 8) > 0x200u ) /*0xffe35dbf*/
{
Service = DebugPrintGetService(); /*0xffe35dc1*/
if ( Service ) /*0xffe35dc8*/
(*(void (__cdecl **)(const char *, int, const char *))(Service + 4))( /*0xffe35dd9*/
"e:\\hs\\PurleySktPkg\\Override\\UefiCpuPkg\\Library\\MpInitLib\\MpLib.c",
451,
"CpuMpData->CpuCount <= _gPcd_FixedAtBuild_PcdCpuMaxLogicalProcessorNumber");
}
while ( *(_DWORD *)(this + 68) < (unsigned int)(*(_DWORD *)(this + 8) - 1) ) /*0xffe35dea*/
_mm_pause(); /*0xffe35de1*/
if ( *(_DWORD *)(this + 8) > 0xFFu ) /*0xffe35df3*/
*(_BYTE *)(this + 132) = 1; /*0xffe35df5*/
if ( *(_BYTE *)(this + 132) ) /*0xffe35dfc*/
{
DebugPrint(64, "Force x2APIC mode!\n"); /*0xffe35e0b*/
MpInitSleepLoop(this, 1, 0, (int)ApEntryPoint, 0); /*0xffe35e1b*/
while ( *(_DWORD *)(this + 68) < (unsigned int)(*(_DWORD *)(this + 8) - 1) ) /*0xffe35e2e*/
_mm_pause(); /*0xffe35e25*/
MpCheckDone(v5); /*0xffe35e30*/
if ( *(_DWORD *)(this + 8) ) /*0xffe35e35*/
{
v6 = 0; /*0xffe35e3a*/
do /*0xffe35e52*/
{
ApSpinLock((_DWORD *)(v6 + *(_DWORD *)(this + 796)), 0); /*0xffe35e46*/
++v1; /*0xffe35e4b*/
v6 += 104; /*0xffe35e4c*/
}
while ( v1 < *(_DWORD *)(this + 8) ); /*0xffe35e52*/
}
}
v7 = ReadCheck(v3); /*0xffe35e54*/
DebugPrint(64, "APIC MODE is %d\n", v7); /*0xffe35e61*/
MpContextInit((char **)this); /*0xffe35e6b*/
DebugPrint(64, "MpInitLib: Find %d processors in system.\n", *(_DWORD *)(this + 8));
return *(_DWORD *)(this + 8); /*0xffe35e85*/
}
// Function: InitializeMpData @ 0xffe35e89 (0x94 bytes)
// Index: 71/163
_DWORD *__fastcall InitializeMpData(int *a1, int a2, int a3, int a4, int a5)
{
int v7; // ebx
int v8; // edi
int v9; // esi
v7 = *a1; /*0xffe35e91*/
v8 = 20 * a2; /*0xffe35e94*/
*(_DWORD *)(v8 + v7) = GetCpuCount(a1); /*0xffe35e9c*/
*(_DWORD *)(v8 + v7 + 4) = GetBistStatus(); /*0xffe35ea8*/
*(_DWORD *)(v8 + v7 + 12) = a4; /*0xffe35eb0*/
v9 = 104 * a2; /*0xffe35eb8*/
*(_DWORD *)(v8 + v7 + 8) = a3; /*0xffe35ebd*/
*(_DWORD *)(v8 + v7 + 16) = a5; /*0xffe35ec1*/
*(_BYTE *)(a1[199] + v9 + 60) = 0; /*0xffe35ece*/
*(_BYTE *)(a1[199] + v9 + 16) = a3 == 0; /*0xffe35ed9*/
if ( *(_DWORD *)(v8 + v7) >= 0xFFu ) /*0xffe35ee4*/
{
AsmExchangeWithSpinlock(a1 + 4); /*0xffe35ee9*/
*((_BYTE *)a1 + 132) = 1; /*0xffe35ef1*/
ApExchangeFunction(a1 + 4); /*0xffe35ef8*/
}
SpinLockInit((_DWORD *)(v9 + a1[199])); /*0xffe35f05*/
return ApSpinLock((_DWORD *)(v9 + a1[199]), 0); /*0xffe35f14*/
}
// Function: InternalSyncIncrement @ 0xffe35f1d (0x320 bytes)
// Index: 72/163
void __cdecl __noreturn InternalSyncIncrement(int a1, int a2)
{
int *v2; // ebx
void *v3; // ecx
unsigned __int32 *v4; // ecx
int v5; // eax
int Service; // eax
int v7; // esi
void (__cdecl *v8)(int); // edi
int v9; // edi
int v10; // edx
int v11; // ecx
unsigned int BistStatus; // eax
void *v13; // ecx
int CpuCount; // eax
int v15; // eax
volatile signed __int32 *i_2; // esi
char n3; // al
int v18; // eax
int v19; // [esp+Ch] [ebp-14h]
int v20; // [esp+10h] [ebp-10h]
volatile signed __int32 *i_1; // [esp+10h] [ebp-10h]
int *v22; // [esp+14h] [ebp-Ch]
int v23; // [esp+18h] [ebp-8h]
volatile signed __int32 *v24; // [esp+18h] [ebp-8h]
int v25; // [esp+18h] [ebp-8h]
int v26; // [esp+18h] [ebp-8h]
int v27; // [esp+1Ch] [ebp-4h] BYREF
volatile signed __int32 *i; // [esp+28h] [ebp+8h]
v2 = *(int **)(a1 + 68); /*0xffe35f29*/
v22 = v2; /*0xffe35f2c*/
MpInitComplete(); /*0xffe35f2f*/
SetApicTimer(v2[202], v2[201], *((_BYTE *)v2 + 813), *((_BYTE *)v2 + 812)); /*0xffe35f50*/
GetApicBase(); /*0xffe35f57*/
v19 = ReadCheck(v3); /*0xffe35f61*/
while ( 1 ) /*0xffe35f64*/
{
if ( v2[32] == 1 ) /*0xffe35f6b*/
{
InternalSyncCompareExchange32(v2 + 2); /*0xffe35f74*/
v27 = a2; /*0xffe35f7c*/
v20 = v2[5] + v2[6] * (a2 + 1); /*0xffe35f88*/
v23 = *(_DWORD *)(v20 - 4); /*0xffe35f8e*/
ApProcedure(v2); /*0xffe35f91*/
v4 = (unsigned __int32 *)v2[199]; /*0xffe35f97*/
__writecr0(v4[6]); /*0xffe35fa6*/
__writecr3(v4[7]); /*0xffe35fb2*/
__writecr4(v4[8]); /*0xffe35fbe*/
v2 = v22; /*0xffe35fc1*/
InitializeMpData(v22, a2, v23, v20, 0); /*0xffe35fd1*/
i = *(volatile signed __int32 **)(104 * a2 + v22[199] + 4); /*0xffe35fe7*/
i_1 = i; /*0xffe35fea*/
v5 = v22[200]; /*0xffe35fed*/
v24 = (volatile signed __int32 *)(v5 + 36); /*0xffe35ff6*/
if ( v5 == -36 ) /*0xffe35ff9*/
{
Service = DebugPrintGetService(); /*0xffe35ffb*/
if ( Service ) /*0xffe36002*/
(*(void (__cdecl **)(const char *, int, const char *))(Service + 4))( /*0xffe36013*/
"e:\\hs\\MdePkg\\Library\\BaseSynchronizationLib\\SynchronizationMsc.c",
293,
"Value != ((void *) 0)");
}
_InterlockedDecrement(v24); /*0xffe3601c*/
}
else
{
WaitApDone(v2, &v27); /*0xffe3602b*/
v7 = 104 * v27; /*0xffe36030*/
i = *(volatile signed __int32 **)(104 * v27 + v2[199] + 4); /*0xffe36047*/
i_1 = i; /*0xffe3604a*/
InternalSyncDecrement(i, 1346458707, 0); /*0xffe3604d*/
if ( *((_BYTE *)v2 + 792) == 1 ) /*0xffe3605a*/
MpDataInit((unsigned __int32 *)(v7 + v2[199] + 24), 1); /*0xffe36069*/
if ( *(_DWORD *)(v7 + v2[199] + 20) == 1 ) /*0xffe36079*/
{
v8 = *(void (__cdecl **)(int))(v7 + v2[199] + 8); /*0xffe36085*/
v25 = *(_DWORD *)(v7 + v2[199] + 12); /*0xffe36093*/
if ( v8 ) /*0xffe36098*/
{
ApSpinLock((_DWORD *)(v7 + v2[199]), 2); /*0xffe360a9*/
v8(v25); /*0xffe360b1*/
v9 = *v2; /*0xffe360ba*/
if ( *((_BYTE *)v2 + 133) ) /*0xffe360b3*/
{
WaitApDone(v2, &v27); /*0xffe360c4*/
v10 = v27; /*0xffe360c9*/
v7 = 104 * v27; /*0xffe360d2*/
*(_DWORD *)(v7 + v2[199] + 8) = 0; /*0xffe360d5*/
*(_DWORD *)(v7 + v2[199] + 12) = 0; /*0xffe360e3*/
v11 = 20 * v2[34]; /*0xffe360eb*/
v10 *= 20; /*0xffe360f8*/
i = *(volatile signed __int32 **)(v7 + v2[199] + 4); /*0xffe360ff*/
i_1 = i; /*0xffe36102*/
*(_DWORD *)(v10 + v9 + 12) = *(_DWORD *)(v11 + v9 + 12); /*0xffe36109*/
*(_DWORD *)(v10 + v9 + 16) = *(_DWORD *)(v11 + v9 + 16); /*0xffe36111*/
}
else
{
v26 = 20 * v27; /*0xffe3611b*/
BistStatus = GetBistStatus(); /*0xffe3611e*/
v13 = (void *)v26; /*0xffe36123*/
if ( *(_DWORD *)(v26 + v9 + 4) != BistStatus /*0xffe36137*/
|| (CpuCount = GetCpuCount((void *)v26), v13 = (void *)v26, *(_DWORD *)(v26 + v9) != CpuCount) )
{
if ( v19 != ReadCheck(v13) ) /*0xffe36141*/
{
v15 = DebugPrintGetService(); /*0xffe36143*/
if ( v15 ) /*0xffe3614a*/
(*(void (__cdecl **)(const char *, int, const char *))(v15 + 4))( /*0xffe3615b*/
"e:\\hs\\PurleySktPkg\\Override\\UefiCpuPkg\\Library\\MpInitLib\\MpLib.c",
651,
"((BOOLEAN)(0==1))");
while ( 1 ) /*0xffe36168*/
; /*0xffe36168*/
}
*(_DWORD *)(v26 + v9 + 4) = GetBistStatus(); /*0xffe36178*/
*(_DWORD *)(v26 + v9) = GetCpuCount((void *)v26); /*0xffe36184*/
}
}
}
ApSpinLock((_DWORD *)(v7 + v2[199]), 3); /*0xffe36192*/
}
}
InternalSyncCompareExchange32(v2 + 17); /*0xffe3619c*/
if ( *((_BYTE *)v2 + 792) == 1 ) /*0xffe361a8*/
{
SemaphoreInit((unsigned __int32 *)(v2[199] + 104 * v27 + 24)); /*0xffe36236*/
_disable(); /*0xffe3623b*/
__halt(); /*0xffe3623c*/
}
i_2 = i; /*0xffe361aa*/
do /*0xffe361fa*/
{
_disable(); /*0xffe361ad*/
n3 = *((_BYTE *)v2 + 792); /*0xffe361ae*/
if ( n3 == 2 ) /*0xffe361b6*/
{
_mm_monitor((const void *)i_1, 0, 0); /*0xffe361c5*/
if ( *i != 1346458707 ) /*0xffe361d1*/
_mm_mwait(0, 16 * *((unsigned __int8 *)v22 + 793)); /*0xffe361eb*/
i_2 = i; /*0xffe361ee*/
v2 = v22; /*0xffe361f1*/
}
else if ( n3 == 3 ) /*0xffe36203*/
{
_mm_pause(); /*0xffe36205*/
}
else
{
v18 = DebugPrintGetService(); /*0xffe36209*/
if ( v18 ) /*0xffe36210*/
(*(void (__cdecl **)(const char *, int, const char *))(v18 + 4))( /*0xffe36221*/
"e:\\hs\\PurleySktPkg\\Override\\UefiCpuPkg\\Library\\MpInitLib\\MpLib.c",
713,
"((BOOLEAN)(0==1))");
}
}
while ( *i_2 != 1346458707 ); /*0xffe361fa*/
}
}
// Function: ReleaseSpinLock @ 0xffe36241 (0x1f bytes)
// Index: 73/163
signed __int32 __fastcall ReleaseSpinLock(volatile signed __int32 *i)
{
volatile signed __int32 *j; // esi
signed __int32 result; // eax
for ( j = i; ; i = j ) /*0xffe36243*/
{
result = InternalSyncDecrement(i, 1346458707, 1346458707); /*0xffe36253*/
if ( !result ) /*0xffe3625b*/
break; /*0xffe3625b*/
_mm_pause(); /*0xffe3624c*/
}
return result; /*0xffe3625d*/
}
// Function: CollectProcessorData @ 0xffe36260 (0xf9 bytes)
// Index: 74/163
void *__thiscall CollectProcessorData(_DWORD *this)
{
_DWORD *v1; // esi
unsigned __int32 v2; // eax
int v3; // eax
BOOL v4; // edx
unsigned __int64 v5; // rax
int Service; // eax
unsigned int v8; // [esp+10h] [ebp-8h] BYREF
unsigned int v9; // [esp+14h] [ebp-4h] BYREF
v1 = (_DWORD *)*(this + 200); /*0xffe36267*/
*v1 = 0; /*0xffe36270*/
v1[1] = *(this + 5); /*0xffe36275*/
v1[2] = *(this + 6); /*0xffe3627b*/
v1[7] = *(this + 12); /*0xffe36281*/
v1[8] = *(this + 8); /*0xffe36287*/
v1[10] = (unsigned __int16)__CS__; /*0xffe36292*/
v1[11] = (unsigned __int16)__DS__; /*0xffe3629d*/
v2 = __readcr3(); /*0xffe362a0*/
v1[13] = v2; /*0xffe362a3*/
v1[3] = InternalSyncIncrement; /*0xffe362a6*/
v1[15] = 0; /*0xffe362ad*/
v1[9] = 0; /*0xffe362b0*/
v1[14] = *(this + 32); /*0xffe362b9*/
v1[16] = *this; /*0xffe362be*/
v1[17] = this; /*0xffe362c1*/
v3 = __readcr0(); /*0xffe362c4*/
v4 = 0; /*0xffe362cc*/
if ( v3 < 0 ) /*0xffe362d0*/
{
BitFieldFieldType(0x80000000, &v9, 0, 0, 0); /*0xffe362d8*/
v4 = 0; /*0xffe362e5*/
if ( v9 >= 0x80000001 ) /*0xffe362ea*/
{
BitFieldFieldType(-2147483647, 0, 0, 0, &v8); /*0xffe362f2*/
v4 = 0; /*0xffe362fa*/
if ( (v8 & 0x100000) != 0 ) /*0xffe36303*/
{
v5 = __readmsr(0xC0000080); /*0xffe3630a*/
v4 = (v5 & 0x800) != 0; /*0xffe36315*/
}
}
}
v1[12] = v4; /*0xffe36319*/
v1[18] = AsmReadCr0; /*0xffe3631c*/
v8 = (unsigned int)(v1 + 4); /*0xffe36323*/
if ( v1 == (_DWORD *)-16 ) /*0xffe36328*/
{
Service = DebugPrintGetService(); /*0xffe3632a*/
if ( Service ) /*0xffe36331*/
(*(void (__cdecl **)(const char *, int, const char *))(Service + 4))( /*0xffe3633f*/
"e:\\hs\\MdePkg\\Library\\BaseLib\\X86ReadGdtr.c",
37,
"Gdtr != ((void *) 0)");
}
__sgdt((void *)v8); /*0xffe36348*/
return AsmReadCr2((char *)v1 + 22); /*0xffe36353*/
}
// Function: MpInitSleepLoop @ 0xffe36359 (0x1b1 bytes)
// Index: 75/163
char __fastcall MpInitSleepLoop(int a1, char a2, int a3, int a4, int a5)
{
unsigned int v6; // ebx
_DWORD *n2; // eax
int v8; // ebp
unsigned int v9; // edi
_DWORD *v10; // ebp
int (__cdecl **MpAlloc)(int); // eax
void *v12; // eax
int v13; // edi
int v14; // edi
int Service; // eax
char v17; // [esp+16h] [ebp-Ah]
int v19; // [esp+1Ch] [ebp-4h]
v6 = 0; /*0xffe36365*/
v17 = 0; /*0xffe36368*/
LOBYTE(n2) = *(_BYTE *)(a1 + 792); /*0xffe3636c*/
*(_DWORD *)(a1 + 68) = 0; /*0xffe36372*/
if ( (_BYTE)n2 == 1 || *(_DWORD *)(a1 + 128) != 3 ) /*0xffe36380*/
{
v17 = 1; /*0xffe3638e*/
MpTimerInit((unsigned int *)a1); /*0xffe36393*/
CollectProcessorData((_DWORD *)a1); /*0xffe3639a*/
LOBYTE(n2) = ApInitConfig(a1); /*0xffe363a1*/
}
else if ( (_BYTE)n2 == 2 ) /*0xffe36384*/
{
*(_BYTE *)(a1 + 793) = 0; /*0xffe36386*/
}
v8 = *(_DWORD *)(a1 + 800); /*0xffe363a6*/
v19 = v8; /*0xffe363ac*/
if ( a2 ) /*0xffe363b4*/
{
v9 = 0; /*0xffe363ba*/
if ( *(_DWORD *)(a1 + 8) ) /*0xffe363bc*/
{
do /*0xffe363ff*/
{
if ( v9 != *(_DWORD *)(a1 + 12) ) /*0xffe363c4*/
{
v10 = (_DWORD *)(v6 + *(_DWORD *)(a1 + 796)); /*0xffe363d2*/
v10[2] = a4; /*0xffe363d7*/
v10[3] = a5; /*0xffe363de*/
LOBYTE(n2) = (unsigned __int8)ApSpinLock(v10, 1); /*0xffe363e1*/
if ( *(_DWORD *)(a1 + 128) != 1 ) /*0xffe363ed*/
{
n2 = (_DWORD *)v10[1]; /*0xffe363ef*/
*n2 = 1346458707; /*0xffe363f2*/
}
}
++v9; /*0xffe363f8*/
v6 += 104; /*0xffe363f9*/
}
while ( v9 < *(_DWORD *)(a1 + 8) ); /*0xffe363ff*/
v8 = v19; /*0xffe36401*/
v6 = 0; /*0xffe36405*/
}
if ( v17 ) /*0xffe3640c*/
LOBYTE(n2) = MpSendApicCommand(*(_DWORD *)(v8 + 28)); /*0xffe36411*/
if ( *(_DWORD *)(a1 + 128) == 1 ) /*0xffe3641d*/
{
MpAlloc = (int (__cdecl **)(int))GetMpAlloc((void *)a1); /*0xffe3641f*/
v12 = (void *)MpAlloc[3](116); /*0xffe36426*/
CheckProcessorsDone(v12); /*0xffe3642d*/
while ( 1 ) /*0xffe36437*/
{
n2 = *(_DWORD **)(a1 + 800); /*0xffe36437*/
if ( !n2[9] ) /*0xffe3643d*/
break; /*0xffe3643d*/
_mm_pause(); /*0xffe36435*/
}
}
else if ( *(_DWORD *)(a1 + 8) ) /*0xffe36447*/
{
v13 = 0; /*0xffe36450*/
do /*0xffe3646d*/
{
if ( v6 != *(_DWORD *)(a1 + 12) ) /*0xffe36455*/
LOBYTE(n2) = ReleaseSpinLock(*(volatile signed __int32 **)(*(_DWORD *)(a1 + 796) + v13 + 4)); /*0xffe36461*/
++v6; /*0xffe36466*/
v13 += 104; /*0xffe36467*/
}
while ( v6 < *(_DWORD *)(a1 + 8) ); /*0xffe3646d*/
}
}
else
{
v14 = *(_DWORD *)(a1 + 796) + 104 * a3; /*0xffe3647f*/
*(_DWORD *)(v14 + 8) = a4; /*0xffe36487*/
*(_DWORD *)(v14 + 12) = a5; /*0xffe3648e*/
ApSpinLock((_DWORD *)v14, 1); /*0xffe36491*/
if ( *(_DWORD *)(a1 + 128) == 1 ) /*0xffe3649d*/
{
Service = DebugPrintGetService(); /*0xffe3649f*/
if ( Service ) /*0xffe364a6*/
(*(void (__cdecl **)(const char *, int, const char *))(Service + 4))( /*0xffe364b7*/
"e:\\hs\\PurleySktPkg\\Override\\UefiCpuPkg\\Library\\MpInitLib\\MpLib.c",
903,
"CpuMpData->InitFlag != ApInitConfig");
}
**(_DWORD **)(v14 + 4) = 1346458707; /*0xffe364c5*/
if ( v17 ) /*0xffe364cb*/
ExecuteBistCommand(*(_DWORD *)(20 * a3 + *(_DWORD *)a1 + 4), *(_DWORD *)(v8 + 28)); /*0xffe364d9*/
LOBYTE(n2) = ReleaseSpinLock(*(volatile signed __int32 **)(v14 + 4)); /*0xffe364e1*/
}
if ( v17 && *(_DWORD *)(a1 + 56) ) /*0xffe364ed*/
LOBYTE(n2) = (unsigned __int8)CopyMemWrapper(*(char **)(a1 + 48), *(char **)(a1 + 52), *(_DWORD *)(a1 + 56)); /*0xffe364fc*/
return (char)n2; /*0xffe36502*/
}
// Function: MpInitCheck @ 0xffe3650a (0x35 bytes)
// Index: 76/163
int __fastcall MpInitCheck(void *a1, _QWORD *a2)
{
__int64 v4; // rax
__int64 v5; // rax
*a2 = __rdtsc(); /*0xffe36513*/
if ( !a1 ) /*0xffe3651a*/
return 0; /*0xffe3651c*/
LODWORD(v4) = MpExchangeData(a1); /*0xffe36522*/
v5 = BitFieldXor64(v4, (unsigned int)a1); /*0xffe3652c*/
return BitFieldRead64(v5, HIDWORD(v5)); /*0xffe3653b*/
}
// Function: CheckAllProcessors @ 0xffe3653f (0xc8 bytes)
// Index: 77/163
bool __fastcall CheckAllProcessors(unsigned __int64 *a1, _DWORD *a2, __int64 a3)
{
int v4; // ecx
__int64 v5; // rdi
unsigned int v6; // eax
unsigned int v7; // ebp
unsigned int v8; // ecx
bool v9; // cf
unsigned __int64 v12; // [esp+14h] [ebp-18h]
__int64 v13; // [esp+1Ch] [ebp-10h] BYREF
__int64 v14; // [esp+24h] [ebp-8h] BYREF
if ( !a3 ) /*0xffe36554*/
return 0; /*0xffe36554*/
ProcedureScope(&v13, &v14); /*0xffe36562*/
v4 = (unsigned __int64)(v14 - v13) >> 32; /*0xffe3656b*/
LODWORD(v5) = v14 - v13; /*0xffe3656b*/
if ( v4 < 0 ) /*0xffe36579*/
{
LODWORD(v5) = v13 - v14; /*0xffe36581*/
v4 = (unsigned __int64)-__SPAIR64__(v4, (int)v13 - (int)v14) >> 32; /*0xffe36586*/
}
v12 = __rdtsc(); /*0xffe3658c*/
HIDWORD(v5) = (v12 - *a1) >> 32; /*0xffe365a0*/
v6 = v12 - *(_DWORD *)a1; /*0xffe365a0*/
v7 = a3; /*0xffe365a7*/
if ( HIDWORD(v13) >= HIDWORD(v14) ) /*0xffe365ab*/
{
if ( HIDWORD(v13) > HIDWORD(v14) || (v7 = a3, (unsigned int)v13 > (unsigned int)v14) ) /*0xffe365bb*/
{
v6 = *(_DWORD *)a1 - v12; /*0xffe365bd*/
HIDWORD(v5) = (unsigned __int64)-__SPAIR64__(HIDWORD(v5), v6) >> 32; /*0xffe365c2*/
}
}
if ( v5 < 0 ) /*0xffe365c6*/
{
v8 = (__PAIR64__(v4, v5) + 1) >> 32; /*0xffe365d1*/
LODWORD(v5) = v5 + 1; /*0xffe365d1*/
HIDWORD(v5) = (v5 + __PAIR64__(v8, v6)) >> 32; /*0xffe365d6*/
v6 += v5; /*0xffe365d6*/
}
v9 = __CFADD__(v6, *a2); /*0xffe365d8*/
*a2 += v6; /*0xffe365d8*/
a2[1] += HIDWORD(v5) + v9; /*0xffe365de*/
*a1 = v12; /*0xffe365e1*/
return *(_QWORD *)a2 > __PAIR64__(HIDWORD(a3), v7); /*0xffe365f9*/
}
// Function: CheckProcessorsDone @ 0xffe36607 (0xa5 bytes)
// Index: 78/163
void __cdecl CheckProcessorsDone(void *a1)
{
int v1; // ecx
int v2; // esi
void *v3; // ecx
int v4; // edx
bool v5; // al
__int64 v6; // rax
unsigned int v7; // eax
int v8; // edx
void *v9; // [esp-4h] [ebp-1Ch]
v2 = v1; /*0xffe3660c*/
if ( a1 )
{
*(_DWORD *)(v1 + 112) = 0; /*0xffe3661e*/
*(_DWORD *)(v1 + 116) = 0; /*0xffe36624*/
*(_DWORD *)(v1 + 96) = MpInitCheck(a1, (_QWORD *)(v1 + 104)); /*0xffe3662d*/
*(_DWORD *)(v2 + 100) = v4; /*0xffe36635*/
while ( *(_DWORD *)(v2 + 68) < 0x1FFu ) /*0xffe36652*/
{
v5 = CheckAllProcessors((unsigned __int64 *)(v2 + 104), (_DWORD *)(v2 + 112), *(_QWORD *)(v2 + 96)); /*0xffe36645*/
v3 = v9; /*0xffe3664b*/
if ( v5 ) /*0xffe3664e*/
break; /*0xffe3664e*/
_mm_pause(); /*0xffe36650*/
}
if ( *(_DWORD *)(v2 + 68) >= 0x1FFu )
{
LODWORD(v6) = MpExchangeData(v3); /*0xffe3665c*/
v7 = BitFieldWrite64(1000000LL * *(_QWORD *)(v2 + 112), v6); /*0xffe36686*/
DebugPrint(0x400000, "%a: reached FinishedApLimit=%u in %Lu microseconds\n", "TimedWaitForApFinish", 511, v7, v8);
}
}
}
// Function: MpInitCompleteNotify @ 0xffe366ac (0x4f bytes)
// Index: 79/163
_DWORD *__fastcall MpInitCompleteNotify(int a1)
{
_DWORD *v2; // esi
v2 = (_DWORD *)StartupAp(); /*0xffe366b6*/
v2[32] = 2; /*0xffe366c1*/
MpInitSleepLoop((int)v2, 0, a1, 0, 0); /*0xffe366cb*/
while ( !v2[17] ) /*0xffe366db*/
_mm_pause(); /*0xffe366d5*/
v2[32] = 3; /*0xffe366e2*/
return ApSpinLock((_DWORD *)(v2[199] + 104 * a1), 0); /*0xffe366f7*/
}
// Function: MpDataCleanup @ 0xffe366fb (0x68 bytes)
// Index: 80/163
int __fastcall MpDataCleanup(int a1)
{
int v2; // esi
_BYTE *v3; // eax
_BYTE *v5; // eax
v2 = *(_DWORD *)(StartupAp() + 796) + 104 * a1; /*0xffe36708*/
if ( *(_DWORD *)(v2 + 20) == 3 ) /*0xffe36712*/
{
v3 = *(_BYTE **)(v2 + 64); /*0xffe36714*/
if ( v3 ) /*0xffe36719*/
*v3 = 1; /*0xffe3671b*/
ApSpinLock((_DWORD *)v2, 0); /*0xffe36722*/
return 0; /*0xffe36727*/
}
else if ( CheckAllProcessors((unsigned __int64 *)(v2 + 80), (_DWORD *)(v2 + 88), *(_QWORD *)(v2 + 72)) ) /*0xffe36737*/
{
v5 = *(_BYTE **)(v2 + 64); /*0xffe36742*/
if ( v5 ) /*0xffe36747*/
*v5 = 0; /*0xffe36749*/
MpInitCompleteNotify(a1); /*0xffe3674e*/
return -2147483630; /*0xffe36753*/
}
else
{
return -2147483642; /*0xffe3675a*/
}
}
// Function: MpSwitchBsp @ 0xffe36763 (0x153 bytes)
// Index: 81/163
int MpSwitchBsp()
{
int v0; // esi
unsigned int v1; // ebx
int v2; // edi
int v3; // ecx
int v4; // eax
unsigned int v5; // ecx
unsigned int v6; // edx
_BYTE *v7; // eax
int Service; // eax
int v10; // ebx
unsigned int v11; // edi
int v12; // ebp
_DWORD *v13; // eax
_DWORD *v14; // eax
v0 = StartupAp(); /*0xffe3676d*/
v1 = 0; /*0xffe3676f*/
if ( *(_DWORD *)(v0 + 8) ) /*0xffe36771*/
{
v2 = 0; /*0xffe36776*/
do /*0xffe367e7*/
{
v3 = v2 + *(_DWORD *)(v0 + 796); /*0xffe3677e*/
if ( *(_BYTE *)(v3 + 60) ) /*0xffe36780*/
{
if ( *(_DWORD *)(v3 + 20) == 3 ) /*0xffe3678a*/
{
++*(_DWORD *)(v0 + 72); /*0xffe3678c*/
*(_BYTE *)(v2 + *(_DWORD *)(v0 + 796) + 60) = 0; /*0xffe36797*/
ApSpinLock((_DWORD *)v3, 0); /*0xffe3679c*/
if ( *(_BYTE *)(v0 + 76) ) /*0xffe367a1*/
{
v4 = StartupAp(); /*0xffe367a7*/
v5 = 0; /*0xffe367ac*/
v6 = *(_DWORD *)(v4 + 8); /*0xffe367ae*/
if ( v6 ) /*0xffe367b3*/
{
v7 = (_BYTE *)(*(_DWORD *)(v4 + 796) + 60); /*0xffe367bb*/
while ( !*v7 ) /*0xffe367c1*/
{
++v5; /*0xffe367c3*/
v7 += 104; /*0xffe367c4*/
if ( v5 >= v6 ) /*0xffe367c9*/
goto LABEL_12; /*0xffe367c9*/
}
MpInitSleepLoop(v0, 0, v5, *(_DWORD *)(v0 + 80), *(_DWORD *)(v0 + 84)); /*0xffe367d8*/
}
}
}
}
LABEL_12:
++v1; /*0xffe367e0*/
v2 += 104; /*0xffe367e1*/
}
while ( v1 < *(_DWORD *)(v0 + 8) ); /*0xffe367e7*/
}
if ( *(_DWORD *)(v0 + 72) == *(_DWORD *)(v0 + 64) ) /*0xffe367ef*/
return 0; /*0xffe367f1*/
if ( !CheckAllProcessors((unsigned __int64 *)(v0 + 104), (_DWORD *)(v0 + 112), *(_QWORD *)(v0 + 96)) ) /*0xffe36804*/
return -2147483642; /*0xffe368ab*/
if ( *(_DWORD *)(v0 + 124) ) /*0xffe36813*/
{
**(_DWORD **)(v0 + 124) = HobGetGuid((void *)(4 * (*(_DWORD *)(v0 + 64) + 1 - *(_DWORD *)(v0 + 68)))); /*0xffe3682f*/
if ( !**(_DWORD **)(v0 + 124) ) /*0xffe36834*/
{
Service = DebugPrintGetService(); /*0xffe36839*/
if ( Service ) /*0xffe36840*/
(*(void (__cdecl **)(const char *, int, const char *))(Service + 4))( /*0xffe36851*/
"e:\\hs\\PurleySktPkg\\Override\\UefiCpuPkg\\Library\\MpInitLib\\MpLib.c",
1279,
"*CpuMpData->FailedCpuList != ((void *) 0)");
}
}
v10 = 0; /*0xffe36857*/
v11 = 0; /*0xffe36859*/
if ( *(_DWORD *)(v0 + 8) ) /*0xffe3685b*/
{
v12 = 0; /*0xffe36860*/
do /*0xffe36895*/
{
if ( *(_BYTE *)(*(_DWORD *)(v0 + 796) + v12 + 60) ) /*0xffe36868*/
{
MpInitCompleteNotify(v11); /*0xffe36871*/
*(_BYTE *)(*(_DWORD *)(v0 + 796) + v12 + 60) = 0; /*0xffe3687c*/
v13 = *(_DWORD **)(v0 + 124); /*0xffe36881*/
if ( v13 ) /*0xffe36886*/
*(_DWORD *)(*v13 + 4 * v10++) = v11; /*0xffe3688a*/
}
++v11; /*0xffe3688e*/
v12 += 104; /*0xffe3688f*/
}
while ( v11 < *(_DWORD *)(v0 + 8) ); /*0xffe36895*/
}
v14 = *(_DWORD **)(v0 + 124); /*0xffe36897*/
if ( v14 ) /*0xffe3689c*/
*(_DWORD *)(*v14 + 4 * v10) = -1; /*0xffe368a0*/
return -2147483630; /*0xffe368b0*/
}
// Function: MpInitLibInitialize @ 0xffe368b6 (0x2d3 bytes)
// Index: 82/163
int MpInitLibInitialize()
{
_DWORD *v0; // edi
_WORD *v1; // eax
unsigned int n512; // ebx
int Service; // eax
unsigned int count; // esi
int buf; // eax
int v6; // eax
int v7; // edx
unsigned int v8; // ebp
unsigned int v9; // eax
int v10; // esi
int v11; // ecx
unsigned int n512_2; // edx
unsigned int n0xFE; // ebp
int v14; // eax
int v15; // edi
_DWORD *v16; // ebx
unsigned int v17; // ebx
int v18; // edi
int buf_1; // [esp+10h] [ebp-28h]
int n512_1; // [esp+14h] [ebp-24h]
char Buffer[4]; // [esp+18h] [ebp-20h] BYREF
int v23; // [esp+1Ch] [ebp-1Ch]
char src[8]; // [esp+24h] [ebp-14h] BYREF
int v25; // [esp+2Ch] [ebp-Ch]
v0 = 0; /*0xffe368c8*/
v1 = PpiFind(Guid); /*0xffe368ca*/
if ( v1 && (v0 = (_DWORD *)*((_DWORD *)v1 + 6)) != 0 ) /*0xffe368dd*/
{
n512 = v0[2]; /*0xffe368df*/
n512_1 = n512; /*0xffe368e2*/
if ( !n512 ) /*0xffe368e8*/
{
Service = DebugPrintGetService(); /*0xffe368ea*/
if ( Service ) /*0xffe368f1*/
(*(void (__cdecl **)(const char *, int, const char *))(Service + 4))( /*0xffe368fe*/
"e:\\hs\\PurleySktPkg\\Override\\UefiCpuPkg\\Library\\MpInitLib\\MpLib.c",
1347,
"MaxLogicalProcessorNumber != 0");
}
}
else
{
n512 = 512; /*0xffe36906*/
n512_1 = 512; /*0xffe3690b*/
}
AsmReadMsr64(src); /*0xffe36914*/
*(_DWORD *)Buffer = v25 + 76; /*0xffe36927*/
count = 4224 * n512 + v25 + 900; /*0xffe36931*/
buf = MpAllocateBuffer(v25 + 76, (count >> 12) + (((4224 * (_WORD)n512 + (_WORD)v25 + 900) & 0xFFF) != 0)); /*0xffe36948*/
buf_1 = buf; /*0xffe3694d*/
if ( !buf ) /*0xffe36953*/
{
v6 = DebugPrintGetService(); /*0xffe36955*/
if ( v6 ) /*0xffe3695c*/
(*(void (__cdecl **)(const char *, int, const char *))(v6 + 4))( /*0xffe36969*/
"e:\\hs\\PurleySktPkg\\Override\\UefiCpuPkg\\Library\\MpInitLib\\MpLib.c",
1360,
"MpBuffer != ((void *) 0)");
buf = 0; /*0xffe3696f*/
}
if ( count ) /*0xffe36975*/
AllocateZeroPool(buf, count); /*0xffe3697b*/
v7 = *(_DWORD *)Buffer; /*0xffe3698b*/
v8 = buf_1 + (n512 << 12); /*0xffe36994*/
v9 = v8 + 4 * n512; /*0xffe36996*/
v10 = v9 + *(_DWORD *)Buffer; /*0xffe36998*/
*(_DWORD *)(v10 + 48) = -1; /*0xffe3699b*/
*(_DWORD *)(v10 + 52) = v9; /*0xffe3699f*/
*(_DWORD *)(v10 + 20) = buf_1; /*0xffe369a5*/
*(_DWORD *)(v10 + 56) = v7; /*0xffe369ae*/
*(_DWORD *)(v10 + 796) = v10 + 824; /*0xffe369b3*/
*(_DWORD *)(v10 + 24) = 4096; /*0xffe369b9*/
*(_BYTE *)(v10 + 60) = 0; /*0xffe369c2*/
*(_DWORD *)(v10 + 8) = 1; /*0xffe369c8*/
*(_DWORD *)(v10 + 12) = 0; /*0xffe369cf*/
*(_DWORD *)(v10 + 120) = 0; /*0xffe369d2*/
*(_BYTE *)(v10 + 133) = 0; /*0xffe369d5*/
*(_DWORD *)v10 = v10 + 824 + 104 * n512; /*0xffe369db*/
*(_DWORD *)(v10 + 4) = 0; /*0xffe369dd*/
SpinLockInit((_DWORD *)(v10 + 16)); /*0xffe369e0*/
SemaphoreInit((unsigned __int32 *)(*(_DWORD *)(v10 + 796) + 24)); /*0xffe369ee*/
InitializeMpData((int *)v10, 0, 0, *(_DWORD *)(v10 + 20), 0); /*0xffe369fe*/
CopyMemWrapper((char *)(v10 + 28), src, 0x14u); /*0xffe36a0f*/
*(_BYTE *)(v10 + 792) = 1; /*0xffe36a1e*/
DebugPrint(64, "AP Loop Mode is %d\n", 1); /*0xffe36a25*/
if ( n512 ) /*0xffe36a2f*/
{
v11 = 0; /*0xffe36a31*/
n512_2 = n512; /*0xffe36a33*/
do /*0xffe36a48*/
{
v11 += 104; /*0xffe36a3b*/
*(_DWORD *)(v11 + *(_DWORD *)(v10 + 796) - 100) = v8; /*0xffe36a3e*/
v8 += 4; /*0xffe36a42*/
--n512_2; /*0xffe36a45*/
}
while ( n512_2 ); /*0xffe36a48*/
}
MicrocodeDetect((_DWORD *)v10); /*0xffe36a4c*/
EnableDisableLmce(v10 + 184); /*0xffe36a57*/
MpInitComplete(); /*0xffe36a5c*/
if ( v0 ) /*0xffe36a63*/
{
n0xFE = 0; /*0xffe36a7d*/
*(_DWORD *)(v10 + 8) = v0[2]; /*0xffe36a7f*/
*(_DWORD *)(v10 + 12) = v0[3]; /*0xffe36a85*/
*(_DWORD *)(v10 + 128) = 2; /*0xffe36a88*/
*(_DWORD *)v10 = *v0; /*0xffe36a94*/
*(_DWORD *)(v10 + 4) = v0[1]; /*0xffe36a99*/
v14 = *(_DWORD *)v10; /*0xffe36a9c*/
*(_DWORD *)Buffer = *(_DWORD *)v10; /*0xffe36a9e*/
if ( *(_DWORD *)(v10 + 8) ) /*0xffe36aa2*/
{
v15 = 0; /*0xffe36aa7*/
v16 = (_DWORD *)v14; /*0xffe36aa9*/
do /*0xffe36b0e*/
{
SpinLockInit((_DWORD *)(v15 + *(_DWORD *)(v10 + 796))); /*0xffe36ab3*/
if ( *v16 >= 0xFFu || n0xFE > 0xFE ) /*0xffe36ac6*/
*(_BYTE *)(v10 + 132) = 1; /*0xffe36ac8*/
*(_BYTE *)(v15 + *(_DWORD *)(v10 + 796) + 16) = v16[2] == 0; /*0xffe36ade*/
*(_DWORD *)(v15 + *(_DWORD *)(v10 + 796) + 8) = 0; /*0xffe36ae8*/
CopyMemWrapper((char *)(v15 + *(_DWORD *)(v10 + 796) + 24), (char *)(*(_DWORD *)(v10 + 796) + 24), 0x24u); /*0xffe36afe*/
++n0xFE; /*0xffe36b03*/
v16 += 5; /*0xffe36b04*/
v15 += 104; /*0xffe36b07*/
}
while ( n0xFE < *(_DWORD *)(v10 + 8) ); /*0xffe36b0e*/
n512 = n512_1; /*0xffe36b10*/
}
if ( n512 > 1 ) /*0xffe36b17*/
{
MpInitSleepLoop(v10, 1, 0, (int)ApProcedure, v10); /*0xffe36b25*/
while ( *(_DWORD *)(v10 + 68) < (unsigned int)(*(_DWORD *)(v10 + 8) - 1) ) /*0xffe36b38*/
_mm_pause(); /*0xffe36b2f*/
v17 = 0; /*0xffe36b3a*/
*(_DWORD *)(v10 + 128) = 3; /*0xffe36b3c*/
if ( *(_DWORD *)(v10 + 8) ) /*0xffe36b46*/
{
v18 = 0; /*0xffe36b4b*/
do /*0xffe36b63*/
{
ApSpinLock((_DWORD *)(v18 + *(_DWORD *)(v10 + 796)), 0); /*0xffe36b57*/
++v17; /*0xffe36b5c*/
v18 += 104; /*0xffe36b5d*/
}
while ( v17 < *(_DWORD *)(v10 + 8) ); /*0xffe36b63*/
}
}
}
else if ( n512 > 1 ) /*0xffe36a68*/
{
MpInitUp(v10); /*0xffe36a70*/
}
v23 = 0; /*0xffe36b65*/
*(_DWORD *)Buffer = v10; /*0xffe36b75*/
MpSafeCopyBuffer((int)Guid, Buffer, 8u); /*0xffe36b79*/
return 0; /*0xffe36b7f*/
}
// Function: CollectBistData @ 0xffe36b89 (0xca bytes)
// Index: 83/163
int __fastcall CollectBistData(unsigned int ProcessorCount, int *SingleCpuInfo, _DWORD *p_ApicId)
{
int *v5; // ebx
unsigned int v7; // esi
int v8; // eax
int v9; // [esp+10h] [ebp-8h]
int v10; // [esp+14h] [ebp-4h] BYREF
v5 = (int *)StartupAp(); /*0xffe36b98*/
v9 = *v5; /*0xffe36ba0*/
MpNotify(&v10); /*0xffe36ba4*/
if ( v10 != v5[3] ) /*0xffe36bb0*/
return -2147483641; /*0xffe36bb2*/
if ( !SingleCpuInfo ) /*0xffe36bbe*/
return -2147483646; /*0xffe36bc0*/
if ( ProcessorCount >= v5[2] ) /*0xffe36bcd*/
return -2147483634; /*0xffe36bcf*/
v7 = 20 * ProcessorCount; /*0xffe36bda*/
v8 = *(_DWORD *)(20 * ProcessorCount + v9 + 4); /*0xffe36bdd*/
SingleCpuInfo[1] = 0; /*0xffe36be1*/
SingleCpuInfo[2] = 0; /*0xffe36be5*/
*SingleCpuInfo = v8; /*0xffe36be9*/
if ( ProcessorCount == v5[3] ) /*0xffe36bee*/
SingleCpuInfo[2] = 1; /*0xffe36bf0*/
if ( *(_BYTE *)(v5[199] + 104 * ProcessorCount + 16) ) /*0xffe36c00*/
SingleCpuInfo[2] |= 4u; /*0xffe36c07*/
if ( *(_DWORD *)(v5[199] + 104 * ProcessorCount + 20) == 4 ) /*0xffe36c16*/
SingleCpuInfo[2] &= ~2u; /*0xffe36c18*/
else
SingleCpuInfo[2] |= 2u; /*0xffe36c1e*/
GetApicId(*(_DWORD *)(v7 + v9 + 4), SingleCpuInfo + 3, SingleCpuInfo + 4, (unsigned int *)SingleCpuInfo + 5); /*0xffe36c31*/
if ( p_ApicId ) /*0xffe36c3e*/
*p_ApicId = *(_DWORD *)(v7 + v9 + 8); /*0xffe36c48*/
return 0; /*0xffe36c4c*/
}
// Function: MpFuncInit @ 0xffe36c53 (0x1bf bytes)
// Index: 84/163
int __fastcall MpFuncInit(unsigned int a1, char a2)
{
unsigned int v3; // eax
unsigned int v4; // kr00_4
unsigned int v5; // eax
int v6; // eax
int v7; // eax
int v8; // ebx
int n4; // eax
unsigned __int64 v11; // rax
int MsrLow; // eax
int MsrHigh; // edx
int v14; // ecx
unsigned __int64 v15; // rax
int v16; // esi
_DWORD *v17; // ecx
int n4_1; // edx
bool v19; // zf
int v20; // eax
int v22; // [esp+14h] [ebp-14h] BYREF
unsigned int v23; // [esp+18h] [ebp-10h]
unsigned int v24; // [esp+1Ch] [ebp-Ch]
unsigned __int64 v25; // [esp+20h] [ebp-8h]
v3 = (unsigned int)SortCpuList(0x320u) >> 16; /*0xffe36c70*/
LOBYTE(v3) = (v3 & 1) == 0; /*0xffe36c75*/
v24 = v3; /*0xffe36c77*/
GetApicBase(); /*0xffe36c7b*/
v4 = __readeflags(); /*0xffe36c80*/
v5 = v4 >> 9; /*0xffe36c82*/
LOBYTE(v5) = (v4 & 0x200) != 0; /*0xffe36c85*/
v23 = v5; /*0xffe36c87*/
_disable(); /*0xffe36c8b*/
v6 = SortCpuList(0x350u); /*0xffe36c93*/
FillCpuData(0x350u, v6 | 0x10000); /*0xffe36ca3*/
v7 = SortCpuList(0x360u); /*0xffe36cad*/
FillCpuData(0x360u, v7 | 0x10000); /*0xffe36cb8*/
v8 = StartupAp(); /*0xffe36cc6*/
MpNotify(&v22); /*0xffe36cc8*/
if ( v22 == *(_DWORD *)(v8 + 12) ) /*0xffe36cd4*/
{
if ( a1 >= *(_DWORD *)(v8 + 8) ) /*0xffe36cdd*/
return -2147483634; /*0xffe36ce4*/
n4 = *(_DWORD *)(104 * a1 + *(_DWORD *)(v8 + 796) + 20); /*0xffe36cf2*/
if ( n4 == 4 || a1 == *(_DWORD *)(v8 + 12) ) /*0xffe36d08*/
return -2147483646; /*0xffe36d00*/
if ( n4 == 2 ) /*0xffe36d0d*/
return -2147483642; /*0xffe36d14*/
*(_BYTE *)(v8 + 133) = 1; /*0xffe36d1f*/
*(_BYTE *)(v8 + 140) = 0; /*0xffe36d2c*/
*(_BYTE *)(v8 + 160) = 0; /*0xffe36d2f*/
*(_DWORD *)(v8 + 136) = a1; /*0xffe36d32*/
v11 = __readmsr(0x1Bu); /*0xffe36d3d*/
v25 = v11 & 0xFFFFFFFFFFFFFEFFuLL; /*0xffe36d48*/
LODWORD(v11) = v11 & 0xFFFFFEFF; /*0xffe36d50*/
__writemsr(0x1Bu, v11); /*0xffe36d59*/
LOBYTE(MsrLow) = MpInitSleepLoop(v8, 0, a1, (int)MpTimerCheck, v8); /*0xffe36d66*/
AsmWriteMsr64(MsrLow, MsrHigh, v14, v8 + 140, (_BYTE *)(v8 + 160)); /*0xffe36d70*/
v15 = __readmsr(0x1Bu); /*0xffe36d7c*/
v25 = v15 | 0x100; /*0xffe36d87*/
LODWORD(v15) = v15 | 0x100; /*0xffe36d8f*/
__writemsr(0x1Bu, v15); /*0xffe36d98*/
v16 = 104 * v22; /*0xffe36d9a*/
while ( *(_DWORD *)(*(_DWORD *)(v8 + 796) + v16 + 20) != 3 ) /*0xffe36dae*/
_mm_pause(); /*0xffe36da1*/
v17 = (_DWORD *)(v16 + *(_DWORD *)(v8 + 796)); /*0xffe36db6*/
*(_BYTE *)(v8 + 133) = 0; /*0xffe36db8*/
if ( a2 ) /*0xffe36dc4*/
n4_1 = 0; /*0xffe36dcb*/
else
n4_1 = 4; /*0xffe36dc8*/
ApSpinLock(v17, n4_1); /*0xffe36dcd*/
v19 = (_BYTE)v23 == 0; /*0xffe36dd2*/
*(_DWORD *)(v8 + 12) = a1; /*0xffe36dd7*/
if ( v19 ) /*0xffe36dda*/
_disable(); /*0xffe36ddf*/
else
_enable(); /*0xffe36ddc*/
if ( (_BYTE)v24 ) /*0xffe36de5*/
{
v20 = SortCpuList(0x320u); /*0xffe36dee*/
FillCpuData(0x320u, v20 & 0xFFFEFFFF); /*0xffe36dfc*/
}
else
{
GetApicBase(); /*0xffe36e03*/
}
}
return 0; /*0xffe36e0a*/
}
// Function: MpEndOfPei @ 0xffe36e12 (0x7d bytes)
// Index: 85/163
int __fastcall MpEndOfPei(unsigned int a1, char a2, _DWORD *a3)
{
_DWORD *v5; // esi
int v6; // eax
unsigned int v8; // edi
int n4; // edx
int v10; // [esp+Ch] [ebp-4h] BYREF
v5 = (_DWORD *)StartupAp(); /*0xffe36e25*/
MpNotify(&v10); /*0xffe36e27*/
v6 = v5[3]; /*0xffe36e2c*/
if ( v10 != v6 ) /*0xffe36e32*/
return -2147483641; /*0xffe36e34*/
if ( a1 == v6 ) /*0xffe36e3d*/
return -2147483646; /*0xffe36e3f*/
if ( a1 >= v5[2] ) /*0xffe36e49*/
return -2147483634; /*0xffe36e4b*/
v8 = 104 * a1; /*0xffe36e58*/
if ( a2 ) /*0xffe36e5f*/
n4 = 0; /*0xffe36e66*/
else
n4 = 4; /*0xffe36e63*/
ApSpinLock((_DWORD *)(v8 + v5[199]), n4); /*0xffe36e68*/
if ( a3 ) /*0xffe36e72*/
*(_BYTE *)(v5[199] + v8 + 16) = (*a3 & 4) != 0; /*0xffe36e82*/
return 0; /*0xffe36e88*/
}
// Function: MpNotify @ 0xffe36e8f (0x1d bytes)
// Index: 86/163
int __thiscall MpNotify(_DWORD *this)
{
_DWORD *v3; // eax
if ( !this ) /*0xffe36e94*/
return -2147483646; /*0xffe36e96*/
v3 = (_DWORD *)StartupAp(); /*0xffe36e9d*/
return WaitApDone(v3, this); /*0xffe36e9b*/
}
// Function: GetSystemConfiguration @ 0xffe36eac (0x7b bytes)
// Index: 87/163
int __fastcall GetSystemConfiguration(_DWORD *p_ProcessorCount, int *p_n8)
{
int *p_n8_1; // esi
_DWORD *v4; // ebx
int v6; // edx
int v7; // ecx
int v8; // ebp
int v9; // esi
int v10; // [esp+14h] [ebp-8h] BYREF
int *p_n8_2; // [esp+18h] [ebp-4h]
p_n8_1 = p_n8; /*0xffe36eb2*/
p_n8_2 = p_n8; /*0xffe36eb5*/
v4 = (_DWORD *)StartupAp(); /*0xffe36ec0*/
if ( !p_ProcessorCount && !p_n8_1 ) /*0xffe36ec8*/
return -2147483646; /*0xffe36eca*/
MpNotify(&v10); /*0xffe36ed5*/
if ( v10 != v4[3] ) /*0xffe36ee1*/
return -2147483641; /*0xffe36ee3*/
v6 = v4[2]; /*0xffe36eea*/
v7 = 0; /*0xffe36eed*/
if ( v6 ) /*0xffe36ef1*/
{
v8 = 0; /*0xffe36ef3*/
v9 = v4[2]; /*0xffe36ef5*/
do /*0xffe36f0b*/
{
if ( *(_DWORD *)(v4[199] + v8 + 20) != 4 ) /*0xffe36f02*/
++v7; /*0xffe36f04*/
v8 += 104; /*0xffe36f05*/
--v9; /*0xffe36f08*/
}
while ( v9 ); /*0xffe36f0b*/
p_n8_1 = p_n8_2; /*0xffe36f0d*/
}
if ( p_ProcessorCount ) /*0xffe36f13*/
*p_ProcessorCount = v6; /*0xffe36f15*/
if ( p_n8_1 ) /*0xffe36f19*/
*p_n8_1 = v7; /*0xffe36f1b*/
return 0; /*0xffe36f1f*/
}
// Function: MpSetStartupAddress @ 0xffe36f27 (0x177 bytes)
// Index: 88/163
int __fastcall MpSetStartupAddress(int a1, char a2, int a3, void *a4, int a5)
{
int v6; // esi
int result; // eax
unsigned int v8; // ebx
unsigned int v9; // eax
int v10; // edx
int n4; // ecx
unsigned int v12; // eax
int v13; // edx
int v14; // ecx
int v15; // edx
char v16; // dl
unsigned int v17; // eax
int v18; // ecx
char v19; // [esp+12h] [ebp-Eh]
unsigned int v21; // [esp+14h] [ebp-Ch]
int v23; // [esp+1Ch] [ebp-4h] BYREF
v6 = StartupAp(); /*0xffe36f42*/
if ( *(_DWORD *)(v6 + 8) == 1 ) /*0xffe36f48*/
return -2147483629; /*0xffe36f4a*/
if ( !a1 ) /*0xffe36f56*/
return -2147483646; /*0xffe36f58*/
MpNotify(&v23); /*0xffe36f66*/
if ( v23 != *(_DWORD *)(v6 + 12) ) /*0xffe36f72*/
return -2147483641; /*0xffe36f74*/
v8 = 0; /*0xffe36f81*/
v21 = *(_DWORD *)(v6 + 8); /*0xffe36f83*/
v9 = 0; /*0xffe36f87*/
v19 = 0; /*0xffe36f89*/
if ( !v21 ) /*0xffe36f8f*/
return 0; /*0xffe37095*/
v10 = 0; /*0xffe36f95*/
do /*0xffe36fc0*/
{
if ( v9 != *(_DWORD *)(v6 + 12) ) /*0xffe36fa0*/
{
n4 = *(_DWORD *)(*(_DWORD *)(v6 + 796) + v10 + 20); /*0xffe36fa2*/
if ( n4 != 4 ) /*0xffe36fa9*/
{
v19 = 1; /*0xffe36fab*/
if ( n4 ) /*0xffe36fb2*/
return -2147483642; /*0xffe37042*/
}
}
++v9; /*0xffe36fb8*/
v10 += 104; /*0xffe36fb9*/
}
while ( v9 < v21 ); /*0xffe36fc0*/
if ( !v19 ) /*0xffe36fc6*/
return 0; /*0xffe36fc6*/
v12 = 0; /*0xffe36fd0*/
*(_DWORD *)(v6 + 64) = 0; /*0xffe36fd2*/
v13 = 0; /*0xffe36fd5*/
do /*0xffe36ffa*/
{
v14 = *(_DWORD *)(v6 + 796); /*0xffe36fd7*/
*(_BYTE *)(v14 + v13 + 60) = 0; /*0xffe36fdd*/
if ( v12 != *(_DWORD *)(v6 + 12) && !*(_DWORD *)(v14 + v13 + 20) ) /*0xffe36fe6*/
{
*(_BYTE *)(v14 + v13 + 60) = 1; /*0xffe36fec*/
++*(_DWORD *)(v6 + 64); /*0xffe36ff1*/
}
++v12; /*0xffe36ff4*/
v13 += 104; /*0xffe36ff5*/
}
while ( v12 < v21 ); /*0xffe36ffa*/
*(_DWORD *)(v6 + 80) = a1; /*0xffe3700a*/
*(_DWORD *)(v6 + 84) = a5; /*0xffe37010*/
*(_BYTE *)(v6 + 76) = a2; /*0xffe37013*/
*(_DWORD *)(v6 + 68) = 0; /*0xffe37016*/
*(_DWORD *)(v6 + 72) = 0; /*0xffe37019*/
*(_DWORD *)(v6 + 124) = 0; /*0xffe3701c*/
*(_DWORD *)(v6 + 96) = MpInitCheck(a4, (_QWORD *)(v6 + 104)); /*0xffe37024*/
*(_DWORD *)(v6 + 100) = v15; /*0xffe37027*/
*(_DWORD *)(v6 + 112) = 0; /*0xffe3702a*/
*(_DWORD *)(v6 + 116) = 0; /*0xffe3702d*/
*(_DWORD *)(v6 + 120) = 0; /*0xffe37030*/
if ( a2 ) /*0xffe37037*/
{
v17 = v21; /*0xffe37044*/
v18 = 0; /*0xffe37048*/
while ( 1 ) /*0xffe3704a*/
{
if ( v8 != v23 ) /*0xffe3704e*/
{
if ( *(_BYTE *)(v18 + *(_DWORD *)(v6 + 796) + 60) ) /*0xffe37056*/
{
v16 = 0; /*0xffe3706b*/
goto LABEL_29; /*0xffe3706b*/
}
v17 = v21; /*0xffe3705d*/
}
++v8; /*0xffe37061*/
v18 += 104; /*0xffe37062*/
if ( v8 >= v17 ) /*0xffe37067*/
goto LABEL_30; /*0xffe37067*/
}
}
v16 = 1; /*0xffe37039*/
LABEL_29:
MpInitSleepLoop(v6, v16, v8, a1, a5); /*0xffe3706d*/
do /*0xffe37091*/
{
LABEL_30:
SwitchStackFinish(0x2710u); /*0xffe3707d*/
result = MpSwitchBsp(); /*0xffe37087*/
}
while ( result == -2147483642 ); /*0xffe37091*/
return result; /*0xffe37097*/
}
// Function: MpSendWakeupCommand @ 0xffe3709e (0xb1 bytes)
// Index: 89/163
int __fastcall MpSendWakeupCommand(int a1, unsigned int a2, int a3, void *a4, int a5)
{
_DWORD *v7; // ebx
int v8; // eax
int result; // eax
unsigned int v10; // esi
int v11; // eax
int v12; // edx
int v13; // [esp-8h] [ebp-20h]
int v14; // [esp+10h] [ebp-8h] BYREF
int v15; // [esp+14h] [ebp-4h]
v15 = a1; /*0xffe370ae*/
v7 = (_DWORD *)StartupAp(); /*0xffe370bb*/
MpNotify(&v14); /*0xffe370bd*/
v8 = v7[3]; /*0xffe370c2*/
if ( v14 != v8 ) /*0xffe370c9*/
return -2147483641; /*0xffe370cb*/
if ( a2 >= v7[2] ) /*0xffe370d5*/
return -2147483634; /*0xffe370d7*/
if ( a2 == v8 || !a1 || *(_DWORD *)(104 * a2 + v7[199] + 20) == 4 ) /*0xffe370fb*/
return -2147483646; /*0xffe370e2*/
v10 = 104 * a2 + v7[199]; /*0xffe37103*/
*(_DWORD *)(v10 + 96) = 0; /*0xffe37108*/
*(_DWORD *)(v10 + 64) = 0; /*0xffe3710f*/
v11 = MpInitCheck(a4, (_QWORD *)(v10 + 80)); /*0xffe37113*/
*(_DWORD *)(v10 + 88) = 0; /*0xffe3711b*/
v13 = v15; /*0xffe37121*/
*(_DWORD *)(v10 + 92) = 0; /*0xffe37125*/
*(_DWORD *)(v10 + 76) = v12; /*0xffe37129*/
*(_DWORD *)(v10 + 72) = v11; /*0xffe3712f*/
MpInitSleepLoop((int)v7, 0, a2, v13, a5); /*0xffe37132*/
do /*0xffe37146*/
result = MpDataCleanup(a2); /*0xffe3713c*/
while ( result == -2147483642 ); /*0xffe37146*/
return result; /*0xffe37148*/
}
// Function: MicrocodePatch @ 0xffe3714f (0x39 bytes)
// Index: 90/163
int MicrocodePatch()
{
unsigned __int64 v0; // rax
unsigned __int8 v2; // [esp+4h] [ebp-8h]
v2 = 0; /*0xffe37157*/
__writemsr(0x8Bu, 0); /*0xffe37168*/
BitFieldFieldType(1, 0, (_DWORD *)v2, (_DWORD *)v2, (_DWORD *)v2); /*0xffe37172*/
v0 = __readmsr(0x8Bu); /*0xffe3717f*/
return HIDWORD(v0); /*0xffe37183*/
}
// Function: MicrocodeDetect @ 0xffe37188 (0x274 bytes)
// Index: 91/163
int __thiscall MicrocodeDetect(_DWORD *this)
{
_DWORD *MpAlloc; // eax
__int64 count_1; // rax
unsigned int count; // ebx
void *v5; // ecx
int Buffer; // eax
int (__cdecl **v7)(int); // eax
char *src; // eax
_DWORD *v9; // eax
unsigned __int64 v10; // rax
char *v11; // esi
_DWORD *this_3; // ecx
char *v13; // ebx
unsigned int count_3; // ebp
char v15; // di
bool v16; // dl
int v17; // edx
unsigned int n2048; // edx
int v19; // eax
unsigned int n2048_1; // edx
char *v21; // ebx
unsigned int v22; // eax
_DWORD *v23; // ebx
_DWORD *this_2; // edi
int Service; // eax
int count_2; // ebx
void *v28; // [esp-4h] [ebp-40h]
void *v29; // [esp-4h] [ebp-40h]
char *v30; // [esp+18h] [ebp-24h]
int v31; // [esp+1Ch] [ebp-20h]
_DWORD *this_4; // [esp+20h] [ebp-1Ch]
int v33; // [esp+24h] [ebp-18h] BYREF
int v34; // [esp+28h] [ebp-14h]
unsigned int v35; // [esp+2Ch] [ebp-10h]
_DWORD *this_1; // [esp+34h] [ebp-8h]
int v37; // [esp+38h] [ebp-4h]
this_1 = this; /*0xffe37191*/
MpAlloc = GetMpAlloc(this); /*0xffe37195*/
count_1 = ((__int64 (__cdecl *)(int))MpAlloc[4])(114); /*0xffe3719c*/
count = count_1; /*0xffe3719f*/
if ( count_1 ) /*0xffe371a6*/
{
v5 = (void *)(*(this + 205) | *(this + 204)); /*0xffe371b2*/
if ( !*((_QWORD *)this + 102) ) /*0xffe371ac*/
{
Buffer = MpAllocateBuffer((int)v5, ((unsigned int)count_1 >> 12) + ((count_1 & 0xFFF) != 0)); /*0xffe371d0*/
*(this + 204) = Buffer; /*0xffe371d5*/
*(this + 205) = 0; /*0xffe371dd*/
if ( Buffer ) /*0xffe371e3*/
{
v7 = (int (__cdecl **)(int))GetMpAlloc(v5); /*0xffe371e5*/
src = (char *)v7[4](113); /*0xffe371ec*/
v5 = v28; /*0xffe371ef*/
if ( count ) /*0xffe371f2*/
{
CopyMemWrapper((char *)*(this + 204), src, count); /*0xffe371fd*/
v5 = v29; /*0xffe37202*/
}
}
}
if ( !*((_QWORD *)this + 102) ) /*0xffe37203*/
{
v9 = GetMpAlloc(v5); /*0xffe37211*/
*((_QWORD *)this + 102) = ((__int64 (__cdecl *)(int))v9[4])(113); /*0xffe3721c*/
}
LODWORD(count_1) = MicrocodePatch(); /*0xffe37228*/
if ( !(_DWORD)count_1 ) /*0xffe3722f*/
{
BitFieldFieldType(1, &v33, 0, 0, 0); /*0xffe3723f*/
v10 = __readmsr(0x17u); /*0xffe3724c*/
v11 = (char *)*(this + 204); /*0xffe3724e*/
this_3 = 0; /*0xffe37254*/
v13 = &v11[count]; /*0xffe37256*/
count_3 = 0; /*0xffe3725b*/
this_4 = 0; /*0xffe3725d*/
v30 = v13; /*0xffe37264*/
v31 = (HIDWORD(v10) >> 18) & 7; /*0xffe37268*/
v15 = v31; /*0xffe3726c*/
while ( 1 ) /*0xffe3726e*/
{
v16 = 0; /*0xffe3726e*/
if ( *(_DWORD *)v11 == 1 ) /*0xffe37277*/
break; /*0xffe37277*/
LODWORD(count_1) = 1024; /*0xffe37370*/
LABEL_40:
v11 += count_1; /*0xffe37375*/
if ( v11 >= v13 ) /*0xffe37379*/
{
this_2 = this_1; /*0xffe3737f*/
if ( count_3 ) /*0xffe37385*/
{
if ( !this_3 ) /*0xffe37389*/
{
Service = DebugPrintGetService(); /*0xffe3738b*/
if ( Service ) /*0xffe37392*/
(*(void (__cdecl **)(const char *, int, const char *))(Service + 4))( /*0xffe373a3*/
"e:\\hs\\PurleySktPkg\\Override\\UefiCpuPkg\\Library\\MpInitLib\\Microcode.c",
222,
"MicrocodeData != ((void *) 0)");
this_3 = this_4; /*0xffe373a9*/
}
v37 = 0; /*0xffe373ad*/
this_1 = this_3; /*0xffe373b2*/
__writemsr(0x79u, (unsigned int)this_3); /*0xffe373c3*/
LODWORD(count_1) = MicrocodePatch(); /*0xffe373c5*/
count_2 = count_1; /*0xffe373ca*/
if ( (_DWORD)count_1 != count_3 ) /*0xffe373ce*/
{
AsmExchangeWithSpinlock(this_2 + 4); /*0xffe373d3*/
DebugPrint( /*0xffe373e4*/
0x80000000,
"Updated microcode signature [0x%08x] does not match loaded microcode signature [0x%08x]\n",
count_2,
count_3);
LODWORD(count_1) = ApExchangeFunction(this_2 + 4); /*0xffe373ef*/
}
}
return count_1; /*0xffe373ef*/
}
}
if ( *((_DWORD *)v11 + 3) == v33 && *((_DWORD *)v11 + 1) > count_3 && ((1 << v15) & *((_DWORD *)v11 + 6)) != 0 ) /*0xffe37295*/
{
v17 = *((_DWORD *)v11 + 7); /*0xffe37297*/
if ( v17 ) /*0xffe3729e*/
n2048 = v17 + 48; /*0xffe372a7*/
else
n2048 = 2048; /*0xffe372a0*/
v16 = AsmWriteCr3((int)v11, n2048) == 0; /*0xffe372b1*/
goto LABEL_31; /*0xffe372b4*/
}
v19 = *((_DWORD *)v11 + 7); /*0xffe372b9*/
if ( !v19 || *((_DWORD *)v11 + 1) <= count_3 ) /*0xffe372c3*/
{
LABEL_31:
LODWORD(count_1) = 2048; /*0xffe3733c*/
if ( *((_DWORD *)v11 + 7) ) /*0xffe3733c*/
LODWORD(count_1) = *((_DWORD *)v11 + 8); /*0xffe37347*/
if ( v16 ) /*0xffe3734c*/
{
count_3 = *((_DWORD *)v11 + 1); /*0xffe3734e*/
this_3 = v11 + 48; /*0xffe37351*/
this_4 = v11 + 48; /*0xffe37354*/
}
else
{
this_3 = this_4; /*0xffe3736a*/
}
goto LABEL_40; /*0xffe37358*/
}
n2048_1 = *((_DWORD *)v11 + 8) - v19 - 48; /*0xffe372ca*/
if ( *((_DWORD *)v11 + 8) - v19 != 48 ) /*0xffe372cd*/
{
v21 = &v11[v19]; /*0xffe372d3*/
if ( (n2048_1 & 3) != 0 || AsmWriteCr3((int)(v21 + 48), n2048_1) ) /*0xffe372de*/
{
LABEL_29:
v16 = 0; /*0xffe37334*/
LABEL_30:
v13 = v30; /*0xffe37338*/
goto LABEL_31; /*0xffe37338*/
}
v22 = *((_DWORD *)v21 + 12); /*0xffe372e7*/
v23 = v21 + 68; /*0xffe372ea*/
v34 = 0; /*0xffe372ed*/
v35 = v22; /*0xffe372f2*/
if ( v22 ) /*0xffe372f8*/
{
while ( AsmWriteCr3((int)v23, 0xCu) || *v23 != v33 || ((1 << v31) & v23[1]) == 0 ) /*0xffe3731c*/
{
v23 += 3; /*0xffe37322*/
if ( ++v34 >= v35 ) /*0xffe3732e*/
{
v15 = v31; /*0xffe37330*/
goto LABEL_29; /*0xffe37330*/
}
}
v16 = 1; /*0xffe3735a*/
v15 = v31; /*0xffe3735c*/
goto LABEL_30; /*0xffe3735e*/
}
v13 = v30; /*0xffe37360*/
}
v16 = 0; /*0xffe37364*/
goto LABEL_31; /*0xffe37368*/
}
}
return count_1; /*0xffe373f4*/
}
// Function: DebugPrintLevelEnabled @ 0xffe373fc (0x4f bytes)
// Index: 92/163
int DebugPrintLevelEnabled()
{
unsigned __int8 v0; // al
char n3; // al
char n3_1; // cl
v0 = __inbyte(0x70u); /*0xffe37402*/
__outbyte(0x70u, v0 & 0x80 | 0x4A); /*0xffe37407*/
n3 = __inbyte(0x71u); /*0xffe3740e*/
n3_1 = n3; /*0xffe3740f*/
if ( (unsigned __int8)n3 <= 3u ) /*0xffe37414*/
{
LABEL_4:
if ( !n3_1 ) /*0xffe3742f*/
return 0; /*0xffe3742f*/
goto LABEL_5; /*0xffe3742f*/
}
n3_1 = n3; /*0xffe37416*/
if ( !n3 ) /*0xffe3741e*/
{
n3_1 = MEMORY[0xFDAF0490] & 2 | 1; /*0xffe3742a*/
goto LABEL_4; /*0xffe3742a*/
}
LABEL_5:
if ( n3_1 != -1 )
return n3_1 != 1 ? -2147483578 : -2147483644;
return 0; /*0xffe37447*/
}
// Function: PeiServicesGetPpi @ 0xffe3744b (0x32 bytes)
// Index: 93/163
int PeiServicesGetPpi()
{
int v0; // esi
_BYTE v2[2]; // [esp+4h] [ebp-8h] BYREF
int v3; // [esp+6h] [ebp-6h]
AsmReadCr2(v2); /*0xffe37454*/
v0 = *(_DWORD *)(v3 - 4); /*0xffe3745c*/
if ( !v0 ) /*0xffe37461*/
DebugAssert( /*0xffe37470*/
(int)"e:\\hs\\MdePkg\\Library\\PeiServicesTablePointerLibIdt\\PeiServicesTablePointer.c",
48,
"PeiServices != ((void *) 0)");
return v0; /*0xffe37478*/
}
// Function: PeiServicesInstallPpi @ 0xffe3747d (0x34 bytes)
// Index: 94/163
_BYTE *__fastcall PeiServicesInstallPpi(_BYTE *a1, unsigned int a2, int i, __int16 a4, int a5)
{
int j; // esi
for ( j = 0; j < i; ++j ) /*0xffe37489*/
{
if ( (unsigned int)a1 >= a2 ) /*0xffe37490*/
break; /*0xffe37490*/
*a1 = a4; /*0xffe37496*/
if ( a5 != 1 ) /*0xffe37498*/
a1[1] = HIBYTE(a4); /*0xffe3749f*/
a1 += a5; /*0xffe374a2*/
}
return a1; /*0xffe374ab*/
}
// Function: PeiServicesLocatePpi @ 0xffe374b1 (0x6d bytes)
// Index: 95/163
_BYTE *__fastcall PeiServicesLocatePpi(_BYTE *_r_n, unsigned int n16, int a3, unsigned int a4)
{
_BYTE *_r_n_1; // esi
int Service; // eax
int v7; // eax
int v8; // edx
unsigned __int64 v9; // rtt
unsigned int v11; // [esp-4h] [ebp-1Ch]
int v12; // [esp+Ch] [ebp-Ch] BYREF
int *v13; // [esp+10h] [ebp-8h]
unsigned int n16_1; // [esp+14h] [ebp-4h]
_r_n_1 = _r_n; /*0xffe374b8*/
v13 = &v12; /*0xffe374c0*/
n16_1 = n16; /*0xffe374c3*/
*_r_n = 0; /*0xffe374c6*/
do /*0xffe37507*/
{
if ( !n16 ) /*0xffe374cb*/
{
Service = DebugPrintGetService(); /*0xffe374cd*/
if ( Service ) /*0xffe374d4*/
(*(void (__cdecl **)(const char *, int, const char *))(Service + 4))( /*0xffe374e2*/
"e:\\hs\\MdePkg\\Library\\BaseLib\\DivU64x32Remainder.c",
47,
"Divisor != 0");
}
v11 = a4 / n16_1; /*0xffe374f2*/
LODWORD(v9) = a3; /*0xffe374f6*/
HIDWORD(v9) = a4 % n16_1; /*0xffe374f6*/
v7 = v9 / n16_1; /*0xffe374f6*/
v8 = v9 % n16_1; /*0xffe374f6*/
if ( v13 ) /*0xffe374fb*/
*v13 = v8; /*0xffe374fd*/
++_r_n_1; /*0xffe37503*/
a3 = v7; /*0xffe37504*/
a4 = v11; /*0xffe37509*/
*_r_n_1 = byte_FFE3AE34[v12]; /*0xffe37512*/
}
while ( v11 | v7 ); /*0xffe37507*/
return _r_n_1; /*0xffe37516*/
}
// Function: PrintLibInternalWorker @ 0xffe3751e (0xc61 bytes)
// Index: 96/163
unsigned int __fastcall PrintLibInternalWorker(
_BYTE *_r_n,
unsigned int n0xF4240,
__int16 a3,
unsigned __int8 *%02d_%02d_%04d__%02d:%02d,
int va)
{
int v5; // ebx
int v7; // edi
int Service; // eax
unsigned __int8 *%02d_%02d_%04d__%02d:%02d_1; // edx
int v11; // eax
int v12; // eax
int v13; // eax
int v14; // eax
unsigned __int8 *%02d_%02d_%04d__%02d:%02d_2; // edx
unsigned __int8 *%02d_%02d_%04d__%02d:%02d_3; // edx
int v17; // eax
_BYTE *_r_n_2; // esi
unsigned int v19; // edi
int v20; // ecx
int n10; // eax
unsigned __int8 *%02d_%02d_%04d__%02d:%02d_5; // edi
unsigned int v23; // ecx
const char *_r_n_5; // esi
int n2_2; // eax
unsigned __int8 *%02d_%02d_%04d__%02d:%02d_9; // edi
int v27; // esi
unsigned int n13_1; // ecx
int v29; // ebx
int v30; // esi
unsigned __int8 *%02d_%02d_%04d__%02d:%02d_10; // edi
unsigned int v32; // ecx
unsigned int v33; // ecx
unsigned int v34; // ecx
unsig... [30935 chars total]
// Function: Routine64 @ 0xffe3817f (0x1f bytes)
// Index: 97/163
unsigned int Routine64(_BYTE *_r_n, unsigned int n38, __int16 a3, char *%02d_%02d_%04d__%02d:%02d, ...)
{
va_list va; // [esp+18h] [ebp+18h] BYREF
va_start(va, %02d_%02d_%04d__%02d:%02d);
return PrintLibInternalWorker(_r_n, n38, a3, (unsigned __int8 *)%02d_%02d_%04d__%02d:%02d, (int)va); /*0xffe3819c*/
}
// Function: LongJump @ 0xffe3819e (0x12 bytes)
// Index: 98/163
unsigned int __thiscall LongJump(void *n1288)
{
unsigned __int32 Cr3; // eax
Cr3 = ReadCr3(n1288); /*0xffe381a0*/
return UnalignedRead32(Cr3, 0, 0x17u); /*0xffe381af*/
}
// Function: SetJump @ 0xffe381b0 (0x33 bytes)
// Index: 99/163
__int16 __fastcall SetJump(_WORD *a1, __int16 n1280)
{
int Service; // eax
if ( ((unsigned __int8)a1 & 1) != 0 ) /*0xffe381ba*/
{
Service = DebugPrintGetService(); /*0xffe381bc*/
if ( Service ) /*0xffe381c3*/
(*(void (__cdecl **)(char *, int, const char *))(Service + 4))( /*0xffe381d4*/
"e:\\hs\\MdePkg\\Library\\BaseIoLibIntrinsic\\IoLib.c",
183,
"(Address & 1) == 0");
}
*a1 = n1280; /*0xffe381da*/
return n1280; /*0xffe381e0*/
}
// Function: ReadCr3 @ 0xffe381e3 (0x2c bytes)
// Index: 100/163
unsigned __int32 __thiscall ReadCr3(void *n1288)
{
unsigned __int16 n1288_1; // bx
int Service; // eax
n1288_1 = (unsigned __int16)n1288; /*0xffe381e4*/
if ( ((unsigned __int8)n1288 & 3) != 0 ) /*0xffe381e9*/
{
Service = DebugPrintGetService(); /*0xffe381eb*/
if ( Service ) /*0xffe381f2*/
(*(void (__cdecl **)(const char *, int, const char *))(Service + 4))( /*0xffe38203*/
"e:\\hs\\MdePkg\\Library\\BaseIoLibIntrinsic\\IoLibMsc.c",
193,
"(Port & 3) == 0");
}
return __indword(n1288_1); /*0xffe3820d*/
}
// Function: GetMpAlloc @ 0xffe3820f (0x58 bytes)
// Index: 101/163
void *__thiscall GetMpAlloc(void *this)
{
int Ppi; // eax
int v2; // eax
int Service; // eax
void *this_1; // [esp+0h] [ebp-4h]
this_1 = this; /*0xffe38212*/
Ppi = PeiServicesGetPpi(); /*0xffe38213*/
v2 = (*(int (__stdcall **)(int))(*(_DWORD *)Ppi + 32))(Ppi); /*0xffe38228*/
if ( v2 < 0 ) /*0xffe38230*/
{
DebugPrint(0x80000000, "\nASSERT_EFI_ERROR (Status = %r)\n", v2); /*0xffe3823d*/
Service = DebugPrintGetService(); /*0xffe38245*/
if ( Service ) /*0xffe3824c*/
(*(void (__cdecl **)(const char *, int, const char *))(Service + 4))( /*0xffe3825a*/
"e:\\hs\\MdePkg\\Library\\PeiPcdLib\\PeiPcdLib.c",
49,
"!EFI_ERROR (Status)");
}
return this_1; /*0xffe38265*/
}
// Function: MpAllocateBuffer @ 0xffe38267 (0x31 bytes)
// Index: 102/163
int __fastcall MpAllocateBuffer(int a1, int a2)
{
int Ppi; // eax
int v5; // [esp+4h] [ebp-8h] BYREF
if ( a2 /*0xffe3828e*/
&& (Ppi = PeiServicesGetPpi(), (*(int (__cdecl **)(int, int, int, int *))(*(_DWORD *)Ppi + 72))(Ppi, 4, a2, &v5) >= 0) )
{
return v5; /*0xffe38290*/
}
else
{
return 0; /*0xffe38273*/
}
}
// Function: HobGetGuid @ 0xffe38298 (0x2a bytes)
// Index: 103/163
int __thiscall HobGetGuid(void *this)
{
int Ppi; // eax
int v4; // [esp+4h] [ebp-4h] BYREF
Ppi = PeiServicesGetPpi(); /*0xffe3829f*/
if ( (*(int (__cdecl **)(int, void *, int *))(*(_DWORD *)Ppi + 76))(Ppi, this, &v4) >= 0 ) /*0xffe382b5*/
return v4; /*0xffe382bb*/
else
return 0; /*0xffe382b7*/
}
// Function: HobGetData @ 0xffe382c2 (0x30 bytes)
// Index: 104/163
int __fastcall HobGetData(int a1, int Guid)
{
__int64 Idtr; // rax
__int64 Idtr_1; // rax
Idtr = AsmReadIdtr((void *)Guid); /*0xffe382ca*/
AsmWbinvd(Idtr, SHIDWORD(Idtr)); /*0xffe382d3*/
Idtr_1 = AsmReadIdtr((void *)(Guid + 8)); /*0xffe382db*/
AsmWbinvd(Idtr_1, SHIDWORD(Idtr_1)); /*0xffe382e5*/
return a1; /*0xffe382ef*/
}
// Function: PcdGetBool @ 0xffe382f2 (0x5f bytes)
// Index: 105/163
bool __fastcall PcdGetBool(char *this, int a2)
{
__int64 Idtr; // rax
int Idtr_1; // ebp
__int64 Idtr_3; // rax
int Idtr_2; // edi
__int64 v8; // kr00_8
__int64 v9; // rax
int v11; // [esp+10h] [ebp-Ch]
int v12; // [esp+14h] [ebp-8h]
Idtr = AsmReadIdtr(this); /*0xffe382fd*/
v12 = HIDWORD(Idtr); /*0xffe38304*/
Idtr_1 = Idtr; /*0xffe38308*/
Idtr_3 = AsmReadIdtr((void *)a2); /*0xffe3830a*/
v11 = HIDWORD(Idtr_3); /*0xffe38312*/
Idtr_2 = Idtr_3; /*0xffe38316*/
v8 = AsmReadIdtr(this + 8); /*0xffe38324*/
v9 = AsmReadIdtr((void *)(a2 + 8)); /*0xffe38326*/
return Idtr_1 == Idtr_2 && v12 == v11 && v8 == v9; /*0xffe38349*/
}
// Function: AllocateZeroPool @ 0xffe38351 (0x53 bytes)
// Index: 106/163
void *__fastcall AllocateZeroPool(int buf, unsigned int count)
{
int Service; // eax
int v5; // eax
if ( !buf ) /*0xffe3835f*/
{
Service = DebugPrintGetService(); /*0xffe38361*/
if ( Service ) /*0xffe38368*/
(*(void (__cdecl **)(const char *, int, const char *))(Service + 4))( /*0xffe38372*/
"e:\\hs\\MdePkg\\Library\\BaseMemoryLibRepStr\\ZeroMemWrapper.c",
53,
"Buffer != ((void *) 0)");
}
if ( count > -buf ) /*0xffe3837e*/
{
v5 = DebugPrintGetService(); /*0xffe38380*/
if ( v5 ) /*0xffe38387*/
(*(void (__cdecl **)(const char *, int, const char *))(v5 + 4))( /*0xffe38391*/
"e:\\hs\\MdePkg\\Library\\BaseMemoryLibRepStr\\ZeroMemWrapper.c",
54,
"Length <= (0xFFFFFFFF - (UINTN)Buffer + 1)");
}
return SetMem((void *)buf, count); /*0xffe383a0*/
}
// Function: AllocatePool @ 0xffe383a4 (0x41 bytes)
// Index: 107/163
void *__fastcall AllocatePool(void *buf, unsigned int n1536)
{
int Service; // eax
if ( n1536 - 1 > -1 - (int)buf ) /*0xffe383b5*/
{
Service = DebugPrintGetService(); /*0xffe383b7*/
if ( Service ) /*0xffe383be*/
(*(void (__cdecl **)(const char *, int, const char *))(Service + 4))( /*0xffe383cc*/
"e:\\hs\\MdePkg\\Library\\BaseMemoryLibRepStr\\SetMemWrapper.c",
54,
"(Length - 1) <= (0xFFFFFFFF - (UINTN)Buffer)");
}
return SetMem16(buf, n1536, 255); /*0xffe383e1*/
}
// Function: BitFieldRead64 @ 0xffe383e5 (0x21 bytes)
// Index: 108/163
int __cdecl BitFieldRead64(int a1, unsigned int a2)
{
unsigned __int64 v3; // rtt
LODWORD(v3) = a1; /*0xffe383ff*/
HIDWORD(v3) = a2 % 0xF4240; /*0xffe383ff*/
return v3 / 0xF4240; /*0xffe38402*/
}
// Function: BitFieldWrite64 @ 0xffe38406 (0x3e bytes)
// Index: 109/163
int __cdecl BitFieldWrite64(unsigned __int64 a1, __int64 a2)
{
int Service; // eax
if ( !a2 ) /*0xffe3840f*/
{
Service = DebugPrintGetService(); /*0xffe38411*/
if ( Service ) /*0xffe38418*/
(*(void (__cdecl **)(const char *, int, const char *))(Service + 4))( /*0xffe38426*/
"e:\\hs\\MdePkg\\Library\\BaseLib\\DivU64x64Remainder.c",
47,
"Divisor != 0");
}
return BitFieldRead32(a1, a2, 0); /*0xffe38442*/
}
// Function: BitFieldAnd64 @ 0xffe38444 (0x42 bytes)
// Index: 110/163
unsigned __int64 __cdecl BitFieldAnd64(unsigned __int64 a1)
{
unsigned int n0x40; // ecx
int Service; // eax
unsigned __int64 v3; // rax
char n0x40_1; // [esp+0h] [ebp-4h]
n0x40_1 = n0x40; /*0xffe38448*/
if ( n0x40 >= 0x40 ) /*0xffe3844e*/
{
Service = DebugPrintGetService(); /*0xffe38450*/
if ( Service ) /*0xffe38457*/
(*(void (__cdecl **)(const char *, int, const char *))(Service + 4))( /*0xffe38465*/
"e:\\hs\\MdePkg\\Library\\BaseLib\\RShiftU64.c",
39,
"Count < 64");
}
v3 = HIDWORD(a1); /*0xffe38470*/
if ( (n0x40_1 & 0x20) == 0 ) /*0xffe38476*/
v3 = a1; /*0xffe3847a*/
return v3 >> (n0x40_1 & 0x1F); /*0xffe38482*/
}
// Function: RclRead @ 0xffe38486 (0x3a bytes)
// Index: 111/163
int __cdecl RclRead(_DWORD *a1, _DWORD *a2, _DWORD *a3, _DWORD *a4)
{
int _EAX_1; // ecx
int _EAX_2; // [esp+8h] [ebp-4h]
_EAX_2 = _EAX_1; /*0xffe3848f*/
_EAX = _EAX_1; /*0xffe38492*/
__asm { cpuid } /*0xffe38498*/
if ( a1 ) /*0xffe3849e*/
*a1 = _EAX; /*0xffe384a0*/
if ( a2 ) /*0xffe384a5*/
*a2 = _EBX; /*0xffe384a7*/
if ( a3 ) /*0xffe384ad*/
*a3 = _ECX; /*0xffe384af*/
if ( a4 ) /*0xffe384b4*/
*a4 = _EDX; /*0xffe384b6*/
return _EAX_2; /*0xffe384bb*/
}
// Function: UnalignedRead16 @ 0xffe384c0 (0x15 bytes)
// Index: 112/163
int __fastcall UnalignedRead16(int n0x80, int a2)
{
int n31; // eax
if ( !n0x80 ) /*0xffe384c2*/
return -1; /*0xffe384c4*/
n31 = 31; /*0xffe384ca*/
while ( n0x80 > 0 ) /*0xffe384d2*/
{
--n31; /*0xffe384cd*/
n0x80 *= 2; /*0xffe384ce*/
}
return n31; /*0xffe384c7*/
}
// Function: BitFieldFieldType @ 0xffe384d5 (0x37 bytes)
// Index: 113/163
int __fastcall BitFieldFieldType(int _EAX, _DWORD *a2, _DWORD *a3, _DWORD *a4, _DWORD *a5)
{
_EAX = _EAX; /*0xffe384e1*/
__asm { cpuid } /*0xffe384e4*/
if ( a2 ) /*0xffe384ea*/
*a2 = _EAX; /*0xffe384ec*/
if ( a3 ) /*0xffe384f1*/
*a3 = _EBX; /*0xffe384f3*/
if ( a4 ) /*0xffe384f9*/
*a4 = _ECX; /*0xffe384fb*/
if ( a5 ) /*0xffe38500*/
*a5 = _EDX; /*0xffe38502*/
return _EAX; /*0xffe38507*/
}
// Function: UnalignedRead32 @ 0xffe3850c (0x3e bytes)
// Index: 114/163
unsigned int __fastcall UnalignedRead32(int this, unsigned int n11, unsigned int n11a)
{
char n11_1; // si
int Service; // eax
n11_1 = n11; /*0xffe3850d*/
if ( n11 > n11a ) /*0xffe38516*/
{
Service = DebugPrintGetService(); /*0xffe38518*/
if ( Service ) /*0xffe3851f*/
(*(void (__cdecl **)(const char *, int, const char *))(Service + 4))( /*0xffe38530*/
"e:\\hs\\MdePkg\\Library\\BaseLib\\BitField.c",
540,
"StartBit <= EndBit");
}
return (this & (unsigned int)~(-2 << n11a)) >> n11_1; /*0xffe38545*/
}
// Function: UnalignedRead64 @ 0xffe3854a (0x50 bytes)
// Index: 115/163
unsigned __int64 __fastcall UnalignedRead64(unsigned int n8, unsigned int n8_1, __int64 a3)
{
int Service; // eax
__int64 v4; // rax
if ( n8 > n8_1 ) /*0xffe38553*/
{
Service = DebugPrintGetService(); /*0xffe38555*/
if ( Service ) /*0xffe3855c*/
(*(void (__cdecl **)(const char *, int, const char *))(Service + 4))( /*0xffe3856d*/
"e:\\hs\\MdePkg\\Library\\BaseLib\\BitField.c",
732,
"StartBit <= EndBit");
}
v4 = BitFieldOr64(-2); /*0xffe38579*/
return BitFieldAnd64(a3 & ~v4); /*0xffe38596*/
}
// Function: UnalignedWrite16 @ 0xffe3859a (0x16 bytes)
// Index: 116/163
unsigned int __cdecl UnalignedWrite16(int a1)
{
return UnalignedRead24(a1); /*0xffe385af*/
}
// Function: UnalignedWrite32 @ 0xffe385b0 (0x7c bytes)
// Index: 117/163
unsigned int __cdecl UnalignedWrite32(int a1)
{
__int64 v1; // rdi
unsigned __int64 v2; // rax
int Service; // eax
int v4; // esi
HIDWORD(v1) = BitFieldAnd64(0) & 1; /*0xffe385c8*/
LODWORD(v1) = 0; /*0xffe385cb*/
v2 = BitFieldAnd64(0); /*0xffe385cd*/
if ( __PAIR64__(v2, HIDWORD(v2)) != v1 ) /*0xffe385d7*/
{
Service = DebugPrintGetService(); /*0xffe385dd*/
if ( Service ) /*0xffe385e4*/
(*(void (__cdecl **)(const char *, int, const char *))(Service + 4))( /*0xffe385f5*/
"e:\\hs\\MdePkg\\Library\\BaseLib\\BitField.c",
817,
"RShiftU64 (OrData, EndBit - StartBit) == (RShiftU64 (OrData, EndBit - StartBit) & 1)");
}
v4 = BitFieldOr64(0); /*0xffe3860e*/
return a1 | v4 & ~(unsigned int)BitFieldOr64(-2); /*0xffe38628*/
}
// Function: UnalignedWrite64 @ 0xffe3862c (0x82 bytes)
// Index: 118/163
unsigned int __cdecl UnalignedWrite64(int a1)
{
__int64 v1; // rdi
unsigned __int64 v2; // rax
int Service; // eax
int v4; // esi
HIDWORD(v1) = BitFieldAnd64(0) & 1; /*0xffe38644*/
LODWORD(v1) = 0; /*0xffe38647*/
v2 = BitFieldAnd64(0); /*0xffe38649*/
if ( __PAIR64__(v2, HIDWORD(v2)) != v1 ) /*0xffe38653*/
{
Service = DebugPrintGetService(); /*0xffe38659*/
if ( Service ) /*0xffe38660*/
(*(void (__cdecl **)(const char *, int, const char *))(Service + 4))( /*0xffe38671*/
"e:\\hs\\MdePkg\\Library\\BaseLib\\BitField.c",
869,
"RShiftU64 (AndData, EndBit - StartBit) == (RShiftU64 (AndData, EndBit - StartBit) & 1)");
}
v4 = BitFieldOr64(-1); /*0xffe3868c*/
return a1 & ~(v4 & ~(unsigned int)BitFieldOr64(-2)); /*0xffe386aa*/
}
// Function: UnalignedRead24 @ 0xffe386ae (0x20 bytes)
// Index: 119/163
unsigned int __cdecl UnalignedRead24(int a1)
{
unsigned int v1; // eax
v1 = UnalignedWrite64(a1); /*0xffe386ba*/
return UnalignedWrite32(v1); /*0xffe386cd*/
}
// Function: UnalignedWrite24 @ 0xffe386ce (0x33 bytes)
// Index: 120/163
int UnalignedWrite24()
{
unsigned __int64 v0; // rax
LODWORD(v0) = UnalignedWrite16(__readmsr(0x2FFu)); /*0xffe386e4*/
__writemsr(0x2FFu, v0); /*0xffe386fb*/
return v0; /*0xffe386fd*/
}
// Function: BitFieldOr64 @ 0xffe38701 (0x42 bytes)
// Index: 121/163
__int64 __cdecl BitFieldOr64(__int64 a1)
{
unsigned int n0x40; // ecx
int Service; // eax
__int64 v3; // rax
char n0x40_1; // [esp+0h] [ebp-4h]
n0x40_1 = n0x40; /*0xffe38705*/
if ( n0x40 >= 0x40 ) /*0xffe3870b*/
{
Service = DebugPrintGetService(); /*0xffe3870d*/
if ( Service ) /*0xffe38714*/
(*(void (__cdecl **)(const char *, int, const char *))(Service + 4))( /*0xffe38722*/
"e:\\hs\\MdePkg\\Library\\BaseLib\\LShiftU64.c",
39,
"Count < 64");
}
LODWORD(v3) = 0; /*0xffe3872b*/
HIDWORD(v3) = a1; /*0xffe3872d*/
if ( (n0x40_1 & 0x20) == 0 ) /*0xffe38733*/
v3 = a1; /*0xffe38735*/
return v3 << (n0x40_1 & 0x1F); /*0xffe3873f*/
}
// Function: WriteMsr64 @ 0xffe38743 (0x16 bytes)
// Index: 122/163
int __fastcall WriteMsr64(int n0x80, int a2)
{
if ( n0x80 ) /*0xffe38745*/
return 1 << UnalignedRead16(n0x80, a2); /*0xffe38756*/
else
return 0; /*0xffe38747*/
}
// Function: ReadMsr64 @ 0xffe38759 (0x5b bytes)
// Index: 123/163
unsigned int __thiscall ReadMsr64(_BYTE *this)
{
_BYTE *this_1; // esi
int Service; // eax
unsigned int n0xF4240; // edi
int v4; // eax
this_1 = this; /*0xffe3875b*/
if ( !this ) /*0xffe38765*/
{
Service = DebugPrintGetService(); /*0xffe38767*/
if ( Service ) /*0xffe3876e*/
(*(void (__cdecl **)(const char *, int, const char *))(Service + 4))( /*0xffe3877b*/
"e:\\hs\\MdePkg\\Library\\BaseLib\\String.c",
1082,
"String != ((void *) 0)");
}
n0xF4240 = 0; /*0xffe38781*/
while ( *this_1 ) /*0xffe387ac*/
{
if ( n0xF4240 >= 0xF4240 ) /*0xffe3878b*/
{
v4 = DebugPrintGetService(); /*0xffe3878d*/
if ( v4 ) /*0xffe38794*/
(*(void (__cdecl **)(const char *, int, const char *))(v4 + 4))( /*0xffe387a1*/
"e:\\hs\\MdePkg\\Library\\BaseLib\\String.c",
1090,
"Length < _gPcd_FixedAtBuild_PcdMaximumAsciiStringLength");
}
++this_1; /*0xffe387a7*/
++n0xF4240; /*0xffe387a8*/
}
return n0xF4240; /*0xffe387b0*/
}
// Function: AsmReadCr2 @ 0xffe387b4 (0x23 bytes)
// Index: 124/163
void *__thiscall AsmReadCr2(void *this)
{
void *this_1; // eax
if ( !this ) /*0xffe387ba*/
DebugAssert((int)"e:\\hs\\MdePkg\\Library\\BaseLib\\X86ReadIdtr.c", 37, "Idtr != ((void *) 0)"); /*0xffe387c9*/
this_1 = this; /*0xffe387cf*/
__sidt(this); /*0xffe387d2*/
return this_1; /*0xffe387d6*/
}
// Function: AsmWriteCr3 @ 0xffe387d7 (0xb0 bytes)
// Index: 125/163
int __fastcall AsmWriteCr3(int a1, unsigned int n2048)
{
char v2; // al
int Service; // eax
int v5; // eax
int v6; // eax
int v7; // eax
unsigned int i_1; // ebx
int result; // eax
unsigned int i; // ecx
v2 = a1; /*0xffe387dc*/
if ( !a1 ) /*0xffe387ec*/
{
Service = DebugPrintGetService(); /*0xffe387ee*/
if ( Service ) /*0xffe387f5*/
(*(void (__cdecl **)(const char *, int, const char *))(Service + 4))( /*0xffe38802*/
"e:\\hs\\MdePkg\\Library\\BaseLib\\CheckSum.c",
204,
"Buffer != ((void *) 0)");
v2 = 0; /*0xffe38808*/
}
if ( (v2 & 3) != 0 ) /*0xffe3880d*/
{
v5 = DebugPrintGetService(); /*0xffe3880f*/
if ( v5 ) /*0xffe38816*/
(*(void (__cdecl **)(const char *, int, const char *))(v5 + 4))( /*0xffe38823*/
"e:\\hs\\MdePkg\\Library\\BaseLib\\CheckSum.c",
205,
"((UINTN) Buffer & 0x3) == 0");
}
if ( (n2048 & 3) != 0 ) /*0xffe3882c*/
{
v6 = DebugPrintGetService(); /*0xffe3882e*/
if ( v6 ) /*0xffe38835*/
(*(void (__cdecl **)(const char *, int, const char *))(v6 + 4))( /*0xffe38842*/
"e:\\hs\\MdePkg\\Library\\BaseLib\\CheckSum.c",
206,
"(Length & 0x3) == 0");
}
if ( n2048 > -a1 ) /*0xffe38851*/
{
v7 = DebugPrintGetService(); /*0xffe38853*/
if ( v7 ) /*0xffe3885a*/
(*(void (__cdecl **)(const char *, int, const char *))(v7 + 4))( /*0xffe38867*/
"e:\\hs\\MdePkg\\Library\\BaseLib\\CheckSum.c",
207,
"Length <= (0xFFFFFFFF - ((UINTN) Buffer) + 1)");
}
i_1 = n2048 >> 2; /*0xffe3886d*/
result = 0; /*0xffe38870*/
for ( i = 0; i < i_1; ++i ) /*0xffe38876*/
result += *(_DWORD *)(a1 + 4 * i); /*0xffe38878*/
return result; /*0xffe38880*/
}
// Function: AsmReadTr @ 0xffe38887 (0x27 bytes)
// Index: 126/163
__int16 __thiscall AsmReadTr(void *this)
{
int Service; // eax
if ( !this ) /*0xffe3888c*/
{
Service = DebugPrintGetService(); /*0xffe3888e*/
if ( Service ) /*0xffe38895*/
(*(void (__cdecl **)(const char *, int, const char *))(Service + 4))( /*0xffe388a3*/
"e:\\hs\\MdePkg\\Library\\BaseLib\\Unaligned.c",
38,
"Buffer != ((void *) 0)");
}
return *(_WORD *)this; /*0xffe388ac*/
}
// Function: AsmLidt @ 0xffe388ae (0x29 bytes)
// Index: 127/163
int __thiscall AsmLidt(void *this)
{
int Service; // eax
if ( !this ) /*0xffe388b3*/
{
Service = DebugPrintGetService(); /*0xffe388b5*/
if ( Service ) /*0xffe388bc*/
(*(void (__cdecl **)(const char *, int, const char *))(Service + 4))( /*0xffe388cd*/
"e:\\hs\\MdePkg\\Library\\BaseLib\\Unaligned.c",
141,
"Buffer != ((void *) 0)");
}
return *(_DWORD *)this; /*0xffe388d5*/
}
// Function: AsmReadIdtr @ 0xffe388d7 (0x2c bytes)
// Index: 128/163
__int64 __thiscall AsmReadIdtr(void *this)
{
int Service; // eax
if ( !this ) /*0xffe388dc*/
{
Service = DebugPrintGetService(); /*0xffe388de*/
if ( Service ) /*0xffe388e5*/
(*(void (__cdecl **)(const char *, int, const char *))(Service + 4))( /*0xffe388f6*/
"e:\\hs\\MdePkg\\Library\\BaseLib\\Unaligned.c",
192,
"Buffer != ((void *) 0)");
}
return *(_QWORD *)this; /*0xffe38901*/
}
// Function: AsmWbinvd @ 0xffe38903 (0x34 bytes)
// Index: 129/163
int __cdecl AsmWbinvd(int Idtr, int a2)
{
_DWORD *v2; // ecx
_DWORD *v3; // esi
int Service; // eax
v3 = v2; /*0xffe38904*/
if ( !v2 ) /*0xffe38908*/
{
Service = DebugPrintGetService(); /*0xffe3890a*/
if ( Service ) /*0xffe38911*/
(*(void (__cdecl **)(const char *, int, const char *))(Service + 4))( /*0xffe38922*/
"e:\\hs\\MdePkg\\Library\\BaseLib\\Unaligned.c",
219,
"Buffer != ((void *) 0)");
}
*v3 = Idtr; /*0xffe38930*/
v3[1] = a2; /*0xffe38932*/
return Idtr; /*0xffe38935*/
}
// Function: AsmReadGdtr @ 0xffe38937 (0x4e bytes)
// Index: 130/163
unsigned int __fastcall AsmReadGdtr(_WORD *%02d_%02d_%04d__%02d:%02d)
{
int Service; // eax
unsigned int n0xF4240; // eax
if ( ((unsigned __int8)%02d_%02d_%04d__%02d:%02d & 1) != 0 ) /*0xffe3893d*/
{
Service = DebugPrintGetService(); /*0xffe3893f*/
if ( Service ) /*0xffe38946*/
(*(void (__cdecl **)(const char *, int, const char *))(Service + 4))( /*0xffe38957*/
"e:\\hs\\MdePkg\\Library\\BaseLib\\SafeString.c",
128,
"((UINTN) String & 0x00000001) == 0");
}
if ( !%02d_%02d_%04d__%02d:%02d ) /*0xffe3895f*/
return 0; /*0xffe38981*/
n0xF4240 = 0; /*0xffe38963*/
if ( *%02d_%02d_%04d__%02d:%02d ) /*0xffe38965*/
{
while ( n0xF4240 < 0xF4240 ) /*0xffe3896f*/
{
if ( !%02d_%02d_%04d__%02d:%02d[++n0xF4240] ) /*0xffe38972*/
return n0xF4240; /*0xffe38976*/
}
return 1000001; /*0xffe3897a*/
}
return n0xF4240; /*0xffe38978*/
}
// Function: AsmReadCr4 @ 0xffe38985 (0x1f bytes)
// Index: 131/163
unsigned int __thiscall AsmReadCr4(_BYTE *this)
{
unsigned int n0xF4240; // eax
n0xF4240 = 0; /*0xffe38985*/
if ( this && *this ) /*0xffe3898b*/
{
while ( n0xF4240 < 0xF4240 ) /*0xffe38994*/
{
if ( !*(this + ++n0xF4240) ) /*0xffe38997*/
return n0xF4240; /*0xffe3899b*/
}
return 1000001; /*0xffe3899e*/
}
return n0xF4240; /*0xffe3899d*/
}
// Function: BitFieldXor64 @ 0xffe389a4 (0x1f bytes)
// Index: 132/163
__int64 __cdecl BitFieldXor64(__int64 a1, __int64 a2)
{
return a2 * a1; /*0xffe389c1*/
}
// Function: InitializeCpuExceptionHandlers @ 0xffe389c3 (0x1d bytes)
// Index: 133/163
int __cdecl InitializeCpuExceptionHandlers(int a1, unsigned int a2, unsigned int a3, _DWORD *a4)
{
int result; // eax
int v5; // edx
unsigned __int64 v6; // rtt
LODWORD(v6) = a1; /*0xffe389d4*/
HIDWORD(v6) = a2 % a3; /*0xffe389d4*/
result = v6 / a3; /*0xffe389d4*/
v5 = v6 % a3; /*0xffe389d4*/
if ( a4 ) /*0xffe389d9*/
*a4 = v5; /*0xffe389db*/
return result; /*0xffe389de*/
}
// Function: MtrrGetNumberOfVariableMtrrs @ 0xffe389e0 (0x8a bytes)
// Index: 134/163
int __fastcall MtrrGetNumberOfVariableMtrrs(char *FixedMtrr, _DWORD *a2)
{
int Service; // eax
int v5; // eax
char *FixedMtrr_1; // eax
int v7; // eax
if ( !FixedMtrr ) /*0xffe389ee*/
{
Service = DebugPrintGetService(); /*0xffe389f0*/
if ( Service ) /*0xffe389f7*/
(*(void (__cdecl **)(const char *, int, const char *))(Service + 4))( /*0xffe38a01*/
"e:\\hs\\MdePkg\\Library\\BasePeCoffGetEntryPointLib\\PeCoffGetEntryPoint.c",
54,
"Pe32Data != ((void *) 0)");
}
if ( !a2 ) /*0xffe38a09*/
{
v5 = DebugPrintGetService(); /*0xffe38a0b*/
if ( v5 ) /*0xffe38a12*/
(*(void (__cdecl **)(const char *, int, const char *))(v5 + 4))( /*0xffe38a1c*/
"e:\\hs\\MdePkg\\Library\\BasePeCoffGetEntryPointLib\\PeCoffGetEntryPoint.c",
55,
"EntryPoint != ((void *) 0)");
}
if ( *(_WORD *)FixedMtrr == 23117 ) /*0xffe38a2a*/
FixedMtrr_1 = &FixedMtrr[*((unsigned __int16 *)FixedMtrr + 30)]; /*0xffe38a30*/
else
FixedMtrr_1 = FixedMtrr; /*0xffe38a34*/
if ( *(_WORD *)FixedMtrr_1 == 23126 ) /*0xffe38a3e*/
{
v7 = *((_DWORD *)FixedMtrr_1 + 2) - *((unsigned __int16 *)FixedMtrr_1 + 3) + 40; /*0xffe38a49*/
LABEL_12:
*a2 = &FixedMtrr[v7]; /*0xffe38a4c*/
return 0; /*0xffe38a52*/
}
if ( *(_DWORD *)FixedMtrr_1 == 17744 ) /*0xffe38a5a*/
{
v7 = *((_DWORD *)FixedMtrr_1 + 10); /*0xffe38a5c*/
goto LABEL_12; /*0xffe38a5f*/
}
return -2147483645; /*0xffe38a66*/
}
// Function: MtrrGetMemoryAttributesInMtrr @ 0xffe38a6a (0x129 bytes)
// Index: 135/163
char *__thiscall MtrrGetMemoryAttributesInMtrr(char *this)
{
int Service; // eax
int v3; // ebx
char *this_1; // eax
_DWORD *v5; // edx
int v6; // edi
char *v7; // eax
int n512; // ecx
__int16 n267; // cx
unsigned int n6; // ecx
unsigned int v11; // edx
unsigned int v12; // edi
_DWORD *i; // ecx
char *v14; // eax
if ( !this ) /*0xffe38a71*/
{
Service = DebugPrintGetService(); /*0xffe38a73*/
if ( Service ) /*0xffe38a7a*/
(*(void (__cdecl **)(const char *, int, const char *))(Service + 4))( /*0xffe38a8b*/
"e:\\hs\\MdePkg\\Library\\BasePeCoffGetEntryPointLib\\PeCoffGetEntryPoint.c",
166,
"Pe32Data != ((void *) 0)");
}
v3 = 0; /*0xffe38a96*/
if ( *(_WORD *)this == 23117 ) /*0xffe38a9b*/
this_1 = this + *((unsigned __int16 *)this + 30); /*0xffe38aa1*/
else
this_1 = this; /*0xffe38aa5*/
if ( *(_WORD *)this_1 != 23126 ) /*0xffe38aaf*/
{
if ( *(_DWORD *)this_1 != 17744 ) /*0xffe38ad3*/
return 0; /*0xffe38ad3*/
n512 = *((unsigned __int16 *)this_1 + 2); /*0xffe38ad9*/
if ( n512 == 332 ) /*0xffe38ae8*/
{
n267 = 267; /*0xffe38b00*/
}
else
{
if ( n512 == 512 || n512 == 34404 ) /*0xffe38af8*/
goto LABEL_18; /*0xffe38af8*/
n267 = *((_WORD *)this_1 + 12); /*0xffe38afa*/
}
if ( n267 == 267 ) /*0xffe38b05*/
{
n6 = *((_DWORD *)this_1 + 29); /*0xffe38b07*/
v5 = this_1 + 168; /*0xffe38b0a*/
goto LABEL_20; /*0xffe38b10*/
}
LABEL_18:
if ( *((_WORD *)this_1 + 12) != 523 ) /*0xffe38b1b*/
goto LABEL_21; /*0xffe38b1b*/
n6 = *((_DWORD *)this_1 + 33); /*0xffe38b1d*/
v5 = this_1 + 184; /*0xffe38b23*/
LABEL_20:
v7 = this + *v5; /*0xffe38b29*/
if ( n6 > 6 ) /*0xffe38b30*/
goto LABEL_22; /*0xffe38b30*/
LABEL_21:
v5 = 0; /*0xffe38b32*/
v7 = 0; /*0xffe38b34*/
goto LABEL_22; /*0xffe38b34*/
}
v5 = this_1 + 32; /*0xffe38ab1*/
v6 = *((_DWORD *)this_1 + 8); /*0xffe38ab4*/
if ( !v6 ) /*0xffe38ab8*/
return 0; /*0xffe38b83*/
v3 = 40 - *((unsigned __int16 *)this_1 + 3); /*0xffe38ac7*/
v7 = &this_1[v6 + v3]; /*0xffe38ac9*/
LABEL_22:
if ( !v7 ) /*0xffe38b38*/
return 0; /*0xffe38b38*/
if ( !v5 ) /*0xffe38b3c*/
return 0; /*0xffe38b3c*/
v11 = v5[1]; /*0xffe38b3e*/
v12 = 0; /*0xffe38b41*/
if ( !v11 ) /*0xffe38b45*/
return 0; /*0xffe38b45*/
for ( i = v7 + 16; ; i += 7 ) /*0xffe38b47*/
{
if ( *(i - 1) != 2 || !*i ) /*0xffe38b50*/
goto LABEL_31; /*0xffe38b53*/
v14 = this + v3 + i[1]; /*0xffe38b5a*/
if ( *(_DWORD *)v14 == 808534606 ) /*0xffe38b62*/
break; /*0xffe38b62*/
if ( *(_DWORD *)v14 == 1129272397 ) /*0xffe38b6a*/
return v14 + 20; /*0xffe38b8c*/
if ( *(_DWORD *)v14 == 1396986706 ) /*0xffe38b72*/
return v14 + 24; /*0xffe38b87*/
LABEL_31:
v12 += 28; /*0xffe38b74*/
if ( v12 >= v11 ) /*0xffe38b7c*/
return 0; /*0xffe38b7c*/
}
return v14 + 16; /*0xffe38b80*/
}
// Function: MtrrGetFixedMtrr @ 0xffe38b93 (0x7e bytes)
// Index: 136/163
_WORD *__fastcall MtrrGetFixedMtrr(unsigned int a1)
{
_WORD *v1; // edx
_DWORD *v2; // eax
bool v3; // zf
__int16 n332; // ax
v1 = (_WORD *)(a1 & 0xFFFFFFFC); /*0xffe38b95*/
if ( (a1 & 0xFFFFFFFC) != 0 ) /*0xffe38b98*/
{
do /*0xffe38b9b*/
{
if ( *v1 == 23117 ) /*0xffe38ba6*/
{
v2 = (_DWORD *)((char *)v1 + (unsigned __int16)v1[30]); /*0xffe38bac*/
if ( v2 > (_DWORD *)v1 && (unsigned int)v2 < a1 ) /*0xffe38bb4*/
{
v3 = *v2 == 17744; /*0xffe38bb6*/
LABEL_13:
if ( v3 ) /*0xffe38c06*/
return v1; /*0xffe38c06*/
}
}
else if ( *v1 == 23126 ) /*0xffe38bc6*/
{
n332 = v1[1]; /*0xffe38bc8*/
if ( n332 == 332 || n332 == 512 || n332 == 3772 || n332 == -31132 || n332 == -21916 ) /*0xffe38bfc*/
return v1; /*0xffe38bfc*/
v3 = n332 == 450; /*0xffe38c03*/
goto LABEL_13; /*0xffe38c03*/
}
v1 -= 2; /*0xffe38c08*/
}
while ( v1 ); /*0xffe38b9b*/
}
return v1; /*0xffe38c10*/
}
// Function: PpiGetCpuCount @ 0xffe38c11 (0x25 bytes)
// Index: 137/163
int PpiGetCpuCount()
{
unsigned __int8 n33; // al
__outbyte(0x72u, 0x5Cu); /*0xffe38c1b*/
n33 = __inbyte(0x73u); /*0xffe38c22*/
return n33 != 33 ? 1016 : 760;
}
// Function: PpiGetBist @ 0xffe38c36 (0x7b bytes)
// Index: 138/163
int __fastcall PpiGetBist(unsigned __int8 *_r_n, int Msr64)
{
unsigned __int8 *_r_n_1; // ebp
int n0xFFFF; // esi
int CpuCount; // eax
unsigned __int16 CpuCount_1; // cx
unsigned __int16 v8; // cx
unsigned __int8 v9; // al
int v10; // ebx
unsigned __int8 v11; // al
unsigned int n0x10; // ebx
int Msr64_1; // [esp+Ch] [ebp-4h]
_r_n_1 = _r_n; /*0xffe38c39*/
n0xFFFF = 0; /*0xffe38c3b*/
if ( !_r_n ) /*0xffe38c42*/
return 0; /*0xffe38c42*/
CpuCount = PpiGetCpuCount(); /*0xffe38c48*/
CpuCount_1 = CpuCount; /*0xffe38c4d*/
if ( !CpuCount ) /*0xffe38c51*/
return 0; /*0xffe38c46*/
if ( !Msr64 ) /*0xffe38c55*/
{
v8 = CpuCount + 5; /*0xffe38c57*/
do /*0xffe38c6b*/
{
v9 = __inbyte(v8); /*0xffe38c5d*/
if ( (v9 & 0x60) == 0x60 ) /*0xffe38c62*/
break; /*0xffe38c62*/
++n0xFFFF; /*0xffe38c64*/
}
while ( n0xFFFF != 0xFFFF ); /*0xffe38c6b*/
return 0; /*0xffe38c6b*/
}
Msr64_1 = Msr64; /*0xffe38c6f*/
LABEL_10:
v10 = 0; /*0xffe38c74*/
while ( 1 ) /*0xffe38c7c*/
{
v11 = __inbyte(CpuCount_1 + 5); /*0xffe38c7c*/
if ( (v11 & 0x40) != 0 ) /*0xffe38c7f*/
break; /*0xffe38c7f*/
if ( ++v10 == 0xFFFF ) /*0xffe38c88*/
return 0; /*0xffe38c8c*/
}
n0x10 = 0; /*0xffe38c8e*/
while ( Msr64 ) /*0xffe38c92*/
{
__outbyte(CpuCount_1, *_r_n_1); /*0xffe38c9a*/
++n0x10; /*0xffe38c9b*/
--Msr64; /*0xffe38c9c*/
++_r_n_1; /*0xffe38c9d*/
if ( n0x10 >= 0x10 ) /*0xffe38ca1*/
{
if ( Msr64 ) /*0xffe38ca5*/
goto LABEL_10; /*0xffe38ca5*/
return Msr64_1; /*0xffe38ca5*/
}
}
return Msr64_1; /*0xffe38cac*/
}
// Function: SpinLockInit @ 0xffe38cb1 (0x2c bytes)
// Index: 139/163
_DWORD *__thiscall SpinLockInit(_DWORD *this)
{
int Service; // eax
if ( !this ) /*0xffe38cb6*/
{
Service = DebugPrintGetService(); /*0xffe38cb8*/
if ( Service ) /*0xffe38cbf*/
(*(void (__cdecl **)(const char *, int, const char *))(Service + 4))( /*0xffe38ccd*/
"e:\\hs\\MdePkg\\Library\\BaseSynchronizationLib\\SynchronizationMsc.c",
75,
"SpinLock != ((void *) 0)");
}
*this = 1; /*0xffe38cd3*/
return this; /*0xffe38cdb*/
}
// Function: AsmExchangeWithSpinlock @ 0xffe38cdd (0x157 bytes)
// Index: 140/163
_DWORD *__thiscall AsmExchangeWithSpinlock(_DWORD *this)
{
unsigned __int64 v2; // kr08_8
int v3; // edx
__int64 v4; // rcx
unsigned int v5; // edx
unsigned __int64 v6; // kr10_8
bool v7; // al
int v8; // edx
unsigned int v9; // edi
unsigned int v10; // kr00_4
unsigned __int64 v11; // kr30_8
int Service; // eax
int v14; // [esp+10h] [ebp-30h]
__int64 v15; // [esp+14h] [ebp-2Ch]
unsigned int v16; // [esp+1Ch] [ebp-24h]
int v17; // [esp+20h] [ebp-20h]
unsigned __int64 v18; // [esp+24h] [ebp-1Ch]
int v19; // [esp+28h] [ebp-18h]
unsigned __int64 v20; // [esp+30h] [ebp-10h] BYREF
unsigned __int64 v21; // [esp+38h] [ebp-8h] BYREF
if ( !ApStateCheck(this) ) /*0xffe38cec*/
{
v2 = __rdtsc(); /*0xffe38d03*/
v20 = 0; /*0xffe38d09*/
v21 = 0; /*0xffe38d11*/
v15 = 0; /*0xffe38d19*/
v19 = ProcedureScope(&v20, &v21); /*0xffe38d26*/
v17 = BitFieldRead64(10000000 * v19, 10000000 * v3 + ((10000000 * (unsigned __int64)(unsigned int)v19) >> 32)); /*0xffe38d4b*/
HIDWORD(v4) = (v21 - v20) >> 32; /*0xffe38d53*/
v16 = v5; /*0xffe38d5c*/
v14 = v21 - v20; /*0xffe38d60*/
if ( v4 < 0 ) /*0xffe38d67*/
{
v6 = v20 - v21; /*0xffe38d71*/
HIDWORD(v4) = HIDWORD(v6); /*0xffe38d71*/
v14 = v6; /*0xffe38d71*/
}
v7 = ApStateCheck(this); /*0xffe38d7c*/
while ( !v7 ) /*0xffe38e24*/
{
_mm_pause(); /*0xffe38d86*/
v18 = __rdtsc(); /*0xffe38d96*/
v8 = (v18 - v2) >> 32; /*0xffe38d94*/
v9 = v18 - v2; /*0xffe38d94*/
if ( v20 > v21 ) /*0xffe38db0*/
{
v9 = v2 - v18; /*0xffe38db2*/
v8 = (unsigned __int64)-__SPAIR64__(v8, (int)v2 - (int)v18) >> 32; /*0xffe38db7*/
}
if ( v8 < 0 ) /*0xffe38dbb*/
{
LODWORD(v4) = v14; /*0xffe38dc3*/
v8 = (v4 + 1 + __PAIR64__(v8, v9)) >> 32; /*0xffe38dd1*/
v9 += v14 + 1; /*0xffe38dd1*/
}
v10 = v15; /*0xffe38ddb*/
LODWORD(v15) = v9 + v15; /*0xffe38ddd*/
v11 = __PAIR64__(HIDWORD(v15), v9) + __PAIR64__(v8, v10); /*0xffe38de1*/
HIDWORD(v15) = (__PAIR64__(HIDWORD(v15), v9) + __PAIR64__(v8, v10)) >> 32; /*0xffe38de3*/
if ( v11 >= __PAIR64__(v16, v17) ) /*0xffe38df3*/
{
Service = DebugPrintGetService(); /*0xffe38df5*/
if ( Service ) /*0xffe38dfc*/
(*(void (__cdecl **)(const char *, int, const char *))(Service + 4))( /*0xffe38e0d*/
"e:\\hs\\MdePkg\\Library\\BaseSynchronizationLib\\SynchronizationMsc.c",
165,
"Total < Timeout");
}
v7 = ApStateCheck(this); /*0xffe38e15*/
v2 = v18; /*0xffe38e1e*/
}
}
return this; /*0xffe38e2a*/
}
// Function: ApStateCheck @ 0xffe38e34 (0x70 bytes)
// Index: 141/163
bool __thiscall ApStateCheck(volatile signed __int32 *this)
{
int Service; // eax
int v3; // eax
if ( !this ) /*0xffe38e44*/
{
Service = DebugPrintGetService(); /*0xffe38e46*/
if ( Service ) /*0xffe38e4d*/
(*(void (__cdecl **)(const char *, int, const char *))(Service + 4))( /*0xffe38e5a*/
"e:\\hs\\MdePkg\\Library\\BaseSynchronizationLib\\SynchronizationMsc.c",
197,
"SpinLock != ((void *) 0)");
}
if ( *this != 2 && *this != 1 ) /*0xffe38e6f*/
{
v3 = DebugPrintGetService(); /*0xffe38e71*/
if ( v3 ) /*0xffe38e78*/
(*(void (__cdecl **)(const char *, int, const char *))(v3 + 4))( /*0xffe38e85*/
"e:\\hs\\MdePkg\\Library\\BaseSynchronizationLib\\SynchronizationMsc.c",
200,
"LockValue == ((UINTN) 2) || LockValue == ((UINTN) 1)");
}
return InternalSyncDecrement(this, 1, 2) == 1; /*0xffe38e9b*/
}
// Function: ApExchangeFunction @ 0xffe38ea4 (0x64 bytes)
// Index: 142/163
_DWORD *__thiscall ApExchangeFunction(_DWORD *this)
{
int Service; // eax
int v3; // eax
if ( !this ) /*0xffe38eb3*/
{
Service = DebugPrintGetService(); /*0xffe38eb5*/
if ( Service ) /*0xffe38ebc*/
(*(void (__cdecl **)(const char *, int, const char *))(Service + 4))( /*0xffe38ec9*/
"e:\\hs\\MdePkg\\Library\\BaseSynchronizationLib\\SynchronizationMsc.c",
235,
"SpinLock != ((void *) 0)");
}
if ( *this != 2 && *this != 1 ) /*0xffe38ede*/
{
v3 = DebugPrintGetService(); /*0xffe38ee0*/
if ( v3 ) /*0xffe38ee7*/
(*(void (__cdecl **)(const char *, int, const char *))(v3 + 4))( /*0xffe38ef4*/
"e:\\hs\\MdePkg\\Library\\BaseSynchronizationLib\\SynchronizationMsc.c",
238,
"LockValue == ((UINTN) 2) || LockValue == ((UINTN) 1)");
}
*this = 1; /*0xffe38efa*/
return this; /*0xffe38f02*/
}
// Function: InternalSyncCompareExchange32 @ 0xffe38f08 (0x30 bytes)
// Index: 143/163
signed __int32 __thiscall InternalSyncCompareExchange32(volatile signed __int32 *this)
{
int Service; // eax
if ( !this ) /*0xffe38f0e*/
{
Service = DebugPrintGetService(); /*0xffe38f10*/
if ( Service ) /*0xffe38f17*/
(*(void (__cdecl **)(const char *, int, const char *))(Service + 4))( /*0xffe38f28*/
"e:\\hs\\MdePkg\\Library\\BaseSynchronizationLib\\SynchronizationMsc.c",
268,
"Value != ((void *) 0)");
}
_InterlockedIncrement(this); /*0xffe38f31*/
return *this; /*0xffe38f37*/
}
// Function: InternalSyncDecrement @ 0xffe38f38 (0x3e bytes)
// Index: 144/163
signed __int32 __fastcall InternalSyncDecrement(volatile signed __int32 *i, signed __int32 n1346458707, int n2)
{
int Service; // eax
if ( !i ) /*0xffe38f45*/
{
Service = DebugPrintGetService(); /*0xffe38f47*/
if ( Service ) /*0xffe38f4e*/
(*(void (__cdecl **)(const char *, int, const char *))(Service + 4))( /*0xffe38f5f*/
"e:\\hs\\MdePkg\\Library\\BaseSynchronizationLib\\SynchronizationMsc.c",
355,
"Value != ((void *) 0)");
}
return _InterlockedCompareExchange(i, n2, n1346458707); /*0xffe38f72*/
}
// Function: InternalSyncExchange @ 0xffe38f76 (0x33 bytes)
// Index: 145/163
int InternalSyncExchange()
{
unsigned __int64 n0x20; // rax
int n0x20_1; // esi
int Service; // eax
n0x20 = __readmsr(0xFEu); /*0xffe38f7e*/
n0x20_1 = (unsigned __int8)n0x20; /*0xffe38f80*/
if ( (unsigned __int8)n0x20 > 0x20u ) /*0xffe38f86*/
{
Service = DebugPrintGetService(); /*0xffe38f88*/
if ( Service ) /*0xffe38f8f*/
(*(void (__cdecl **)(const char *, int, const char *))(Service + 4))( /*0xffe38f9d*/
"e:\\hs\\PurleySktPkg\\Override\\UefiCpuPkg\\Library\\MtrrLib\\MtrrLib.c",
126,
"VariableMtrrCount <= 32");
}
return n0x20_1; /*0xffe38fa5*/
}
// Function: InternalSyncExchange8 @ 0xffe38fa9 (0x15 bytes)
// Index: 146/163
unsigned int InternalSyncExchange8()
{
unsigned int v0; // eax
v0 = InternalSyncExchange(); /*0xffe38fa9*/
if ( v0 >= dword_FFE3B964 ) /*0xffe38fb6*/
return v0 - dword_FFE3B964; /*0xffe38fbb*/
else
return 0; /*0xffe38fb8*/
}
// Function: InternalSyncAnd @ 0xffe38fbe (0x53 bytes)
// Index: 147/163
int __thiscall InternalSyncAnd(_BYTE *this)
{
__int16 v1; // kr00_2
unsigned __int32 v2; // eax
unsigned __int32 v3; // eax
unsigned __int32 v4; // eax
v1 = __readeflags(); /*0xffe38fc8*/
_disable(); /*0xffe38fca*/
*(this + 4) = (v1 & 0x200) != 0; /*0xffe38fd0*/
v2 = __readcr0(); /*0xffe38fd3*/
__writecr0(v2 & 0x9FFFFFFF | 0x40000000); /*0xffe38fde*/
__wbinvd(); /*0xffe38fe1*/
v3 = __readcr4(); /*0xffe38fe3*/
*(_DWORD *)this = v3; /*0xffe38fe9*/
__writecr4(v3 & 0xFFFFFF7F); /*0xffe38ff6*/
v4 = __readcr3(); /*0xffe38ff9*/
__writecr3(v4); /*0xffe38ffc*/
return UnalignedWrite24(); /*0xffe3900a*/
}
// Function: WriteRegister @ 0xffe39011 (0x40 bytes)
// Index: 148/163
int __thiscall WriteRegister(int this)
{
unsigned __int32 v1; // eax
unsigned __int32 v2; // eax
int this_1; // eax
v1 = __readcr3(); /*0xffe3901c*/
__writecr3(v1); /*0xffe3901f*/
__wbinvd(); /*0xffe39022*/
v2 = __readcr0(); /*0xffe39024*/
__writecr0(v2 & 0x9FFFFFFF); /*0xffe3902f*/
__writecr4(*(_DWORD *)this); /*0xffe3903a*/
this_1 = this; /*0xffe3903d*/
if ( *(_BYTE *)(this + 4) ) /*0xffe39040*/
_enable(); /*0xffe39046*/
else
_disable(); /*0xffe39049*/
return this_1; /*0xffe3904a*/
}
// Function: ReadTimeStampCounter @ 0xffe39051 (0x34 bytes)
// Index: 149/163
_QWORD *__thiscall ReadTimeStampCounter(_QWORD *this)
{
unsigned int n33; // ebx
_QWORD *this_1; // edi
unsigned __int64 v3; // rax
n33 = 0; /*0xffe39056*/
this_1 = this; /*0xffe39059*/
do /*0xffe3907c*/
{
v3 = __readmsr(dword_FFE3B634[n33]); /*0xffe39069*/
n33 += 3; /*0xffe3906b*/
*this_1++ = v3; /*0xffe3906e*/
}
while ( n33 < 33 ); /*0xffe3907c*/
return this; /*0xffe3907e*/
}
// Function: MtrrGetMemoryAttribute @ 0xffe39085 (0xa0 bytes)
// Index: 150/163
_DWORD *__fastcall MtrrGetMemoryAttribute(int a1, unsigned int n0x20, _DWORD *a3)
{
unsigned int n0x20_1; // ebx
int v4; // eax
int Service; // eax
_DWORD *v6; // esi
unsigned int n513; // ebp
_DWORD *v8; // edi
n0x20_1 = n0x20; /*0xffe39088*/
v4 = a1; /*0xffe3908a*/
if ( n0x20 > 0x20 ) /*0xffe39093*/
{
Service = DebugPrintGetService(); /*0xffe39095*/
if ( Service ) /*0xffe3909c*/
(*(void (__cdecl **)(const char *, int, const char *))(Service + 4))( /*0xffe390ad*/
"e:\\hs\\PurleySktPkg\\Override\\UefiCpuPkg\\Library\\MtrrLib\\MtrrLib.c",
399,
"VariableMtrrCount <= 32");
v4 = a1; /*0xffe390b3*/
}
if ( n0x20_1 ) /*0xffe390b9*/
{
v6 = a3; /*0xffe390bd*/
n513 = 513; /*0xffe390c1*/
v8 = (_DWORD *)(v4 + 96); /*0xffe390c7*/
do /*0xffe39118*/
{
if ( v4 ) /*0xffe390cc*/
{
*v6 = *(v8 - 2); /*0xffe390f5*/
v6[1] = *(v8 - 1); /*0xffe390fa*/
v6[2] = *v8; /*0xffe390ff*/
v6[3] = v8[1]; /*0xffe39105*/
}
else
{
*(_QWORD *)v6 = __readmsr(n513 - 1); /*0xffe390db*/
*((_QWORD *)v6 + 1) = __readmsr(n513); /*0xffe390ea*/
}
v4 = a1; /*0xffe39108*/
n513 += 2; /*0xffe3910c*/
v8 += 4; /*0xffe3910f*/
v6 += 4; /*0xffe39112*/
--n0x20_1; /*0xffe39115*/
}
while ( n0x20_1 ); /*0xffe39118*/
}
return a3; /*0xffe39121*/
}
// Function: MtrrSetMemoryAttribute @ 0xffe39125 (0x96 bytes)
// Index: 151/163
int __fastcall MtrrSetMemoryAttribute(unsigned __int8 *a1, unsigned int a2, __int64 a3, __int64 a4, int buf)
{
int v6; // ebx
unsigned int v7; // edi
int v8; // edx
int v9; // eax
int v10; // eax
AllocateZeroPool(buf, 0x400u); /*0xffe3913b*/
v6 = 0; /*0xffe39140*/
v7 = 0; /*0xffe39142*/
if ( a2 ) /*0xffe39148*/
{
v8 = buf + 8; /*0xffe3914a*/
do /*0xffe391b1*/
{
if ( (*((_DWORD *)a1 + 2) & 0x800) != 0 ) /*0xffe39158*/
{
*(_DWORD *)(v8 + 16) = v7; /*0xffe3915a*/
v9 = HIDWORD(a4) & *((_DWORD *)a1 + 1); /*0xffe39162*/
*(_DWORD *)(v8 - 8) = a4 & *(_DWORD *)a1; /*0xffe3916a*/
*(_DWORD *)(v8 - 4) = v9; /*0xffe3916d*/
*(_QWORD *)v8 = (a3 & ~(a4 & *((_QWORD *)a1 + 1))) + 1; /*0xffe3918d*/
v10 = *a1; /*0xffe39195*/
*(_DWORD *)(v8 + 12) = 0; /*0xffe39198*/
++v6; /*0xffe3919c*/
*(_DWORD *)(v8 + 8) = v10; /*0xffe3919d*/
*(_WORD *)(v8 + 20) = 257; /*0xffe391a0*/
}
++v7; /*0xffe391a6*/
a1 += 16; /*0xffe391a7*/
v8 += 32; /*0xffe391aa*/
}
while ( v7 < a2 ); /*0xffe391b1*/
}
return v6; /*0xffe391b3*/
}
// Function: MtrrValidate @ 0xffe391bb (0x58 bytes)
// Index: 152/163
int __cdecl MtrrValidate(unsigned int n6, int a2)
{
int v2; // ecx
int n6_1; // eax
unsigned __int64 v4; // rax
if ( !a2 ) /*0xffe391c2*/
{
n6_1 = 6; /*0xffe391c9*/
if ( n6 <= 6 ) /*0xffe391ce*/
{
switch ( n6 ) /*0xffe391d3*/
{
case 0u: /*0xffe391d3*/
return 0; /*0xffe39207*/
case 1u: /*0xffe391d3*/
return 1; /*0xffe39203*/
case 4u: /*0xffe391d3*/
return 4; /*0xffe391fa*/
}
if ( n6 != 5 ) /*0xffe391e2*/
{
if ( n6 == 6 ) /*0xffe391e7*/
return n6_1; /*0xffe391e7*/
goto LABEL_8; /*0xffe391e7*/
}
return 5; /*0xffe391fe*/
}
}
LABEL_8:
if ( v2 ) /*0xffe391eb*/
LODWORD(v4) = *(_DWORD *)(v2 + 600); /*0xffe39208*/
else
v4 = __readmsr(0x2FFu); /*0xffe391f2*/
return v4 & 7; /*0xffe391fd*/
}
// Function: MtrrGetVariableSettings @ 0xffe39213 (0x78 bytes)
// Index: 153/163
int __fastcall MtrrGetVariableSettings(_DWORD *a1, _DWORD *a2)
{
__int64 v4; // rax
int v5; // ecx
int n15; // eax
unsigned int v7; // [esp+Ch] [ebp-4h] BYREF
BitFieldFieldType(0x80000000, &v7, 0, 0, 0); /*0xffe3922b*/
if ( v7 < 0x80000008 ) /*0xffe3923b*/
{
*a1 = -1; /*0xffe39272*/
n15 = 15; /*0xffe39277*/
a1[1] = 15; /*0xffe39278*/
*a2 = -4096; /*0xffe3927b*/
}
else
{
BitFieldFieldType(-2147483640, &v7, 0, 0, 0); /*0xffe39243*/
v4 = BitFieldOr64(1) - 1; /*0xffe39257*/
*(_QWORD *)a1 = v4; /*0xffe3925f*/
v5 = v4 & 0xFFFFF000; /*0xffe39266*/
n15 = HIDWORD(v4); /*0xffe3926c*/
*a2 = v5; /*0xffe3926e*/
}
a2[1] = n15; /*0xffe39281*/
return n15; /*0xffe39284*/
}
// Function: MtrrFixCalculateMtrr @ 0xffe3928b (0xb1 bytes)
// Index: 154/163
int __cdecl MtrrFixCalculateMtrr(unsigned __int64 n7, __int64 n6)
{
int n7_1; // esi
bool v3; // zf
bool v4; // zf
n7_1 = 7; /*0xffe3929a*/
if ( n7 <= 7 ) /*0xffe392a9*/
{
if ( (_DWORD)n7 ) /*0xffe392b1*/
{
if ( (_DWORD)n7 == 1 ) /*0xffe392b6*/
{
v4 = (_DWORD)n6 == 1; /*0xffe3930c*/
goto LABEL_19; /*0xffe3930c*/
}
if ( (_DWORD)n7 != 4 ) /*0xffe392bb*/
{
if ( (_DWORD)n7 != 5 ) /*0xffe392c0*/
{
if ( (_DWORD)n7 != 6 ) /*0xffe392c5*/
{
v3 = (_DWORD)n7 == 7; /*0xffe392c7*/
goto LABEL_22; /*0xffe392ca*/
}
if ( n6 && n6 != 4 ) /*0xffe392d5*/
{
if ( (_DWORD)n6 != 6 ) /*0xffe392de*/
goto LABEL_25; /*0xffe392de*/
v3 = HIDWORD(n6) == 0; /*0xffe392e0*/
LABEL_22:
if ( !v3 ) /*0xffe39319*/
goto LABEL_25; /*0xffe39319*/
goto LABEL_23; /*0xffe39319*/
}
goto LABEL_23; /*0xffe392d5*/
}
v4 = (_DWORD)n6 == 5; /*0xffe392e4*/
LABEL_19:
if ( !v4 || HIDWORD(n6) ) /*0xffe39313*/
{
v3 = n6 == 0; /*0xffe39317*/
goto LABEL_22; /*0xffe39317*/
}
LABEL_23:
n7_1 = n6; /*0xffe3931b*/
goto LABEL_25; /*0xffe3931f*/
}
if ( n6 == 4 || n6 == 6 ) /*0xffe392f5*/
{
n7_1 = 4; /*0xffe392fd*/
}
else if ( !n6 ) /*0xffe39304*/
{
return 0; /*0xffe3930a*/
}
}
else
{
n7_1 = 0; /*0xffe39321*/
}
}
LABEL_25:
if ( n6 == 7 ) /*0xffe39328*/
return n7; /*0xffe39331*/
return n7_1; /*0xffe39338*/
}
// Function: MtrrSetAllAttributes @ 0xffe3933c (0x206 bytes)
// Index: 155/163
int __cdecl MtrrSetAllAttributes(unsigned __int64 n0x100000)
{
int v1; // ecx
int v2; // edi
unsigned __int64 v3; // rax
unsigned __int64 n7; // rdi
int v5; // ecx
unsigned int n33; // edx
unsigned int n0x100000_1; // ebx
unsigned int n0x20; // eax
unsigned int v9; // eax
unsigned int n0x20_1; // ebx
int Service; // eax
int v12; // eax
int *buf_1; // ebx
int v14; // edx
unsigned __int64 v15; // rax
unsigned __int8 n6_1; // al
__int64 v18; // [esp-14h] [ebp-648h]
__int64 v19; // [esp-Ch] [ebp-640h]
__int64 v20; // [esp+10h] [ebp-624h] BYREF
unsigned int n6; // [esp+1Ch] [ebp-618h]
__int64 v22; // [esp+20h] [ebp-614h] BYREF
int v23; // [esp+2Ch] [ebp-608h]
unsigned __int8 v24[512]; // [esp+30h] [ebp-604h] BYREF
int buf[257]; // [esp+230h] [ebp-404h] BYREF
v2 = v1; /*0xffe39346*/
v23 = v1; /*0xffe39348*/
if ( v1 ) /*0xffe3934e*/
{
HIDWORD(v3) = *(_DWORD *)(v1 + 600); /*0xffe39365*/
HIDWORD(v22) = *(_DWORD *)(v1 + 604); /*0xffe3936b*/
}
else
{
v3 = __readmsr(0x2FFu); /*0xffe39355*/
HIDWORD(v22) = HIDWORD(v3); /*0xffe39357*/
WORD2(v3) = v3; /*0xffe3935b*/
}
n6 = 7; /*0xffe39371*/
HIDWORD(n7) = 0; /*0xffe39379*/
LODWORD(v3) = WORD2(v3) & 0x800; /*0xffe39380*/
if ( (v3 & 0x80000000000LL) != 0 ) /*0xffe39382*/
{
if ( n0x100000 < 0x100000 && (v3 & 0x40000000000LL) != 0 ) /*0xffe393aa*/
{
v5 = 0; /*0xffe393ac*/
n33 = 0; /*0xffe393ae*/
while ( 1 ) /*0xffe393b0*/
{
n0x100000_1 = dword_FFE3B638[n33]; /*0xffe393b0*/
if ( (unsigned int)n0x100000 >= n0x100000_1 && (unsigned int)n0x100000 < n0x100000_1 + 8 * dword_FFE3B63C[n33] ) /*0xffe393df*/
break; /*0xffe393df*/
n33 += 3; /*0xffe393e5*/
++v5; /*0xffe393e8*/
if ( n33 >= 33 ) /*0xffe393ef*/
goto LABEL_11; /*0xffe393ef*/
}
if ( v2 ) /*0xffe39508*/
v15 = *(_QWORD *)(v2 + 8 * v5); /*0xffe3951c*/
else
v15 = __readmsr(dword_FFE3B634[3 * v5]); /*0xffe39518*/
n6_1 = BitFieldAnd64(v15); /*0xffe3952a*/
LODWORD(v3) = MtrrValidate(n6_1, 0); /*0xffe39538*/
}
else
{
LABEL_11:
MtrrGetVariableSettings(&v22, &v20); /*0xffe393f1*/
n0x20 = InternalSyncExchange(); /*0xffe39403*/
MtrrGetMemoryAttribute(v2, n0x20, v24); /*0xffe3940c*/
v19 = v20; /*0xffe3941e*/
v18 = v22; /*0xffe39426*/
v9 = InternalSyncExchange8(); /*0xffe3942a*/
MtrrSetMemoryAttribute(v24, v9, v18, v19, (int)buf); /*0xffe39435*/
n0x20_1 = InternalSyncExchange(); /*0xffe39442*/
LODWORD(v20) = n0x20_1; /*0xffe39444*/
if ( n0x20_1 > 0x20 ) /*0xffe3944b*/
{
Service = DebugPrintGetService(); /*0xffe3944d*/
if ( Service ) /*0xffe39454*/
(*(void (__cdecl **)(const char *, int, const char *))(Service + 4))( /*0xffe39465*/
"e:\\hs\\PurleySktPkg\\Override\\UefiCpuPkg\\Library\\MtrrLib\\MtrrLib.c",
1317,
"VariableMtrrCount <= 32");
}
if ( n0x20_1 ) /*0xffe3946d*/
{
v12 = v20; /*0xffe3946f*/
buf_1 = buf; /*0xffe39473*/
LODWORD(n7) = 7; /*0xffe3947c*/
do /*0xffe394ce*/
{
if ( *((_BYTE *)buf_1 + 28) ) /*0xffe3947d*/
{
if ( n0x100000 >= *(_QWORD *)buf_1 && n0x100000 < *((_QWORD *)buf_1 + 1) + *(_QWORD *)buf_1 ) /*0xffe394aa*/
{
LODWORD(n7) = MtrrFixCalculateMtrr(n7, *((_QWORD *)buf_1 + 2)); /*0xffe394bc*/
HIDWORD(n7) = v14; /*0xffe394be*/
}
v12 = v20; /*0xffe394c0*/
}
buf_1 += 8; /*0xffe394c4*/
LODWORD(v20) = --v12; /*0xffe394ca*/
}
while ( v12 ); /*0xffe394ce*/
n6 = n7; /*0xffe394d0*/
}
LODWORD(v3) = MtrrValidate(n6, SHIDWORD(n7)); /*0xffe394df*/
}
}
return v3; /*0xffe394e6*/
}
// Function: MtrrSetAttribute @ 0xffe39542 (0x4af bytes)
// Index: 156/163
char MtrrSetAttribute()
{
char result; // al
unsigned int n0xB; // esi
unsigned int v2; // ebx
unsigned int v3; // edi
char *v4; // esi
unsigned int *v5; // eax
int *v6; // ebp
unsigned int v7; // ecx
unsigned int v8; // edi
unsigned int v9; // edx
unsigned int v10; // esi
unsigned int n7_1; // ebx
unsigned int v12; // kr00_4
bool v13; // zf
int v14; // ebp
__int64 v15; // kr08_8
unsigned __int64 n0x100000; // kr28_8
unsigned int n7_3; // ebx
int n15_1; // ebx
unsigned int n15_2; // edx
unsigned int v20; // ecx
_DWORD *v21; // eax
int v22; // ebx
__int64 v23; // rcx
__int64 v24; // rax
unsigned __int64 n0x100000_3; // kr10_8
int v26; // edx
unsigned __int64 n0x100000_5; // kr20_8
double v28; // [esp-Ch] [ebp-2C0h]
double v29; // [esp-Ch] [ebp-2C0h]
char v30; // [esp+17h] [ebp-29Dh]
int n11; // [esp+18h] [ebp-29Ch]
unsigned int n15_3; // [esp+18h] [ebp-29Ch]
int *v33; // [esp+1Ch] [ebp-298h]
int n15; // [esp+1Ch] [ebp... [9439 chars total]
// Function: BitFieldMsr @ 0xffe399f1 (0x86 bytes)
// Index: 157/163
int __thiscall BitFieldMsr(unsigned __int64 *this)
{
unsigned __int64 n0x20; // rax
int n0x20_1; // esi
unsigned int n513; // ebx
LODWORD(n0x20) = InternalSyncExchange(); /*0xffe399fc*/
n0x20_1 = n0x20; /*0xffe39a01*/
if ( (unsigned int)n0x20 > 0x20 ) /*0xffe39a06*/
{
LODWORD(n0x20) = DebugPrintGetService(); /*0xffe39a08*/
if ( (_DWORD)n0x20 ) /*0xffe39a0f*/
LODWORD(n0x20) = (*(int (__cdecl **)(const char *, int, const char *))(n0x20 + 4))( /*0xffe39a20*/
"e:\\hs\\PurleySktPkg\\Override\\UefiCpuPkg\\Library\\MtrrLib\\MtrrLib.c",
2042,
"VariableMtrrCount <= 32");
}
if ( n0x20_1 ) /*0xffe39a28*/
{
n513 = 513; /*0xffe39a2a*/
do /*0xffe39a6e*/
{
__writemsr(n513 - 1, *this); /*0xffe39a49*/
n0x20 = *(this + 1); /*0xffe39a5d*/
__writemsr(n513, n0x20); /*0xffe39a63*/
n513 += 2; /*0xffe39a65*/
this += 2; /*0xffe39a68*/
--n0x20_1; /*0xffe39a6b*/
}
while ( n0x20_1 ); /*0xffe39a6e*/
}
return n0x20; /*0xffe39a70*/
}
// Function: MtrrGetMemoryAttributeInVariableMtrr @ 0xffe39a77 (0x3f bytes)
// Index: 158/163
unsigned __int64 __thiscall MtrrGetMemoryAttributeInVariableMtrr(unsigned __int64 *this)
{
unsigned int i; // edi
unsigned __int64 result; // rax
for ( i = 0; i < 33; i += 3 ) /*0xffe39a81*/
{
result = *this; /*0xffe39a9a*/
__writemsr(dword_FFE3B634[i], *this++); /*0xffe39aa0*/
}
return result; /*0xffe39ab0*/
}
// Function: EnableDisableLmce @ 0xffe39ab6 (0x3d bytes)
// Index: 159/163
int __thiscall EnableDisableLmce(int this)
{
unsigned int n0x20; // eax
if ( MtrrPrefetchCheck() ) /*0xffe39ab9*/
{
ReadTimeStampCounter((_QWORD *)this); /*0xffe39ac4*/
n0x20 = InternalSyncExchange(); /*0xffe39acd*/
MtrrGetMemoryAttribute(0, n0x20, (_DWORD *)(this + 88)); /*0xffe39ad6*/
*(_QWORD *)(this + 600) = __readmsr(0x2FFu); /*0xffe39ae3*/
}
return this; /*0xffe39af1*/
}
// Function: MtrrPrefetchCheck @ 0xffe39af3 (0x68 bytes)
// Index: 160/163
bool MtrrPrefetchCheck()
{
__int64 v0; // rax
unsigned int v1; // edi
unsigned int v2; // esi
bool result; // al
int v4; // [esp+Ch] [ebp-4h] BYREF
BitFieldFieldType(1, 0, 0, 0, &v4); /*0xffe39b07*/
result = 0; /*0xffe39b4f*/
if ( UnalignedRead32(v4, 0xCu, 0xCu) ) /*0xffe39b16*/
{
v0 = __readmsr(0xFEu); /*0xffe39b25*/
v1 = HIDWORD(v0); /*0xffe39b27*/
v2 = v0; /*0xffe39b2b*/
if ( UnalignedRead64(0, 7u, v0) ) /*0xffe39b32*/
{
if ( UnalignedRead64(8u, 8u, __SPAIR64__(v1, v2)) ) /*0xffe39b44*/
return 1; /*0xffe39b1e*/
}
}
return result; /*0xffe39b55*/
}
// Function: GetModuleParameter @ 0xffe39b5b (0xc bytes)
// Index: 161/163
// (too small: 0xc bytes)
// Function: ReadModuleConfig @ 0xffe39b67 (0x30 bytes)
// Index: 162/163
char __thiscall ReadModuleConfig(unsigned int n1024068)
{
int Service; // eax
if ( (n1024068 & 0xF0000000) != 0 ) /*0xffe39b70*/
{
Service = DebugPrintGetService(); /*0xffe39b72*/
if ( Service ) /*0xffe39b79*/
(*(void (__cdecl **)(const char *, int, const char *))(Service + 4))( /*0xffe39b87*/
"e:\\hs\\MdePkg\\Library\\BasePciExpressLib\\PciExpressLib.c",
109,
"((Address) & ~0xfffffff) == 0");
}
return *(_BYTE *)(GetModuleParameter((void *)n1024068) + n1024068); /*0xffe39b95*/
}
// Function: WriteModuleConfig @ 0xffe39b97 (0x16 bytes)
// Index: 163/163
__int16 __thiscall WriteModuleConfig(void *this)
{
int v1; // eax
v1 = GetModuleParameter(this); /*0xffe39b97*/
return SetJump((_WORD *)(v1 + 1024064), 1280);
}