HalpInterruptRemap
NTSTATUS __stdcall HalpInterruptRemap(
INT64 BusNumber,
UINT64 SlotNumber,
_PCI_BUSMASTER_DESCRIPTOR *BusMasterDescriptor,
UINT8 PhantomBits,
_INTERRUPT_VECTOR_DATA *VectorData,
UINT64 VectorCount){
_INTERRUPT_VECTOR_DATA *v6;
unsigned __int8 Irql;
_INTERRUPT_REMAPPING_INFO *p_IntRemapInfo;
_GROUP_AFFINITY *p_TargetProcessors;
unsigned __int64 v10;
char *v11;
unsigned int v12;
unsigned int v13;
NTSTATUS BestRouting;
INTERRUPT_CONNECTION_TYPE Type;
NTSTATUS v16;
unsigned int v17;
_INTERRUPT_REMAPPING_INFO *v18;
INT64 v19;
NTSTATUS v20;
UINT64 Gsiv;
__int64 v22;
_REGISTERED_INTERRUPT_CONTROLLER *v23;
INT64 v24;
NTSTATUS v25;
int v26;
UINT64 v28;
UINT64 IrtIndex;
INT64 v30;
_GROUP_AFFINITY *v31;
_INTERRUPT_REMAPPING_INFO *v32;
_INTERRUPT_LINE_STATE v33[2];
_PCI_BUSMASTER_DESCRIPTOR *v34;
CHAR v35;
v35 = PhantomBits;
v34 = BusMasterDescriptor;
v6 = VectorData;
HIDWORD(v30) = 0;
memset(v33, 0, 32);
LODWORD(IrtIndex) = -1;
Irql = VectorData->Irql;
p_IntRemapInfo = &VectorData->IntRemapInfo;
p_TargetProcessors = &VectorData->TargetProcessors;
v10 = (unsigned __int64)LOBYTE(VectorData->Vector) >> 4;
v11 = (char *)&CmpDummyThreadEvent + 7040;
v33[0].Routing.UnitId = -1;
v12 = -1;
v32 = &VectorData->IntRemapInfo;
v13 = VectorCount;
BestRouting = -1073741823;
*((_BYTE *)&CmpDummyThreadEvent + v10 + 7040) = Irql;
*(_QWORD *)&v33[0].Vector = 0i64;
v33[0].Polarity = v6->Polarity;
v33[0].TriggerMode = v6->Mode;
v33[0].Vector = v6->Vector;
Type = v6->Type;
LODWORD(v30) = 1;
v31 = p_TargetProcessors;
v33[0].Flags = 16;
v33[0].Routing.Line = 1;
v33[0].ProcessorTarget.8 = 0i64;
if( Type == InterruptTypeControllerInput )
{
Gsiv = v6->ControllerInput.Gsiv;
VectorData = 0i64;
if( HalpInterruptGsiToLine(Gsiv, (_INTERRUPT_LINE *)&VectorData) >= 0 )
{
HalpInterruptApplyOverrides((_INTERRUPT_LINE *)&VectorData, &v33[0].Polarity, &v33[0].TriggerMode);
if( v33[0].Polarity == InterruptActiveBoth )
{
v33[0].TriggerMode = LevelSensitive;
v33[0].EmulateActiveBoth = 1;
v33[0].Polarity = InterruptActiveLow;
}
else if( v33[0].Polarity == InterruptActiveBothTriggerHigh )
{
v33[0].TriggerMode = LevelSensitive;
v33[0].EmulateActiveBoth = 1;
v33[0].Polarity = InterruptActiveHigh;
}
else
{
v33[0].EmulateActiveBoth = 0;
}
v23 = HalpInterruptLookupController((unsigned int)VectorData);
if( v23 )
{
BestRouting = HalpInterruptDestinationToTarget(v22, (__int64)&v30, (__int64)&v33[0].ProcessorTarget);
if( BestRouting < 0 )
{
LABEL_10:
*(&CmpDummyThreadEvent + 1789) = 19;
goto LABEL_42;
}
BestRouting = HalpInterruptFindBestRouting((_INTERRUPT_LINE *)&VectorData, v33[0].Routing, &v33[0].Routing);
if( BestRouting < 0 )
return BestRouting;
HalpInterruptRemapUpdateDeliveryMode((INT64)v6, (INT64)v33);
if( (*(_DWORD *)(Controller + 220) & 0x100) != 0 && HalpInterruptModel() == 1 )
{
if( (p_IntRemapInfo->_bf_0 & 0x40000000) == 0 )
{
v25 = HalpIrtAllocateIndex(&IrtIndex, 1i64);
v12 = IrtIndex;
BestRouting = v25;
if( v25 < 0 )
goto LABEL_7;
p_IntRemapInfo->_bf_0 ^= (IrtIndex ^ p_IntRemapInfo->_bf_0) & 0x3FFFFFFF;
}
HalpIommuUpdateRemappingTableEntry(0, p_IntRemapInfo->_bf_0 & 0x3FFFFFFF, (INT64)v33);
v26 = p_IntRemapInfo->_bf_0 & 0x3FFFFFFF;
v33[0].ProcessorTarget.Target = InterruptTargetRemapIndex;
v33[0].ProcessorTarget.PhysicalTarget = v26;
p_TargetProcessors = &v6->TargetProcessors;
}
if( qword_140C4A168 )
{
BestRouting = HalpHvMapDeviceInterrupt(v23->UnitId, v24, (INT64)v33, (INT64)p_TargetProcessors);
if( BestRouting < 0 )
goto LABEL_7;
}
v33[0].Flags &= ~0x10u;
v20 = HalpInterruptSetRemappedLineStateInternal(v23, (_INTERRUPT_LINE *)&VectorData, v33);
goto LABEL_40;
}
*(&CmpDummyThreadEvent + 1789) = 17;
}
else
{
*(&CmpDummyThreadEvent + 1789) = 18;
}
return -1073741811;
}
if( Type != InterruptTypeMessageRequest )
{
*(&CmpDummyThreadEvent + 1789) = 19;
return BestRouting;
}
if( (*(_DWORD *)(Controller + 220) & 0x100) != 0 )
{
if( (p_IntRemapInfo->_bf_0 & 0x40000000) != 0 )
{
v12 = p_IntRemapInfo->_bf_0 & 0x3FFFFFFF;
}
else
{
v16 = HalpIrtAllocateIndex(&IrtIndex, v13);
v12 = IrtIndex;
BestRouting = v16;
if( v16 < 0 )
{
LABEL_7:
*(&CmpDummyThreadEvent + 1789) = 31;
goto LABEL_42;
}
}
BestRouting = HalpInterruptDestinationToTarget((__int64)v11, (__int64)&v30, (__int64)&v33[0].ProcessorTarget);
if( BestRouting < 0 )
goto LABEL_10;
HalpInterruptRemapUpdateDeliveryMode((INT64)v6, (INT64)v33);
v17 = 0;
if( v13 )
{
v18 = p_IntRemapInfo;
do
{
v18->_bf_0 ^= (v18->_bf_0 ^ (v17 + v12)) & 0x3FFFFFFF;
v19 = v18->_bf_0 & 0x3FFFFFFF;
v33[0].Vector = *(_DWORD *)&v18[-3].u.MessageData;
HalpIommuUpdateRemappingTableEntry(1, v19, (INT64)v33);
++v17;
v18 = (_INTERRUPT_REMAPPING_INFO *)((char *)v18 + 88);
}
while( v17 < v13 );
}
BusMasterDescriptor = v34;
PhantomBits = v35;
}
if( qword_140C4A168 )
{
LODWORD(v28) = v13;
BestRouting = HalpHvMapDeviceMsiRange(
(INT64)v11,
SlotNumber,
(INT64 *)BusMasterDescriptor,
PhantomBits,
(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 BestRouting;
}
if( v12 != -1 && (p_IntRemapInfo->_bf_0 & 0x40000000) == 0 )
HalpIrtFreeIndex(v12, v13);
return BestRouting;
}Referenced by:
HaliAddInterruptRemapping
HalpInterruptConnect
HalpIommuConfigureInterrupt
HalpTimerConfigureInterrupt