VirtualBox

Changeset 41640 in vbox for trunk/src/VBox/Additions/common


Ignore:
Timestamp:
Jun 11, 2012 9:17:49 AM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
78440
Message:

Additions/common/VBoxGuest: add an internal IOCtl based on the current Windows one for installing a kernel mouse event handler.

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

Legend:

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

    r41639 r41640  
    727727        pDevExt->acMouseFeatureUsage[i] = 0;
    728728    pDevExt->fMouseStatus = 0;
     729    pDevExt->MouseSetNotifyCallback.pfnNotify = NULL;
     730    pDevExt->MouseSetNotifyCallback.pvNotify = NULL;
     731    pDevExt->cISR = 0;
    729732
    730733    /*
     
    12251228    return VINF_SUCCESS;
    12261229}
     1230
     1231
     1232#ifndef RT_OS_WINDOWS
     1233/**
     1234 * Set the callback for the kernel mouse handler.
     1235 *
     1236 * returns IPRT status code.
     1237 * @param   pDevExt         The device extension.
     1238 * @param   pNotify         The new callback information.
     1239 * @note  This function takes the session spinlock to update the callback
     1240 *        information, but the interrupt handler will not do this.  To make
     1241 *        sure that the interrupt handler sees a consistent structure, we
     1242 *        set the function pointer to NULL before updating the data and only
     1243 *        set it to the correct value once the data is updated.  Since the
     1244 *        interrupt handler executes atomically this ensures that the data is
     1245 *        valid if the function pointer is non-NULL.
     1246 */
     1247int VBoxGuestCommonIOCtl_SetMouseNotifyCallback(PVBOXGUESTDEVEXT pDevExt, VBoxGuestMouseSetNotifyCallback *pNotify)
     1248{
     1249    Log(("VBoxGuestCommonIOCtl: SET_MOUSE_NOTIFY_CALLBACK\n"));
     1250    RTSpinlockAcquire(pDevExt->SessionSpinlock);
     1251    ASMAtomicWriteNullPtr(&pDevExt->MouseSetNotifyCallback.pfnNotify);
     1252    pDevExt->MouseSetNotifyCallback.pvNotify = pNotify->pvNotify;
     1253    ASMAtomicWritePtr(&pDevExt->MouseSetNotifyCallback.pfnNotify,
     1254                      pNotify->pfnNotify);
     1255    RTSpinlockReleaseNoInts(pDevExt->SessionSpinlock);
     1256    /* Make sure no one is referencing the old data - hacky but should be
     1257     * effective. */
     1258    while (pDevExt->cISR > 0);
     1259    return VINF_SUCCESS;
     1260}
     1261#endif
    12271262
    12281263
     
    25042539                break;
    25052540
     2541#ifndef RT_OS_WINDOWS  /* Windows has its own implementation of this. */
     2542            case VBOXGUEST_IOCTL_INTERNAL_SET_MOUSE_NOTIFY_CALLBACK:
     2543                CHECKRET_RING0("SET_MOUSE_NOTIFY_CALLBACK");
     2544                CHECKRET_SIZE("SET_MOUSE_NOTIFY_CALLBACK",
     2545                           sizeof(VBoxGuestMouseSetNotifyCallback));
     2546                rc = VBoxGuestCommonIOCtl_SetMouseNotifyCallback(pDevExt, (VBoxGuestMouseSetNotifyCallback *)pvData);
     2547                break;
     2548#endif
     2549
    25062550            case VBOXGUEST_IOCTL_WAITEVENT:
    25072551                CHECKRET_MIN_SIZE("WAITEVENT", sizeof(VBoxGuestWaitEventInfo));
     
    26072651
    26082652    /*
    2609      * Enter the spinlock and check if it's our IRQ or not.
     2653     * Enter the spinlock, increase the ISR count and check if it's our IRQ or
     2654     * not.
    26102655     */
    26112656    RTSpinlockAcquire(pDevExt->EventSpinlock);
     2657    ASMAtomicIncU32(&pDevExt->cISR);
    26122658    fOurIrq = pDevExt->pVMMDevMemory->V.V1_04.fHaveEvents;
    26132659    if (fOurIrq)
     
    27132759        ASMAtomicIncU32(&pDevExt->u32MousePosChangedSeq);
    27142760        VBoxGuestNativeISRMousePollEvent(pDevExt);
    2715     }
    2716 
     2761#ifndef RT_OS_WINDOWS
     2762        if (pDevExt->MouseSetNotifyCallback.pfnNotify)
     2763            pDevExt->MouseSetNotifyCallback.pfnNotify(pDevExt->MouseSetNotifyCallback.pvNotify);
     2764#endif
     2765    }
     2766
     2767    ASMAtomicDecU32(&pDevExt->cISR);
    27172768    Assert(rc == 0);
    27182769    return fOurIrq;
  • trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuestInternal.h

    r41619 r41640  
    167167     * together inside the session spinlock. */
    168168    uint32_t volatile           fMouseStatus;
     169    /** Callback and user data for a kernel mouse handler. */
     170    VBoxGuestMouseSetNotifyCallback volatile MouseSetNotifyCallback;
     171    /** Counter of number of active ISRs.  Currently used for safely removing
     172     * the mouse handler callback. */
     173    uint32_t volatile           cISR;
    169174
    170175    /** Windows part. */
Note: See TracChangeset for help on using the changeset viewer.

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