The KeFlushIoBuffers routine flushes the memory region described by an MDL from caches of all processors.
VOID
KeFlushIoBuffers(
IN PMDL Mdl,
IN BOOLEAN ReadOperation,
IN BOOLEAN DmaOperation
);
None
Declared in wdm.h and ntddk.h. Include wdm.h or ntddk.h.
Drivers call KeFlushIoBuffers to maintain data integrity during DMA or PIO device transfer operations. Calling this routine affects all processors in the machine.
If ReadOperation is TRUE, the driver is reading information from the device to system memory, so valid data still might be in the processor instruction and data caches. KeFlushIoBuffers flushes data from all processors’ caches to system memory, including the processor on which the caller is running.
If ReadOperation is FALSE, the driver is writing data from system memory to a device, so valid data might be in the processor’s data cache but not yet transferred to the device. KeFlushIoBuffers flushes all processors' data caches, including that of the processor on which the caller is running.
As a general rule, drivers should call this routine just before beginning a DMA transfer operation or immediately following any PIO read operation.
Callers of this routine must be running at IRQL <= DISPATCH_LEVEL.