Newer
Older
AMI-Aptio-BIOS-Reversed / Build / CpuCsrAccess / CpuCsrAccess.c
@Ajax Dong Ajax Dong 2 days ago 30 KB Restructure the repo
/*
 *CpuCsrAccess.efi - Full Decompilation
 *HR650X BIOS PE Module 0107
 *SHA256: 753fbd8daa6f30dc45ad0b7126574fd3f8ac4f1258508cd37203d325fefc76ec
 *Decompiled from IDA Pro
 */

#include "CpuCsrAccess.h"

// Forward declarations __int64 CpuCsrCpuid(unsigned int a1, _DWORD *a2, _DWORD *a3, _DWORD *a4, _DWORD *a5);
void CpuCsrCpuPause();
unsigned __int64 CpuCsrReadTsc();
void CpuCsrEnableInterrupts();
void CpuCsrDisableInterrupts();
unsigned __int64 CpuCsrReadEflags();
EFI_STATUS ModuleEntryPoint(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable);
void CpuCsrInitUefiBootServices(__int64 a1, __int64 a2);
__int64 CpuCsrUnloadDriver();
__int64 CpuCsrWriteDispatch1(char a1, int a2, int a3, __int64 a4);
__int64 CpuCsrReadWriteDispatch(unsigned __int8 a1, __int64 a2, __int64 a3);
__int64 CpuCsrWriteDispatch2(unsigned __int8 a1, unsigned __int8 a2, int a3, int a4);
__int64 CpuCsrWriteDispatch3(char a1, __int64 a2, unsigned int a3);
__int64 CpuCsrWriteDispatch4(char a1, __int64 a2, unsigned int a3);
__int64 CpuCsrWriteDispatch5(char a1, __int64 a2, __int64 a3);
__int64 CpuCsrWriteDispatch6(char a1, __int64 a2, __int64 a3, int a4);
__int64 CpuCsrWriteDispatch7(char a1, __int64 a2, __int64 a3);
__int64 CpuCsrWriteDispatch8(char a1, __int64 a2);
__int64 CpuCsrWriteDispatch9(char a1, __int64 a2, unsigned int a3);
__int64 CpuCsrWriteDispatch10(char a1, __int64 a2);
__int64 CpuCsrWriteCheckpoint(unsigned __int8 a1, unsigned __int8 a2, unsigned __int16 a3);
char CpuCsrParsePlatformConfig();
__int64 CpuCsrDriverEntry(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable);
__int64 CpuCsrPacketRead(__int64 a1, unsigned __int8 a2, unsigned __int8 a3, int a4);
__int64 CpuCsrPacketWrite(__int64 a1, unsigned __int8 a2, unsigned __int8 a3, int a4, ...);
__int64 CpuCsrPollWithRetry(__int64 a1, unsigned __int8 a2, __int64 a3, int a4);
void CpuCsrAssertHalt(__int64 a1, __int64 a2, __int64 a3);
__int64 CpuCsrZeroMem(__int64 p_psub_1794, unsigned __int64 n104);
unsigned __int32 PciCfgInDword(unsigned __int16 n0x508);
__int64 CpuCsrGetDebugProtocol();
__int64 CpuCsrDebugPrint(__int64 a1, __int64 a2, ...);
__int64 CpuCsrDebugAssert(__int64 a1, __int64 a2, __int64 a3);
char CpuCsrDebugEnabled();
bool CpuCsrDebugLevelEnabled(int n64);
void CpuCsrNotifyVirtualAddrChange();
__int64 CpuCsrCloseDebugEvent();
unsigned __int64 CpuCsrGetConfigTable(__int64 a1, _QWORD *a2);
__int64 CpuCsrGetHobList();
void CpuCsrNotifyEventStub();
__int64 CpuCsrRuntimeVirtualAddrCallback();
__int64 CpuCsrPciExpressVirtualAddrCallback();
__int64 CpuCsrPciExpressTranslateAddr(__int64 n1024064);
__int64 CpuCsrMicrosecondDelay(unsigned int n35);
__int64 CpuCsrGetPcdProtocol();
__int64 CpuCsrReadUnaligned64(__int64 a1);
__int64 CpuCsrPciExpressEnable(_WORD *a1);
__int64 CpuCsrFreePool();

// Module Entry Point EFI_STATUS EFIAPI ModuleEntryPoint(
 IN EFI_HANDLE ImageHandle,
 IN EFI_SYSTEM_TABLE *SystemTable
)
{
 signed __int64 v4; // rbx CpuCsrInitUefiBootServices(); /*0x1154*/
 v4 = CpuCsrDriverEntry(ImageHandle, SystemTable); /*0x1164*/
 if ( v4 < 0 ) /*0x116a*/
 CpuCsrUnloadDriver(); /*0x116c*/
 return v4; /*0x1179*/
}

__int64 CpuCsrCpuid(unsigned int a1, _DWORD *a2, _DWORD *a3, _DWORD *a4, _DWORD *a5)
{
 __int64 Result; // [rsp-8h] [rbp-10h]

 Result = a1; /*0x1073*/
 __asm { cpuid } /*0x1075*/
 if ( a4 ) /*0x107a*/
 *a4 = _RCX; /*0x107c*/
 if ( a2 ) /*0x1080*/
 *a2 = _RAX; /*0x1082*/
 if ( a3 ) /*0x1087*/
 *a3 = _RBX; /*0x1089*/
 if ( a5 ) /*0x1090*/
 *a5 = _RDX; /*0x1092*/
 return Result; /*0x1095*/
}

void CpuCsrCpuPause()
{
 _mm_pause(); /*0x1100*/
}

unsigned __int64 CpuCsrReadTsc()
{
 return __rdtsc(); /*0x1119*/
}

void CpuCsrEnableInterrupts()
{
 _enable(); /*0x1120*/
}

void CpuCsrDisableInterrupts()
{
 _disable(); /*0x1130*/
}

unsigned __int64 CpuCsrReadEflags()
{
 return __getcallerseflags(); /*0x1142*/
}

