//
// LnvPurleyDriverPei.efi - Full Decompilation
//
#include <Uefi.h>
#include <PiPei.h>
void *memset(void *buf, unsigned int count, char value)
{
memset(buf, value, count);
return buf;
}
int InternalFillMemory(int a1, int a2, int a3, int a4)
{
do {
*(_DWORD *)(a1 + 8 * a2 - 8) = a3;
*(_DWORD *)(a1 + 8 * a2-- - 4) = a4;
} while (a2);
return a1;
}
void *memset32(void *buf, unsigned int count, int value)
{
memset32(buf, value, count);
return buf;
}
char *CopyMem(char *dst, char *src, unsigned int count)
{
unsigned int count_1;
char *dst_1;
char *src_1;
count_1 = count;
if (src < dst && &src[count - 1] >= dst) {
src_1 = &src[count - 1];
dst_1 = &dst[count - 1];
} else {
count_1 = count & 3;
qmemcpy(dst, src, 4 * (count >> 2));
src_1 = &src[4 * (count >> 2)];
dst_1 = &dst[4 * (count >> 2)];
}
qmemcpy(dst_1, src_1, count_1);
return dst;
}
EFI_STATUS ModuleEntryPoint(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
{
int v2;
int v3;
int v4;
EFI_STATUS v5;
if ((*(int (**)(EFI_SYSTEM_TABLE *, void *, _DWORD, _DWORD, void *))(LODWORD(SystemTable->Hdr.Signature) + 32))(
SystemTable,
&unk_FFE3EDEC,
0,
0,
&unk_FFE3EE60) < 0)
{
v2 = (*(int (**)(EFI_SYSTEM_TABLE *, void *))(LODWORD(SystemTable->Hdr.Signature) + 36))(
SystemTable,
&unk_FFE3EE50);
v3 = v2;
if (v2 < 0) {
DebugPrint(-1, "PEI - PeiLnvSendIpmiCmdLibConstructor NotifyPpi Status = %r \n", v2);
DebugPrint(-1, "PeiLnvSendIpmiCmdLibConstructor Status = %r \n", v3);
}
}
v4 = (*(int (**)(EFI_SYSTEM_TABLE *, void *))(LODWORD(SystemTable->Hdr.Signature) + 36))(
SystemTable,
&unk_FFE3EE2C);
v5 = v4;
if (v4 < 0) {
DebugPrint(-1, "PEI - LnvPurleyDriverPEI_Init Notify PPI Status = %r \n", v4);
}
return v5;
}
int PpiNotifyCallbackStub(void)
{
return 0;
}
int GetDebugPpiInterface(void)
{
int PeiServicesTablePointer;
int v2;
int v3;
PeiServicesTablePointer = GetPeiServicesTablePointer();
if ((*(int (**)(int, void *, _DWORD, int *, int *))(*(_DWORD *)PeiServicesTablePointer + 32))(
PeiServicesTablePointer,
&unk_FFE3EDDC,
0,
&v2,
&v3) >= 0)
{
return v3;
}
return 0;
}
int DebugPrint(int a1, const char *Format, ...)
{
int result;
int (**v3)(int, const char *, char *);
va_list va;
va_start(va, Format);
result = GetDebugPpiInterface();
v3 = (int (**)(int, const char *, char *))result;
if (result) {
result = PeiGetPlatformType();
if ((result & a1) != 0) {
return (*v3)(a1, Format, (char *)va);
}
}
return result;
}
int DebugAssert(int e, int n48, int PeiServices)
{
int result;
result = GetDebugPpiInterface();
if (result) {
return (*(int (**)(int, int, int))(result + 4))(e, n48, PeiServices);
}
return result;
}
int LnvSendIpmiCmd(int a1)
{
int v1;
int v2;
int DebugPpiInterface;
v1 = (*(int (**)(int, void *, _DWORD, _DWORD, void *))(*(_DWORD *)a1 + 32))(
a1,
&unk_FFE3EDEC,
0,
0,
&unk_FFE3EE60);
v2 = v1;
if (v1 < 0) {
DebugPrint(0x80000000, "\nASSERT_EFI_ERROR (Status = %r)\n", v1);
DebugPpiInterface = GetDebugPpiInterface();
if (DebugPpiInterface) {
(*(void (**)(const char *, int, const char *))(DebugPpiInterface + 4))(
"e:\\hs\\LenovoServerPkg\\Library\\LnvIpmiLib\\IpmiCmd\\PeiLnvSendIpmiCmdLib.c",
218,
"!EFI_ERROR (Status)");
}
}
return v2;
}
int PeiGetPlatformType(void)
{
unsigned __int8 v0;
char n3;
char n3_1;
v0 = __inbyte(0x70u);
__outbyte(0x70u, v0 & 0x80 | 0x4A);
n3 = __inbyte(0x71u);
n3_1 = n3;
if ((unsigned __int8)n3 <= 3u) {
LABEL_4:
if (!n3_1) {
return 0;
}
goto LABEL_5;
}
n3_1 = n3;
if (!n3) {
n3_1 = MEMORY[0xFDAF0490] & 2 | 1;
goto LABEL_4;
}
LABEL_5:
if (n3_1 != -1) {
return n3_1 != 1 ? -2147483578 : -2147483644;
}
return 0;
}
int GetPeiServicesTablePointer(void)
{
int v0;
_BYTE v2[8];
InternalX86ReadIdtr(v2);
v0 = *(_DWORD *)(*(_DWORD *)&v2[2] - 4);
if (!v0) {
DebugAssert(
(int)"e:\\hs\\MdePkg\\Library\\PeiServicesTablePointerLibIdt\\PeiServicesTablePointer.c",
48,
(int)"PeiServices != ((void *) 0)");
}
return v0;
}
void *__thiscall InternalX86ReadIdtr(void *this)
{
void *this_1;
if (!this) {
DebugAssert((int)"e:\\hs\\MdePkg\\Library\\BaseLib\\X86ReadIdtr.c", 37, (int)"Idtr != ((void *) 0)");
}
this_1 = this;
__sidt(this);
return this_1;
}