HalpInterruptUnmap

VOID __stdcall HalpInterruptUnmap(
        UINT64 BusNumber,
        UINT64 SlotNumber,
        PCI_BUSMASTER_DESCRIPTOR *BusMasterDescriptor,
        UINT8 PhantomBits,
        _INTERRUPT_VECTOR_DATA *VectorData,
        UINT64 VectorCount){
  _INTERRUPT_VECTOR_DATA *v6; 
  unsigned int *p_Vector; 
  _KINTERRUPT_POLARITY Polarity; 
  unsigned int Vector; 
  INTERRUPT_CONNECTION_TYPE Type; 
  INT64 v11; 
  INT64 v12; 
  INT64 *v13; 
  CHAR v14; 
  _LARGE_INTEGER *v15; 
  _KENLISTMENT *bf_0; 
  UINT64 Gsiv; 
  _REGISTERED_INTERRUPT_CONTROLLER *v18; 
  _LIST_ENTRY *Lines; 
  INT64 v20; 
  _LIST_ENTRY *v21; 
  _INTERRUPT_PROBLEM v22; 
  INT64 v23; 
  unsigned int v24; 
  _INTERRUPT_REMAPPING_INFO *p_IntRemapInfo; 
  __int64 v26; 
  _REGISTERED_INTERRUPT_CONTROLLER *v27; 
  __int32 v28; 
  UINT64 SourceLine; 
  __int128 v30; 
  __int128 v31; 
  __int128 v32; 
  __int64 v33; 

  v6 = VectorData;
  v33 = 0i64;
  v30 = 0i64;
  p_Vector = &VectorData->Vector;
  Polarity = VectorData->Polarity;
  *((_QWORD *)&v30 + 1) = (unsigned int)VectorData->Mode;
  Vector = VectorData->Vector;
  v31 = 0i64;
  *(_QWORD *)&v31 = 0x1FFFFFFFFi64;
  LODWORD(v33) = Vector;
  Type = VectorData->Type;
  LODWORD(v30) = Polarity;
  v32 = 0i64;
  if( Type )
  {
    if( Type == InterruptTypeMessageRequest )
    {
      if( HalpInterruptIsHvLineBasedIntRemappingSupported() )
        HalpHvUnmapDeviceMsiRange(v12, v11, v13, v14);
      if( (unsigned __int8)HalpInterruptIsRemappingRequired() )
      {
        v24 = VectorCount;
        if( (_DWORD)VectorCount )
        {
          p_IntRemapInfo = &v6->IntRemapInfo;
          v26 = (unsigned int)VectorCount;
          do
          {
            LODWORD(v33) = *p_Vector;
            HalpSetIrtEntry(1, p_IntRemapInfo, (INT64)&v30);
            p_IntRemapInfo = (_INTERRUPT_REMAPPING_INFO *)((char *)p_IntRemapInfo + 88);
            p_Vector += 22;
            --v26;
          }
          while( v26 );
        }
        bf_0 = (_KENLISTMENT *)(unsigned int)v6->IntRemapInfo._bf_0;
        if( ((unsigned int)bf_0 & 0x40000000) == 0 )
          HalpIrtFreeIndex((unsigned int)bf_0 & 0x3FFFFFFF, v24);
      }
      xHalUnmaskInterrupt(bf_0, v15);
      return;
    }
    v22 = InterruptProblemBadConnectionData;
    LODWORD(SourceLine) = 3219;
    v23 = 2i64;
    goto LABEL_24;
  }
  Gsiv = VectorData->ControllerInput.Gsiv;
  VectorData = 0i64;
  if( HalpInterruptGsiToLine(Gsiv, (_INTERRUPT_LINE *)&VectorData) < 0 )
  {
    v23 = 0i64;
    LODWORD(SourceLine) = 3133;
    v22 = InterruptProblemNoSuchLines;
LABEL_24:
    v27 = 0i64;
LABEL_26:
    HalpInterruptSetProblemEx(v27, v22, v23, "minkernel\\hals\\lib\\interrupts\\common\\connect.c", SourceLine);
    return;
  }
  if( (unsigned int)(Polarity - 3) <= 1 )
  {
    DWORD2(v30) = 0;
    BYTE4(v30) = 1;
  }
  v18 = HalpInterruptLookupController((unsigned int)VectorData);
  if( !v18 )
  {
    v22 = InterruptProblemNoSuchController;
    LODWORD(SourceLine) = 3165;
    v23 = 1i64;
    goto LABEL_24;
  }
  Lines = HalpInterruptFindLines((unsigned int *)&VectorData);
  v21 = Lines;
  if( !Lines )
  {
    v23 = 0i64;
    LODWORD(SourceLine) = 3173;
    v27 = v18;
    v22 = InterruptProblemNoSuchLines;
    goto LABEL_26;
  }
  if( qword_140C4A168 )
  {
    HIDWORD(Lines[2].Blink->Blink) |= 0x10u;
    HalpHvUnmapDeviceInterrupt(v18->UnitId, v20, (INT64)Lines[2].Blink);
    HIDWORD(v21[2].Blink->Blink) &= ~0x10u;
  }
  if( (unsigned __int8)HalpInterruptIsRemappingRequired() )
  {
    if( HalpInterruptModel() == 1 )
    {
      LODWORD(v33) = *p_Vector;
      HalpSetIrtEntry(0, &v6->IntRemapInfo._bf_0, (INT64)&v30);
      v28 = v6->IntRemapInfo._bf_0;
      if( (v28 & 0x40000000) == 0 )
        HalpIrtFreeIndex(v28 & 0x3FFFFFFF, 1ui64);
    }
  }
  BYTE4(v21[3].Flink->Blink) = 0;
}

Referenced by:

HaliRemoveInterruptRemapping
HalpTimerUnmapInterrupt