HsaAllocateRemappingTableEntry
INT64 __fastcall HsaAllocateRemappingTableEntry(
INT64 a1,
UINT64 a2,
INT64 er8,
INT64 a4,
INT16 a5,
CHAR a6,
CHAR a7,
INT64 a8,
INT64 a9){
int v9;
unsigned int v10;
char v12;
int PhysicalMemory;
unsigned int v14;
INT64 v15;
__int64 v16;
__int64 v17;
unsigned __int64 v18;
INT64 v19;
INT64 v20;
__int64 v21;
__int128 v22;
INT64 v23;
unsigned __int64 v24;
char v26;
unsigned int v27;
INT64 result;
INT64 v29;
LARGE_INTEGER v30[2];
size_t Size[2];
INT64 v32;
char v33;
v9 = er8;
v10 = a2;
if( (_DWORD)er8 && (((_DWORD)er8 - 1) & (unsigned int)er8) == 0 )
{
result = 0i64;
v12 = 0;
v29 = 0i64;
v33 = 0;
PhysicalMemory = 0;
v32 = 0i64;
*(_OWORD *)&v30[0].LowPart = 0i64;
*(_OWORD *)Size = 0i64;
if( *(_DWORD *)(a1 + 160) != (_DWORD)a4 )
return(unsigned int)-1073741594;
v14 = a7 & 7 | (8 * (a6 & 0x1F | (32 * (unsigned __int8)a5)));
if( a9 && *(_DWORD *)a9 == 1 && (*(_BYTE *)(a1 + 18) & 1) == 0 && (*(_BYTE *)(a9 + 10) & 4) == 0 )
v14 = *(unsigned __int16 *)(a9 + 12);
if( _bittest(*(const signed __int32 **)(a1 + 192), v14) )
{
v15 = a2 & 0x1FF;
v27 = WORD1(a2);
if( WORD1(a2) >= 0x20u || (unsigned int)a2 >> 9 >= HsaTotalDeviceApertures || (unsigned int)(v15 + er8) > 0x200 )
{
PhysicalMemory = -1073741811;
goto LABEL_30;
}
byte_140C48698 = HalpAcquireHighLevelLock(&qword_140C48690);
HsaGetDeviceAperture(v10);
v17 = v16;
if( v16 && *(_QWORD *)(v16 + 16) )
{
*(_DWORD *)(v16 + 48) += v9;
v26 = 0;
}
else
{
v26 = 1;
}
v18 = (unsigned __int8)byte_140C48698;
KxReleaseSpinLock(&qword_140C48690);
__writecr8(v18);
if( !v26 )
return(unsigned int)PhysicalMemory;
if( v17 )
{
LABEL_22:
Size[0] = 0x20000002000i64;
PhysicalMemory = ExtEnvAllocatePhysicalMemory(v19, 0x2000ui64, 0i64, MmCached, v30, (INT64)&v30[1]);
if( PhysicalMemory < 0 )
goto LABEL_35;
memset(v30[1].QuadPart, 0i64);
v12 = 1;
PhysicalMemory = ExtEnvAllocateMemory(
v20,
4 * (unsigned int)(((unsigned __int64)HIDWORD(Size[0]) + 31) >> 5),
&v29);
if( PhysicalMemory < 0 )
{
LABEL_31:
if( v30[1].QuadPart )
ExtEnvFreePhysicalMemory(v15, (VOID *)v30[1].QuadPart, LODWORD(Size[0]), 1ui64);
if( v29 )
ExtEnvFreeMemory(v15, v29);
goto LABEL_35;
}
LODWORD(Size[1]) = HIDWORD(Size[0]);
v32 = v29;
RtlClearBits((RTL_BITMAP *)&Size[1], 0i64, HIDWORD(Size[0]));
byte_140C48698 = HalpAcquireHighLevelLock(&qword_140C48690);
if( !HsaDeviceApertureRanges[v27] )
{
HsaDeviceApertureRanges[v27] = result;
HsaGetDeviceAperture(v10);
HsaAllocatedDeviceApertures += 128;
v17 = v21;
v33 = 0;
}
if( !*(_QWORD *)(v17 + 16) )
{
v22 = *(_OWORD *)Size;
*(_OWORD *)(v17 + 8) = *(_OWORD *)&v30[0].LowPart;
v23 = v32;
*(_OWORD *)(v17 + 24) = v22;
*(_QWORD *)(v17 + 40) = v23;
*(_QWORD *)v17 = a1;
*(_DWORD *)(v17 + 52) = v14;
HsaUpdateRemappingTableInDeviceTableEntry((UINT64 *)a1, v14, (UINT8 *)v30);
v12 = 0;
}
*(_DWORD *)(v17 + 48) += v9;
v24 = (unsigned __int8)byte_140C48698;
KxReleaseSpinLock(&qword_140C48690);
__writecr8(v24);
LABEL_30:
if( v12 )
goto LABEL_31;
LABEL_35:
if( v33 )
ExtEnvFreeMemory(v15, result);
return(unsigned int)PhysicalMemory;
}
PhysicalMemory = ExtEnvAllocateMemory(v19, 0x1C00ui64, &result);
if( PhysicalMemory >= 0 )
{
memset(result, 0i64);
v33 = 1;
goto LABEL_22;
}
}
else
{
return(unsigned int)-1073741594;
}
return(unsigned int)PhysicalMemory;
}
return 3221225485i64;
}Referenced by:
No references.