HalpDmaGetTranslationEntries
_HALP_DMA_TRANSLATION_ENTRY *__fastcall HalpDmaGetTranslationEntries(
_HALP_DMA_ADAPTER_OBJECT *Adapter,
_HALP_DMA_MAP_BUFFER_TYPE Type,
UINT64 EntriesNeeded){
_HALP_DMA_TRANSLATION_ENTRY *result;
__int64 v4;
_HALP_DMA_ADAPTER_OBJECT *v6;
__int64 v7;
__int64 v8;
__int64 *v9;
unsigned int v10;
__int64 i;
unsigned int v12;
_HALP_DMA_TRANSLATION_ENTRY *v13;
__int64 v14;
__int64 v15;
unsigned int v16;
__int64 v17;
unsigned __int64 OldIrql;
__int64 NewTranslationBuffer;
struct _KLOCK_QUEUE_HANDLE LockHandle;
result = 0i64;
v4 = (unsigned int)EntriesNeeded;
v6 = Adapter;
memset(&LockHandle, 0, sizeof(LockHandle));
if( Type == HalpDmaContiguousMapBuffer )
{
v7 = 56i64;
goto LABEL_3;
}
if( Type == HalpDmaNonContiguousMapBuffer )
{
v7 = 72i64;
LABEL_3:
KeAcquireInStackQueuedSpinLock((UINT64 *)Adapter + 16, &LockHandle);
v8 = *(_QWORD *)((char *)v6 + v7);
if( v8 )
{
v9 = *(__int64 **)((char *)v6 + v7);
v10 = *(_DWORD *)(v8 + 8) - *(_DWORD *)((char *)v6 + v7 + 8);
for( i = *(_QWORD *)v8; i; i = *(_QWORD *)i )
{
v10 += *(_DWORD *)(i + 8);
v9 = (__int64 *)i;
}
if( v10 >= (unsigned int)v4 )
goto LABEL_7;
}
else
{
v10 = 0;
v9 = 0i64;
}
NewTranslationBuffer = HalpDmaAllocateNewTranslationBuffer((__int64)v6, (unsigned int)v4 - v10);
if( !NewTranslationBuffer )
{
KeReleaseInStackQueuedSpinLockFromDpcLevel(&LockHandle);
OldIrql = LockHandle.OldIrql;
result = 0i64;
LABEL_16:
__writecr8(OldIrql);
return result;
}
if( v9 )
{
*v9 = NewTranslationBuffer;
}
else
{
v8 = NewTranslationBuffer;
if( Type )
*((_QWORD *)v6 + 6) = NewTranslationBuffer;
else
*((_QWORD *)v6 + 5) = NewTranslationBuffer;
}
LABEL_7:
v12 = *(_DWORD *)((char *)v6 + v7 + 8);
v13 = 0i64;
v14 = 0i64;
v15 = 0i64;
if( (_DWORD)v4 )
{
v16 = *(_DWORD *)(v8 + 8);
do
{
if( v12 >= v16 )
{
v8 = *(_QWORD *)v8;
v12 = 0;
v16 = *(_DWORD *)(v8 + 8);
}
v17 = *(_QWORD *)(v8 + 16);
v15 = v17 + 72i64 * v12;
if( v13 )
*(_QWORD *)(v14 + 8) = v15;
else
v13 = (_HALP_DMA_TRANSLATION_ENTRY *)(v17 + 72i64 * v12);
memset(v17 + 72i64 * v12++, 0i64);
*(_QWORD *)(v15 + 56) = v15;
v14 = v15;
--v4;
}
while( v4 );
v6 = Adapter;
}
*(_QWORD *)((char *)v6 + v7) = v8;
*(_DWORD *)((char *)v6 + v7 + 8) = v12;
*(_QWORD *)(v15 + 8) = 0i64;
KeReleaseInStackQueuedSpinLockFromDpcLevel(&LockHandle);
OldIrql = LockHandle.OldIrql;
result = v13;
goto LABEL_16;
}
return result;
}Referenced by:
HalpDmaAllocateMapRegisters
HalpDmaCommitContiguousMapBuffers
HalpDmaCommitScatterMapBuffers