/**
 * ISR handler.
 *
 * @return  BOOLEAN         Indicates whether the IRQ came from us (TRUE) or not (FALSE).
 * @param   pInterrupt      Interrupt that was triggered.
 * @param   pServiceContext Context specific pointer.
 */
BOOLEAN vboxguestwinIsrHandler(PKINTERRUPT pInterrupt, PVOID pServiceContext)
{
    PVBOXGUESTDEVEXT pDevExt = (PVBOXGUESTDEVEXT)pServiceContext;
    if (pDevExt == NULL)
        return FALSE;

    /*Log(("VBoxGuest::vboxguestwinGuestIsrHandler: pDevExt = 0x%p, pVMMDevMemory = 0x%p\n",
             pDevExt, pDevExt ? pDevExt->pVMMDevMemory : NULL));*/

    /* Enter the common ISR routine and do the actual work. */
    BOOLEAN fIRQTaken = VBoxGuestCommonISR(pDevExt);

    /* If we need to wake up some events we do that in a DPC to make
     * sure we're called at the right IRQL. */
    if (fIRQTaken)
    {
        Log(("VBoxGuest::vboxguestwinGuestIsrHandler: IRQ was taken! pInterrupt = 0x%p, pDevExt = 0x%p\n",
             pInterrupt, pDevExt));
        if (ASMAtomicUoReadU32(&pDevExt->u32MousePosChangedSeq) || !RTListIsEmpty(&pDevExt->WakeUpList))
        {
            Log(("VBoxGuest::vboxguestwinGuestIsrHandler: Requesting DPC ...\n"));
            IoRequestDpc(pDevExt->win.s.pDeviceObject, pDevExt->win.s.pCurrentIrp, NULL);
        }
    }
    return fIRQTaken;
}
/**
 * Interrupt service routine.
 *
 * @returns Whether the interrupt was from VMMDev.
 * @param   pvState Opaque pointer to the device state.
 */
static int32 VBoxGuestHaikuISR(void *pvState)
{
    LogFlow((MODULE_NAME ":VBoxGuestHaikuISR pvState=%p\n", pvState));

    bool fOurIRQ = VBoxGuestCommonISR(&g_DevExt);

    return fOurIRQ ? B_HANDLED_INTERRUPT : B_UNHANDLED_INTERRUPT;
}
/**
 * Interrupt Service Routine for VMMDev.
 *
 * @param   Arg     Private data (unused, will be NULL).
 * @returns DDI_INTR_CLAIMED if it's our interrupt, DDI_INTR_UNCLAIMED if it isn't.
 */
static uint_t VBoxGuestSolarisISR(caddr_t Arg)
{
    LogFlow((DEVICE_NAME "::ISR:\n"));

    mutex_enter(&g_IrqMtx);
    bool fOurIRQ = VBoxGuestCommonISR(&g_DevExt);
    mutex_exit(&g_IrqMtx);

    return fOurIRQ ? DDI_INTR_CLAIMED : DDI_INTR_UNCLAIMED;
}
/**
 * Callback triggered when interrupt occurs.
 */
static bool
directInterruptHandler(OSObject *pOwner, IOFilterInterruptEventSource *pSrc)
{
    if (!pSrc)
        return false;

    bool fTaken = VBoxGuestCommonISR(&g_DevExt);
    if (!fTaken) /** @todo r=bird: This looks bogus as we might actually be sharing interrupts with someone. */
        PDEBUG("VBoxGuestCommonISR error\n");

    return fTaken;
}
/**
 * Callback triggered when interrupt occurs.
 */
static bool
checkForInterrupt(OSObject *pOwner, IOFilterInterruptEventSource *pSrc)
{
    if (!pSrc)
        return false;

    bool fTaken = VBoxGuestCommonISR(&g_DevExt);
    if (!fTaken)
        printf("VBoxGuestCommonISR error\n");

    return fTaken;
}
static irqreturn_t vboxguestLinuxISR(int iIrrq, void *pvDevId, struct pt_regs *pRegs)
#endif
{
    bool fTaken = VBoxGuestCommonISR(&g_DevExt);
    return IRQ_RETVAL(fTaken);
}