HalpDmaMapScatterTransferV3

VOID __stdcall HalpDmaMapScatterTransferV3(
        _ADAPTER_OBJECT *ChildAdapter,
        _MDL *Mdl,
        _HALP_DMA_TRANSLATION_ENTRY *TranslationBase,
        VOID *CurrentVa,
        UINT64 *Length,
        INT64 WriteToDevice,
        INT64 DeferFlushing,
        _LARGE_INTEGER *LogicalAddressOut){
  unsigned int ContiguousPiece; 
  unsigned int v13; 
  __int64 v14; 
  __int64 v15; 
  LONGLONG v16; 
  __int64 v17; 
  _HALP_DMA_TRANSLATION_ENTRY *NextMapping; 
  _HALP_DMA_TRANSLATION_ENTRY *v19; 
  unsigned __int64 v20; 
  __int64 v21; 
  bool v22; 
  INT64 v23; 
  INT64 v24; 
  UINT64 v25; 
  INT64 v26; 
  UINT8 CacheSyncOnly; 
  UINT8 v28; 

  LODWORD(v25) = *(_DWORD *)Length;
  LOBYTE(v23) = WriteToDevice;
  ContiguousPiece = HalpDmaNextContiguousPiece(ChildAdapter, Mdl, TranslationBase, CurrentVa, v23, v25);
  v13 = ContiguousPiece;
  *(_DWORD *)Length = ContiguousPiece;
  if( !ContiguousPiece )
    return;
  v14 = (unsigned __int16)CurrentVa & 0xFFF;
  v15 = (unsigned int)(((unsigned __int64)CurrentVa - (unsigned __int64)Mdl->StartVa) >> 12);
  v16 = v14 + (*((_QWORD *)&Mdl[1].Next + v15) << 12);
  if( TranslationBase )
  {
    if( (v17 = ContiguousPiece,
          ChildAdapter->AdapterObject.MaximumPhysicalAddress.QuadPart < v16 + (unsigned __int64)ContiguousPiece - 1)
      && ChildAdapter->TranslationType != ExtTranslationTypeTranslate
      || !ChildAdapter->CacheCoherent
      && !(_BYTE)WriteToDevice
      && ((LODWORD(v15) = HalpDmaGetAdapterCacheAlignment(ChildAdapter) - 1, ((unsigned int)v15 & (unsigned int)v16) != 0)
       || ((unsigned int)v15 & v13) != 0)
      || TranslationBase->LogicalBounceBufferPremapped )
    {
      NextMapping = TranslationBase->NextMapping;
      LogicalAddressOut->QuadPart = v14 + NextMapping->PhysicalAddress;
      if( (_BYTE)WriteToDevice )
      {
        v28 = DeferFlushing;
        CacheSyncOnly = 0;
        LOBYTE(v26) = WriteToDevice;
      }
      else
      {
        if( ChildAdapter->CacheCoherent )
        {
LABEL_15:
          v19 = TranslationBase->NextMapping;
          v20 = (unsigned __int64)(v17 + v14 + 4095) >> 12;
          if( (_DWORD)v20 )
          {
            v21 = (unsigned int)v20;
            do
            {
              v19 = v19->Next;
              --v21;
            }
            while( v21 );
          }
          TranslationBase->NextMapping = v19;
          return;
        }
        v28 = DeferFlushing;
        CacheSyncOnly = 1;
        LOBYTE(v26) = 0;
      }
      LODWORD(v24) = v13;
      HalpDmaSyncMapBuffers(ChildAdapter, Mdl, CurrentVa, NextMapping, v24, v26, CacheSyncOnly, v28);
      goto LABEL_15;
    }
  }
  v22 = ChildAdapter->CacheCoherent == 0;
  LogicalAddressOut->QuadPart = v16;
  if( v22 )
  {
    LOBYTE(v26) = DeferFlushing;
    LOBYTE(v24) = WriteToDevice;
    HalpDmaFlushBuffer(v15, Mdl, CurrentVa, v13, v24, v26);
  }
}

Referenced by:

HalpMapTransferV3