void CpuCsrInitUefiBootServices(__int64 a1, __int64 a2)
{
 __int64 v3; // r10 __int64 v4; // r10 __int64 Status; // rax __int64 Status; // rax __int64 Status; // rbx __int64 Status; // rax __int64 Status; // rbx __int64 v10; // rax __int64 Status; // rax __int64 Status; // rbx __int64 Status; // rax __int64 v14; // rax _BYTE *v15; // rax __int16 v16; // bx bool v17; // bl unsigned __int32 v18; // edi unsigned __int32 i; // eax qword_60D0 = a1; /*0x1195*/
 if ( !a1 ) /*0x11a9*/
 CpuCsrDebugAssert( /*0x11b8*/
 (__int64)"e:\\hs\\MdePkg\\Library\\UefiBootServicesTableLib\\UefiBootServicesTableLib.c",
 51,
 (__int64)"gImageHandle != ((void *) 0)");
 qword_60C0 = a2; /*0x11bd*/
 if ( !a2 ) /*0x11c7*/
 CpuCsrDebugAssert( /*0x11d6*/
 (__int64)"e:\\hs\\MdePkg\\Library\\UefiBootServicesTableLib\\UefiBootServicesTableLib.c",
 57,
 (__int64)"gST != ((void *) 0)");
 qword_60C8 = *(_QWORD *)(a2 + 96); /*0x11df*/
 if ( !qword_60C8 ) /*0x11e9*/
 CpuCsrDebugAssert( /*0x11f8*/
 (__int64)"e:\\hs\\MdePkg\\Library\\UefiBootServicesTableLib\\UefiBootServicesTableLib.c",
 63,
 (__int64)"gBS != ((void *) 0)");
 qword_60D8 = *(_QWORD *)(a2 + 88); /*0x1201*/
 if ( !qword_60D8 ) /*0x120b*/
 CpuCsrDebugAssert( /*0x121e*/
 (__int64)"e:\\hs\\MdePkg\\Library\\UefiRuntimeServicesTableLib\\UefiRuntimeServicesTableLib.c",
 47,
 (__int64)"gRT != ((void *) 0)");
 v3 = *(_QWORD *)(a2 + 96); /*0x122e*/
 qword_60E0 = *(_QWORD *)(a2 + 88); /*0x1235*/
 qword_60F8 = v3; /*0x1248*/
 (*(void ( **)(__int64, __int64, __int64 ( *)()))(v3 + 80))(513, 8, CpuCsrNotifyVirtualAddrChange); /*0x125a*/
 (*(void ( **)(__int64, __int64, __int64 ( *)(), _QWORD, __int64 *))(qword_60F8 + 80))( /*0x1282*/
 1610613250,
 8,
 CpuCsrCloseDebugEvent,
 0,
 &qword_60F0);
 CpuCsrGetHobList(); /*0x1285*/
 if ( !qword_60D8 ) /*0x1292*/
 CpuCsrDebugAssert((__int64)"e:\\hs\\MdePkg\\Library\\UefiRuntimeLib\\RuntimeLib.c", 95, (__int64)"gRT != ((void *) 0)"); /*0x12a5*/
 v4 = qword_60C8; /*0x12aa*/
 if ( !qword_60C8 ) /*0x12b4*/
 {
 CpuCsrDebugAssert((__int64)"e:\\hs\\MdePkg\\Library\\UefiRuntimeLib\\RuntimeLib.c", 96, (__int64)"gBS != ((void *) 0)"); /*0x12c8*/
 v4 = qword_60C8; /*0x12cd*/
 }
 qword_6178 = qword_60D8; /*0x12e2*/
 Status = (*(__int64 ( **)(__int64, __int64, __int64 ( *)()))(v4 + 368))(512, 16, CpuCsrRuntimeVirtualAddrCallback); /*0x130f*/
 if ( Status < 0 ) /*0x132c*/
 {
 CpuCsrDebugPrint(0x80000000LL, (__int64)"\nASSERT_EFI_ERROR (Status = %r)\n", Status); /*0x1336*/
 CpuCsrDebugAssert((__int64)"e:\\hs\\MdePkg\\Library\\UefiRuntimeLib\\RuntimeLib.c", 111, (__int64)"!EFI_ERROR (Status)"); /*0x1348*/
 }
 Status = (*(__int64 ( **)(__int64, __int64, __int64 ( *)(), _QWORD, void *, __int64 *))(qword_60C8 + 368))( /*0x137e*/
 512,
 16,
 nullsub_1,
 0,
 &unk_6060,
 &qword_6180);
 Status = Status; /*0x1384*/
 if ( Status < 0 ) /*0x138a*/
 {
 CpuCsrDebugPrint(0x80000000LL, (__int64)"\nASSERT_EFI_ERROR (Status = %r)\n", Status); /*0x1395*/
 CpuCsrDebugAssert((__int64)"e:\\hs\\MdePkg\\Library\\UefiRuntimeLib\\RuntimeLib.c", 122, (__int64)"!EFI_ERROR (Status)"); /*0x13a9*/
 CpuCsrDebugPrint(0x80000000LL, (__int64)"\nASSERT_EFI_ERROR (Status = %r)\n", Status); /*0x13b7*/
 CpuCsrDebugAssert( /*0x13cb*/
 (__int64)"e:\\hs\\Build\\HR6N0XMLK\\DEBUG_VS2015\\X64\\Build\\CpuCsrAccess\\DEBUG\\AutoGen.c",
 390,
 (__int64)"!EFI_ERROR (Status)");
 }
 Status = CpuCsrGetConfigTable(&unk_6090, &qword_6118); /*0x13de*/
 Status = Status; /*0x13e3*/
 if ( Status < 0 ) /*0x13e9*/
 {
 CpuCsrDebugPrint(0x80000000LL, (__int64)"\nASSERT_EFI_ERROR (Status = %r)\n", Status); /*0x13f4*/
 CpuCsrDebugAssert( /*0x1408*/
 (__int64)"e:\\hs\\MdePkg\\Library\\DxeServicesTableLib\\DxeServicesTableLib.c",
 64,
 (__int64)"!EFI_ERROR (Status)");
 }
 if ( !qword_6118 ) /*0x1415*/
 CpuCsrDebugAssert( /*0x142a*/
 (__int64)"e:\\hs\\MdePkg\\Library\\DxeServicesTableLib\\DxeServicesTableLib.c",
 65,
 (__int64)"gDS != ((void *) 0)");
 if ( Status < 0 ) /*0x1432*/
 {
 CpuCsrDebugPrint(0x80000000LL, (__int64)"\nASSERT_EFI_ERROR (Status = %r)\n", Status); /*0x143d*/
 CpuCsrDebugAssert( /*0x1451*/
 (__int64)"e:\\hs\\Build\\HR6N0XMLK\\DEBUG_VS2015\\X64\\Build\\CpuCsrAccess\\DEBUG\\AutoGen.c",
 393,
 (__int64)"!EFI_ERROR (Status)");
 }
 v10 = CpuCsrGetPcdProtocol(); /*0x1456*/
 qword_6130 = (*(__int64 ( **)(__int64))(v10 + 32))(5); /*0x1463*/
 Status = (*(__int64 ( **)(__int64, __int64, __int64 ( *)()))(qword_60C8 + 368))(512, 16, CpuCsrPciExpressVirtualAddrCallback); /*0x149c*/
 Status = Status; /*0x14a2*/
 if ( Status < 0 ) /*0x14a8*/
 {
 CpuCsrDebugPrint(0x80000000LL, (__int64)"\nASSERT_EFI_ERROR (Status = %r)\n", Status); /*0x14b3*/
 CpuCsrDebugAssert( /*0x14c7*/
 (__int64)"e:\\hs\\MdePkg\\Library\\DxeRuntimePciExpressLib\\PciExpressLib.c",
 141,
 (__int64)"!EFI_ERROR (Status)");
 CpuCsrDebugPrint(0x80000000LL, (__int64)"\nASSERT_EFI_ERROR (Status = %r)\n", Status); /*0x14d5*/
 CpuCsrDebugAssert( /*0x14e9*/
 (__int64)"e:\\hs\\Build\\HR6N0XMLK\\DEBUG_VS2015\\X64\\Build\\CpuCsrAccess\\DEBUG\\AutoGen.c",
 396,
 (__int64)"!EFI_ERROR (Status)");
 }
 if ( !qword_6148 ) /*0x14f6*/
 {
 Status = (*(__int64 ( **)(void *, _QWORD, __int64 *))(qword_60C8 + 320))(&unk_6020, 0, &qword_6148); /*0x150f*/
 if ( Status < 0 ) /*0x1518*/
 {
 CpuCsrDebugPrint(0x80000000LL, (__int64)"\nASSERT_EFI_ERROR (Status = %r)\n", Status); /*0x1523*/
 CpuCsrDebugAssert((__int64)"e:\\hs\\CpRcPkg\\Library\\DxeUsraLib\\DxeUsraIface.c", 46, (__int64)"!EFI_ERROR (Status)"); /*0x1537*/
 }
 if ( !qword_6148 ) /*0x1544*/
 CpuCsrDebugAssert((__int64)"e:\\hs\\CpRcPkg\\Library\\DxeUsraLib\\DxeUsraIface.c", 47, (__int64)"mUsra != ((void *) 0)"); /*0x1559*/
 }
 if ( *(char *)CpuCsrPciExpressTranslateAddr(1024068) >= 0 ) /*0x156e*/
 {
 v14 = CpuCsrPciExpressTranslateAddr(1024064); /*0x1573*/
 CpuCsrPciExpressEnable(v14); /*0x157b*/
 v15 = (_BYTE *)CpuCsrPciExpressTranslateAddr(1024068); /*0x1582*/
 *v15 |= 0x80u; /*0x158c*/
 }
 v16 = CpuCsrReadEflags(); /*0x1593*/
 disable_w(); /*0x1596*/
 v17 = (v16 & 0x200) != 0; /*0x15a5*/
 v18 = PciCfgInDword(0x508u) & 0xFFFFFF; /*0x15af*/
 _rdtsc_w(); /*0x15b5*/
 for ( i = PciCfgInDword(0x508u); ((v18 + 357 - i) & 0x800000) == 0; i = PciCfgInDword(0x508u) ) /*0x15bc*/
 mm_pause_w(); /*0x15c9*/
 _rdtsc_w(); /*0x15e3*/
 if ( v17 ) /*0x15ea*/
 CpuCsrEnableInterrupts(); /*0x15ec*/
 else disable_w(); /*0x15f3*/
}

