/*
*SmbiosPeim.c
*SmbiosPeim PEI module decompiled from IDA
*/
#include "SmbiosPeim.h"
// SetMem @ 0xffe09190 void *SetMem(void *buf, unsigned int count, char value)
{
memset(buf, value, count); /*0xffe0919d*/
return buf; /*0xffe091a3*/
}
// InternalMemSetMem32 @ 0xffe091b0 int InternalMemSetMem32(int a1, int a2, int a3, int a4)
{
do /*0xffe091c9*/
{
*(_DWORD *)(a1 + 8 *a2 - 8) = a3; /*0xffe091c1*/
*(_DWORD *)(a1 + 8 *a2-- - 4) = a4; /*0xffe091c5*/
}
while ( a2 ); /*0xffe091c9*/
return a1; /*0xffe091cd*/
}
// SetMem32 @ 0xffe091d0 void *SetMem32(void *buf, unsigned int count, int value)
{
memset32(buf, value, count); /*0xffe091dd*/
return buf; /*0xffe091e3*/
}
// CopyMem @ 0xffe091f0 char *CopyMem(char *dst, char *src, unsigned int count)
{
unsigned int count_1; // edx char *dst_1; // edi char *src_1; // esi count_1 = count; /*0xffe091fa*/
if ( src < dst && &src[count - 1] >= dst ) /*0xffe09208*/
{
src_1 = &src[count - 1]; /*0xffe0921c*/
dst_1 = &dst[count - 1]; /*0xffe0921e*/
}
else
{
count_1 = count & 3; /*0xffe0920c*/
qmemcpy(dst, src, 4 * (count >> 2)); /*0xffe09215*/
src_1 = &src[4 * (count >> 2)]; /*0xffe09215*/
dst_1 = &dst[4 * (count >> 2)]; /*0xffe09215*/
}
qmemcpy(dst_1, src_1, count_1); /*0xffe09225*/
return dst; /*0xffe0922c*/
}
// _ModuleEntryPoint @ 0xffe09250 EFI_STATUS ModuleEntryPoint(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
{
int BootMode; // esi int RestoreStatus; // eax EFI_SYSTEM_TABLE *EnablePam; // ecx void *PcdArg; // ecx int ( **PcdFunc)(int); // eax char PcdValue; // al EFI_SYSTEM_TABLE *SystemTable_1; // ecx int ( **PcdTable)(int); // eax int BootModeArg; // [esp-4h] [ebp-18h]
void *PpiList[3]; // [esp+0h] [ebp-14h] BYREF void *BootModeVal; // [esp+14h] [ebp+0h]
unsigned int SystemTableHi; // [esp+20h] [ebp+Ch]
if ( (*(int (__stdcall **)(EFI_SYSTEM_TABLE *, void **, int, int))(LODWORD(SystemTable->Hdr.Signature) + 40))( /*0xffe09272*/
SystemTable,
PpiList,
BootMode,
BootModeArg) < 0 )
DebugPrint(0x80000000, (int)"Failed to get BootMode\n"); /*0xffe0927e*/
if ( BootModeVal == (void *)17 ) /*0xffe0928a*/
{
ImageHandle = (EFI_HANDLE)8; /*0xffe09293*/
RestoreStatus = RestoreLockBox((char *)&SystemTable, &ImageHandle); /*0xffe0929c*/
EnablePam = (EFI_SYSTEM_TABLE *)PpiList[2]; /*0xffe092a1*/
if ( !RestoreStatus ) /*0xffe092a4*/
{
if ( __PAIR64__(SystemTableHi, (unsigned int)SystemTable) > 0xF0000 ) /*0xffe092b4*/
{
PcdTable = (int ( **)(int))PcdGetPtr(PpiList[2]); /*0xffe092d6*/
LOBYTE(SystemTable->Hdr.Signature) = PcdTable[1](8); /*0xffe092e4*/
}
else
{
LOBYTE(EnablePam) = 1; /*0xffe092b6*/
ConfigurePamRegisters(EnablePam); /*0xffe092b8*/
PcdFunc = (int ( **)(int))PcdGetPtr(PcdArg); /*0xffe092bd*/
PcdValue = PcdFunc[1](8); /*0xffe092c3*/
SystemTable_1 = SystemTable; /*0xffe092c7*/
LOBYTE(SystemTable->Hdr.Signature) = PcdValue; /*0xffe092cb*/
LOBYTE(SystemTable_1) = 0; /*0xffe092cd*/
ConfigurePamRegisters(SystemTable_1); /*0xffe092cf*/
}
}
}
return 0; /*0xffe092ec*/
}
// GetDebugLibInterface @ 0xffe092ed int GetDebugLibInterface()
{
int v1; // [esp+0h] [ebp-8h] BYREF int p_this; // [esp+4h] [ebp-4h] BYREF if ( PeiLocatePpi((int)&v1, (int)&p_this) >= 0 ) /*0xffe09308*/
return p_this; /*0xffe0930e*/
else return 0; /*0xffe0930a*/
}
// DebugPrint @ 0xffe09315 int DebugPrint(int a1, int a2, ...)
{
int result; // eax int ( **v3)(int, int, char *); // esi va_list va; // [esp+10h] [ebp+Ch] BYREF va_start(va, a2);
result = GetDebugLibInterface(); /*0xffe09316*/
v3 = (int ( **)(int, int, char *))result; /*0xffe0931b*/
if ( result ) /*0xffe0931f*/
{
result = GetBootMode(); /*0xffe09321*/
if ( (result & a1) != 0 ) /*0xffe0932c*/
return (*v3)(a1, a2, (char *)va); /*0xffe09338*/
}
return result; /*0xffe0933d*/
}
// DebugAssert @ 0xffe0933f int DebugAssert(
int e:__hs__MdePkg__Library__PeiServicesTablePointerLibIdt__PeiServ,
int n48,
int PeiServices____((void__)_0))
{
int result; // eax result = GetDebugLibInterface(); /*0xffe09345*/
if ( result ) /*0xffe0934c*/
return (*(int ( **)(int, int, int))(result + 4))( /*0xffe09354*/
e:__hs__MdePkg__Library__PeiServicesTablePointerLibIdt__PeiServ,
n48,
PeiServices____((void__)_0));
return result; /*0xffe0935a*/
}
// PeiLocatePpi @ 0xffe0935d int PeiLocatePpi(int a1, int p_this)
{
int v2; // ecx int v3; // esi int PeiServicesTablePointer; // eax v3 = v2; /*0xffe0935e*/
PeiServicesTablePointer = GetPeiServicesTablePointer(); /*0xffe09360*/
return (*(int ( **)(int, int, _DWORD, int, int))(*(_DWORD *)PeiServicesTablePointer + 32))( /*0xffe09379*/
PeiServicesTablePointer,
v3,
0,
a1,
p_this);
}
// CompareGuid @ 0xffe0937b bool CompareGuid(int this, int _n)
{
__int64 Unaligned64; // rax int Unaligned64_1; // ebp __int64 Unaligned64_3; // rax int Unaligned64_2; // edi __int64 v8; // kr00_8 __int64 v9; // rax int v11; // [esp+10h] [ebp-Ch]
int v12; // [esp+14h] [ebp-8h]
Unaligned64 = ReadUnaligned64((void *)this); /*0xffe09386*/
v12 = HIDWORD(Unaligned64); /*0xffe0938d*/
Unaligned64_1 = Unaligned64; /*0xffe09391*/
Unaligned64_3 = ReadUnaligned64((void *)_n); /*0xffe09393*/
v11 = HIDWORD(Unaligned64_3); /*0xffe0939b*/
Unaligned64_2 = Unaligned64_3; /*0xffe0939f*/
v8 = ReadUnaligned64((void *)(this + 8)); /*0xffe093ad*/
v9 = ReadUnaligned64((void *)(_n + 8)); /*0xffe093af*/
return Unaligned64_1 == Unaligned64_2 && v12 == v11 && v8 == v9; /*0xffe093d2*/
}
// GetSmmLockBoxContext @ 0xffe093da int GetSmmLockBoxContext()
{
_WORD *Hob; // esi int DebugLib; // eax int HobData; // eax int ContextPtr; // esi unsigned int Index; // edi int Smst; // eax int LockBoxList; // ebp int LockBoxEntry; // ebx int DebugLib2; // eax unsigned int Index_1; // [esp+10h] [ebp-4h]
Hob = GetFirstGuidHob(&unk_FFE0A570); /*0xffe093e9*/
if ( !Hob ) /*0xffe093ed*/
{
DebugLib = GetDebugLibInterface(); /*0xffe093ef*/
if ( DebugLib ) /*0xffe093f6*/
(*(void ( **)(const char *, int, const char *))(DebugLib + 4))( /*0xffe09407*/
"e:\\hs\\MdeModulePkg\\Library\\SmmLockBoxLib\\SmmLockBoxPeiLib.c",
217,
"GuidHob != ((void *) 0)");
}
HobData = *((_DWORD *)Hob + 8); /*0xffe0940d*/
ContextPtr = 0; /*0xffe09410*/
Index = 0; /*0xffe09412*/
Smst = *(_DWORD *)(HobData + 90); /*0xffe09414*/
LockBoxList = *(_DWORD *)(Smst + 160); /*0xffe09417*/
Index_1 = *(_DWORD *)(Smst + 152); /*0xffe09423*/
if ( Index_1 ) /*0xffe09429*/
{
LockBoxEntry = *(_DWORD *)(Smst + 160); /*0xffe0942b*/
while ( !CompareGuid(LockBoxEntry, (int)src) ) /*0xffe0943b*/
{
++Index; /*0xffe0943d*/
LockBoxEntry += 24; /*0xffe0943e*/
if ( Index >= Index_1 ) /*0xffe09445*/
goto LABEL_10; /*0xffe09445*/
}
ContextPtr = *(_DWORD *)(24 *Index + LockBoxList + 16); /*0xffe0944c*/
}
LABEL_10:
if ( !ContextPtr ) /*0xffe09452*/
{
DebugLib2 = GetDebugLibInterface(); /*0xffe09454*/
if ( DebugLib2 ) /*0xffe0945b*/
(*(void ( **)(const char *, int, const char *))(DebugLib2 + 4))( /*0xffe0946c*/
"e:\\hs\\MdeModulePkg\\Library\\SmmLockBoxLib\\SmmLockBoxPeiLib.c",
226,
"SmmLockBoxContext != ((void *) 0)");
}
return ContextPtr; /*0xffe09472*/
}
// SmmCommunicationNotifyPpi @ 0xffe0947a int __usercall SmmCommunicationNotifyPpi@<eax>(char *dst@<edx>, unsigned int *p_ImageHandle)
{
int PpiCount; // esi int PeiServices; // eax int Result; // eax _DWORD **ListHead; // ebp _DWORD *ListEntry; // edi _DWORD *SmmEntry; // esi unsigned int BufferSize; // ecx bool IsSmaller; // cf int PpiDescriptor; // [esp-8h] [ebp-20h]
int DbgLib; // [esp+14h] [ebp-4h] BYREF if ( PeiLocatePpi(0, (int)&DbgLib) >= 0 ) /*0xffe09497*/
{
PpiCount = 0; /*0xffe09499*/
do /*0xffe094b2*/
{
PpiDescriptor = DbgLib; /*0xffe0949c*/
PeiServices = GetPeiServicesTablePointer(); /*0xffe094a0*/
Result = (*(int ( **)(int, int, int))DbgLib)(PeiServices, PpiDescriptor, PpiCount++); /*0xffe094aa*/
}
while ( Result >= 0 ); /*0xffe094b2*/
}
ListHead = *(_DWORD ***)(GetSmmLockBoxContext() + 8); /*0xffe094b9*/
for ( ListEntry = *ListHead; ListEntry != ListHead; ListEntry = (_DWORD *)*ListEntry ) /*0xffe094bc*/
{
SmmEntry = ListEntry - 14; /*0xffe094c1*/
if ( CompareGuid((int)(ListEntry - 12), (int)asc_FFE0A5B0) )// "\n" /*0xffe094cc*/
goto LABEL_9; /*0xffe094d3*/
}
SmmEntry = 0; /*0xffe094db*/
LABEL_9:
if ( !SmmEntry ) /*0xffe094df*/
return -2147483634; /*0xffe094e6*/
if ( !dst ) /*0xffe094ea*/
{
if ( (SmmEntry[10] & 1) == 0 ) /*0xffe094f4*/
return -2147483640; /*0xffe094fb*/
dst = (char *)SmmEntry[6]; /*0xffe094fd*/
}
if ( p_ImageHandle ) /*0xffe09506*/
{
BufferSize = SmmEntry[8]; /*0xffe09508*/
IsSmaller = *p_ImageHandle < BufferSize; /*0xffe0950b*/
*p_ImageHandle = BufferSize; /*0xffe0950d*/
if ( IsSmaller ) /*0xffe0950f*/
return -2147483643; /*0xffe09511*/
}
if ( SmmEntry[8] ) /*0xffe09518*/
CopyMemS(dst, (char *)SmmEntry[12], SmmEntry[8]); /*0xffe09526*/
return 0; /*0xffe0952e*/
}
// RestoreLockBox @ 0xffe09535 int __usercall RestoreLockBox@<eax>(char *p_SystemTable@<edx>, EFI_HANDLE *p_ImageHandle)
{
int PpiResult; // eax int Status; // esi int Status_3; // ecx int Status_1; // eax int DebugLib; // eax int BufferSize; // [esp+10h] [ebp-58h] BYREF int DbgLib; // [esp+14h] [ebp-54h] BYREF char ParamHdr[4]; // [esp+18h] [ebp-50h] BYREF int ParamSize; // [esp+1Ch] [ebp-4Ch]
char CommBuffer[16]; // [esp+20h] [ebp-48h] BYREF char dst[8]; // [esp+30h] [ebp-38h] BYREF _DWORD LockBoxParam[2]; // [esp+38h] [ebp-30h] BYREF int Status_2; // [esp+40h] [ebp-28h]
int NotifyFlag; // [esp+44h] [ebp-24h]
char CommBufferHdr[16]; // [esp+48h] [ebp-20h] BYREF char *SavedSystemTable; // [esp+58h] [ebp-10h]
int SavedFlags; // [esp+5Ch] [ebp-Ch]
void *ImageHandle; // [esp+60h] [ebp-8h]
int ResultFlags; // [esp+64h] [ebp-4h]
DebugPrint(64, (int)"SmmLockBoxPeiLib RestoreLockBox - Enter\n"); /*0xffe09545*/
if ( p_SystemTable ) /*0xffe09552*/
{
if ( !p_ImageHandle ) /*0xffe09567*/
return -2147483646; /*0xffe09567*/
}
else if ( p_ImageHandle ) /*0xffe09556*/
{
return -2147483646; /*0xffe09564*/
}
PpiResult = PeiLocatePpi(0, (int)&DbgLib); /*0xffe09576*/
if ( PpiResult >= 0 ) /*0xffe0957f*/
{
CopyMemS(CommBuffer, src, 0x10u); /*0xffe095bb*/
*(_DWORD *)ParamHdr = 48; /*0xffe095ca*/
ParamSize = 0; /*0xffe095d2*/
CopyMemS(dst, ParamHdr, 8u); /*0xffe095d6*/
DebugPrint(64, (int)"SmmLockBoxPeiLib CommBuffer - %x\n", CommBuffer); /*0xffe095e8*/
DebugPrint(64, (int)"SmmLockBoxPeiLib LockBoxParameterRestore - %x\n", LockBoxParam); /*0xffe095fc*/
Status_2 = -1; /*0xffe09601*/
NotifyFlag = -1; /*0xffe0960a*/
LockBoxParam[0] = 3; /*0xffe09617*/
LockBoxParam[1] = 48; /*0xffe0961f*/
CopyMemS( /*0xffe09625*/
CommBufferHdr,
asc_FFE0A5B0, // "\n"
0x10u); // "\n"
SavedSystemTable = p_SystemTable; /*0xffe0962a*/
SavedFlags = 0; /*0xffe0962e*/
ResultFlags = 0; /*0xffe09632*/
if ( p_ImageHandle ) /*0xffe09639*/
ImageHandle = *p_ImageHandle; /*0xffe0963d*/
else ImageHandle = 0; /*0xffe09643*/
BufferSize = 72; /*0xffe0964b*/
Status_3 = (*(int ( **)(int, char *, int *))DbgLib)(DbgLib, CommBuffer, &BufferSize); /*0xffe09660*/
if ( Status_3 == -2147483629 ) /*0xffe0966c*/
{
DebugPrint(64, (int)"SmmLockBoxPeiLib Communicate - (%r)\n", -2147483629); /*0xffe09676*/
Status_1 = SmmCommunicationNotifyPpi(p_SystemTable, (unsigned int *)p_ImageHandle); /*0xffe09681*/
NotifyFlag = 0; /*0xffe09686*/
Status_3 = Status_1; /*0xffe0968b*/
Status = Status_1; /*0xffe0968d*/
Status_2 = Status_1; /*0xffe0968f*/
if ( p_ImageHandle ) /*0xffe09695*/
{
ImageHandle = *p_ImageHandle; /*0xffe09699*/
ResultFlags = 0; /*0xffe0969d*/
}
}
else
{
Status = Status_2; /*0xffe096a3*/
}
if ( Status_3 < 0 ) /*0xffe096ae*/
{
DebugPrint(0x80000000, (int)"\nASSERT_EFI_ERROR (Status = %r)\n", Status_3); /*0xffe096b7*/
DebugLib = GetDebugLibInterface(); /*0xffe096bf*/
if ( DebugLib ) /*0xffe096c6*/
(*(void ( **)(const char *, int, const char *))(DebugLib + 4))( /*0xffe096d7*/
"e:\\hs\\MdeModulePkg\\Library\\SmmLockBoxLib\\SmmLockBoxPeiLib.c",
626,
"!EFI_ERROR (Status)");
Status = Status_2; /*0xffe096dd*/
}
if ( p_ImageHandle ) /*0xffe096e3*/
*p_ImageHandle = ImageHandle; /*0xffe096e9*/
if ( Status ) /*0xffe096ed*/
Status |= 0x80000000; /*0xffe096f3*/
}
else
{
DebugPrint(64, (int)"SmmLockBoxPeiLib LocatePpi - (%r)\n", PpiResult); /*0xffe09589*/
Status = SmmCommunicationNotifyPpi(p_SystemTable, (unsigned int *)p_ImageHandle); /*0xffe0959a*/
}
DebugPrint(64, (int)"SmmLockBoxPeiLib RestoreLockBox - Exit (%r)\n", Status); /*0xffe095a4*/
return Status; /*0xffe0955d*/
}
// ConfigurePamRegisters @ 0xffe096fa char __thiscall ConfigurePamRegisters(EFI_SYSTEM_TABLE *SystemTable)
{
int SegIndex; // edi int ( **DbgLib)(int); // eax _DWORD *PcdData; // eax _DWORD *PcdData_1; // esi int ( **PcdData2)(int); // eax _DWORD *PcdData2b; // eax _DWORD *PcdData2b_1; // esi int Status; // esi unsigned __int8 BusNum; // al int BusNum_2; // ebx int MmioAddr; // ebx char IsEnable; // al int MmioAddr_2; // esi int Pam0123Reg; // [esp-Ch] [ebp-40h]
EFI_SYSTEM_TABLE *SystemTable_1; // [esp-4h] [ebp-38h]
int Pam456Reg; // [esp-4h] [ebp-38h]
char SystemTableFlag; // [esp+14h] [ebp-20h]
unsigned __int8 BusNum_1; // [esp+15h] [ebp-1Fh]
unsigned __int8 StackSeg; // [esp+16h] [ebp-1Eh]
int MmioAddr_1; // [esp+18h] [ebp-1Ch] BYREF int LoopCount; // [esp+1Ch] [ebp-18h]
_DWORD PcieSegEntry[5]; // [esp+20h] [ebp-14h] BYREF SystemTableFlag = (char)SystemTable; /*0xffe09701*/
SegIndex = 0; /*0xffe09705*/
LoopCount = 4; /*0xffe09707*/
do
{
DbgLib = (int ( **)(int))PcdGetPtr(SystemTable); /*0xffe0970f*/
PcdData = (_DWORD *)DbgLib[5](7); /*0xffe09716*/
PcdData_1 = PcdData; /*0xffe09719*/
SystemTable = SystemTable_1; /*0xffe0971b*/
if ( !*(_BYTE *)PcdData && AmiUpdatePcieSegmentBusTable(PcdData) < 0 || (PcdData_1[2 *SegIndex + 2] & 0x200) == 0 ) /*0xffe09736*/
goto LABEL_19; /*0xffe09736*/
PcdData2 = (int ( **)(int))PcdGetPtr(SystemTable); /*0xffe0973c*/
PcdData2b = (_DWORD *)PcdData2[5](7); /*0xffe09743*/
PcdData2b_1 = PcdData2b; /*0xffe09746*/
if ( !*(_BYTE *)PcdData2b && AmiUpdatePcieSegmentBusTable(PcdData2b) < 0 ) /*0xffe09757*/
{
Status = -2147483642; /*0xffe09759*/
LABEL_8:
BusNum = BusNum_1; /*0xffe0975e*/
goto LABEL_13; /*0xffe09762*/
}
if ( ((1 << SegIndex) & PcdData2b_1[1]) == 0 || (PcdData2b_1[2 *SegIndex + 2] & 0x200) == 0 ) /*0xffe0977c*/
{
Status = -2147483645; /*0xffe09770*/
goto LABEL_8; /*0xffe09775*/
}
StackSeg = PcdData2b_1[2 *SegIndex + 2]; /*0xffe09782*/
BusNum = HIBYTE(PcdData2b_1[2 *SegIndex + 2]); /*0xffe09786*/
Status = 0; /*0xffe0978a*/
BusNum_1 = BusNum; /*0xffe0978c*/
LABEL_13:
BusNum_2 = BusNum; /*0xffe09790*/
DebugPrint(64, (int)"AmiGetPcieSegmentBus - Status = %r StackSeg : %x, StackBus = %x\n", Status, StackSeg, BusNum);
if ( Status >= 0 ) /*0xffe097ae*/
{
PcieSegEntry[3] = 0; /*0xffe097b4*/
PcieSegEntry[2] = 512; /*0xffe097ce*/
PcieSegEntry[1] = StackSeg; /*0xffe097d8*/
PcieSegEntry[0] = (BusNum_2 << 20) | 0xE8000; /*0xffe097dc*/
MmPciAddress(0, 0, PcieSegEntry, &MmioAddr_1); /*0xffe097e0*/
MmioAddr = MmioAddr_1; /*0xffe097e5*/
DebugPrint(64, (int)"MmPciAddress - Address = %x\n", MmioAddr_1); /*0xffe097f1*/
IsEnable = SystemTableFlag; /*0xffe097f6*/
if ( SystemTableFlag ) /*0xffe097ff*/
{
if ( ::SystemTable ) /*0xffe09808*/
goto LABEL_20; /*0xffe09808*/
MmioAddr_2 = MmioAddr_1; /*0xffe09811*/
dword_FFE0A600[SegIndex] = *(_DWORD *)(MmioAddr + 64); /*0xffe09815*/
Pam456Reg = *(_DWORD *)(MmioAddr_2 + 68); /*0xffe0981f*/
Pam0123Reg = dword_FFE0A600[SegIndex]; /*0xffe09821*/
dword_FFE0A610[SegIndex] = Pam456Reg; /*0xffe09828*/
DebugPrint( /*0xffe09837*/
64,
(int)"MmioRead32 PAM0123Reg[%d] = %x PAM456Reg[%d] = %x\n",
SegIndex,
Pam0123Reg,
SegIndex,
Pam456Reg);
*(_DWORD *)(MmioAddr + 64) = dword_FFE0A600[SegIndex] | 0x30; /*0xffe09849*/
*(_DWORD *)(MmioAddr_2 + 68) = dword_FFE0A610[SegIndex] | 0x333333; /*0xffe09858*/
}
else
{
if ( !::SystemTable ) /*0xffe09864*/
goto LABEL_20; /*0xffe09864*/
DebugPrint( /*0xffe0987d*/
64,
(int)"MmioWrite32 PAM0123Reg[%d] = %x PAM456Reg[%d] = %x\n",
SegIndex,
dword_FFE0A600[SegIndex],
SegIndex,
dword_FFE0A610[SegIndex]);
*(_DWORD *)(MmioAddr + 64) = dword_FFE0A600[SegIndex]; /*0xffe0988c*/
*(_DWORD *)(MmioAddr + 68) = dword_FFE0A610[SegIndex]; /*0xffe09896*/
}
}
LABEL_19:
IsEnable = SystemTableFlag; /*0xffe09899*/
LABEL_20:
++SegIndex; /*0xffe0989d*/
--LoopCount; /*0xffe0989e*/
}
while ( LoopCount );
::SystemTable = IsEnable; /*0xffe098ac*/
return IsEnable; /*0xffe098a9*/
}
// GetHobList @ 0xffe098b6 int GetHobList()
{
int PeiServices; // eax int Result; // eax int DebugLib; // eax int DebugLib2; // eax int HobList; // [esp+4h] [ebp-4h] BYREF PeiServices = GetPeiServicesTablePointer(); /*0xffe098bb*/
Result = (*(int ( **)(int, int *))(*(_DWORD *)PeiServices + 48))(PeiServices, &HobList); /*0xffe098c7*/
if ( Result < 0 ) /*0xffe098d3*/
{
DebugPrint(0x80000000, (int)"\nASSERT_EFI_ERROR (Status = %r)\n", Result); /*0xffe098e0*/
DebugLib = GetDebugLibInterface(); /*0xffe098e8*/
if ( DebugLib ) /*0xffe098ef*/
(*(void ( **)(const char *, int, const char *))(DebugLib + 4))( /*0xffe098f9*/
"e:\\hs\\MdePkg\\Library\\PeiHobLib\\HobLib.c",
50,
"!EFI_ERROR (Status)");
}
if ( !HobList ) /*0xffe09903*/
{
DebugLib2 = GetDebugLibInterface(); /*0xffe09905*/
if ( DebugLib2 ) /*0xffe0990c*/
(*(void ( **)(const char *, int, const char *))(DebugLib2 + 4))( /*0xffe09916*/
"e:\\hs\\MdePkg\\Library\\PeiHobLib\\HobLib.c",
51,
"HobList != ((void *) 0)");
}
return HobList; /*0xffe0991f*/
}
// GetNextHobByType @ 0xffe09924 _WORD *GetNextHobByType(int a1, _WORD *i)
{
_WORD *i_1; // esi int DebugLibInterface; // eax i_1 = i; /*0xffe09925*/
if ( !i ) /*0xffe09929*/
{
DebugLibInterface = GetDebugLibInterface(); /*0xffe0992b*/
if ( DebugLibInterface ) /*0xffe09932*/
(*(void ( **)(const char *, int, const char *))(DebugLibInterface + 4))( /*0xffe09940*/
"e:\\hs\\MdePkg\\Library\\PeiHobLib\\HobLib.c",
82,
"HobStart != ((void *) 0)");
}
while ( 1 ) /*0xffe09959*/
{
if ( *i_1 == 0xFFFF ) /*0xffe0995f*/
return 0; /*0xffe09964*/
if ( *i_1 == 4 ) /*0xffe09951*/
break; /*0xffe09951*/
i_1 = (_WORD *)((char *)i_1 + (unsigned __int16)i_1[1]); /*0xffe09957*/
}
return i_1; /*0xffe09963*/
}
// GetFirstGuidHob @ 0xffe09969 _WORD *__thiscall GetFirstGuidHob(void *this)
{
_WORD *i; // edx int v3; // ecx _WORD *NextHobByType; // eax _WORD *NextHobByType_1; // esi for ( i = (_WORD *)GetHobList(); ; i = (_WORD *)((char *)NextHobByType_1 + (unsigned __int16)NextHobByType_1[1]) ) /*0xffe09973*/
{
NextHobByType = GetNextHobByType(v3, i); /*0xffe0998b*/
NextHobByType_1 = NextHobByType; /*0xffe09990*/
if ( !NextHobByType || CompareGuid((int)this, (int)(NextHobByType + 4)) ) /*0xffe0997c*/
break; /*0xffe0997c*/
}
return NextHobByType_1; /*0xffe09996*/
}
// GetPeiServicesTablePointer @ 0xffe0999c int GetPeiServicesTablePointer()
{
int Result; // esi _BYTE v2[2]; // [esp+4h] [ebp-8h] BYREF int v3; // [esp+6h] [ebp-6h]
ReadIdtr(v2); /*0xffe099a5*/
Result = *(_DWORD *)(v3 - 4); /*0xffe099ad*/
if ( !Result ) /*0xffe099b2*/
DebugAssert( /*0xffe099c1*/
(int)"e:\\hs\\MdePkg\\Library\\PeiServicesTablePointerLibIdt\\PeiServicesTablePointer.c",
48,
(int)"PeiServices != ((void *) 0)");
return Result; /*0xffe099c9*/
}
// GetBootMode @ 0xffe099ce int GetBootMode()
{
unsigned __int8 v0; // al char Result; // al char n3_1; // cl v0 = __inbyte(0x70u); /*0xffe099d4*/
__outbyte(0x70u, v0 & 0x80 | 0x4A); /*0xffe099d9*/
Result = __inbyte(0x71u); /*0xffe099e0*/
n3_1 = Result; /*0xffe099e1*/
if ( (unsigned __int8)Result <= 3u ) /*0xffe099e6*/
{
LABEL_4:
if ( !n3_1 ) /*0xffe09a01*/
return 0; /*0xffe09a01*/
goto LABEL_5; /*0xffe09a01*/
}
n3_1 = Result; /*0xffe099e8*/
if ( !Result ) /*0xffe099f0*/
{
n3_1 = MEMORY[0xFDAF0490] & 2 | 1; /*0xffe099fc*/
goto LABEL_4; /*0xffe099fc*/
}
LABEL_5:
if ( n3_1 != -1 )
return n3_1 != 1 ? -2147483578 : -2147483644;
return 0; /*0xffe09a19*/
}
// ReadUnaligned64 @ 0xffe09a1d __int64 __thiscall ReadUnaligned64(void *this)
{
int DebugLibInterface; // eax if ( !this ) /*0xffe09a22*/
{
DebugLibInterface = GetDebugLibInterface(); /*0xffe09a24*/
if ( DebugLibInterface ) /*0xffe09a2b*/
(*(void ( **)(const char *, int, const char *))(DebugLibInterface + 4))( /*0xffe09a3c*/
"e:\\hs\\MdePkg\\Library\\BaseLib\\Unaligned.c",
192,
"Buffer != ((void *) 0)");
}
return *(_QWORD *)this; /*0xffe09a47*/
}
// ReadIdtr @ 0xffe09a49 void *__thiscall ReadIdtr(void *this)
{
void *this_1; // eax if ( !this ) /*0xffe09a4f*/
DebugAssert((int)"e:\\hs\\MdePkg\\Library\\BaseLib\\X86ReadIdtr.c", 37, (int)"Idtr != ((void *) 0)"); /*0xffe09a5e*/
this_1 = this; /*0xffe09a64*/
__sidt(this); /*0xffe09a67*/
return this_1; /*0xffe09a6b*/
}
// CopyMemS @ 0xffe09a6c char *CopyMemS(char *dst, char *src, unsigned int n16)
{
int DebugLib; // eax int DebugLib2; // eax if ( n16 - 1 > -1 - (int)dst ) /*0xffe09a82*/
{
DebugLib = GetDebugLibInterface(); /*0xffe09a84*/
if ( DebugLib ) /*0xffe09a8b*/
(*(void ( **)(const char *, int, const char *))(DebugLib + 4))( /*0xffe09a99*/
"e:\\hs\\MdePkg\\Library\\BaseMemoryLibRepStr\\CopyMemWrapper.c",
56,
"(Length - 1) <= (0xFFFFFFFF - (UINTN)DestinationBuffer)");
}
if ( n16 - 1 > -1 - (int)src ) /*0xffe09aa3*/
{
DebugLib2 = GetDebugLibInterface(); /*0xffe09aa5*/
if ( DebugLib2 ) /*0xffe09aac*/
(*(void ( **)(const char *, int, const char *))(DebugLib2 + 4))( /*0xffe09aba*/
"e:\\hs\\MdePkg\\Library\\BaseMemoryLibRepStr\\CopyMemWrapper.c",
57,
"(Length - 1) <= (0xFFFFFFFF - (UINTN)SourceBuffer)");
}
if ( dst == src ) /*0xffe09ac2*/
return dst; /*0xffe09ac4*/
else return CopyMem(dst, src, n16); /*0xffe09ace*/
}
// PcdGetPtr @ 0xffe09adb void *__thiscall PcdGetPtr(void *this)
{
int Ppi; // eax int DebugLibInterface; // eax void *this_1; // [esp+0h] [ebp-4h] BYREF this_1 = this; /*0xffe09ade*/
Ppi = PeiLocatePpi(0, (int)&this_1); /*0xffe09aea*/
if ( Ppi < 0 ) /*0xffe09af3*/
{
DebugPrint(0x80000000, (int)"\nASSERT_EFI_ERROR (Status = %r)\n", Ppi); /*0xffe09b00*/
DebugLibInterface = GetDebugLibInterface(); /*0xffe09b08*/
if ( DebugLibInterface ) /*0xffe09b0f*/
(*(void ( **)(const char *, int, const char *))(DebugLibInterface + 4))( /*0xffe09b1d*/
"e:\\hs\\MdePkg\\Library\\PeiPcdLib\\PeiPcdLib.c",
49,
"!EFI_ERROR (Status)");
}
return this_1; /*0xffe09b28*/
}
// PcdGetSize @ 0xffe09b2a int __thiscall PcdGetSize(void *this)
{
int ( **Ptr)(void *); // eax Ptr = (int ( **)(void *))PcdGetPtr(this); /*0xffe09b2d*/
return Ptr[4](this); /*0xffe09b37*/
}
// PcdSet64 @ 0xffe09b39 int __thiscall PcdSet64(void *this)
{
int ( **Ptr)(void *); // eax Ptr = (int ( **)(void *))PcdGetPtr(this); /*0xffe09b3c*/
return Ptr[5](this); /*0xffe09b46*/
}
// AmiUpdatePcieSegmentBusTable @ 0xffe09b48 int __thiscall AmiUpdatePcieSegmentBusTable(_DWORD *this)
{
int ( **PcdTable)(int); // eax int DbgLib; // eax _WORD *Hob; // eax _BYTE *DstPtr; // ecx _BYTE *SrcPtr; // edx int SegCount; // ebx _BYTE *DstBus; // esi char *SrcBus; // edi int ByteCount; // ebp char ByteVal; // al PcdTable = (int ( **)(int))PcdGetPtr(this); /*0xffe09b4f*/
if ( (unsigned int)PcdTable[7](7) > 0x48 ) /*0xffe09b5d*/
{
DbgLib = GetDebugLibInterface(); /*0xffe09b5f*/
if ( DbgLib ) /*0xffe09b66*/
(*(void ( **)(const char *, int, const char *))(DbgLib + 4))( /*0xffe09b74*/
"e:\\hs\\AmiCRBPkg\\Library\\AmiPcieSegBusLib\\AmiPcieSegBusPei.c",
56,
"sizeof (PCIE_SEG_BUS_TABLE) >= LibPcdGetSize(7U)");
}
Hob = GetFirstGuidHob(&unk_FFE0A5C0); /*0xffe09b7f*/
if ( Hob ) /*0xffe09b88*/
{
*(_BYTE *)this = 1; /*0xffe09ba0*/
DstPtr = (char *)this + 9; /*0xffe09ba3*/
SrcPtr = (char *)Hob + 65; /*0xffe09bac*/
*(this + 1) = *(_DWORD *)((char *)Hob + 2091); /*0xffe09bb1*/
SegCount = 4; /*0xffe09bb4*/
do /*0xffe09bdc*/
{
DstBus = DstPtr + 1; /*0xffe09bb8*/
*(DstPtr - 1) = *(SrcPtr - 10); /*0xffe09bbb*/
SrcBus = SrcPtr + 1; /*0xffe09bbe*/
*DstPtr = *SrcPtr; /*0xffe09bc5*/
ByteCount = 6; /*0xffe09bc7*/
do /*0xffe09bd1*/
{
ByteVal = *SrcBus++; /*0xffe09bc8*/
*DstBus++ = ByteVal; /*0xffe09bcb*/
--ByteCount; /*0xffe09bce*/
}
while ( ByteCount ); /*0xffe09bd1*/
DstPtr += 8; /*0xffe09bd3*/
SrcPtr += 43; /*0xffe09bd6*/
--SegCount; /*0xffe09bd9*/
}
while ( SegCount ); /*0xffe09bdc*/
DebugPrint(64, (int)"AmiUpdatePcieSegmentBusTable Updated SEG BUS table PCD with IIO UDS HOB\n"); /*0xffe09be5*/
return 0; /*0xffe09bea*/
}
else
{
DebugPrint(0x80000000, (int)"AmiUpdatePcieSegmentBusTable Can't locate the IIO UDS HOB\n"); /*0xffe09b94*/
return -2147483634; /*0xffe09b99*/
}
}
// MmPciAddress @ 0xffe09bf4 int *MmPciAddress(int a1, int a2, _DWORD *PcieSegEntry, int *p_MmioAddr)
{
int Device; // ecx Device = GetPcieMmioAddress((int)PcieSegEntry) + (*PcieSegEntry & 0xFFFFFFF); /*0xffe09c08*/
*p_MmioAddr = Device; /*0xffe09c0f*/
return p_MmioAddr; /*0xffe09c0e*/
}
// InitPcieSegBusTable @ 0xffe09c12 int InitPcieSegBusTable(_DWORD *a1, int n8)
{
int PcdData; // [esp+Ch] [ebp-4h]
PcdData = PcdSet64((void *)6); /*0xffe09c42*/
a1[1] = 16 *n8 + 16; /*0xffe09c4b*/
if ( !a1[4] && !a1[5] ) /*0xffe09c67*/
{
*(_DWORD *)(PcdData + 16) = PcdGetSize((void *)5); /*0xffe09c8c*/
*(_DWORD *)(PcdData + 20) = 0; /*0xffe09ca3*/
}
return 0; /*0xffe09ca9*/
}
// GetPcieMmioAddress @ 0xffe09cad int GetPcieMmioAddress(int PcieSegEntry)
{
int PcdData; // [esp+Ch] [ebp-Ch]
int MmioBase; // [esp+10h] [ebp-8h]
int MmioSize; // [esp+14h] [ebp-4h]
if ( *(_DWORD *)(PcieSegEntry + 12) ) /*0xffe09cc2*/
{
MmioBase = *(_DWORD *)(*(_DWORD *)(PcieSegEntry + 12) + 4 * (unsigned __int16)*(_DWORD *)(PcieSegEntry + 4) + 255544); /*0xffe09db8*/
MmioSize = *(_DWORD *)(*(_DWORD *)(PcieSegEntry + 12) + 4 * (unsigned __int16)*(_DWORD *)(PcieSegEntry + 4) + 255560); /*0xffe09dd4*/
}
else
{
PcdData = PcdSet64((void *)6); /*0xffe09cd5*/
if ( *(_DWORD *)(PcdData + 4) ) /*0xffe09cdb*/
{
MmioBase = *(_DWORD *)(PcdData + 16 * (unsigned __int16)*(_DWORD *)(PcieSegEntry + 4) + 20); /*0xffe09cf6*/
MmioSize = *(_DWORD *)(PcdData + 16 * (unsigned __int16)*(_DWORD *)(PcieSegEntry + 4) + 16); /*0xffe09d0e*/
}
else
{
InitPcieSegBusTable(dword_FFE0A5D0, 8); /*0xffe09d21*/
MmioBase = dword_FFE0A5E4[4 * (unsigned __int16)*(_DWORD *)(PcieSegEntry + 4)]; /*0xffe09d3c*/
MmioSize = dword_FFE0A5E0[4 * (unsigned __int16)*(_DWORD *)(PcieSegEntry + 4)]; /*0xffe09d53*/
if ( !MmioSize && !MmioBase ) /*0xffe09d60*/
{
MmioSize = PcdGetSize((void *)5); /*0xffe09d8d*/
MmioBase = 0; /*0xffe09d9a*/
}
}
}
if ( !MmioSize && !MmioBase ) /*0xffe09de1*/
return PcdGetSize((void *)5); /*0xffe09e0e*/
return MmioSize; /*0xffe09e27*/
}