3.2. WD_IntEnable()

Purpose

Registers an interrupt service routine (ISR) to be called upon interrupt.

Prototype
DWORD WD_IntEnable(
   HANDLE hWD,
   WD_INTERRUPT *pInterrupt);
Parameters
NameTypeInput/Output
hWDHANDLEInput
pInterruptWD_INTERRUPT* 
• hInterruptHANDLEInput
• dwOptionsDWORDInput
• CmdWD_TRANSFER*Input
• dwCmdsDWORDInput
• kpCallWD_KERNEL_PLUGIN_CALL 
 * hKernelPlugInHANDLEInput
 * dwMessageDWORDN/A
 * pDataPVOIDN/A
 * dwResultDWORDN/A
• fEnableOkDWORDOutput
• dwCounterDWORDN/A
• dwLostDWORDN/A
• fStoppedDWORDN/A
• dwLastMessageDWORDN/A
• dwEnabledIntTypeDWORDOutput
Description
NameDescription
HWDHandle to WinDriver's kernel-mode driver as received from WD_Open() [5.2]
pInterruptPointer to an interrupt information structure:
• hInterrupt Interrupt handle. The handle is returned by WD_CardRegister() [2.6] in pCardReg->Card.Item[i].I.Int.hInterrupt.
• dwOptions A bit mask flag. May be 0 for no option, or:
INTERRUPT_CMD_COPY: if set, WinDriver will copy the data received from the read commands that were used to acknowledge the interrupt in the kernel, back to the user mode. The data will be available when WD_IntWait() [3.3] returns.
• Cmd An array of transfer commands information structures that define the operations to be performed at the kernel level upon the detection of an interrupt, or NULL if no transfer commands are required.
NOTE:
• Memory allocated for the transfer commands must remain available until the interrupts are disabled .
• When handling level-sensitive interrupts (such as PCI interrupts) in the user mode (without a Kernel PlugIn driver), you must use this array to define the hardware-specific commands for acknowledging the interrupts in the kernel, immediately when they are received.
The commands in the array can be either of the following:
• A read/write transfer command that conforms to the following format: <dir><p>_[S]<size> — see the description of pTrans->cmdTrans in Section 2.9.
CMD_MASK: an interrupt mask command for determining the source of the interrupt: When this command is set, upon the arrival of an interrupt in the kernel WinDriver masks the value of the previous read command in the WD_TRANSFER commands array with the mask that is set in the relevant Data field union member of the mask transfer command. For example, for a Cmd WD_TRANSFER array, if Cmd[i-1].cmdTrans is RM_BYTE, WinDriver performs the following mask: Cmd[i-1].Data.Byte & Cmd[i].Data.Byte. If the mask is successful, the driver claims ownership of the interrupt and when the control is returned to the user mode, the interrupt handler routine that was passed to the interrupt enable function is invoked; otherwise, the driver rejects ownership of the interrupt, the interrupt handler routine is not invoked and the subsequent transfer commands in the array are not executed.
(Acceptance and rejection of the interrupt is relevant only when handling legacy interrupts; since MSI/MSI-X interrupts are not shared, WinDriver will always accept control of such interrupts.)
NOTE: A CMD_MASK command must be preceded by a read transfer command (RM_XXX / RP_XXX).
• dwCmdsNumber of transfer commands in Cmd array
• kpCallPointer to a Kernel PlugIn message information structure:
 * hKernelPlugIn Handle to Kernel PlugIn returned from WD_KernelPlugInOpen() [6.1]
• fEnableOk Set by the function to TRUE if WD_IntEnable() [3.2] succeeds
• dwEnabledIntType Updated by the function to indicate the type of interrupt enabled for the device. Can be set to any of the following values:
INTERRUPT_MESSAGE_X: Extended Message-Signaled Interrupts (MSI-X). *
INTERRUPT_MESSAGE: Message-Signaled Interrupts (MSI). *
INTERRUPT_LEVEL_SENSITIVE: Legacy level-sensitive interrupts.
0: Default interrupt type — Legacy edge-triggered interrupts.
NOTE:
* The Windows APIs do not distinguish between MSI and MSI-X; therefore, on this OS the WinDriver functions set the INTERRUPT_MESSAGE flag for both MSI and MSI-X.
** This field normally relevant only in the case of PCI devices that support more than one type of interrupt.
Return Value

Returns WD_STATUS_SUCCESS (0) on success, or an appropriate error code otherwise [A].

Remarks
Example