__int64 CpuCsrUnloadDriver()
{
 __int64 Status; // rax __int64 Status; // rbx __int64 v2; // rax __int64 Status; // rax __int64 Status; // rax __int64 Status; // rbx if ( qword_6120 ) /*0x162d*/
 CpuCsrFreePool(); /*0x162f*/
 Status = (*(__int64 ( **)(__int64))(qword_60C8 + 112))(qword_6140); /*0x1642*/
 Status = Status; /*0x1658*/
 if ( Status < 0 ) /*0x165e*/
 {
 CpuCsrDebugPrint(0x80000000LL, (__int64)"\nASSERT_EFI_ERROR (Status = %r)\n", Status); /*0x1668*/
 CpuCsrDebugAssert( /*0x167c*/
 (__int64)"e:\\hs\\MdePkg\\Library\\DxeRuntimePciExpressLib\\PciExpressLib.c",
 178,
 (__int64)"!EFI_ERROR (Status)");
 CpuCsrDebugPrint(0x80000000LL, (__int64)"\nASSERT_EFI_ERROR (Status = %r)\n", Status); /*0x1689*/
 CpuCsrDebugAssert( /*0x169d*/
 (__int64)"e:\\hs\\Build\\HR6N0XMLK\\DEBUG_VS2015\\X64\\Build\\CpuCsrAccess\\DEBUG\\AutoGen.c",
 439,
 (__int64)"!EFI_ERROR (Status)");
 }
 v2 = qword_60C8; /*0x16a2*/
 if ( !qword_60C8 ) /*0x16ac*/
 {
 CpuCsrDebugAssert((__int64)"e:\\hs\\MdePkg\\Library\\UefiRuntimeLib\\RuntimeLib.c", 151, (__int64)"gBS != ((void *) 0)"); /*0x16c1*/
 v2 = qword_60C8; /*0x16c6*/
 }
 Status = (*(__int64 ( **)(__int64))(v2 + 112))(qword_6170); /*0x16d4*/
 if ( Status < 0 ) /*0x16da*/
 {
 CpuCsrDebugPrint(0x80000000LL, (__int64)"\nASSERT_EFI_ERROR (Status = %r)\n", Status); /*0x16e5*/
 CpuCsrDebugAssert((__int64)"e:\\hs\\MdePkg\\Library\\UefiRuntimeLib\\RuntimeLib.c", 153, (__int64)"!EFI_ERROR (Status)"); /*0x16f9*/
 }
 Status = (*(__int64 ( **)(__int64))(qword_60C8 + 112))(qword_6180); /*0x170c*/
 Status = Status; /*0x170f*/
 if ( Status < 0 ) /*0x1715*/
 {
 CpuCsrDebugPrint(0x80000000LL, (__int64)"\nASSERT_EFI_ERROR (Status = %r)\n", Status); /*0x1720*/
 CpuCsrDebugAssert((__int64)"e:\\hs\\MdePkg\\Library\\UefiRuntimeLib\\RuntimeLib.c", 156, (__int64)"!EFI_ERROR (Status)"); /*0x1734*/
 CpuCsrDebugPrint(0x80000000LL, (__int64)"\nASSERT_EFI_ERROR (Status = %r)\n", Status); /*0x1742*/
 CpuCsrDebugAssert( /*0x1756*/
 (__int64)"e:\\hs\\Build\\HR6N0XMLK\\DEBUG_VS2015\\X64\\Build\\CpuCsrAccess\\DEBUG\\AutoGen.c",
 442,
 (__int64)"!EFI_ERROR (Status)");
 }
 (*(void ( **)(__int64))(qword_60F8 + 112))(qword_60E8); /*0x1769*/
 return (*(__int64 ( **)(__int64))(qword_60F8 + 112))(qword_60F0);
}

