VirtualBox

Ignore:
Timestamp:
Feb 21, 2014 12:11:24 PM (11 years ago)
Author:
vboxsync
Message:

Additions/common/VBoxGuest: simplify the mouse call-back management.

Location:
trunk/src/VBox/Additions/common/VBoxGuest
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest.cpp

    r50523 r50537  
    927927    pDevExt->MouseNotifyCallback.pfnNotify = NULL;
    928928    pDevExt->MouseNotifyCallback.pvUser = NULL;
    929     pDevExt->cISR = 0;
    930929
    931930    /*
     
    14631462 * @param   pDevExt         The device extension.
    14641463 * @param   pNotify         The new callback information.
    1465  * @note  This function takes the session spinlock to update the callback
    1466  *        information, but the interrupt handler will not do this.  To make
    1467  *        sure that the interrupt handler sees a consistent structure, we
    1468  *        set the function pointer to NULL before updating the data and only
    1469  *        set it to the correct value once the data is updated.  Since the
    1470  *        interrupt handler executes atomically this ensures that the data is
    1471  *        valid if the function pointer is non-NULL.
    14721464 */
    14731465int VBoxGuestCommonIOCtl_SetMouseNotifyCallback(PVBOXGUESTDEVEXT pDevExt, VBoxGuestMouseSetNotifyCallback *pNotify)
     
    14781470    pDevExt->MouseNotifyCallback = *pNotify;
    14791471    RTSpinlockReleaseNoInts(pDevExt->EventSpinlock);
    1480 
    1481     /* Make sure no active ISR is referencing the old data - hacky but should be
    1482      * effective. */
    1483     while (pDevExt->cISR > 0)
    1484         ASMNopPause();
    1485 
    14861472    return VINF_SUCCESS;
    14871473}
     
    29692955bool VBoxGuestCommonISR(PVBOXGUESTDEVEXT pDevExt)
    29702956{
    2971 #ifndef RT_OS_WINDOWS
    2972     VBoxGuestMouseSetNotifyCallback MouseNotifyCallback   = { NULL, NULL };
    2973 #endif
    29742957    bool                            fMousePositionChanged = false;
    29752958    VMMDevEvents volatile          *pReq                  = pDevExt->pIrqAckEvents;
     
    29842967
    29852968    /*
    2986      * Enter the spinlock, increase the ISR count and check if it's our IRQ or
    2987      * not.
     2969     * Enter the spinlock and check if it's our IRQ or not.
    29882970     */
    29892971    RTSpinlockAcquire(pDevExt->EventSpinlock);
    2990     ASMAtomicIncU32(&pDevExt->cISR);
    29912972    fOurIrq = pDevExt->pVMMDevMemory->V.V1_04.fHaveEvents;
    29922973    if (fOurIrq)
     
    30142995            if (fEvents & VMMDEV_EVENT_MOUSE_POSITION_CHANGED)
    30152996            {
    3016 #ifndef RT_OS_WINDOWS
    3017                 MouseNotifyCallback = pDevExt->MouseNotifyCallback;
    3018 #endif
    30192997                fMousePositionChanged = true;
    30202998                fEvents &= ~VMMDEV_EVENT_MOUSE_POSITION_CHANGED;
     2999#ifndef RT_OS_WINDOWS
     3000                if (pDevExt->MouseNotifyCallback.pfnNotify)
     3001                    pDevExt->MouseNotifyCallback.pfnNotify
     3002                                          (pDevExt->MouseNotifyCallback.pvUser);
     3003#endif
    30213004            }
    30223005
     
    30963079        ASMAtomicIncU32(&pDevExt->u32MousePosChangedSeq);
    30973080        VBoxGuestNativeISRMousePollEvent(pDevExt);
    3098 #ifndef RT_OS_WINDOWS
    3099         if (MouseNotifyCallback.pfnNotify)
    3100             MouseNotifyCallback.pfnNotify(MouseNotifyCallback.pvUser);
    3101 #endif
    3102     }
    3103 
    3104     ASMAtomicDecU32(&pDevExt->cISR);
     3081    }
     3082
    31053083    Assert(rc == 0);
    31063084    NOREF(rc);
  • trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuestInternal.h

    r50523 r50537  
    170170    /** Memory balloon information for RTR0MemObjAllocPhysNC(). */
    171171    VBOXGUESTMEMBALLOON         MemBalloon;
    172     /** Counter of number of active ISRs.  Currently used for safely removing
    173      * the mouse handler callback. */
    174     uint32_t volatile           cISR;
    175172    /** Callback and user data for a kernel mouse handler. */
    176173    VBoxGuestMouseSetNotifyCallback MouseNotifyCallback;
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette