VirtualBox

Changeset 3379 in vbox for trunk/src/VBox/Devices/VMMDev


Ignore:
Timestamp:
Jul 3, 2007 9:25:38 AM (18 years ago)
Author:
vboxsync
Message:

Reimplemented r22537: Automatically enable HGCM host events, when the guest issues HGCM commands.

Location:
trunk/src/VBox/Devices/VMMDev
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/VMMDev/VBoxDev.cpp

    r3345 r3379  
    3232#include <VBox/pgm.h>
    3333#include <VBox/err.h>
     34#include <VBox/vm.h> /* for VM_IS_EMT */
    3435
    3536#define LOG_GROUP LOG_GROUP_DEV_VMM
     
    209210}
    210211
    211 void vmmdevCtlGuestFilterMask_EMT (VMMDevState *pVMMDevState,
    212                                    uint32_t u32OrMask,
    213                                    uint32_t u32NotMask)
     212static void vmmdevCtlGuestFilterMask_EMT (VMMDevState *pVMMDevState,
     213                                          uint32_t u32OrMask,
     214                                          uint32_t u32NotMask)
    214215{
    215216    const bool fHadEvents =
     
    230231        pVMMDevState->u32GuestFilterMask &= ~u32NotMask;
    231232        vmmdevMaybeSetIRQ_EMT (pVMMDevState);
     233    }
     234}
     235
     236void VMMDevCtlSetGuestFilterMask (VMMDevState *pVMMDevState,
     237                                  uint32_t u32OrMask,
     238                                  uint32_t u32NotMask)
     239{
     240    PPDMDEVINS pDevIns = VMMDEVSTATE_2_DEVINS(pVMMDevState);
     241    PVM pVM = PDMDevHlpGetVM(pDevIns);
     242
     243#ifdef DEBUG_sunlover
     244    Log(("VMMDevCtlSetGuestFilterMask: u32OrMask = 0x%08X, u32NotMask = 0x%08X.\n", u32OrMask, u32NotMask));
     245#endif /* DEBUG_sunlover */
     246
     247    if (VM_IS_EMT(pVM))
     248    {
     249        vmmdevCtlGuestFilterMask_EMT (pVMMDevState, u32OrMask, u32NotMask);
     250    }
     251    else
     252    {
     253        int rc;
     254        PVMREQ pReq;
     255
     256        rc = VMR3ReqCallVoid (pVM, &pReq, RT_INDEFINITE_WAIT,
     257                              (PFNRT) vmmdevCtlGuestFilterMask_EMT,
     258                              3, pVMMDevState, u32OrMask, u32NotMask);
     259        AssertReleaseRC (rc);
     260        VMR3ReqFree (pReq);
    232261    }
    233262}
     
    898927
    899928                pCtlMaskRequest = (VMMDevCtlGuestFilterMask *) requestHeader;
     929                /* The HGCM events are enabled by the VMMDev device automatically when any
     930                 * HGCM command is issued. The guest then can not disable these events.
     931                 */
    900932                vmmdevCtlGuestFilterMask_EMT (pData,
    901933                                              pCtlMaskRequest->u32OrMask,
    902                                               pCtlMaskRequest->u32NotMask);
     934                                              pCtlMaskRequest->u32NotMask & ~VMMDEV_EVENT_HGCM);
    903935                requestHeader->rc = VINF_SUCCESS;
    904936
     
    17771809    rc = RTCritSectInit(&pData->critsectHGCMCmdList);
    17781810    AssertRCReturn(rc, rc);
    1779     pData->u32HGCMRefs = 0;
     1811    pData->u32HGCMEnabled = 0;
    17801812#endif /* VBOX_HGCM */
    17811813
  • trunk/src/VBox/Devices/VMMDev/VMMDevHGCM.cpp

    r3345 r3379  
    132132            || enmCmdType == VBOXHGCMCMDTYPE_CALL)
    133133        {
    134             uint32_t u32 = ASMAtomicIncU32 (&pVMMDevState->u32HGCMRefs);
    135             Assert(u32 != 0);
    136             vmmdevCtlGuestFilterMask_EMT (pVMMDevState, VMMDEV_EVENT_HGCM, 0);
     134            if (ASMAtomicCmpXchgU32(&pVMMDevState->u32HGCMEnabled, 1, 0))
     135            {
     136                 VMMDevCtlSetGuestFilterMask (pVMMDevState, VMMDEV_EVENT_HGCM, 0);
     137            }
    137138        }
    138139
     
    169170        {
    170171            pVMMDevState->pHGCMCmdList = pCmd->pNext;
    171         }
    172 
    173         /* Automatically disable HGCM events, if there are no more HGCM commands. */
    174         if (   pCmd->enmCmdType == VBOXHGCMCMDTYPE_CONNECT
    175             || pCmd->enmCmdType == VBOXHGCMCMDTYPE_DISCONNECT
    176             || pCmd->enmCmdType == VBOXHGCMCMDTYPE_CALL)
    177         {
    178             uint32_t u32 = ASMAtomicDecU32 (&pVMMDevState->u32HGCMRefs);
    179             Assert(u32 != 0xFFFFFFFF);
    180             if (u32 == 0)
    181             {
    182                 vmmdevCtlGuestFilterMask_EMT (pVMMDevState, 0, VMMDEV_EVENT_HGCM);
    183             }
    184172        }
    185173
  • trunk/src/VBox/Devices/VMMDev/VMMDevState.h

    r3345 r3379  
    148148    /** Critical section to protect the list. */
    149149    RTCRITSECT critsectHGCMCmdList;
    150     /** How many HGCM commands are pending. */
    151     volatile uint32_t u32HGCMRefs;
     150    /** Whether the HGCM events are already automatically enabled. */
     151    uint32_t u32HGCMEnabled;
    152152#endif /* VBOX_HGCM */
    153153
     
    155155
    156156void VMMDevNotifyGuest (VMMDevState *pVMMDevState, uint32_t u32EventMask);
    157 void vmmdevCtlGuestFilterMask_EMT (VMMDevState *pVMMDevState,
    158                                    uint32_t u32OrMask,
    159                                    uint32_t u32NotMask);
     157void VMMDevCtlSetGuestFilterMask (VMMDevState *pVMMDevState,
     158                                  uint32_t u32OrMask,
     159                                  uint32_t u32NotMask);
    160160
    161161#endif /* __VMMDevState_h__ */
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