__int64 CpuCsrWriteDispatch1(char a1, int a2, int a3, __int64 a4)
{
 int v4; // r9d v4 = a3; /*0x17b4*/
 LOBYTE(a3) = a2; /*0x17b9*/
 LOBYTE(a2) = a1; /*0x17be*/
 return sub_2118(qword_60A0, a2, a3, v4, a4); /*0x17ce*/
}

__int64 CpuCsrReadWriteDispatch(unsigned __int8 a1, __int64 a2, __int64 a3)
{
 unsigned int v4; // [rsp+50h] [rbp+18h]

 v4 = a3; /*0x17d4*/
 if ( BYTE3(a3) != 7 && BYTE3(a3) != 11 && BYTE3(a3) != 8 ) /*0x1819*/
 return CpuCsrPacketRead(qword_60A0, a1, a2, a3); /*0x184e*/
 LOBYTE(a3) = a2; /*0x1820*/
 LOBYTE(a2) = a1; /*0x1825*/
 return sub_268C(qword_60A0, a2, a3, v4); /*0x1853*/
}

__int64 CpuCsrWriteDispatch2(unsigned __int8 a1, unsigned __int8 a2, int a3, int a4)
{
 int v6; // [rsp+60h] [rbp+18h]

 v6 = a3; /*0x185d*/
 if ( HIBYTE(a3) != 7 && HIBYTE(a3) != 11 && HIBYTE(a3) != 8 ) /*0x18a2*/
 return CpuCsrPacketWrite(qword_60A0, a1, a2, a3, a4); /*0x18e5*/
 LOBYTE(a3) = a2; /*0x18b1*/
 return sub_27D8(qword_60A0, a1, a3, v6, a4); /*0x18ea*/
}

__int64 CpuCsrWriteDispatch3(char a1, __int64 a2, unsigned int a3)
{
 __int64 v3; // r9 __int64 v4; // r8 v3 = a3; /*0x1901*/
 v4 = (unsigned int)a2; /*0x1906*/
 LOBYTE(a2) = a1; /*0x190b*/
 return sub_29E8(qword_60A0, a2, v4, v3); /*0x191b*/
}

__int64 CpuCsrWriteDispatch4(char a1, __int64 a2, unsigned int a3)
{
 __int64 v3; // r9 __int64 v4; // r8 v3 = a3; /*0x1931*/
 v4 = (unsigned int)a2; /*0x1936*/
 LOBYTE(a2) = a1; /*0x190b*/
 return sub_2AC0(qword_60A0, a2, v4, v3); /*0x195f*/
}

__int64 CpuCsrWriteDispatch5(char a1, __int64 a2, __int64 a3)
{
 __int64 v3; // r9 v3 = (unsigned int)a3; /*0x1975*/
 LOBYTE(a3) = a2; /*0x197a*/
 LOBYTE(a2) = a1; /*0x197f*/
 return sub_2760(qword_60A0, a2, a3, v3); /*0x198f*/
}

__int64 CpuCsrWriteDispatch6(char a1, __int64 a2, __int64 a3, int a4)
{
 __int64 v4; // r9 v4 = (unsigned int)a3; /*0x19b2*/
 LOBYTE(a3) = a2; /*0x19b7*/
 LOBYTE(a2) = a1; /*0x19bc*/
 return sub_286C(qword_60A0, a2, a3, v4, a4); /*0x19cc*/
}

__int64 CpuCsrWriteDispatch7(char a1, __int64 a2, __int64 a3)
{
 __int64 v3; // r9 v3 = (unsigned int)a3; /*0x19e5*/
 LOBYTE(a3) = a2; /*0x19ea*/
 LOBYTE(a2) = a1; /*0x19ef*/
 return sub_28E8(qword_60A0, a2, a3, v3); /*0x19ff*/
}

__int64 CpuCsrWriteDispatch8(char a1, __int64 a2)
{
 __int64 v2; // r8 v2 = (unsigned int)a2; /*0x1a10*/
 LOBYTE(a2) = a1; /*0x1a15*/
 return sub_22A8(qword_60A0, a2, v2); /*0x1a25*/
}

__int64 CpuCsrWriteDispatch9(char a1, __int64 a2, unsigned int a3)
{
 __int64 v3; // r9 __int64 v4; // r8 v3 = a3; /*0x1a3d*/
 v4 = (unsigned int)a2; /*0x1a42*/
 LOBYTE(a2) = a1; /*0x1a47*/
 return sub_23E0(qword_60A0, a2, v4, v3); /*0x1a57*/
}

__int64 CpuCsrWriteDispatch10(char a1, __int64 a2)
{
 __int64 v2; // r8 v2 = (unsigned int)a2; /*0x1a68*/
 LOBYTE(a2) = a1; /*0x1a6d*/
 return sub_2518(qword_60A0, a2, v2); /*0x1a7d*/
}

__int64 CpuCsrWriteCheckpoint(unsigned __int8 a1, unsigned __int8 a2, unsigned __int16 a3)
{
 __int64 v3; // rdx __int64 result; // rax unsigned __int16 Result; // [rsp+34h] [rbp-14h]
 int v6; // [rsp+38h] [rbp-10h]

 Result = a2 | (a1 << 8); /*0x1aaa*/
 v6 = a3 | (Result << 16); /*0x1abe*/
 CpuCsrPacketWrite(qword_60A0, 0, 0, 318914684, v6); /*0x1ade*/
 dword_6270 = v6; /*0x1ae7*/
 LOBYTE(v3) = HIBYTE(v6); /*0x1af6*/
 sub_3960(128, v3); /*0x1afd*/
 if ( CpuCsrDebugEnabled() && CpuCsrDebugLevelEnabled(64) )
 CpuCsrDebugPrint(64, (__int64)"Checkpoint Code: Socket %d, 0x%02X, 0x%02X, 0x%04X\n", 0, a1, a2, a3);
 result = (unsigned int)CpuCsrPacketRead(qword_60A0, 0, 0, 318914744) >> 16; /*0x1b7d*/
 if ( (_DWORD)result == Result ) /*0x1b87*/
 {
 if ( CpuCsrDebugEnabled() && CpuCsrDebugLevelEnabled(64) ) /*0x1b9a*/
 CpuCsrDebugPrint(64, (__int64)"Breakpoint match found. S:%x waiting...\n", 0); /*0x1bba*/
 do /*0x1bf6*/
 result = (unsigned int)CpuCsrPacketRead(qword_60A0, 0, 0, 318914744) >> 16; /*0x1bed*/
 while ( Result == (_DWORD)result ); /*0x1bf6*/
 }
 return result; /*0x1bfa*/
}

