VirtualBox

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


Ignore:
Timestamp:
Apr 26, 2013 3:18:59 PM (12 years ago)
Author:
vboxsync
Message:

VBoxGuest: better caps filtering; cleanup

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

Legend:

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

    r45778 r45779  
    7373static int VBoxGuestCommonGuestCapsAcquire(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession, uint32_t fOrMask, uint32_t fNotMask);
    7474
    75 #define VBOXGUEST_ACQUIRE_STYLE_CAPS (VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST | VMMDEV_EVENT_SEAMLESS_MODE_CHANGE_REQUEST)
     75#define VBOXGUEST_ACQUIRE_STYLE_EVENTS (VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST | VMMDEV_EVENT_SEAMLESS_MODE_CHANGE_REQUEST)
    7676
    7777DECLINLINE(uint32_t) VBoxGuestCommonGetHandledEventsLocked(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession)
    7878{
    79     if(pDevExt->enmGuestCapsAcquireMode != VBOXGUUESTCAPS_MODE_ACQUIRE)
     79    if(!pDevExt->u32AcquireModeGuestCaps)
    8080        return VMMDEV_EVENT_VALID_EVENT_MASK;
    8181
    82     uint32_t u32AquiredGuestCaps = pSession->u32AquiredGuestCaps;
    83     uint32_t u32CleanupEvents = VBOXGUEST_ACQUIRE_STYLE_CAPS;
    84     if (u32AquiredGuestCaps & VMMDEV_GUEST_SUPPORTS_GRAPHICS)
     82    uint32_t u32AllowedGuestCaps = pSession->u32AquiredGuestCaps | (VMMDEV_EVENT_VALID_EVENT_MASK & ~pDevExt->u32AcquireModeGuestCaps);
     83    uint32_t u32CleanupEvents = VBOXGUEST_ACQUIRE_STYLE_EVENTS;
     84    if (u32AllowedGuestCaps & VMMDEV_GUEST_SUPPORTS_GRAPHICS)
    8585        u32CleanupEvents &= ~VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST;
    86     if (u32AquiredGuestCaps & VMMDEV_GUEST_SUPPORTS_SEAMLESS)
     86    if (u32AllowedGuestCaps & VMMDEV_GUEST_SUPPORTS_SEAMLESS)
    8787        u32CleanupEvents &= ~VMMDEV_EVENT_SEAMLESS_MODE_CHANGE_REQUEST;
    8888
     
    9898}
    9999
    100 DECLINLINE(bool) VBoxGuestCommonGuestCapsModeSet(PVBOXGUESTDEVEXT pDevExt, VBOXGUUESTCAPS_MODE enmMode)
    101 {
    102     VBOXGUUESTCAPS_MODE enmOldMode;
    103     if (ASMAtomicCmpXchgExU32((volatile uint32_t*)&pDevExt->enmGuestCapsAcquireMode, enmMode, VBOXGUUESTCAPS_MODE_UNDEFINED, (uint32_t*)&enmOldMode))
    104         return true;
    105     return enmOldMode == enmMode;
     100DECLINLINE(bool) VBoxGuestCommonGuestCapsModeSet(PVBOXGUESTDEVEXT pDevExt, uint32_t fCaps, bool fAcquire, uint32_t *pu32OtherVal)
     101{
     102    uint32_t *pVal = fAcquire ? &pDevExt->u32AcquireModeGuestCaps : &pDevExt->u32SetModeGuestCaps;
     103    const uint32_t fNotVal = !fAcquire ? pDevExt->u32AcquireModeGuestCaps : pDevExt->u32SetModeGuestCaps;
     104    bool fResult = true;
     105    RTSpinlockAcquire(pDevExt->EventSpinlock);
     106
     107    if (!(fNotVal & fCaps))
     108        *pVal |= fCaps;
     109    else
     110    {
     111        AssertMsgFailed(("trying to change caps mode\n"));
     112        fResult = false;
     113    }
     114
     115    RTSpinlockReleaseNoInts(pDevExt->EventSpinlock);
     116
     117    if (pu32OtherVal)
     118        *pu32OtherVal = fNotVal;
     119    return fResult;
    106120}
    107121
     
    803817    }
    804818
    805     pDevExt->enmGuestCapsAcquireMode = VBOXGUUESTCAPS_MODE_UNDEFINED;
     819    pDevExt->u32AcquireModeGuestCaps = 0;
     820    pDevExt->u32SetModeGuestCaps = 0;
    806821    pDevExt->u32GuestCaps = 0;
    807822
     
    15851600         */
    15861601        case VMMDevReq_SetGuestCapabilities:
    1587 #if 0
    1588             /* @todo: currently windows clients use both Set and Acquire for different caps
    1589              * this should not lead to any problem, however, better switch to consistent behavior */
    1590             if (!VBoxGuestCommonGuestCapsModeSet(pDevExt, VBOXGUUESTCAPS_MODE_SET))
     1602        {
     1603            VMMDevReqGuestCapabilities2 *pCaps = (VMMDevReqGuestCapabilities2*)pReqHdr;
     1604            uint32_t fAcquireCaps = 0;
     1605            if (!VBoxGuestCommonGuestCapsModeSet(pDevExt, pCaps->u32OrMask, false, &fAcquireCaps))
    15911606            {
    1592                 Assert(0);
    1593                 LogRel(("calling caps set for invalid caps mode %d\n", pDevExt->enmGuestCapsAcquireMode));
     1607                AssertFailed();
     1608                LogRel(("calling caps set for acquired caps %d\n", pCaps->u32OrMask));
    15941609                enmRequired = kLevel_NoOne;
    15951610                break;
    15961611            }
    1597 #endif
     1612            /* hack to adjust the notcaps.
     1613             * @todo: move to a better place
     1614             * user-mode apps are allowed to pass any mask to the notmask,
     1615             * the driver cleans up them accordingly */
     1616            pCaps->u32NotMask &= ~fAcquireCaps;
    15981617            /* do not break, make it fall through to the below enmRequired setting */
     1618        }
    15991619        /*
    16001620         * Anyone.
     
    25102530    ASMAtomicWriteU32(&pDevExt->f32PendingEvents, fEvents);
    25112531
    2512     RTSpinlockRelease(pDevExt->EventSpinlock);
     2532    RTSpinlockReleaseNoInts(pDevExt->EventSpinlock);
    25132533
    25142534#ifdef VBOXGUEST_USE_DEFERRED_WAKE_UP
     
    25192539static int VBoxGuestCommonGuestCapsAcquire(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession, uint32_t fOrMask, uint32_t fNotMask)
    25202540{
    2521     if (!VBoxGuestCommonGuestCapsModeSet(pDevExt, VBOXGUUESTCAPS_MODE_ACQUIRE))
     2541    uint32_t fSetCaps = 0;
     2542    if (!VBoxGuestCommonGuestCapsModeSet(pDevExt, fOrMask, true, &fSetCaps))
    25222543    {
    25232544        Assert(0);
    2524         LogRel(("calling caps acquire for invalid caps mode %d\n", pDevExt->enmGuestCapsAcquireMode));
     2545        LogRel(("calling caps acquire for set caps %d\n", fOrMask));
    25252546        return VERR_INVALID_STATE;
    25262547    }
     2548
     2549    /* user-mode apps are allowed to pass any mask to the notmask,
     2550     * the driver cleans up them accordingly */
     2551    fNotMask &= ~fSetCaps;
     2552
    25272553    if (!VBoxGuestCommonGuestCapsValidateValues(fOrMask))
    25282554        return VERR_INVALID_PARAMETER;
  • trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuestInternal.h

    r45778 r45779  
    107107/** Pointer to a memory balloon. */
    108108typedef VBOXGUESTMEMBALLOON *PVBOXGUESTMEMBALLOON;
    109 
    110 typedef enum VBOXGUUESTCAPS_MODE
    111 {
    112     VBOXGUUESTCAPS_MODE_UNDEFINED = 0,
    113     /* uncomment when/if guests have consistent Acquire/Set behavior,
    114      * i.e. only either of those should be used, while at leats on win they are used interchangeably */
    115     /*VBOXGUUESTCAPS_MODE_SET,*/
    116     VBOXGUUESTCAPS_MODE_ACQUIRE,
    117     VBOXGUUESTCAPS_MODE_Make32bit = 0x7fffffff,
    118 } VBOXGUUESTCAPS_MODE;
    119109
    120110/**
     
    190180    /** Callback and user data for a kernel mouse handler. */
    191181    VBoxGuestMouseSetNotifyCallback MouseNotifyCallback;
    192     /* true if the driver is in caps acquire mode,
    193      * i.e. no seamless of resize events are reported unless the driver has acquired the corresponding guest caps */
    194     volatile VBOXGUUESTCAPS_MODE enmGuestCapsAcquireMode;
     182    /* list of caps used in acquire mode */
     183    uint32_t                    u32AcquireModeGuestCaps;
     184    /* list of caps used in set mode */
     185    uint32_t                    u32SetModeGuestCaps;
    195186    /* currently acquired (and reported) guest caps */
    196187    uint32_t                    u32GuestCaps;
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