HalpInterruptEnableNmi

VOID __stdcall HalpInterruptEnableNmi(){
  unsigned __int8 v0; 
  struct _KPRCB *CurrentPrcb; 
  char *v2; 
  _KINTERRUPT_MODE v3; 
  unsigned __int64 v4; 
  _KINTERRUPT_MODE v5; 
  __int64 *v6; 
  char v7; 
  int v8; 
  _KINTERRUPT_POLARITY TriggerMode; 
  int Polarity; 
  unsigned int v11; 
  __int64 Number; 
  __int64 v13; 
  _LIST_ENTRY *Lines; 
  __int64 v15; 
  _REGISTERED_INTERRUPT_CONTROLLER *v16; 
  int v17; 
  INT64 v18; 
  NTSTATUS v19; 
  _INTERRUPT_LINE Line; 
  unsigned int v21; 
  _INTERRUPT_LINE_STATE Flags; 
  _INTERRUPT_LINE Destination[2]; 
  __int128 *v24; 
  __int128 v25; 
  __int128 v26; 

  Line = 0i64;
  v21 = 0;
  *(_OWORD *)&Destination[0].UnitId = 0i64;
  v24 = 0i64;
  v26 = 0i64;
  memset(&Flags, 0, sizeof(Flags));
  v25 = 0i64;
  v0 = HalpAcquireHighLevelLock(&qword_140C49C40);
  CurrentPrcb = KeGetCurrentPrcb();
  v2 = 0i64;
  v3 = LevelSensitive;
  v4 = v0;
  v5 = (int)qword_140C50640;
  if( (_DWORD)qword_140C50640 )
  {
    while( 1 )
    {
      v2 = (char *)HalpInterruptProcessorState + 64 * (unsigned __int64)(unsigned int)v3;
      if( *((_WORD *)v2 + 8) == CurrentPrcb->Group && v2[18] == CurrentPrcb->GroupIndex )
        break;
      if( ++v3 >= (unsigned int)qword_140C50640 )
        goto LABEL_7;
    }
    v5 = v3;
  }
LABEL_7:
  if( v5 == (_DWORD)qword_140C50640 )
    KeBugCheckEx(
      0x5Cu,
      (PVOID)0x104,
      (PVOID)(CurrentPrcb->GroupIndex | ((unsigned __int64)CurrentPrcb->Group << 8)),
      (PVOID)(unsigned int)qword_140C50640,
      0i64);
  v6 = (__int64 *)*(&CmpDummyThreadEvent + 893);
  if( *(&CmpDummyThreadEvent + 893) )
  {
    do
    {
      v7 = 0;
      if( *((_BYTE *)v6 + 8) )
      {
        if( !v2[13] )
          goto LABEL_20;
        v8 = *((_DWORD *)v6 + 3);
        if( v8 != -1 && v8 != *((_DWORD *)v2 + 1) )
          goto LABEL_20;
        v7 = 1;
      }
      else if( CurrentPrcb->Number )
      {
        goto LABEL_20;
      }
      memset(&Flags, 0, sizeof(Flags));
      TriggerMode = InterruptPolarityUnknown;
      v25 = 0i64;
      if( *((_BYTE *)v6 + 8) )
      {
        if( (v6[2] & 0xC) != 12 )
          TriggerMode = InterruptActiveHigh;
        Flags.TriggerMode = TriggerMode;
        Polarity = ((v6[2] & 3) == 3) + 1;
      }
      else
      {
        if( (v6[2] & 8) == 0 )
          TriggerMode = InterruptActiveHigh;
        Flags.TriggerMode = TriggerMode;
        Polarity = 2 - (((_BYTE)v6[2] & 3u) < 2);
      }
      Destination[0] = 0i64;
      Destination[1] = 0i64;
      Flags.Routing = (_INTERRUPT_LINE)0x2FFFFFFFFi64;
      LODWORD(v25) = v25 & 0x80000000 | 0x40000002;
      v24 = &v25;
      Flags.Polarity = Polarity;
      Flags.Flags = 16;
      if( v7 )
      {
        Destination[0].UnitId = 5;
        v11 = *(_DWORD *)(Controller + 232);
        Line.Line = *((_DWORD *)v6 + 5);
        Line.UnitId = v11;
LABEL_19:
        LOBYTE(v5) = 15;
        if( HalpInterruptSetLineState(
               &Line,
               0i64,
               v5,
               TriggerMode,
               (_KINTERRUPT_POLARITY)Polarity,
               Destination,
               (UINT64)&Flags.Routing) < 0 )
          break;
        goto LABEL_20;
      }
      if( HalpInterruptGsiToLine(*((unsigned int *)v6 + 5), &Line) >= 0 )
      {
        if( *(&stru_140CF2E80 + 6616) )
        {
          Destination[0].UnitId = 3;
        }
        else
        {
          v26 = 0i64;
          Number = CurrentPrcb->Number;
          Destination[0].UnitId = 1;
          v13 = 0i64;
          _bittestandset64(&v13, KiProcessorIndexToNumberMappingTable[Number] & 0x3F);
          *(_QWORD *)&v26 = v13;
          Destination[1] = (_INTERRUPT_LINE)&v26;
        }
        Lines = HalpInterruptFindLines((unsigned int *)&Line);
        if( !Lines )
        {
          *(&CmpDummyThreadEvent + 1789) = 18;
          break;
        }
        if( !BYTE4(Lines[3].Flink[v21].Blink) )
        {
          v16 = HalpInterruptLookupController(Line.UnitId);
          if( !v16 )
          {
            *(&CmpDummyThreadEvent + 1789) = 17;
            break;
          }
          v17 = HalpInterruptDestinationToTarget(v15, (__int64)Destination, (__int64)&Flags.ProcessorTarget);
          if( v17 < 0 )
          {
            v16->ProblemStatus = v17;
            *(&CmpDummyThreadEvent + 1789) = 19;
            v16->ProblemSourceFile = "minkernel\\hals\\lib\\interrupts\\common\\intrupt.c";
            v16->Problem = InterruptProblemBadConnectionData;
            v16->ProblemSourceLine = 1546;
            break;
          }
          if( (*(_DWORD *)(Controller + 220) & 0x100) != 0 && KeGetCurrentPrcb()->CpuVendor != 1 )
          {
            HalpIommuUpdateRemappingTableEntry(0, v25 & 0x3FFFFFFF, (INT64)&Flags);
            Flags.ProcessorTarget.Target = InterruptTargetRemapIndex;
            Flags.ProcessorTarget.PhysicalTarget = v25 & 0x3FFFFFFF;
          }
          if( qword_140C4A168 )
          {
            v19 = HalpHvMapDeviceInterrupt(v16->UnitId, v18, (INT64)&Flags, 0i64);
            if( v19 < 0 )
            {
              v16->ProblemStatus = v19;
              *(&CmpDummyThreadEvent + 1789) = 31;
              v16->Problem = InterruptProblemNoIrtEntries;
              v16->ProblemSourceFile = "minkernel\\hals\\lib\\interrupts\\common\\intrupt.c";
              v16->ProblemSourceLine = 1597;
              break;
            }
          }
          Flags.Flags &= ~0x10u;
          if( HalpInterruptSetRemappedLineStateInternal(v16, &Line, &Flags) < 0 )
            break;
          TriggerMode = Flags.TriggerMode;
          Polarity = Flags.Polarity;
        }
        goto LABEL_19;
      }
      *(&CmpDummyThreadEvent + 1789) = 18;
LABEL_20:
      v6 = (__int64 *)*v6;
    }
    while( v6 );
  }
  KxReleaseSpinLock(&qword_140C49C40);
  __writecr8(v4);
}

Referenced by:

HalpDpPostReplaceInitialization
HalpInterruptInitSystem
HalpPostSleepMP