HalpDmaInitializeMasterAdapter

__int64 __fastcall HalpDmaInitializeMasterAdapter(
        __int64 a1,
        unsigned __int64 a2,
        unsigned int a3,
        __int64 a4,
        __int64 a5,
        int a6,
        char a7){
  UINT64 v8; 
  unsigned int v9; 
  __int64 v11; 
  __int64 v12; 
  __int64 v13; 
  __int64 v14; 
  __int64 v15; 
  __int64 TranslationBuffer; 
  __int64 v17; 
  void *v18; 
  __int64 v20; 
  *(_QWORD *)(a1 + 160) = a1 + 152;
  *(_QWORD *)(a1 + 152) = a1 + 152;
  v8 = a3;
  *(_QWORD *)(a1 + 176) = a1 + 168;
  v9 = (a6 + 31) & 0xFFFFFFE0;
  *(_QWORD *)(a1 + 168) = a1 + 168;
  *(_QWORD *)(a1 + 120) = 0i64;
  *(_QWORD *)(a1 + 128) = 0i64;
  *(_QWORD *)(a1 + 16) = 0i64;
  *(_BYTE *)(a1 + 144) = 1;
  *(_BYTE *)(a1 + 145) = a7;
  v12 = HalpMmAllocCtxAlloc(a1, (unsigned __int64)v9 >> 3);
  if( v12 )
  {
    v13 = HalpMmAllocCtxAlloc(v11, 16i64);
    *(_QWORD *)(a1 + 16) = v13;
    if( v13 )
    {
      *(_DWORD *)v13 = v9;
      *(_QWORD *)(v13 + 8) = v12;
      RtlSetAllBits(*(RTL_BITMAP **)(a1 + 16));
      if( !(_DWORD)v8 )
        return 0i64;
      TranslationBuffer = HalpDmaAllocateTranslationBuffer(v15, a1 + 56);
      *(_QWORD *)(a1 + 40) = TranslationBuffer;
      if( TranslationBuffer )
      {
        MmMapIoSpaceEx((_LARGE_INTEGER)a2, (unsigned int)v8, 4ui64);
        v18 = (void *)v17;
        if( v17 )
        {
          if( HalpDmaCommitContiguousMapBuffers(a1, v17, a2, ((unsigned int)v8 >> 12) + ((v8 & 0xFFF) != 0)) )
          {
            *(_DWORD *)(a1 + 204) = (unsigned int)v8 >> 13;
            return 0i64;
          }
          MmUnmapIoSpace(v18, v8);
        }
        HalpDmaFreeTranslationBuffer(*(_QWORD *)(a1 + 40));
      }
    }
    HalpMmAllocCtxFree(v14, v12);
  }
  v20 = *(_QWORD *)(a1 + 16);
  if( v20 )
    HalpMmAllocCtxFree(v11, v20);
  return 3221225626i64;
}

Referenced by:

HalpDmaInit