Expand Minimize

EvtProgramDma function

[Applies to KMDF only]

A framework-based driver's EvtProgramDma event callback function programs a specified device to perform a DMA transfer operation.

Syntax


EVT_WDF_PROGRAM_DMA EvtProgramDma;

BOOLEAN EvtProgramDma(
  _In_  WDFDMATRANSACTION Transaction,
  _In_  WDFDEVICE Device,
  _In_  WDFCONTEXT Context,
  _In_  WDF_DMA_DIRECTION Direction,
  _In_  PSCATTER_GATHER_LIST SgList
)
{ ... }

Parameters

Transaction [in]

A handle to the DMA transaction object that represents the current DMA transaction.

Device [in]

A handle to a framework device object.

Context [in]

The context pointer that the driver specified in a previous call to WdfDmaTransactionExecute.

Direction [in]

A WDF_DMA_DIRECTION-typed value that specifies the direction of the DMA transfer operation.

SgList [in]

A pointer to a SCATTER_GATHER_LIST structure.

Return value

The EvtProgramDma callback function must return TRUE if it successfully starts the DMA transfer operation. Otherwise, this callback function must return FALSE. However, the framework currently ignores the return value.

Remarks

Drivers register an EvtProgramDma event callback function by calling WdfDmaTransactionInitializeUsingRequest or WdfDmaTransactionInitialize.

The framework calls a driver's EvtProgramDma event callback function when a DMA transfer is available. The callback function must program the hardware to start the transfer.

The driver must not manipulate the data buffers associated with the transaction until after WdfDmaTransactionDmaCompletedXxx has returned TRUE.

For single packet transfers, the scatter/gather list that the SgList parameter points to contains a single element.

For more information about this callback function, see Programming DMA Hardware.

Examples

To define an EvtProgramDma callback function, you must first provide a function declaration that identifies the type of callback function you’re defining. Windows provides a set of callback function types for drivers. Declaring a function using the callback function types helps Code Analysis for Drivers, Static Driver Verifier (SDV), and other verification tools find errors, and it’s a requirement for writing drivers for the Windows operating system.

For example, to define an EvtProgramDma callback function that is named MyProgramDma, use the EVT_WDF_PROGRAM_DMA type as shown in this code example:


EVT_WDF_PROGRAM_DMA  MyProgramDma;

Then, implement your callback function as follows:


_Use_decl_annotations_
BOOLEAN
 MyProgramDma (
    WDFDMATRANSACTION  Transaction,
    WDFDEVICE  Device,
    PVOID  Context,
    WDF_DMA_DIRECTION  Direction,
    PSCATTER_GATHER_LIST  SgList
    )
  {...}

The EVT_WDF_PROGRAM_DMA function type is defined in the Wdfdmatransaction.h header file. To more accurately identify errors when you run the code analysis tools, be sure to add the _Use_decl_annotations_ annotation to your function definition. The _Use_decl_annotations_ annotation ensures that the annotations that are applied to the EVT_WDF_PROGRAM_DMA function type in the header file are used. For more information about the requirements for function declarations, see Declaring Functions by Using Function Role Types for KMDF Drivers. For information about _Use_decl_annotations_, see Annotating Function Behavior.

Requirements

Minimum KMDF version

1.0

Header

Wdfdmatransaction.h (include Wdf.h)

IRQL

DISPATCH_LEVEL

See also

WdfDmaTransactionExecute
WdfDmaTransactionInitialize
WdfDmaTransactionInitializeUsingRequest

 

 

Send comments about this topic to Microsoft

Show:
© 2014 Microsoft