IoFlushAdapterBuffers

BOOLEAN
IoFlushAdapterBuffers(

IN PADAPTER_OBJECT AdapterObject,
IN PMDL Mdl,
IN PVOID MapRegisterBase,
IN PVOID CurrentVa,
IN ULONG Length,
IN BOOLEAN WriteToDevice
);

IoFlushAdapterBuffers flushes any data remaining in the system DMA controller's internal cache or in a busmaster adapter's internal cache at the end of a DMA transfer operation.

Parameters

AdapterObject

Is the adapter object pointer returned by HalGetAdapter when the driver initialized.

Mdl

Points to the MDL that describes the buffer passed in the driver's call to IoMapTransfer.

MapRegisterBase

Points to the handle returned by the driver's call to IoAllocateAdapterChannel.

CurrentVa

Points to the current virtual address in the buffer, described by the Mdl, where the I/O operation occurred.

Length

Specifies the length, in bytes, of the buffer.

WriteToDevice

Specifies the direction of the DMA transfer operation: TRUE for a transfer from a buffer in system memory to the driver's device.

Return Value

IoFlushAdapterBuffers returns TRUE if any data remaining in the DMA controller's or busmaster adapter's internal cache has been successfully flushed into system memory or out to the device.

Comments

Every driver that performs DMA operations must call IoFlushAdapterBuffers before completing the IRP that requested the DMA transfer to ensure that the transfer is complete.

The initial CurrentVa for the start of a packet-based DMA transfer can be obtained by calling MmGetMdlVirtualAddress. However, the value returned is an index into the Mdl, rather than a valid virtual address. If the driver must split a large transfer request into more than one DMA operation, CurrentVa and Length must be updated for each DMA operation.

Callers of IoFlushAdapterBuffers must be running at IRQL <= DISPATCH_LEVEL.

See Also

HalGetAdapter, IoAllocateAdapterChannel, IoMapTransfer, KeFlushIoBuffers, MmGetMdlVirtualAddress