DWORD PCIE_SW_IntEnable(WDC_DEVICE_HANDLE hDev, PCIE_SW_INT_HANDLER funcIntHandler) { DWORD dwStatus; PWDC_DEVICE pDev = (PWDC_DEVICE)hDev; PPCIE_SW_DEV_CTX pDevCtx; TraceLog("PCIE_SW_IntEnable entered. Device handle: 0x%p\n", hDev); if (!IsValidDevice(pDev, "PCIE_SW_IntEnable")) return WD_INVALID_PARAMETER; if (!IsItemExists(pDev, ITEM_INTERRUPT)) return WD_OPERATION_FAILED; pDevCtx = (PPCIE_SW_DEV_CTX)WDC_GetDevContext(pDev); /* Check if interrupts are already enabled */ if (WDC_IntIsEnabled(hDev)) { ErrLog("Interrupts are already enabled ...\n"); return WD_OPERATION_ALREADY_DONE; } /* Define the number of interrupt transfer commands to use */ #define NUM_TRANS_CMDS 0 /* NOTE: In order to correctly handle PCI interrupts, you need to ADD CODE HERE to set up transfer commands to read/write the relevant register(s) in order to correctly acknowledge the interrupts, as dictated by your hardware's specifications. When adding transfer commands, be sure to also modify the definition of NUM_TRANS_CMDS (above) accordingly. */ /* Store the diag interrupt handler routine, which will be executed by PCIE_SW_IntHandler() when an interrupt is received */ pDevCtx->funcDiagIntHandler = funcIntHandler; /* Enable the interrupts */ /* NOTE: When adding read transfer commands, set the INTERRUPT_CMD_COPY flag in the 4th argument (dwOptions) passed to WDC_IntEnable() */ dwStatus = WDC_IntEnable(hDev, NULL, 0, 0, PCIE_SW_IntHandler, (PVOID)pDev, WDC_IS_KP(hDev)); if (WD_STATUS_SUCCESS != dwStatus) { ErrLog("Failed enabling interrupts. Error 0x%lx - %s\n", dwStatus, Stat2Str(dwStatus)); return dwStatus; } /* TODO: You can add code here to write to the device in order to physically enable the hardware interrupts */ TraceLog("PCIE_SW_IntEnable: Interrupts enabled\n"); return WD_STATUS_SUCCESS; }
DWORD EDEN_IntEnable(WDC_DEVICE_HANDLE hDev, EDEN_INT_HANDLER funcIntHandler) { DWORD dwStatus; PWDC_DEVICE pDev = (PWDC_DEVICE)hDev; PEDEN_DEV_CTX pDevCtx; TraceLog("EDEN_IntEnable entered. Device handle: 0x%p\n", hDev); if (!IsValidDevice(pDev, "EDEN_IntEnable")) return WD_INVALID_PARAMETER; if (!IsItemExists(pDev, ITEM_INTERRUPT)) return WD_OPERATION_FAILED; pDevCtx = (PEDEN_DEV_CTX)WDC_GetDevContext(pDev); /* Check if interrupts are already enabled */ if (WDC_IntIsEnabled(hDev)) { ErrLog("Interrupts are already enabled ...\n"); return WD_OPERATION_ALREADY_DONE; } /* Store the diag interrupt handler routine, which will be executed by EDEN_IntHandler() when an interrupt is received */ pDevCtx->funcDiagIntHandler = funcIntHandler; /* Enable the interrupts */ /* NOTE: When adding read transfer commands, set the INTERRUPT_CMD_COPY flag in the 4th argument (dwOptions) passed to WDC_IntEnable() */ dwStatus = WDC_IntEnable(hDev, NULL, 0, 0, EDEN_IntHandler, (PVOID)pDev, WDC_IS_KP(hDev)); if (WD_STATUS_SUCCESS != dwStatus) { ErrLog("Failed enabling interrupts. Error 0x%lx - %s\n", dwStatus, Stat2Str(dwStatus)); return dwStatus; } /* TODO: You can add code here to write to the device in order to physically enable the hardware interrupts */ TraceLog("EDEN_IntEnable: Interrupts enabled\n"); return WD_STATUS_SUCCESS; }