/*
*PlatformReset.c - HR650X BIOS DXE Runtime Reset Driver
*
*Source: PurleyPlatPkg/Platform/RuntimeDxe/PlatformReset/PlatformReset.c
*Build: HR6N0XMLK DEBUG_VS2015 X64
*
*This DXE Runtime Driver installs the EFI Reset Architecture Protocol
*and provides the ResetSystem runtime service for Purley platform.
*
*Decompiled from: 0120_PlatformReset_8c2a5899326f/PlatformReset.efi
*MD5: e2973b50c40d9e6bd2f9efae2ecf7395
*SHA256: 8c2a5899326fcab061278ca00757faf5ecc86faf8c9eed519ec3dedc4bd4c10f
*/
#include "PlatformReset.h"
//
// Module global variables
//
EFI_HANDLE ImageHandle = NULL; // 0x40C8 EFI_SYSTEM_TABLE *gST = NULL; // 0x40B8 EFI_BOOT_SERVICES *gBS = NULL; // 0x40C0 EFI_RUNTIME_SERVICES *gRT = NULL; // 0x40D0 STATIC EFI_BOOT_SERVICES *mBS = NULL; // 0x40F0 STATIC EFI_RUNTIME_SERVICES *mRT = NULL; // 0x40D8 STATIC EFI_DS *gDS = NULL; // 0x4100 STATIC EFI_EVENT mRuntimePciEvent = NULL; // 0x40E0 STATIC EFI_EVENT mEfiExitBootServiceEvent = NULL; // 0x40E8 STATIC EFI_MM_PCI_USRA *mPciUsra = NULL; // 0x4108 STATIC VOID *mHobList = NULL; // 0x4110 STATIC EFI_EVENT mRuntimeEvent = NULL; // 0x4140 STATIC EFI_EVENT mEfiEventReadyToBoot = NULL; // 0x4148 STATIC EFI_EVENT mVirtualAddressChangeEvent = NULL; // 0x4150 STATIC EFI_RUNTIME_SERVICES *mRuntimeServices = NULL; // 0x4160 STATIC EFI_EVENT mSetVirtualAddressMapEvent = NULL; // 0x4168 STATIC EFI_RESET_SYSTEM mOriginalResetSystem = NULL; // 0x4170 STATIC UINTN mPciExpressRegBase = 0; // 0x4120 STATIC UINTN mPciExpressMmBaseCount = 0; // 0x4128 STATIC UINTN mPciExpressMmBaseIndex = 0; // 0x4138 STATIC VOID *mPciExpressMmBaseRegBase = NULL; // 0x4130 STATIC PCD_PROTOCOL *mPcd = NULL; // 0x4148 STATIC BOOLEAN mRuntimeVirtualAddrMapDone = FALSE; // 0x4118 STATIC BOOLEAN mRuntimePciExpressInitialized = FALSE; // 0x4119
//
// ZeroMem() - ZeroMem wrapper from BaseMemoryLibRepStr
// Address: 0x1000
//
VOID *EFIAPI ZeroMemWrapper (
IN VOID *Buffer,
IN UINTN Length
)
{
ZeroMem (Buffer, Length);
return Buffer;
}
//
// CpuPause() - Yield CPU (pause instruction)
// Address: 0x10D0
//
VOID CpuPauseWrapper (VOID)
{
CpuPause ();
}
//
// AsmReadTsc() - Read Time-Stamp Counter
// Address: 0x10E0
//
UINT64 AsmReadTscWrapper (VOID)
{
return AsmReadTsc ();
}
//
// EnableInterrupts()
// Address: 0x10F0
//
VOID EnableInterruptsWrapper (VOID)
{
EnableInterrupts ();
}
//
// DisableInterrupts()
// Address: 0x1100
//
VOID DisableInterruptsWrapper (VOID)
{
DisableInterrupts ();
}
//
// AsmReadEflags() - Read EFLAGS (caller's interrupt state)
// Address: 0x1110
//
UINTN AsmReadEflagsWrapper (VOID)
{
return AsmReadEflags ();
}
//
// ModuleEntryPoint - UEFI DXE driver entry point
// Address: 0x1114
//
// Original build path:
// PurleyPlatPkg/Platform/RuntimeDxe/PlatformReset/PlatformReset/DEBUG/AutoGen.c
EFI_STATUS EFIAPI ModuleEntryPoint (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
PlatformResetDriverEntryPoint (ImageHandle, SystemTable);
Status = PlatformResetEntryPoint (ImageHandle, SystemTable);
if (EFI_ERROR (Status)) {
PlatformResetUnload ();
}
return Status;
}
//
// PlatformResetDriverEntryPoint - Initialize driver globals,
// install BS protocol notification events, configure
// PCI Express MMIO access and runtime services.
// Address: 0x1140
//
// Original build path:
// PurleyPlatPkg/Platform/RuntimeDxe/PlatformReset/PlatformReset/DEBUG/AutoGen.c
EFI_STATUS EFIAPI PlatformResetDriverEntryPoint (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable)
{
__int64 v3; // r10 __int64 v4; // rax __int64 v5; // rbx __int64 v6; // rax __int64 v7; // r10 __int64 v8; // rax __int64 v9; // rax __int64 v10; // rbx __int64 v11; // rax __int64 v12; // rax __int64 v13; // rbx __int64 v14; // rax _BYTE *v15; // rax __int16 v16; // bx bool v17; // bl __int64 v18; // rdi int i; // eax
::ImageHandle = ImageHandle; /*0x1159*/
if ( !ImageHandle ) /*0x116d*/
DebugAssert( /*0x117c*/
"e:\\hs\\MdePkg\\Library\\UefiBootServicesTableLib\\UefiBootServicesTableLib.c",
51,
"gImageHandle != ((void *) 0)");
qword_40B8 = a2; /*0x1181*/
if ( !a2 ) /*0x118b*/
DebugAssert("e:\\hs\\MdePkg\\Library\\UefiBootServicesTableLib\\UefiBootServicesTableLib.c", 57, "gST != ((void *) 0)"); /*0x119a*/
qword_40C0 = *(_QWORD *)(a2 + 96); /*0x11a3*/
if ( !qword_40C0 ) /*0x11ad*/
DebugAssert("e:\\hs\\MdePkg\\Library\\UefiBootServicesTableLib\\UefiBootServicesTableLib.c", 63, "gBS != ((void *) 0)"); /*0x11bc*/
qword_40D0 = *(_QWORD *)(a2 + 88); /*0x11c5*/
if ( !qword_40D0 ) /*0x11cf*/
DebugAssert( /*0x11e2*/
"e:\\hs\\MdePkg\\Library\\UefiRuntimeServicesTableLib\\UefiRuntimeServicesTableLib.c",
47,
"gRT != ((void *) 0)");
v3 = *(_QWORD *)(a2 + 96); /*0x11f2*/
qword_40D8 = *(_QWORD *)(a2 + 88); /*0x11f9*/
qword_40F0 = v3; /*0x120c*/
(*(void ( **)(__int64, __int64, __int64 ( *)()))(v3 + 80))(513, 8, ClearBootServicesPointerNotify); /*0x121e*/
(*(void ( **)(__int64, __int64, __int64 ( *)(), _QWORD, __int64 *))(qword_40F0 + 80))( /*0x1246*/
1610613250,
8,
ExitBootServicesNotify,
0,
&qword_40E8);
v4 = EfiGetSystemConfigurationTable(&unk_40A0, &qword_4100); /*0x1257*/
v5 = v4; /*0x1263*/
if ( v4 < 0 ) /*0x1275*/
{
DebugPrint(0x80000000LL, "\nASSERT_EFI_ERROR (Status = %r)\n", v4); /*0x127f*/
DebugAssert("e:\\hs\\MdePkg\\Library\\DxeServicesTableLib\\DxeServicesTableLib.c", 64, "!EFI_ERROR (Status)"); /*0x1293*/
}
if ( !qword_4100 ) /*0x12a0*/
DebugAssert("e:\\hs\\MdePkg\\Library\\DxeServicesTableLib\\DxeServicesTableLib.c", 65, "gDS != ((void *) 0)"); /*0x12b5*/
if ( v5 < 0 ) /*0x12bd*/
{
DebugPrint(0x80000000LL, "\nASSERT_EFI_ERROR (Status = %r)\n", v5); /*0x12c8*/
DebugAssert( /*0x12dc*/
"e:\\hs\\Build\\HR6N0XMLK\\DEBUG_VS2015\\X64\\PurleyPlatPkg\\Platform\\RuntimeDxe\\PlatformReset\\PlatformReset\\DEBUG\\AutoGen.c",
427,
"!EFI_ERROR (Status)");
}
if ( !qword_4108 ) /*0x12e9*/
{
v6 = (*(__int64 ( **)(void *, _QWORD, __int64 *))(qword_40C0 + 320))(&unk_4040, 0, &qword_4108); /*0x1302*/
if ( v6 < 0 ) /*0x130b*/
{
DebugPrint(0x80000000LL, "\nASSERT_EFI_ERROR (Status = %r)\n", v6); /*0x1316*/
DebugAssert("e:\\hs\\CpRcPkg\\Library\\DxeMmPciBaseLib\\DxeMmPciBaseLib.c", 52, "!EFI_ERROR (Status)"); /*0x132a*/
}
if ( !qword_4108 ) /*0x1337*/
DebugAssert("e:\\hs\\CpRcPkg\\Library\\DxeMmPciBaseLib\\DxeMmPciBaseLib.c", 53, "mPciUsra != ((void *) 0)"); /*0x134c*/
}
GetHobListPointer(); /*0x1351*/
if ( !qword_40D0 ) /*0x135e*/
DebugAssert("e:\\hs\\MdePkg\\Library\\UefiRuntimeLib\\RuntimeLib.c", 95, "gRT != ((void *) 0)"); /*0x1373*/
v7 = qword_40C0; /*0x1378*/
if ( !qword_40C0 ) /*0x1382*/
{
DebugAssert("e:\\hs\\MdePkg\\Library\\UefiRuntimeLib\\RuntimeLib.c", 96, "gBS != ((void *) 0)"); /*0x1396*/
v7 = qword_40C0; /*0x139b*/
}
qword_4160 = qword_40D0; /*0x13b0*/
v8 = (*(__int64 ( **)(__int64, __int64, __int64 ( *)()))(v7 + 368))(512, 16, ConvertRuntimePointersNotify); /*0x13de*/
if ( v8 < 0 ) /*0x13e8*/
{
DebugPrint(0x80000000LL, "\nASSERT_EFI_ERROR (Status = %r)\n", v8); /*0x13f3*/
DebugAssert("e:\\hs\\MdePkg\\Library\\UefiRuntimeLib\\RuntimeLib.c", 111, "!EFI_ERROR (Status)"); /*0x1407*/
}
v9 = (*(__int64 ( **)(__int64, __int64, __int64 ( *)(), _QWORD, void *, __int64 *))(qword_40C0 + 368))( /*0x143d*/
512,
16,
SetVirtualAddressMapNotify,
0,
&unk_4080,
&qword_4168);
v10 = v9; /*0x1443*/
if ( v9 < 0 ) /*0x1449*/
{
DebugPrint(0x80000000LL, "\nASSERT_EFI_ERROR (Status = %r)\n", v9); /*0x1454*/
DebugAssert("e:\\hs\\MdePkg\\Library\\UefiRuntimeLib\\RuntimeLib.c", 122, "!EFI_ERROR (Status)"); /*0x1468*/
DebugPrint(0x80000000LL, "\nASSERT_EFI_ERROR (Status = %r)\n", v10); /*0x1476*/
DebugAssert( /*0x148a*/
"e:\\hs\\Build\\HR6N0XMLK\\DEBUG_VS2015\\X64\\PurleyPlatPkg\\Platform\\RuntimeDxe\\PlatformReset\\PlatformReset\\DEBUG\\AutoGen.c",
436,
"!EFI_ERROR (Status)");
}
v11 = GetPcdProtocolPointer(); /*0x148f*/
qword_4130 = (*(__int64 ( **)(__int64))(v11 + 32))(5); /*0x149c*/
v12 = (*(__int64 ( **)(__int64, __int64, __int64 ( *)(), _QWORD, void *, __int64 *))(qword_40C0 + 368))( /*0x14d4*/
512,
16,
RuntimePciExpressCleanupNotify,
0,
&unk_4090,
&qword_4140);
v13 = v12; /*0x14da*/
if ( v12 < 0 ) /*0x14e0*/
{
DebugPrint(0x80000000LL, "\nASSERT_EFI_ERROR (Status = %r)\n", v12); /*0x14eb*/
DebugAssert("e:\\hs\\MdePkg\\Library\\DxeRuntimePciExpressLib\\PciExpressLib.c", 141, "!EFI_ERROR (Status)"); /*0x14ff*/
DebugPrint(0x80000000LL, "\nASSERT_EFI_ERROR (Status = %r)\n", v13); /*0x150d*/
DebugAssert( /*0x1521*/
"e:\\hs\\Build\\HR6N0XMLK\\DEBUG_VS2015\\X64\\PurleyPlatPkg\\Platform\\RuntimeDxe\\PlatformReset\\PlatformReset\\DEBUG\\AutoGen.c",
439,
"!EFI_ERROR (Status)");
}
if ( *(char *)GetPciExpressMmioConfigSpaceAddress(1024068) >= 0 ) /*0x1536*/
{
v14 = GetPciExpressMmioConfigSpaceAddress(1024064); /*0x153b*/
IoWrite16Wrapper(v14); /*0x1543*/
v15 = (_BYTE *)GetPciExpressMmioConfigSpaceAddress(1024068); /*0x154a*/
*v15 |= 0x80u; /*0x1554*/
}
v16 = AsmReadEflagsWrapper(); /*0x155b*/
DisableInterruptsWrapper(); /*0x155e*/
v17 = (v16 & 0x200) != 0; /*0x156d*/
v18 = IoRead32Wrapper(1288) & 0xFFFFFF; /*0x1577*/
AsmReadTscWrapper(); /*0x157d*/
for ( i = IoRead32Wrapper(1288); (((_DWORD)v18 + 357 - i) & 0x800000) == 0; i = IoRead32Wrapper(1288) ) /*0x1584*/
CpuPauseWrapper(); /*0x1591*/
AsmReadTscWrapper(); /*0x15ab*/
if ( v17 ) /*0x15b2*/
return EnableInterruptsWrapper(); /*0x15b4*/
else return DisableInterruptsWrapper(); /*0x15bb*/
}
//
// PlatformResetUnload - Driver unload handler
// Unregisters runtime PCI Express mappings, frees events.
// Address: 0x15DC
//
__int64 PlatformResetUnload()
{
__int64 v0; // rax __int64 v1; // rbx __int64 v2; // rax __int64 v3; // rax __int64 v4; // rax __int64 v5; // rbx if ( qword_4120 ) /*0x15f9*/
FreeRuntimePciExpressMap(); /*0x15fb*/
v0 = (*(__int64 ( **)(__int64))(qword_40C0 + 112))(qword_4140); /*0x160e*/
v1 = v0; /*0x1624*/
if ( v0 < 0 ) /*0x162a*/
{
DebugPrint(0x80000000LL, "\nASSERT_EFI_ERROR (Status = %r)\n", v0); /*0x1634*/
DebugAssert("e:\\hs\\MdePkg\\Library\\DxeRuntimePciExpressLib\\PciExpressLib.c", 178, "!EFI_ERROR (Status)"); /*0x1648*/
DebugPrint(0x80000000LL, "\nASSERT_EFI_ERROR (Status = %r)\n", v1); /*0x1655*/
DebugAssert( /*0x1669*/
"e:\\hs\\Build\\HR6N0XMLK\\DEBUG_VS2015\\X64\\PurleyPlatPkg\\Platform\\RuntimeDxe\\PlatformReset\\PlatformReset\\DEBUG\\AutoGen.c",
479,
"!EFI_ERROR (Status)");
}
v2 = qword_40C0; /*0x166e*/
if ( !qword_40C0 ) /*0x1678*/
{
DebugAssert("e:\\hs\\MdePkg\\Library\\UefiRuntimeLib\\RuntimeLib.c", 151, "gBS != ((void *) 0)"); /*0x168d*/
v2 = qword_40C0; /*0x1692*/
}
v3 = (*(__int64 ( **)(__int64))(v2 + 112))(qword_4158); /*0x16a0*/
if ( v3 < 0 ) /*0x16a6*/
{
DebugPrint(0x80000000LL, "\nASSERT_EFI_ERROR (Status = %r)\n", v3); /*0x16b1*/
DebugAssert("e:\\hs\\MdePkg\\Library\\UefiRuntimeLib\\RuntimeLib.c", 153, "!EFI_ERROR (Status)"); /*0x16c5*/
}
v4 = (*(__int64 ( **)(__int64))(qword_40C0 + 112))(qword_4168); /*0x16d8*/
v5 = v4; /*0x16db*/
if ( v4 < 0 ) /*0x16e1*/
{
DebugPrint(0x80000000LL, "\nASSERT_EFI_ERROR (Status = %r)\n", v4); /*0x16ec*/
DebugAssert("e:\\hs\\MdePkg\\Library\\UefiRuntimeLib\\RuntimeLib.c", 156, "!EFI_ERROR (Status)"); /*0x1700*/
DebugPrint(0x80000000LL, "\nASSERT_EFI_ERROR (Status = %r)\n", v5); /*0x170e*/
DebugAssert( /*0x1722*/
"e:\\hs\\Build\\HR6N0XMLK\\DEBUG_VS2015\\X64\\PurleyPlatPkg\\Platform\\RuntimeDxe\\PlatformReset\\PlatformReset\\DEBUG\\AutoGen.c",
482,
"!EFI_ERROR (Status)");
}
(*(void ( **)(__int64))(qword_40F0 + 112))(qword_40E0); /*0x1735*/
return (*(__int64 ( **)(__int64))(qword_40F0 + 112))(qword_40E8);
}
//
// PlatformResetEntryPoint - Main entry point for PlatformReset driver.
// Installs the EFI Reset Architecture Protocol and registers
// the PlatformResetSystem() as the runtime ResetSystem handler.
// Address: 0x1760
//
EFI_STATUS PlatformResetEntryPoint (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable)
{
__int64 v3; // rax __int64 v4; // rax __int64 v5; // rax __int64 v7; // [rsp+40h] [rbp+8h] BYREF char v8; // [rsp+48h] [rbp+10h] BYREF v7 = a1; /*0x1765*/
v3 = (*(__int64 ( **)(void *, _QWORD, __int64 *))(qword_40C0 + 320))(&unk_4070, 0, &qword_4170); /*0x1789*/
if ( v3 < 0 ) /*0x1797*/
{
DebugPrint(0x80000000LL, "\nASSERT_EFI_ERROR (Status = %r)\n", v3); /*0x17a5*/
DebugAssert("e:\\hs\\PurleyPlatPkg\\Platform\\RuntimeDxe\\PlatformReset\\PlatformReset.c", 169, "!EFI_ERROR (Status)"); /*0x17bd*/
}
if ( (*(__int64 ( **)(void *, _QWORD, char *))(qword_40C0 + 320))(&unk_4010, 0, &v8) >= 0 ) /*0x17e0*/
DebugAssert( /*0x17f5*/
"e:\\hs\\PurleyPlatPkg\\Platform\\RuntimeDxe\\PlatformReset\\PlatformReset.c",
174,
"&gEfiResetArchProtocolGuid already installed in database");
SystemTable->RuntimeServices->ResetSystem = (EFI_RESET_SYSTEM)PlatformResetSystem; /*0x1812*/
v7 = 0; /*0x1822*/
v4 = (*(__int64 ( **)(__int64 *, void *, _QWORD, _QWORD))(qword_40C0 + 328))(&v7, &unk_4010, 0, 0); /*0x1828*/
if ( v4 < 0 ) /*0x1831*/
{
DebugPrint(0x80000000LL, "\nASSERT_EFI_ERROR (Status = %r)\n", v4); /*0x1840*/
DebugAssert("e:\\hs\\PurleyPlatPkg\\Platform\\RuntimeDxe\\PlatformReset\\PlatformReset.c", 191, "!EFI_ERROR (Status)"); /*0x1858*/
}
v5 = (*(__int64 ( **)(__int64, __int64, __int64 ( *)()))(qword_40C0 + 368))(512, 16, SaveOriginalResetSystemNotify); /*0x188f*/
if ( v5 < 0 ) /*0x1898*/
{
DebugPrint(0x80000000LL, "\nASSERT_EFI_ERROR (Status = %r)\n", v5); /*0x18a7*/
DebugAssert("e:\\hs\\PurleyPlatPkg\\Platform\\RuntimeDxe\\PlatformReset\\PlatformReset.c", 206, "!EFI_ERROR (Status)"); /*0x18bf*/
}
return (*(__int64 ( **)(__int64, __int64, __int64 ( *)()))(qword_40C0 + 368))(512, 8, NullNotification); /*0x18fe*/
}
//
// PlatformResetSystem - Runtime ResetSystem service handler.
// Handles cold reset (0), warm reset (1), shutdown (3),
// and platform-specific reset (4, 5).
// Calls through PCH SMBus controller or via PCH reset register.
// Address: 0x1908
//
VOID EFIAPI PlatformResetSystem (
IN EFI_RESET_TYPE ResetType,
IN EFI_STATUS ResetStatus,
IN UINTN DataSize,
IN VOID *ResetData OPTIONAL)
{
unsigned __int64 n4; // rdi int n3; // ecx void ( **v5)(char *); // [rsp+20h] [rbp-18h] BYREF char v6; // [rsp+40h] [rbp+8h] BYREF if ( !byte_4118 && qword_40B0 ) /*0x1931*/
{
(*(void (**)(void))(qword_40C0 + 104))(); /*0x193a*/
n4 = (*(__int64 ( **)(__int64))(qword_40C0 + 24))(31); /*0x194a*/
if ( n4 <= 4 ) /*0x1950*/
{
(*(void ( **)(unsigned __int64))(qword_40C0 + 32))(n4); /*0x1977*/
}
else
{
(*(void ( **)(__int64))(qword_40C0 + 32))(4); /*0x195b*/
(*(void ( **)(unsigned __int64))(qword_40C0 + 24))(n4); /*0x1968*/
}
(*(void ( **)(__int64))(qword_40C0 + 112))(qword_40B0); /*0x1988*/
}
ZeroMemValidated(&v6, 1); /*0x1995*/
if ( !byte_4118 /*0x19c6*/
&& n3_1 <= 1
&& (*(__int64 ( **)(void *, _QWORD, void ( ***)(char *)))(qword_40C0 + 320))(&unk_4000, 0, &v5) >= 0 )
{
(*v5)(&v6); /*0x19d2*/
n3 = 3; /*0x19d8*/
if ( (v6 & 1) == 0 ) /*0x19df*/
n3 = n3_1; /*0x19df*/
n3_1 = n3; /*0x19e4*/
if ( (v6 & 2) != 0 ) /*0x19e6*/
n3_1 = 4; /*0x19e6*/
if ( (v6 & 4) != 0 ) /*0x19f1*/
n3_1 = 5; /*0x19f1*/
}
(*(void ( **)(__int64, _QWORD, _QWORD, _QWORD))qword_4170)(qword_4170, n3_1, 0, 0); /*0x1a06*/
return DebugAssert( /*0x1a2a*/
"e:\\hs\\PurleyPlatPkg\\Platform\\RuntimeDxe\\PlatformReset\\PlatformReset.c",
140,
"((BOOLEAN)(0==1))");
}
//
// NullNotification - Null notification function
// Address: 0x1904
//
VOID NullNotification (VOID)
{
}
//
// SaveOriginalResetSystemNotify - Save the original ResetSystem pointer to mOriginalResetSystem
// Address: 0x1A30
//
__int64 SaveOriginalResetSystemNotify()
{
return (*(__int64 ( **)(__int64, __int64 *))(qword_40D0 + 64))(4, &qword_4170);
}
//
// ZeroMemValidated - ZeroMem with validation (BaseMemoryLib wrapper)
// Address: 0x1A48
//
__int64 ZeroMemValidated(__int64 a1, unsigned __int64 a2)
{
if ( !a1 ) /*0x1a5b*/
DebugAssert("e:\\hs\\MdePkg\\Library\\BaseMemoryLibRepStr\\ZeroMemWrapper.c", 53, "Buffer != ((void *) 0)"); /*0x1a6e*/
if ( a2 > -a1 ) /*0x1a7c*/
DebugAssert( /*0x1a91*/
"e:\\hs\\MdePkg\\Library\\BaseMemoryLibRepStr\\ZeroMemWrapper.c",
54,
"Length <= (0xFFFFFFFFFFFFFFFFULL - (UINTN)Buffer + 1)");
return ZeroMemWrapper(a1, a2); /*0x1aa1*/
}
//
// GetDebugOutputProtocol - Get the Debug Output protocol for ASSERT/DEBUG output
// Address: 0x1AAC
//
__int64 GetDebugOutputProtocol()
{
__int64 result; // rax unsigned __int64 n0x10; // rbx __int64 v2; // rax __int64 v3; // rcx result = qword_40F8; /*0x1ab6*/
if ( !qword_40F8 ) /*0x1ac2*/
{
if ( qword_40F0 /*0x1af0*/
&& (n0x10 = (*(__int64 ( **)(__int64))(qword_40F0 + 24))(31),
(*(void ( **)(unsigned __int64))(qword_40F0 + 32))(n0x10),
n0x10 <= 0x10) )
{
v2 = (*(__int64 ( **)(void *, _QWORD, __int64 *))(qword_40F0 + 320))(&unk_4030, 0, &qword_40F8); /*0x1b09*/
v3 = qword_40F8; /*0x1b0f*/
if ( v2 < 0 ) /*0x1b19*/
v3 = 0; /*0x1b19*/
qword_40F8 = v3; /*0x1b1d*/
return v3; /*0x1b24*/
}
else
{
return 0; /*0x1ad0*/
}
}
return result; /*0x1b2c*/
}
//
// DebugPrintWrapper - Debug print wrapper (supports NMI lock via CMOS 0x4B)
// Address: 0x1B34
//
__int64 DebugPrintWrapper(__int64 a1, const char *a2, ...)
{
__int64 result; // rax __int64 v4; // r8 __int64 ( **v5)(__int64, const char *, __int64 *); // r9 unsigned __int8 v6; // al unsigned __int8 n3; // al int n113; // edx va_list va; // [rsp+40h] [rbp+18h] BYREF va_start(va, a2);
result = GetDebugOutputProtocol(); /*0x1b4b*/
v4 = 0; /*0x1b50*/
v5 = (__int64 ( **)(__int64, const char *, __int64 *))result; /*0x1b53*/
if ( result ) /*0x1b59*/
{
v6 = __inbyte(0x70u); /*0x1b5f*/
__outbyte(0x70u, v6 & 0x80 | 0x4B); /*0x1b64*/
n113 = 113; /*0x1b65*/
n3 = __inbyte(0x71u); /*0x1b69*/
LOBYTE(n113) = n3; /*0x1b6a*/
if ( n3 > 3u ) /*0x1b6e*/
{
n113 = 3; /*0x1b77*/
if ( n113 ) /*0x1b7d*/
n113 = (unsigned __int8)n113; /*0x1b7d*/
}
result = (unsigned int)(n113 - 1); /*0x1b80*/
if ( (unsigned __int8)(n113 - 1) <= 0xFDu ) /*0x1b85*/
{
result = 2147483652LL; /*0x1b8a*/
v4 = 2147483718LL; /*0x1b8f*/
if ( (_BYTE)n113 == 1 ) /*0x1b95*/
v4 = 2147483652LL; /*0x1b95*/
}
if ( (v4 & a1) != 0 ) /*0x1b9c*/
return (*v5)(a1, a2, (__int64 *)va); /*0x1bab*/
}
return result; /*0x1bae*/
}
//
// DebugAssertWrapper - Debug assert (via Debug Output protocol)
// Address: 0x1BB4
//
__int64 DebugAssertWrapper(__int64 a1, __int64 a2, __int64 a3)
{
__int64 result; // rax result = GetDebugOutputProtocol(); /*0x1bcc*/
if ( result ) /*0x1bd4*/
return (*(__int64 ( **)(__int64, __int64, __int64))(result + 8))(a1, a2, a3); /*0x1bdf*/
return result; /*0x1bec*/
}
//
// ClearBootServicesPointerNotify - BS event notification: clear gBS pointer
// Address: 0x1BF4
//
VOID ClearBootServicesPointerNotify (VOID)
{
gBS = NULL;
}
//
// ExitBootServicesNotify - ExitBootServices notification handler
// Address: 0x1C00
//
VOID ExitBootServicesNotify (VOID)
{
if (mDebugOutputProtocol != NULL) {
gRT->FreePool (mDebugOutputProtocol);
}
}
VOID *mDebugOutputProtocol = NULL; // 0x40F8
//
// GetSystemConfigurationTableByGuid - Get system configuration table by GUID (UefiLib wrapper)
// Address: 0x1C28
//
unsigned __int64 GetSystemConfigurationTableByGuid(__int64 a1, _QWORD *a2)
{
__int64 v4; // rdi __int64 v5; // rbx __int64 i; // r14 if ( !a1 ) /*0x1c4a*/
DebugAssert((__int64)"e:\\hs\\MdePkg\\Library\\UefiLib\\UefiLib.c", 97, (__int64)"TableGuid != ((void *) 0)"); /*0x1c5d*/
if ( !a2 ) /*0x1c65*/
DebugAssert((__int64)"e:\\hs\\MdePkg\\Library\\UefiLib\\UefiLib.c", 98, (__int64)"Table != ((void *) 0)"); /*0x1c78*/
v4 = qword_40B8; /*0x1c7d*/
v5 = 0; /*0x1c84*/
*a2 = 0; /*0x1c86*/
if ( !*(_QWORD *)(v4 + 104) ) /*0x1c8a*/
return 0x800000000000000EuLL; /*0x1cb3*/
for ( i = 0; !(unsigned __int8)CompareGuid64(a1, i + *(_QWORD *)(v4 + 112)); i += 24 ) /*0x1c90*/
{
if ( (unsigned __int64)++v5 >= *(_QWORD *)(v4 + 104) ) /*0x1cb1*/
return 0x800000000000000EuLL; /*0x1cb1*/
}
*a2 = *(_QWORD *)(*(_QWORD *)(v4 + 112) + 24 *v5 + 16); /*0x1ce7*/
return 0; /*0x1cd1*/
}
//
// GetHobListPointer - Get HOB list pointer (HobLib wrapper)
// Address: 0x1CEC
//
__int64 GetHobListPointer()
{
__int64 result; // rax signed __int64 v1; // rax result = qword_4110; /*0x1cf0*/
if ( !qword_4110 ) /*0x1cfa*/
{
v1 = GetSystemConfigurationTableByGuid((__int64)&unk_4060, &qword_4110); /*0x1d0a*/
if ( v1 < 0 ) /*0x1d12*/
{
DebugPrint(0x80000000LL, "\nASSERT_EFI_ERROR (Status = %r)\n", v1); /*0x1d23*/
DebugAssert((__int64)"e:\\hs\\MdePkg\\Library\\DxeHobLib\\HobLib.c", 54, (__int64)"!EFI_ERROR (Status)"); /*0x1d3b*/
}
result = qword_4110; /*0x1d40*/
if ( !qword_4110 ) /*0x1d4a*/
{
DebugAssert((__int64)"e:\\hs\\MdePkg\\Library\\DxeHobLib\\HobLib.c", 55, (__int64)"mHobList != ((void *) 0)"); /*0x1d5d*/
return qword_4110; /*0x1d62*/
}
}
return result; /*0x1d69*/
}
//
// SetVirtualAddressMapNotify - SetVirtualAddressMap notification: mark VA map done
// Address: 0x1D70
//
VOID SetVirtualAddressMapNotify (VOID)
{
mRuntimeVirtualAddrMapDone = TRUE;
}
//
// ConvertRuntimePointersNotify - Runtime event: convert RT pointers for virtual address mode
// Address: 0x1D78
//
VOID ConvertRuntimePointersNotify (VOID)
{
EfiConvertPointer (0, &mRuntimeServices);
mRuntimePciExpressInitialized = TRUE;
}
//
// RuntimePciExpressCleanupNotify - Runtime PCI Express address map cleanup
// Address: 0x1D9C
//
__int64 RuntimePciExpressCleanupNotify()
{
__int64 result; // rax unsigned __int64 v1; // rbx __int64 v2; // rdi result = qword_4120; /*0x1da6*/
v1 = 0; /*0x1dad*/
if ( qword_4120 ) /*0x1db2*/
{
if ( qword_4128 ) /*0x1dbb*/
{
v2 = 0; /*0x1dbd*/
while ( 1 ) /*0x1dcf*/
{
(*(void ( **)(_QWORD, __int64))(qword_40D0 + 64))(0, v2 + result + 8); /*0x1dcf*/
++v1; /*0x1dd2*/
v2 += 16; /*0x1dd5*/
if ( v1 >= qword_4128 ) /*0x1de0*/
break; /*0x1de0*/
result = qword_4120; /*0x1de2*/
}
}
return (*(__int64 ( **)(_QWORD, __int64 *))(qword_40D0 + 64))(0, &qword_4120); /*0x1dfb*/
}
return result; /*0x1e03*/
}
//
// GetPciExpressMmioConfigSpaceAddress - Get PCI Express MMIO config space address
// Resolves a PCI Express address to its MMIO base + offset.
// Address: 0x1E0C
//
__int64 GetPciExpressMmioConfigSpaceAddress(__int64 n1024064)
{
__int64 v2; // rbx unsigned __int64 v3; // rax _QWORD *v4; // rcx if ( (n1024064 & 0xFFFFFFFFF0000000uLL) != 0 ) /*0x1e1c*/
DebugAssert( /*0x1e31*/
(__int64)"e:\\hs\\MdePkg\\Library\\DxeRuntimePciExpressLib\\PciExpressLib.c",
203,
(__int64)"((Address) & ~0xfffffff) == 0");
v2 = qword_4130 + n1024064; /*0x1e36*/
v3 = 0; /*0x1e3d*/
if ( byte_4119 ) /*0x1e45*/
{
if ( *(_QWORD *)(qword_4120 + 16 *qword_4138) == (v2 & 0xFFFFFFFFFFFFF000uLL) ) /*0x1e66*/
{
return *(_QWORD *)(qword_4120 + 16 *qword_4138 + 8) + (v2 & 0xFFF); /*0x1e6e*/
}
else
{
if ( !qword_4128 ) /*0x1e7f*/
{
LABEL_10:
DebugAssert( /*0x1e95*/
(__int64)"e:\\hs\\MdePkg\\Library\\DxeRuntimePciExpressLib\\PciExpressLib.c",
246,
(__int64)"((BOOLEAN)(0==1))");
__debugbreak(); /*0x1ead*/
}
v4 = (_QWORD *)qword_4120; /*0x1e81*/
while ( *v4 != (v2 & 0xFFFFFFFFFFFFF000uLL) ) /*0x1e87*/
{
++v3; /*0x1e89*/
v4 += 2; /*0x1e8c*/
if ( v3 >= qword_4128 ) /*0x1e93*/
goto LABEL_10; /*0x1e93*/
}
qword_4138 = v3; /*0x1eb7*/
return *(_QWORD *)(qword_4120 + 16 *v3 + 8) + (v2 & 0xFFF); /*0x1ec7*/
}
}
return v2; /*0x1eb1*/
}
//
// CompareGuid64 - Compare two GUIDs for equality (ReadUnaligned64 wrapper)
// Address: 0x1ED0
//
bool CompareGuid64(__int64 a1, __int64 a2)
{
__int64 v4; // rsi __int64 v5; // rbx __int64 v6; // rdi __int64 v7; // rax v4 = ((__int64 (*)(void))ReadUnaligned64)(); /*0x1ef2*/
v5 = ReadUnaligned64(a2); /*0x1efe*/
v6 = ReadUnaligned64(a1 + 8); /*0x1f0a*/
v7 = ReadUnaligned64(a2 + 8); /*0x1f0d*/
return v4 == v5 && v6 == v7; /*0x1f31*/
}
//
// ReadUnaligned64 - Read unaligned 64-bit value (BaseLib wrapper)
// Address: 0x1F38
//
__int64 ReadUnaligned64(__int64 a1)
{
if ( !a1 ) /*0x1f44*/
DebugAssert((__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\Unaligned.c", 192, (__int64)"Buffer != ((void *) 0)"); /*0x1f59*/
return *(_QWORD *)a1; /*0x1f61*/
}
//
// GetPcdProtocolPointer - Get the PCD protocol pointer
// Address: 0x1F68
//
__int64 GetPcdProtocolPointer()
{
__int64 result; // rax __int64 v1; // rax result = qword_4148; /*0x1f6c*/
if ( !qword_4148 ) /*0x1f76*/
{
v1 = (*(__int64 ( **)(void *, _QWORD, __int64 *))(qword_40C0 + 320))(&unk_4050, 0, &qword_4148); /*0x1f8f*/
if ( v1 < 0 ) /*0x1f98*/
{
DebugPrint(0x80000000LL, "\nASSERT_EFI_ERROR (Status = %r)\n", v1); /*0x1fa9*/
DebugAssert((__int64)"e:\\hs\\MdePkg\\Library\\DxePcdLib\\DxePcdLib.c", 78, (__int64)"!EFI_ERROR (Status)"); /*0x1fc1*/
}
result = qword_4148; /*0x1fc6*/
if ( !qword_4148 ) /*0x1fd0*/
{
DebugAssert((__int64)"e:\\hs\\MdePkg\\Library\\DxePcdLib\\DxePcdLib.c", 79, (__int64)"mPcd != ((void *) 0)"); /*0x1fe3*/
return qword_4148; /*0x1fe8*/
}
}
return result; /*0x1fef*/
}
//
// IoWrite16Wrapper - Write 16-bit I/O port (IoLib wrapper)
// Address: 0x1FF4
//
__int64 IoWrite16Wrapper(_WORD *a1)
{
if ( ((unsigned __int8)a1 & 1) != 0 ) /*0x2000*/
DebugAssert((__int64)"e:\\hs\\MdePkg\\Library\\BaseIoLibIntrinsic\\IoLib.c", 183, (__int64)"(Address & 1) == 0"); /*0x2015*/
*a1 = 1280; /*0x201f*/
return 1280; /*0x2022*/
}
//
// IoRead32Wrapper - Read 32-bit I/O port (IoLib wrapper)
// Address: 0x2028
//
unsigned __int32 IoRead32Wrapper(unsigned __int16 n1288)
{
if ( (n1288 & 3) != 0 ) /*0x2034*/
DebugAssert((__int64)"e:\\hs\\MdePkg\\Library\\BaseIoLibIntrinsic\\IoLibMsc.c", 193, (__int64)"(Port & 3) == 0"); /*0x2049*/
return __indword(n1288); /*0x2052*/
}
//
// FreeRuntimePciExpressMap - Free pool memory (MemoryAllocationLib wrapper)
// Address: 0x2058
//
__int64 FreeRuntimePciExpressMap()
{
__int64 result; // rax result = (*(__int64 ( **)(__int64))(qword_40C0 + 72))(qword_4120); /*0x206a*/
if ( result < 0 ) /*0x2070*/
{
DebugPrint(0x80000000LL, "\nASSERT_EFI_ERROR (Status = %r)\n", result); /*0x2081*/
return DebugAssert( /*0x2099*/
(__int64)"e:\\hs\\MdePkg\\Library\\UefiMemoryAllocationLib\\MemoryAllocationLib.c",
819,
(__int64)"!EFI_ERROR (Status)");
}
return result; /*0x209e*/
}