char CpuCsrParsePlatformConfig()
{
 char result; // al unsigned __int8 i; // [rsp+0h] [rbp-18h]
 unsigned __int8 k; // [rsp+1h] [rbp-17h]
 unsigned __int8 m; // [rsp+2h] [rbp-16h]
 unsigned __int8 j; // [rsp+3h] [rbp-15h]

 for ( i = 0; i < 4u; ++i ) /*0x1c12*/
 {
 byte_61A0[i] = *(_BYTE *)(qword_6268 + 43LL *i + 41); /*0x1c4c*/
 byte_61BC[i] = *(_BYTE *)(qword_6268 + 43LL *i + 29); /*0x1c6e*/
 byte_61C4[i] = *(_BYTE *)(qword_6268 + 43LL *i + 30); /*0x1c90*/
 byte_61C8[i] = *(_BYTE *)(qword_6268 + 43LL *i + 31); /*0x1cb2*/
 for ( j = 0; j < 6u; ++j ) /*0x1cb5*/
 byte_61A4[6 *i + j] = *(_BYTE *)(qword_6268 + 43LL *i + 28 + j + 14); /*0x1d08*/
 for ( k = 0; k < 2u; ++k ) /*0x1d0e*/
 *((_BYTE *)&qword_61DA + 2 *i + k + 3) = *(_BYTE *)(qword_6268 + 2LL *i + 2094 + k); /*0x1d59*/
 for ( m = 0; m < 6u; ++m ) /*0x1d5f*/
 byte_61E5[6 *i + m] = *(_BYTE *)(qword_6268 + 6LL *i + 2131 + m); /*0x1db4*/
 }
 byte_61CC = *(_BYTE *)(qword_6268 + 1780); /*0x1dcc*/
 byte_61CD = *(_BYTE *)(qword_6268 + 1777); /*0x1ddf*/
 dword_61CE = *(_DWORD *)(qword_6268 + 2067); /*0x1df2*/
 dword_61D2 = *(_DWORD *)(qword_6268 + 2071); /*0x1e05*/
 dword_61D6 = *(_DWORD *)(qword_6268 + 280); /*0x1e18*/
 BYTE2(qword_61DA) = *(_BYTE *)(qword_6268 + 2102); /*0x1e2b*/
 LOBYTE(qword_61DA) = *(_BYTE *)(qword_6268 + 2103); /*0x1e3e*/
 result = *(_BYTE *)(qword_6268 + 2104); /*0x1e4b*/
 BYTE1(qword_61DA) = result; /*0x1e51*/
 return result; /*0x1e57*/
}

