PURPOSE
Call a callback function upon interrupt reception. A convenient
function for setting up interrupt handling.
PROTOTYPE
DWORD InterruptEnable(
HANDLE *phThread,
HANDLE hWD,
WD_INTERRUPT *pInt,
INT_HANDLER func,
PVOID pData);
PARAMETERS
| Name | Type | Input/Output |
|---|---|---|
| HANDLE* | Output | |
| HANDLE | Input | |
| WD_INTERRUPT* | ||
| DWORD | Input | |
| DWORD | Input | |
| WD_TRANSFER* | Input | |
| DWORD | Input | |
| WD_KERNEL_PLUGIN_CALL | ||
| DWORD | Input | |
| DWORD | N/A | |
| PVOID | N/A | |
| DWORD | N/A | |
| DWORD | N/A | |
| DWORD | N/A | |
| DWORD | N/A | |
| DWORD | N/A | |
| INT_HANDLER | Input | |
| PVOID | Input |
DESCRIPTION
| Name | Description |
|---|---|
| phThread | Pointer to the handle to the spawned interrupt thread, which should be passed to InterruptDisable() [2.19] when disabling the interrupt |
| hWD | The handle to WinDriver's kernel-mode driver received from WD_Open() [5.2] |
| pInt | Pointer to an interrupt information structure: |
| hInterrupt | Internal interrupt handle, as received from WD_CardRegister() [2.8] in I.Int.hInterrupt |
| dwOptions | Interrupt options bit-mask. Can be set to zero or to:
|
| 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: 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: NOTE: A CMD_MASK command must be preceded by a read transfer command (RM_XXX / RP_XXX). |
| dwCmds | Number of transfer commands in the Cmd array |
| kpCall | Kernel PlugIn message information structure: |
| hKernelPlugIn | Handle to Kernel PlugIn returned from WD_KernelPlugInOpen() [6.1]. |
| func | The interrupt handler routine, which will be called once for every interrupt occurrence. (Note: The INT_HANDLER function type is defined in windrvr_int_thread.h). |
| pData | Pointer to the data to be passed as the argument to the interrupt handler routine (func) |
RETURN VALUE
Returns WD_STATUS_SUCCESS (0) on success, or an appropriate error code otherwise [A].
REMARKS
EXAMPLE
VOID DLLCALLCONV interrupt_handler(PVOID pData)
{
WD_INTERRUPT *pIntrp = (WD_INTERRUPT *)pData;
/* Implement your interrupt handler routine here */
printf("Got interrupt %d\n", pIntrp->dwCounter);
}
....
main()
{
WD_CARD_REGISTER cardReg;
WD_INTERRUPT Intrp;
HANDLE hWD, thread_handle;
....
hWD = WD_Open();
BZERO(cardReg);
cardReg.Card.dwItems = 1;
cardReg.Card.Item[0].item = ITEM_INTERRUPT;
cardReg.Card.Item[0].fNotSharable = TRUE;
cardReg.Card.Item[0].I.Int.dwInterrupt = MY_IRQ;
cardReg.Card.Item[0].I.Int.dwOptions = 0;
....
WD_CardRegister(hWd, &cardReg);
....
PVOID pdata = NULL;
BZERO (Intrp);
Intrp.hInterrupt = cardReg.Card.Item[0].I.Int.hInterrupt;
Intrp.Cmd = NULL;
Intrp.dwCmds = 0;
Intrp.dwOptions = 0;
printf("starting interrupt thread\n");
pData = &Intrp;
if (!InterruptEnable(&thread_handle, hWD, &Intrp,
interrupt_handler, pdata))
{
printf ("failed enabling interrupt\n")
}
else
{
printf("Press Enter to uninstall interrupt\n");
fgets(line, sizeof(line), stdin);
InterruptDisable(thread_handle); /* Calls WD_IntDisable() */
}
WD_CardUnregister(hWD, &cardReg);
....
}