KeFlushIoBuffers

VOID __stdcall KeFlushIoBuffers(_MDL *Mdl, UINT8 ReadOperation, UINT8 DmaOperation){
  unsigned __int8 CurrentIrql; 
  INT64 ByteCount; 
  char v8; 
  void *MappedSystemVa; 
  INT64 v10[2]; 
  __int128 v11; 
  *(_OWORD *)v10 = 0i64;
  v11 = 0i64;
  if( !KiSystemFullyCoherent )
  {
    CurrentIrql = KeGetCurrentIrql();
    ByteCount = Mdl->ByteCount;
    if( DmaOperation || ReadOperation )
    {
      v8 = 1;
      if( (Mdl->MdlFlags & 5) != 0 )
        MappedSystemVa = Mdl->MappedSystemVa;
      else
        MappedSystemVa = MmMapLockedPagesSpecifyCache(Mdl, 0, MmCached, 0i64, 0, 0x40000020u);
      if( !MappedSystemVa && CurrentIrql == 15 )
        KeBugCheckEx(0x55u, 0x86ui64, 0xBADui64, 0i64, 0i64);
      if( (*(_DWORD *)(&PerfGlobalGroupMask + 2) & 0x4000000) != 0 )
        EtwGetKernelTraceTimestamp((LARGE_INTEGER *)v10, 0x84000000ui64);
      else
        v8 = 0;
      if( MappedSystemVa )
      {
        KiFlushRangeAllCaches(Mdl, MappedSystemVa, (unsigned int)ByteCount, ReadOperation, DmaOperation);
      }
      else if( DmaOperation )
      {
        KeInvalidateAllCaches();
      }
      if( v8 )
        EtwTraceCpuCacheFlush((INT64)v10, (INT64)MappedSystemVa, ByteCount, ReadOperation == 0);
    }
  }
}

Referenced by:

HalFlushDmaBuffer
HalpDmaFlushBuffer
HalpDmaFlushBufferWithEmergencyResources
HalpDmaFlushDriverMdl
HalpDmaSyncMapBuffersWithEmergencyResources
HalpFlushMapBuffers
ViMapDoubleBuffer