__int64 CpuCsrDriverEntry(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
{
 _BYTE v3[8]; // [rsp+20h] [rbp-28h] BYREF __int64 Status; // [rsp+28h] [rbp-20h]
 _QWORD v5[3]; // [rsp+30h] [rbp-18h] BYREF v5[0] = 0; /*0x1e6a*/
 Status = (*(__int64 ( **)(void *, _QWORD, __int64 *))(qword_60C8 + 320))(&unk_6070, 0, &qword_60B0); /*0x1e90*/
 if ( qword_60B0 ) /*0x1e9d*/
 {
 (*(void ( **)(__int64, _BYTE *))qword_60B0)(qword_60B0, v3); /*0x1eb9*/
 (*(void ( **)(__int64, __int64 *))(qword_60B0 + 8))(qword_60B0, &qword_60A8); /*0x1ed0*/
 }
 else
 {
 v3[0] = 0; /*0x1e9f*/
 }
 Status = (*(__int64 ( **)(void *, _QWORD, __int64 *))(qword_60C8 + 320))(&unk_6030, 0, &qword_6160); /*0x1ef0*/
 if ( CpuCsrDebugEnabled() && Status < 0 ) /*0x1f07*/
 {
 if ( CpuCsrDebugEnabled() && CpuCsrDebugLevelEnabled(0x80000000) ) /*0x1f1a*/
 CpuCsrDebugPrint(0x80000000LL, (__int64)"\nASSERT_EFI_ERROR (Status = %r)\n", Status); /*0x1f37*/
 CpuCsrDebugAssert((__int64)"e:\\hs\\PurleySktPkg\\Dxe\\CpuCsrAccess\\CpuCsrAccess.c", 460, (__int64)"!EFI_ERROR (Status)"); /*0x1f5b*/
 }
 CpuCsrZeroMem(&psub_1794, 104); /*0x1f72*/
 qword_6268 = *(_QWORD *)qword_6160; /*0x1f81*/
 psub_1794 = (__int64)CpuCsrWriteDispatch1; /*0x1f8f*/
 psub_17D4 = (__int64)CpuCsrReadWriteDispatch; /*0x1f9d*/
 psub_1858 = (__int64)CpuCsrWriteDispatch2; /*0x1fab*/
 psub_18F0 = (__int64)CpuCsrWriteDispatch3; /*0x1fb9*/
 psub_1920 = (__int64)CpuCsrWriteDispatch4; /*0x1fc7*/
 psub_1964 = (__int64)CpuCsrWriteDispatch5; /*0x1fd5*/
 psub_1994 = (__int64)CpuCsrWriteDispatch6; /*0x1fe3*/
 psub_19D4 = (__int64)CpuCsrWriteDispatch7; /*0x1ff1*/
 psub_1A04 = (__int64)CpuCsrWriteDispatch8; /*0x1fff*/
 psub_1A2C = (__int64)CpuCsrWriteDispatch9; /*0x200d*/
 psub_1A5C = (__int64)CpuCsrWriteDispatch10; /*0x201b*/
 psub_1A84 = (__int64)CpuCsrWriteCheckpoint; /*0x2029*/
 psub_1C00 = (__int64)CpuCsrParsePlatformConfig; /*0x2037*/
 CpuCsrParsePlatformConfig(); /*0x203e*/
 if ( v3[0] ) /*0x204a*/
 Status = (*(__int64 ( **)(_QWORD *, void *, _QWORD, __int64 *))(qword_60A8 + 168))( /*0x206f*/
 v5,
 &unk_6010,
 0,
 &psub_1794);
 else Status = (*(__int64 ( **)(_QWORD *, void *, _QWORD, __int64 *))(qword_60C8 + 128))( /*0x2099*/
 v5,
 &unk_6010,
 0,
 &psub_1794);
 if ( CpuCsrDebugEnabled() && Status < 0 ) /*0x20b0*/
 {
 if ( CpuCsrDebugEnabled() && CpuCsrDebugLevelEnabled(0x80000000) ) /*0x20c3*/
 CpuCsrDebugPrint(0x80000000LL, (__int64)"\nASSERT_EFI_ERROR (Status = %r)\n", Status); /*0x20e0*/
 CpuCsrDebugAssert((__int64)"e:\\hs\\PurleySktPkg\\Dxe\\CpuCsrAccess\\CpuCsrAccess.c", 500, (__int64)"!EFI_ERROR (Status)"); /*0x2104*/
 }
 return 0; /*0x2111*/
}

__int64 CpuCsrPacketRead(__int64 a1, unsigned __int8 a2, unsigned __int8 a3, int a4)
{
 _DWORD v5[6]; // [rsp+20h] [rbp-18h] BYREF unsigned int Result; // [rsp+48h] [rbp+10h] BYREF Result = 0; /*0x2224*/
 v5[3] = 0; /*0x2229*/
 v5[0] = a4; /*0x223f*/
 v5[1] = a3 | (a2 << 8); /*0x224b*/
 v5[2] = 32770; /*0x2254*/
 (*(void ( **)(_DWORD *, unsigned int *))qword_6148)(v5, &Result); /*0x225c*/
 return Result; /*0x2262*/
}

__int64 CpuCsrPacketWrite(__int64 a1, unsigned __int8 a2, unsigned __int8 a3, int a4, ...)
{
 _DWORD Status[6]; // [rsp+20h] [rbp-18h] BYREF va_list va; // [rsp+60h] [rbp+28h] BYREF va_start(va, a4);
 Status[3] = 0; /*0x226c*/
 Status[2] = 2; /*0x2282*/
 Status[1] = a3 | (a2 << 8); /*0x2291*/
 Status[0] = a4; /*0x229a*/
 return (*(__int64 ( **)(_DWORD *, char *))(qword_6148 + 8))(Status, (char *)va); /*0x22a2*/
}

__int64 CpuCsrPollWithRetry(__int64 a1, unsigned __int8 a2, __int64 a3, int a4)
{
 int Result; // ebx __int64 v7; // rcx __int64 result; // rax Result = 500; /*0x29a0*/
 if ( (int)CpuCsrPacketRead(a1, a2, 0, a4) >= 0 ) /*0x29ac*/
 return 0; /*0x29ac*/
 do /*0x29cd*/
 {
 CpuCsrMicrosecondDelay(35); /*0x29b3*/
 result = CpuCsrPacketRead(v7, a2, 0, a4); /*0x29c1*/
 --Result; /*0x29c6*/
 }
 while ( Result && (int)result < 0 ); /*0x29cd*/
 if ( (int)result >= 0 ) /*0x29d1*/
 return 0; /*0x29d3*/
 return result; /*0x29df*/
}

void CpuCsrAssertHalt(__int64 a1, __int64 a2, __int64 a3)
{
 unsigned __int16 v3; // [rsp+50h] [rbp+18h]

 v3 = a3; /*0x2e9b*/
 if ( a1 ) /*0x2ead*/
 {
 a3 = (unsigned int)a3; /*0x2eaf*/
 if ( (a3 & 0xFFFFFF00) == 0xFFFFFF00 ) /*0x2ebf*/
 {
 a3 = (unsigned __int8)a3; /*0x2ec1*/
 v3 = (unsigned __int8)a3; /*0x2ec5*/
 }
 if ( (a3 & 0xFFFF0000) == 0xFFFF0000 ) /*0x2ed5*/
 a3 = v3; /*0x2edc*/
 CpuCsrDebugPrint(0x80000000LL, a2, a3); /*0x2ee6*/
 }
 while ( 1 ) /*0x2ef0*/
 ; /*0x2ef0*/
}

__int64 CpuCsrZeroMem(__int64 p_psub_1794, unsigned __int64 n104)
{
 if ( !n104 ) /*0x3863*/
 return p_psub_1794; /*0x3865*/
 if ( !p_psub_1794 ) /*0x386d*/
 CpuCsrDebugAssert( /*0x3880*/
 (__int64)"e:\\hs\\MdePkg\\Library\\BaseMemoryLibRepStr\\ZeroMemWrapper.c",
 53,
 (__int64)"Buffer != ((void *) 0)");
 if ( n104 > -p_psub_1794 ) /*0x388e*/
 CpuCsrDebugAssert( /*0x38a3*/
 (__int64)"e:\\hs\\MdePkg\\Library\\BaseMemoryLibRepStr\\ZeroMemWrapper.c",
 54,
 (__int64)"Length <= (0xFFFFFFFFFFFFFFFFULL - (UINTN)Buffer + 1)");
 return sub_1000(p_psub_1794, n104); /*0x38b8*/
}

unsigned __int32 PciCfgInDword(unsigned __int16 n0x508)
{
 if ( (n0x508 & 3) != 0 ) /*0x3974*/
 CpuCsrDebugAssert((__int64)"e:\\hs\\MdePkg\\Library\\BaseIoLibIntrinsic\\IoLibMsc.c", 193, (__int64)"(Port & 3) == 0"); /*0x3989*/
 return __indword(n0x508); /*0x3992*/
}

__int64 CpuCsrGetDebugProtocol()
{
 __int64 result; // rax unsigned __int64 n0x10; // rbx __int64 v2; // rax __int64 Result; // rcx result = qword_6100; /*0x39a2*/
 if ( !qword_6100 ) /*0x39ae*/
 {
 if ( qword_60F8 /*0x39dc*/
 && (n0x10 = (*(__int64 ( **)(__int64))(qword_60F8 + 24))(31),
 (*(void ( **)(unsigned __int64))(qword_60F8 + 32))(n0x10),
 n0x10 <= 0x10) )
 {
 v2 = (*(__int64 ( **)(void *, _QWORD, __int64 *))(qword_60F8 + 320))(&unk_6000, 0, &qword_6100); /*0x39f5*/
 Result = qword_6100; /*0x39fb*/
 if ( v2 < 0 ) /*0x3a05*/
 Result = 0; /*0x3a05*/
 qword_6100 = Result; /*0x3a09*/
 return Result; /*0x3a10*/
 }
 else
 {
 return 0; /*0x39bc*/
 }
 }
 return result; /*0x3a18*/
}

__int64 CpuCsrDebugPrint(__int64 a1, __int64 a2, ...)
{
 __int64 result; // rax __int64 v4; // r8 __int64 ( **v5)(__int64, __int64, __int64 *); // r9 unsigned __int8 v6; // al unsigned __int8 n3; // al int Result; // edx va_list va; // [rsp+40h] [rbp+18h] BYREF va_start(va, a2);
 result = CpuCsrGetDebugProtocol(); /*0x3a37*/
 v4 = 0; /*0x3a3c*/
 v5 = (__int64 ( **)(__int64, __int64, __int64 *))result; /*0x3a3f*/
 if ( result ) /*0x3a45*/
 {
 v6 = __inbyte(0x70u); /*0x3a4b*/
 __outbyte(0x70u, v6 & 0x80 | 0x4B); /*0x3a50*/
 Result = 113; /*0x3a51*/
 n3 = __inbyte(0x71u); /*0x3a55*/
 LOBYTE(Result) = n3; /*0x3a56*/
 if ( n3 > 3u ) /*0x3a5a*/
 {
 Result = 3; /*0x3a63*/
 if ( Result ) /*0x3a69*/
 Result = (unsigned __int8)Result; /*0x3a69*/
 }
 result = (unsigned int)(Result - 1); /*0x3a6c*/
 if ( (unsigned __int8)(Result - 1) <= 0xFDu ) /*0x3a71*/
 {
 result = 2147483652LL; /*0x3a76*/
 v4 = 2147483718LL; /*0x3a7b*/
 if ( (_BYTE)Result == 1 ) /*0x3a81*/
 v4 = 2147483652LL; /*0x3a81*/
 }
 if ( (v4 & a1) != 0 ) /*0x3a88*/
 return (*v5)(a1, a2, (__int64 *)va); /*0x3a97*/
 }
 return result; /*0x3a9a*/
}

__int64 CpuCsrDebugAssert(__int64 a1, __int64 a2, __int64 a3)
{
 __int64 result; // rax result = CpuCsrGetDebugProtocol(); /*0x3ab8*/
 if ( result ) /*0x3ac0*/
 return (*(__int64 ( **)(__int64, __int64, __int64))(result + 8))(a1, a2, a3); /*0x3acb*/
 return result; /*0x3ad8*/
}

char CpuCsrDebugEnabled()
{
 return 1; /*0x3ae2*/
}

bool CpuCsrDebugLevelEnabled(int n64)
{
 return n64 != 0; /*0x3ae9*/
}

void CpuCsrNotifyVirtualAddrChange()
{
 qword_60F8 = 0; /*0x3aec*/
}

__int64 CpuCsrCloseDebugEvent()
{
 __int64 result; // rax if ( qword_6100 ) /*0x3b04*/
 return (*(__int64 ( **)(_QWORD, __int64 *))(qword_60E0 + 64))(0, &qword_6100); /*0x3b16*/
 return result; /*0x3b19*/
}

unsigned __int64 CpuCsrGetConfigTable(__int64 a1, _QWORD *a2)
{
 __int64 Index; // rdi __int64 Index; // rbx __int64 i; // r14 if ( !a1 ) /*0x3b42*/
 CpuCsrDebugAssert((__int64)"e:\\hs\\MdePkg\\Library\\UefiLib\\UefiLib.c", 97, (__int64)"TableGuid != ((void *) 0)"); /*0x3b55*/
 if ( !a2 ) /*0x3b5d*/
 CpuCsrDebugAssert((__int64)"e:\\hs\\MdePkg\\Library\\UefiLib\\UefiLib.c", 98, (__int64)"Table != ((void *) 0)"); /*0x3b70*/
 Index = qword_60C0; /*0x3b75*/
 Index = 0; /*0x3b7c*/
 *a2 = 0; /*0x3b7e*/
 if ( !*(_QWORD *)(Index + 104) ) /*0x3b82*/
 return 0x800000000000000EuLL; /*0x3bab*/
 for ( i = 0; !(unsigned __int8)sub_3E38(a1, i + *(_QWORD *)(Index + 112)); i += 24 ) /*0x3b88*/
 {
 if ( (unsigned __int64)++Index >= *(_QWORD *)(Index + 104) ) /*0x3ba9*/
 return 0x800000000000000EuLL; /*0x3ba9*/
 }
 *a2 = *(_QWORD *)(*(_QWORD *)(Index + 112) + 24 *Index + 16); /*0x3bdf*/
 return 0; /*0x3bc9*/
}

__int64 CpuCsrGetHobList()
{
 __int64 result; // rax signed __int64 Status; // rax result = qword_6108; /*0x3be8*/
 if ( !qword_6108 ) /*0x3bf2*/
 {
 Status = CpuCsrGetConfigTable((__int64)&unk_6050, &qword_6108); /*0x3c02*/
 if ( Status < 0 ) /*0x3c0a*/
 {
 CpuCsrDebugPrint(0x80000000LL, (__int64)"\nASSERT_EFI_ERROR (Status = %r)\n", Status); /*0x3c1b*/
 CpuCsrDebugAssert((__int64)"e:\\hs\\MdePkg\\Library\\DxeHobLib\\HobLib.c", 54, (__int64)"!EFI_ERROR (Status)"); /*0x3c33*/
 }
 result = qword_6108; /*0x3c38*/
 if ( !qword_6108 ) /*0x3c42*/
 {
 CpuCsrDebugAssert((__int64)"e:\\hs\\MdePkg\\Library\\DxeHobLib\\HobLib.c", 55, (__int64)"mHobList != ((void *) 0)"); /*0x3c55*/
 return qword_6108; /*0x3c5a*/
 }
 }
 return result; /*0x3c61*/
}

void nullsub_1()
{
 ; /*0x3c68*/
}

__int64 CpuCsrRuntimeVirtualAddrCallback()
{
 __int64 result; // rax result = (*(__int64 ( **)(_QWORD, __int64 *))(qword_60D8 + 64))(0, &qword_6178); /*0x3c80*/
 byte_6110 = 1; /*0x3c83*/
 return result; /*0x3c8a*/
}

__int64 CpuCsrPciExpressVirtualAddrCallback()
{
 __int64 result; // rax unsigned __int64 Index; // rbx __int64 Result; // rdi result = qword_6120; /*0x3c9a*/
 Index = 0; /*0x3ca1*/
 if ( qword_6120 ) /*0x3ca6*/
 {
 if ( qword_6128 ) /*0x3caf*/
 {
 Result = 0; /*0x3cb1*/
 while ( 1 ) /*0x3cc3*/
 {
 (*(void ( **)(_QWORD, __int64))(qword_60D8 + 64))(0, Result + result + 8); /*0x3cc3*/
 ++Index; /*0x3cc6*/
 Result += 16; /*0x3cc9*/
 if ( Index >= qword_6128 ) /*0x3cd4*/
 break; /*0x3cd4*/
 result = qword_6120; /*0x3cd6*/
 }
 }
 return (*(__int64 ( **)(_QWORD, __int64 *))(qword_60D8 + 64))(0, &qword_6120); /*0x3cef*/
 }
 return result; /*0x3cf7*/
}

__int64 CpuCsrPciExpressTranslateAddr(__int64 n1024064)
{
 __int64 Result; // rbx unsigned __int64 Index; // rax _QWORD *v4; // rcx if ( (n1024064 & 0xFFFFFFFFF0000000uLL) != 0 ) /*0x3d10*/
 CpuCsrDebugAssert( /*0x3d25*/
 (__int64)"e:\\hs\\MdePkg\\Library\\DxeRuntimePciExpressLib\\PciExpressLib.c",
 203,
 (__int64)"((Address) & ~0xfffffff) == 0");
 Result = qword_6130 + n1024064; /*0x3d2a*/
 Index = 0; /*0x3d31*/
 if ( byte_6110 ) /*0x3d39*/
 {
 if ( *(_QWORD *)(qword_6120 + 16 *qword_6138) == (Result & 0xFFFFFFFFFFFFF000uLL) ) /*0x3d5a*/
 {
 return *(_QWORD *)(qword_6120 + 16 *qword_6138 + 8) + (Result & 0xFFF); /*0x3d62*/
 }
 else
 {
 if ( !qword_6128 ) /*0x3d73*/
 {
LABEL_10:
 CpuCsrDebugAssert( /*0x3d89*/
 (__int64)"e:\\hs\\MdePkg\\Library\\DxeRuntimePciExpressLib\\PciExpressLib.c",
 246,
 (__int64)"((BOOLEAN)(0==1))");
 __debugbreak(); /*0x3da1*/
 }
 v4 = (_QWORD *)qword_6120; /*0x3d75*/
 while ( *v4 != (Result & 0xFFFFFFFFFFFFF000uLL) ) /*0x3d7b*/
 {
 ++Index; /*0x3d7d*/
 v4 += 2; /*0x3d80*/
 if ( Index >= qword_6128 ) /*0x3d87*/
 goto LABEL_10; /*0x3d87*/
 }
 qword_6138 = Index; /*0x3dab*/
 return *(_QWORD *)(qword_6120 + 16 *Index + 8) + (Result & 0xFFF); /*0x3dbb*/
 }
 }
 return Result; /*0x3da5*/
}

__int64 CpuCsrMicrosecondDelay(unsigned int n35)
{
 unsigned int Result; // ebx int n0x400000; // edi unsigned __int32 v3; // esi __int64 result; // rax Result = n35 >> 22; /*0x3ddc*/
 n0x400000 = n35 & 0x3FFFFF; /*0x3de4*/
 do /*0x3e20*/
 {
 v3 = n0x400000 + (PciCfgInDword(0x508u) & 0xFFFFFF); /*0x3dfa*/
 n0x400000 = 0x400000; /*0x3dfc*/
 while ( ((v3 - PciCfgInDword(0x508u)) & 0x800000) == 0 ) /*0x3e18*/
 mm_pause_w(); /*0x3e03*/
 result = Result--; /*0x3e1a*/
 }
 while ( (_DWORD)result ); /*0x3e20*/
 return result; /*0x3e31*/
}

__int64 CpuCsrGetPcdProtocol()
{
 __int64 result; // rax __int64 Status; // rax result = qword_6150; /*0x3ea4*/
 if ( !qword_6150 ) /*0x3eae*/
 {
 Status = (*(__int64 ( **)(void *, _QWORD, __int64 *))(qword_60C8 + 320))(&unk_6040, 0, &qword_6150); /*0x3ec7*/
 if ( Status < 0 ) /*0x3ed0*/
 {
 CpuCsrDebugPrint(0x80000000LL, (__int64)"\nASSERT_EFI_ERROR (Status = %r)\n", Status); /*0x3ee1*/
 CpuCsrDebugAssert((__int64)"e:\\hs\\MdePkg\\Library\\DxePcdLib\\DxePcdLib.c", 78, (__int64)"!EFI_ERROR (Status)"); /*0x3ef9*/
 }
 result = qword_6150; /*0x3efe*/
 if ( !qword_6150 ) /*0x3f08*/
 {
 CpuCsrDebugAssert((__int64)"e:\\hs\\MdePkg\\Library\\DxePcdLib\\DxePcdLib.c", 79, (__int64)"mPcd != ((void *) 0)"); /*0x3f1b*/
 return qword_6150; /*0x3f20*/
 }
 }
 return result; /*0x3f27*/
}

__int64 CpuCsrReadUnaligned64(__int64 a1)
{
 if ( !a1 ) /*0x3f38*/
 CpuCsrDebugAssert((__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\Unaligned.c", 192, (__int64)"Buffer != ((void *) 0)"); /*0x3f4d*/
 return *(_QWORD *)a1; /*0x3f55*/
}

__int64 CpuCsrPciExpressEnable(_WORD *a1)
{
 if ( ((unsigned __int8)a1 & 1) != 0 ) /*0x3f68*/
 CpuCsrDebugAssert((__int64)"e:\\hs\\MdePkg\\Library\\BaseIoLibIntrinsic\\IoLib.c", 183, (__int64)"(Address & 1) == 0"); /*0x3f7d*/
 *a1 = 1280; /*0x3f87*/
 return 1280; /*0x3f8a*/
}

__int64 CpuCsrFreePool()
{
 __int64 result; // rax result = (*(__int64 ( **)(__int64))(qword_60C8 + 72))(qword_6120); /*0x3fa2*/
 if ( result < 0 ) /*0x3fa8*/
 {
 CpuCsrDebugPrint(0x80000000LL, (__int64)"\nASSERT_EFI_ERROR (Status = %r)\n", result); /*0x3fb9*/
 return CpuCsrDebugAssert( /*0x3fd1*/
 (__int64)"e:\\hs\\MdePkg\\Library\\UefiMemoryAllocationLib\\MemoryAllocationLib.c",
 819,
 (__int64)"!EFI_ERROR (Status)");
 }
 return result; /*0x3fd6*/
}