HalpInterruptRemap
__int64 __fastcall HalpInterruptRemap(unsigned int a1, __int64 a2, int *a3, char a4, __int64 a5, INT64 a6){
int *v6;
char v7;
_DWORD *v8;
INT64 v9;
unsigned __int64 v10;
__int128 *v11;
unsigned int v12;
unsigned int v13;
int BestRouting;
int v15;
int v16;
unsigned int v17;
_DWORD *v18;
INT64 v19;
int v20;
unsigned int v21;
__int64 v22;
ULONG_PTR *v23;
INT64 v24;
int v25;
int v26;
UINT64 v28;
UINT64 IrtIndex;
INT64 v30;
INT64 v31;
__int64 v32;
INT64 v33[2];
INT64 a2a[2];
__int128 v35;
__int64 v36;
int *v37;
CHAR v38;
v38 = a4;
v37 = a3;
v6 = (int *)a5;
HIDWORD(v30) = 0;
*(_OWORD *)v33 = 0i64;
LODWORD(IrtIndex) = -1;
v7 = *(_BYTE *)(a5 + 8);
v8 = (_DWORD *)(a5 + 40);
v9 = a5 + 24;
v10 = (unsigned __int64)*(unsigned __int8 *)(a5 + 4) >> 4;
*(_OWORD *)a2a = 0i64;
v11 = &HalpHwToSwIrqlMap;
LODWORD(a2a[0]) = -1;
v12 = -1;
v32 = a5 + 40;
v13 = a6;
BestRouting = -1073741823;
*((_BYTE *)&HalpHwToSwIrqlMap + v10) = v7;
v36 = 0i64;
LODWORD(v33[0]) = v6[3];
LODWORD(v33[1]) = v6[4];
LODWORD(v36) = v6[1];
v15 = *v6;
LODWORD(v30) = 1;
v31 = v9;
HIDWORD(v33[1]) = 16;
HIDWORD(a2a[0]) = 1;
v35 = 0i64;
if( !v15 )
{
v21 = v6[14];
a5 = 0i64;
if( (int)HalpInterruptGsiToLine(v21, &a5) >= 0 )
{
HalpInterruptApplyOverrides(&a5, v33, &v33[1]);
if( LODWORD(v33[0]) == 3 )
{
LODWORD(v33[1]) = 0;
BYTE4(v33[0]) = 1;
LODWORD(v33[0]) = 2;
}
else if( LODWORD(v33[0]) == 4 )
{
LODWORD(v33[1]) = 0;
BYTE4(v33[0]) = 1;
LODWORD(v33[0]) = 1;
}
else
{
BYTE4(v33[0]) = 0;
}
v23 = HalpInterruptLookupController(a5);
if( v23 )
{
BestRouting = HalpInterruptDestinationToTarget(v22, (__int64)&v30, (__int64)&a2a[1]);
if( BestRouting < 0 )
{
LABEL_10:
HalpInterruptLastProblem = 19;
goto LABEL_42;
}
BestRouting = HalpInterruptFindBestRouting((UINT64 *)&a5, a2a[0]);
if( BestRouting < 0 )
return(unsigned int)BestRouting;
HalpInterruptRemapUpdateDeliveryMode((INT64)v6, (INT64)v33);
if( (*(_DWORD *)(HalpInterruptController + 220) & 0x100) != 0 && (unsigned int)HalpInterruptModel() == 1 )
{
if( (*v8 & 0x40000000) == 0 )
{
v25 = HalpIrtAllocateIndex(&IrtIndex, 1i64);
v12 = IrtIndex;
BestRouting = v25;
if( v25 < 0 )
goto LABEL_7;
*v8 ^= (IrtIndex ^ *v8) & 0x3FFFFFFF;
}
HalpIommuUpdateRemappingTableEntry(0, *v8 & 0x3FFFFFFF, (INT64)v33);
v26 = *v8 & 0x3FFFFFFF;
LODWORD(a2a[1]) = 7;
LODWORD(v35) = v26;
v9 = (INT64)(v6 + 6);
}
if( qword_140C4A168 )
{
BestRouting = HalpHvMapDeviceInterrupt(*((_DWORD *)v23 + 58), v24, (INT64)v33, v9);
if( BestRouting < 0 )
goto LABEL_7;
}
HIDWORD(v33[1]) &= ~0x10u;
v20 = HalpInterruptSetRemappedLineStateInternal((__int64)v23, (int *)&a5, (__int64)v33);
goto LABEL_40;
}
HalpInterruptLastProblem = 17;
}
else
{
HalpInterruptLastProblem = 18;
}
return(unsigned int)-1073741811;
}
if( v15 != 3 )
{
HalpInterruptLastProblem = 19;
return(unsigned int)BestRouting;
}
if( (*(_DWORD *)(HalpInterruptController + 220) & 0x100) != 0 )
{
if( (*v8 & 0x40000000) != 0 )
{
v12 = *v8 & 0x3FFFFFFF;
}
else
{
v16 = HalpIrtAllocateIndex(&IrtIndex, v13);
v12 = IrtIndex;
BestRouting = v16;
if( v16 < 0 )
{
LABEL_7:
HalpInterruptLastProblem = 31;
goto LABEL_42;
}
}
BestRouting = HalpInterruptDestinationToTarget((__int64)v11, (__int64)&v30, (__int64)&a2a[1]);
if( BestRouting < 0 )
goto LABEL_10;
HalpInterruptRemapUpdateDeliveryMode((INT64)v6, (INT64)v33);
v17 = 0;
if( v13 )
{
v18 = v8;
do
{
*v18 ^= (*v18 ^ (v17 + v12)) & 0x3FFFFFFF;
v19 = *v18 & 0x3FFFFFFF;
LODWORD(v36) = *(v18 - 9);
HalpIommuUpdateRemappingTableEntry(1, v19, (INT64)v33);
++v17;
v18 += 22;
}
while( v17 < v13 );
}
a3 = v37;
a4 = v38;
}
if( qword_140C4A168 )
{
LODWORD(v28) = v13;
BestRouting = HalpHvMapDeviceMsiRange((INT64)v11, a2, (INT64 *)a3, a4, (INT64)v6, v28);
if( BestRouting < 0 )
goto LABEL_7;
goto LABEL_41;
}
v20 = HalpPopulateMsiMessages((INT64)&v30, (INT64)v6, v13);
LABEL_40:
BestRouting = v20;
if( v20 >= 0 )
{
LABEL_41:
BestRouting = 0;
LABEL_42:
if( BestRouting >= 0 )
return(unsigned int)BestRouting;
}
if( v12 != -1 && (*v8 & 0x40000000) == 0 )
HalpIrtFreeIndex(v12, v13);
return(unsigned int)BestRouting;
}Referenced by:
HaliAddInterruptRemapping
HalpInterruptConnect
HalpIommuConfigureInterrupt
HalpTimerConfigureInterrupt