/*
* UbaInitPei.c
* UbaInitPei PEI module decompiled from IDA
*/
#include "UbaInitPei.h"
// UbaMemset @ 0xffdf50d8
void * UbaMemset(void *buf, unsigned int count, char value)
{
memset(buf, value, count); /*0xffdf50e5*/
return buf; /*0xffdf50eb*/
}
// UbaMemmove @ 0xffdf50f8
char * UbaMemmove(char *dst, char *src, unsigned int count)
{
unsigned int count_1; // edx
char *dst_1; // edi
char *src_1; // esi
count_1 = count; /*0xffdf5102*/
if ( src < dst && &src[count - 1] >= dst ) /*0xffdf5110*/
{
src_1 = &src[count - 1]; /*0xffdf5124*/
dst_1 = &dst[count - 1]; /*0xffdf5126*/
}
else
{
count_1 = count & 3; /*0xffdf5114*/
qmemcpy(dst, src, 4 * (count >> 2)); /*0xffdf511d*/
src_1 = &src[4 * (count >> 2)]; /*0xffdf511d*/
dst_1 = &dst[4 * (count >> 2)]; /*0xffdf511d*/
}
qmemcpy(dst_1, src_1, count_1); /*0xffdf512d*/
return dst; /*0xffdf5134*/
}
// UbaSetMem32 @ 0xffdf5158
int UbaSetMem32(int Result, int Ptr, int Temp, int Temp)
{
do /*0xffdf5171*/
{
*(_DWORD *)(Result + 8 * Ptr - 8) = Temp; /*0xffdf5169*/
*(_DWORD *)(Result + 8 * Ptr-- - 4) = Temp; /*0xffdf516d*/
}
while ( Ptr ); /*0xffdf5171*/
return Result; /*0xffdf5175*/
}
// UbaMemset32 @ 0xffdf5178
void * UbaMemset32(void *buf, unsigned int count, int value)
{
memset32(buf, value, count); /*0xffdf5185*/
return buf; /*0xffdf518b*/
}
// UbaInitEntryPoint @ 0xffdf518d
EFI_STATUS UbaInitEntryPoint(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
{
int PeiServices; // eax
EFI_STATUS result; // eax
_WORD *HobList; // eax
int PeiServicesPtr; // ecx
int HobType; // ecx
_WORD *HobByType; // esi
int PeiServicesPtr_1; // ecx
int BoardInitStatus; // eax
EFI_STATUS BoardInitStatus_1; // edi
int Protocol; // eax
int BoardInitStatus_2; // eax
int ProtocolPtr0; // eax
int BoardInitStatus_3; // eax
int ProtocolPtr1; // eax
int BoardInitStatus_4; // eax
int ProtocolPtr2; // eax
int BoardInitStatus_5; // eax
int ProtocolPtr3; // eax
int BoardInitStatus_6; // eax
int ProtocolPtr4; // eax
int BoardInitStatus_7; // eax
int ProtocolPtr5; // eax
int BoardInitStatus_8; // eax
int ProtocolPtr6; // eax
int BoardInitStatus_9; // eax
int ProtocolPtr7; // eax
int BoardInitStatus_10; // eax
int ProtocolPtr8; // eax
int BoardInitStatus_11; // eax
int ProtocolPtr9; // eax
int BoardInitStatus_12; // eax
int Pro... [22324 chars total]
// UbaGetProtocol @ 0xffdf5856
int UbaGetProtocol()
{
int PeiServices; // eax
int v2; // [esp+0h] [ebp-8h] BYREF
int Result; // [esp+4h] [ebp-4h] BYREF
PeiServices = UbaGetPeiServices(); /*0xffdf585b*/
if ( (*(int ( **)(int, void *, _DWORD, int *, int *))(*(_DWORD *)PeiServices + 32))( /*0xffdf587a*/
PeiServices,
&unk_FFDF5E88,
0,
&v2,
&Result) >= 0 )
return Result; /*0xffdf5880*/
else
return 0; /*0xffdf587c*/
}
// UbaDebugPrint @ 0xffdf5887
int UbaDebugPrint(int Result, const char *Result, ...)
{
int result; // eax
int ( **Result)(int, const char *, char *); // esi
va_list va; // [esp+10h] [ebp+Ch] BYREF
va_start(va, Result);
result = UbaGetProtocol(); /*0xffdf5888*/
Result = (int ( **)(int, const char *, char *))result; /*0xffdf588d*/
if ( result ) /*0xffdf5891*/
{
result = UbaGetPlatformType(); /*0xffdf5893*/
if ( (result & Result) != 0 ) /*0xffdf589e*/
return (*Result)(Result, Result, (char *)va); /*0xffdf58aa*/
}
return result; /*0xffdf58af*/
}
// UbaAssertHandler @ 0xffdf58b1
int UbaAssertHandler(
int e:__hs__MdePkg__Library__PeiServicesTablePointerLibIdt__PeiServ,
int n48,
int PeiServices____((void__)_0))
{
int result; // eax
result = UbaGetProtocol(); /*0xffdf58b7*/
if ( result ) /*0xffdf58be*/
return (*(int ( **)(int, int, int))(result + 4))( /*0xffdf58c6*/
e:__hs__MdePkg__Library__PeiServicesTablePointerLibIdt__PeiServ,
n48,
PeiServices____((void__)_0));
return result; /*0xffdf58cc*/
}
// UbaGuidCompare @ 0xffdf58cf
bool UbaGuidCompare(int HobType, int Protocol)
{
__int64 GuidData1; // rax
int GuidData1_1; // ebx
__int64 Qword; // rax
int GuidData1_lo; // esi
__int64 GuidData3; // kr00_8
__int64 GuidData3_1; // rax
int GuidPart1_hi; // [esp+10h] [ebp-Ch]
int GuidPart1_hi_1; // [esp+14h] [ebp-8h]
GuidData1 = UbaReadQword(&unk_FFDF5ED8); /*0xffdf58dd*/
GuidPart1_hi_1 = HIDWORD(GuidData1); /*0xffdf58e4*/
GuidData1_1 = GuidData1; /*0xffdf58e8*/
Qword = UbaReadQword((void *)Protocol); /*0xffdf58ea*/
GuidPart1_hi = HIDWORD(Qword); /*0xffdf58f4*/
GuidData1_lo = Qword; /*0xffdf58f8*/
GuidData3 = UbaReadQword(&unk_FFDF5EE0); /*0xffdf5906*/
GuidData3_1 = UbaReadQword((void *)(Protocol + 8)); /*0xffdf5908*/
return GuidData1_1 == GuidData1_lo && GuidPart1_hi_1 == GuidPart1_hi && GuidData3 == GuidData3_1; /*0xffdf592b*/
}
// UbaReadQword @ 0xffdf5933
__int64 __thiscall UbaReadQword(void *this)
{
int Protocol; // eax
if ( !this ) /*0xffdf5938*/
{
Protocol = UbaGetProtocol(); /*0xffdf593a*/
if ( Protocol ) /*0xffdf5941*/
(*(void ( **)(const char *, int, const char *))(Protocol + 4))( /*0xffdf5952*/
"e:\\hs\\MdePkg\\Library\\BaseLib\\Unaligned.c",
192,
"Buffer != ((void *) 0)");
}
return *(_QWORD *)this; /*0xffdf595d*/
}
// UbaGetHobList @ 0xffdf595f
int UbaGetHobList()
{
int PeiServices; // eax
int LocateStatus; // eax
int AssertProtocolPtr; // eax
int AssertProtocol; // eax
int HobListPtr; // [esp+4h] [ebp-4h] BYREF
PeiServices = UbaGetPeiServices(); /*0xffdf5964*/
LocateStatus = (*(int ( **)(int, int *))(*(_DWORD *)PeiServices + 48))(PeiServices, &HobListPtr); /*0xffdf5970*/
if ( LocateStatus < 0 ) /*0xffdf597c*/
{
UbaDebugPrint(0x80000000, "\nASSERT_EFI_ERROR (Status = %r)\n", LocateStatus); /*0xffdf5989*/
AssertProtocolPtr = UbaGetProtocol(); /*0xffdf5991*/
if ( AssertProtocolPtr ) /*0xffdf5998*/
(*(void ( **)(const char *, int, const char *))(AssertProtocolPtr + 4))( /*0xffdf59a2*/
"e:\\hs\\MdePkg\\Library\\PeiHobLib\\HobLib.c",
50,
"!EFI_ERROR (Status)");
}
if ( !HobListPtr ) /*0xffdf59ac*/
{
AssertProtocol = UbaGetProtocol(); /*0xffdf59ae*/
if ( AssertProtocol ) /*0xffdf59b5*/
(*(void ( **)(const char *, int, const char *))(AssertProtocol + 4))( /*0xffdf59bf*/
"e:\\hs\\MdePkg\\Library\\PeiHobLib\\HobLib.c",
51,
"HobList != ((void *) 0)");
}
return HobListPtr; /*0xffdf59c8*/
}
// UbaFindHobByType @ 0xffdf59cd
_WORD * UbaFindHobByType(int PeiServicesPtr, _WORD *HobList)
{
_WORD *HobList_1; // esi
int Protocol; // eax
HobList_1 = HobList; /*0xffdf59ce*/
if ( !HobList ) /*0xffdf59d2*/
{
Protocol = UbaGetProtocol(); /*0xffdf59d4*/
if ( Protocol ) /*0xffdf59db*/
(*(void ( **)(const char *, int, const char *))(Protocol + 4))( /*0xffdf59e9*/
"e:\\hs\\MdePkg\\Library\\PeiHobLib\\HobLib.c",
82,
"HobStart != ((void *) 0)");
}
while ( 1 ) /*0xffdf5a02*/
{
if ( *HobList_1 == 0xFFFF ) /*0xffdf5a08*/
return 0; /*0xffdf5a0d*/
if ( *HobList_1 == 4 ) /*0xffdf59fa*/
break; /*0xffdf59fa*/
HobList_1 = (_WORD *)((char *)HobList_1 + (unsigned __int16)HobList_1[1]); /*0xffdf5a00*/
}
return HobList_1; /*0xffdf5a0c*/
}
// UbaGetPlatformType @ 0xffdf5a12
int UbaGetPlatformType()
{
unsigned __int8 Ptr; // al
char RawPlatformType; // al
char RawPlatformType_1; // cl
Ptr = __inbyte(0x70u); /*0xffdf5a18*/
__outbyte(0x70u, Ptr & 0x80 | 0x4A); /*0xffdf5a1d*/
RawPlatformType = __inbyte(0x71u); /*0xffdf5a24*/
RawPlatformType_1 = RawPlatformType; /*0xffdf5a25*/
if ( (unsigned __int8)RawPlatformType <= 3u ) /*0xffdf5a2a*/
{
LABEL_4:
if ( !RawPlatformType_1 ) /*0xffdf5a45*/
return 0; /*0xffdf5a45*/
goto LABEL_5; /*0xffdf5a45*/
}
RawPlatformType_1 = Temp; /*0xffdf5a2c*/
if ( !Temp ) /*0xffdf5a34*/
{
RawPlatformType_1 = MEMORY[0xFDAF0490] & 2 | 1; /*0xffdf5a40*/
goto LABEL_4; /*0xffdf5a40*/
}
LABEL_5:
if ( RawPlatformType_1 != -1 )
return RawPlatformType_1 != 1 ? -2147483578 : -2147483644;
return 0; /*0xffdf5a5d*/
}
// UbaGetPeiServices @ 0xffdf5a61
int UbaGetPeiServices()
{
int Result; // esi
_BYTE Offset[8]; // [esp+4h] [ebp-8h] BYREF
UbaReadIdtr(Offset); /*0xffdf5a6a*/
Result = *(_DWORD *)(*(_DWORD *)&Offset[2] - 4); /*0xffdf5a72*/
if ( !Result ) /*0xffdf5a77*/
UbaAssertHandler( /*0xffdf5a86*/
(int)"e:\\hs\\MdePkg\\Library\\PeiServicesTablePointerLibIdt\\PeiServicesTablePointer.c",
48,
(int)"PeiServices != ((void *) 0)");
return Result; /*0xffdf5a8e*/
}
// UbaReadIdtr @ 0xffdf5a93
void *__thiscall UbaReadIdtr(void *this)
{
void *this_1; // eax
if ( !this ) /*0xffdf5a99*/
UbaAssertHandler((int)"e:\\hs\\MdePkg\\Library\\BaseLib\\X86ReadIdtr.c", 37, (int)"Idtr != ((void *) 0)"); /*0xffdf5aa8*/
this_1 = this; /*0xffdf5aae*/
__sidt(this); /*0xffdf5ab1*/
return this_1; /*0xffdf5ab5*/
}