Changeset 54522 in vbox
- Timestamp:
- Feb 26, 2015 1:39:47 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest.cpp
r54239 r54522 67 67 static DECLCALLBACK(int) VBoxGuestHGCMAsyncWaitCallback(VMMDevHGCMRequestHeader *pHdrNonVolatile, void *pvUser, uint32_t u32User); 68 68 #endif 69 70 static int VBoxGuestCommonGuestCapsAcquire(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession, uint32_t fOrMask, uint32_t fNotMask, VBOXGUESTCAPSACQUIRE_FLAGS enmFlags); 69 static int VBoxGuestCommonGuestCapsAcquire(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession, uint32_t fOrMask, 70 uint32_t fNotMask, VBOXGUESTCAPSACQUIRE_FLAGS enmFlags); 71 static int VBoxGuestCommonIOCtl_CancelAllWaitEvents(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession); 71 72 72 73 #define VBOXGUEST_ACQUIRE_STYLE_EVENTS (VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST | VMMDEV_EVENT_SEAMLESS_MODE_CHANGE_REQUEST) … … 135 136 * @param fMask The new mask. 136 137 */ 137 static int vboxGuestSetFilterMask(VMMDevCtlGuestFilterMask *pReq, 138 uint32_t fMask) 138 static int vboxGuestSetFilterMask(VMMDevCtlGuestFilterMask *pReq, uint32_t fMask) 139 139 { 140 140 int rc; … … 158 158 * @param fMask The new mask. 159 159 */ 160 static int vboxGuestSetCapabilities(VMMDevReqGuestCapabilities2 *pReq, 161 uint32_t fMask) 160 static int vboxGuestSetCapabilities(VMMDevReqGuestCapabilities2 *pReq, uint32_t fMask) 162 161 { 163 162 int rc; … … 197 196 /** Host flags to be updated by a given invocation of the 198 197 * vboxGuestUpdateHostFlags() method. */ 198 /** @todo r=bird: Use RT_BIT_32 for the bits, preferably replace enum with 199 * \#define. */ 199 200 enum 200 201 { … … 218 219 int rc = VINF_SUCCESS; 219 220 221 /** @todo r=bird: Please just do the global bit counting thing. This code 222 * gives me the [performances] creeps. */ 220 223 RTListForEach(&pDevExt->SessionList, pIterator, VBOXGUESTSESSION, ListNode) 221 224 { … … 245 248 246 249 247 /** Check which host flags in a given category are being asserted by some guest 250 /** 251 * Calls the host and set the filter mask, capabilities and/or mouse status. 252 * 253 * Check which host flags in a given category are being asserted by some guest 248 254 * session and assert exactly those on the host which are being asserted by one 249 255 * or more sessions. pCallingSession is purely for sanity checking and can be 250 256 * NULL. 257 * 251 258 * @note Takes the session spin-lock. 252 259 */ 253 260 static int vboxGuestUpdateHostFlags(PVBOXGUESTDEVEXT pDevExt, 254 261 PVBOXGUESTSESSION pSession, 255 unsigned enmFlags)262 unsigned fFlags) 256 263 { 257 264 int rc; … … 259 266 VMMDevReqGuestCapabilities2 *pCapabilitiesReq = NULL; 260 267 VMMDevReqMouseStatus *pStatusReq = NULL; 261 uint32_t fFilterMask = 0, fCapabilities = 0, fMouseStatus = 0; 268 uint32_t fFilterMask = 0; 269 uint32_t fCapabilities = 0; 270 uint32_t fMouseStatus = 0; 262 271 263 272 rc = VbglGRAlloc((VMMDevRequestHeader **)&pFilterReq, sizeof(*pFilterReq), … … 270 279 rc = VbglGRAlloc((VMMDevRequestHeader **)&pStatusReq, 271 280 sizeof(*pStatusReq), VMMDevReq_SetMouseStatus); 272 RTSpinlockAcquire(pDevExt->SessionSpinlock);273 281 if (RT_SUCCESS(rc)) 282 { 283 RTSpinlockAcquire(pDevExt->SessionSpinlock); 274 284 rc = vboxGuestGetHostFlagsFromSessions(pDevExt, pSession, &fFilterMask, 275 285 &fCapabilities, &fMouseStatus); 276 if (RT_SUCCESS(rc)) 277 { 278 fFilterMask |= pDevExt->fFixedEvents; 279 /* Since VMMDEV_MOUSE_GUEST_NEEDS_HOST_CURSOR is inverted in the session 280 * capabilities we invert it again before sending it to the host. */ 281 fMouseStatus ^= VMMDEV_MOUSE_GUEST_NEEDS_HOST_CURSOR; 282 if (enmFlags & HostFlags_FilterMask) 283 vboxGuestSetFilterMask(pFilterReq, fFilterMask); 284 fCapabilities |= pDevExt->u32GuestCaps; 285 if (enmFlags & HostFlags_Capabilities) 286 vboxGuestSetCapabilities(pCapabilitiesReq, fCapabilities); 287 if (enmFlags & HostFlags_MouseStatus) 288 vboxGuestSetMouseStatus(pStatusReq, fMouseStatus); 289 } 290 RTSpinlockRelease(pDevExt->SessionSpinlock); 286 if (RT_SUCCESS(rc)) 287 { 288 fFilterMask |= pDevExt->fFixedEvents; 289 /* Since VMMDEV_MOUSE_GUEST_NEEDS_HOST_CURSOR is inverted in the session 290 * capabilities we invert it again before sending it to the host. */ 291 fMouseStatus ^= VMMDEV_MOUSE_GUEST_NEEDS_HOST_CURSOR; 292 if (fFlags & HostFlags_FilterMask) 293 vboxGuestSetFilterMask(pFilterReq, fFilterMask); 294 fCapabilities |= pDevExt->u32GuestCaps; 295 if (fFlags & HostFlags_Capabilities) 296 vboxGuestSetCapabilities(pCapabilitiesReq, fCapabilities); 297 if (fFlags & HostFlags_MouseStatus) 298 vboxGuestSetMouseStatus(pStatusReq, fMouseStatus); 299 } 300 RTSpinlockRelease(pDevExt->SessionSpinlock); 301 } 291 302 if (pFilterReq) 292 303 VbglGRFree(&pFilterReq->header); … … 299 310 300 311 312 /** @todo r=bird: WTF did someone add code before the globals? */ 301 313 /******************************************************************************* 302 314 * Global Variables * … … 1333 1345 } 1334 1346 1335 static int VBoxGuestCommonIOCtl_CancelAllWaitEvents(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession);1336 1347 1337 1348 /** … … 1343 1354 void VBoxGuestCloseSession(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession) 1344 1355 { 1345 unsigned i; NOREF(i); 1356 #ifdef VBOX_WITH_HGCM 1357 unsigned i; 1358 #endif 1346 1359 LogFlow(("VBoxGuestCloseSession: pSession=%p proc=%RTproc (%d) r0proc=%p\n", 1347 1360 pSession, pSession->Process, (int)pSession->Process, (uintptr_t)pSession->R0Process)); /** @todo %RTr0proc */ … … 1373 1386 RTMemFree(pSession); 1374 1387 /* Update the host flags (mouse status etc) not to reflect this session. */ 1375 vboxGuestUpdateHostFlags(pDevExt, NULL, HostFlags_All 1388 vboxGuestUpdateHostFlags(pDevExt, NULL, 1389 HostFlags_All 1376 1390 #ifdef RT_OS_WINDOWS 1377 & (~HostFlags_MouseStatus)1391 & ~HostFlags_MouseStatus 1378 1392 #endif 1379 );1393 ); 1380 1394 } 1381 1395 … … 2081 2095 2082 2096 2083 static int VBoxGuestCommonIOCtl_CtlFilterMask(PVBOXGUESTDEVEXT pDevExt, 2084 PVBOXGUESTSESSION pSession, 2097 static int VBoxGuestCommonIOCtl_CtlFilterMask(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession, 2085 2098 VBoxGuestFilterMaskInfo *pInfo) 2086 2099 { … … 2098 2111 2099 2112 2100 static int VBoxGuestCommonIOCtl_SetCapabilities(PVBOXGUESTDEVEXT pDevExt, 2101 PVBOXGUESTSESSION pSession, 2102 VBoxGuestSetCapabilitiesInfo *pInfo) 2113 static int VBoxGuestCommonIOCtl_SetCapabilities(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession, 2114 VBoxGuestSetCapabilitiesInfo *pInfo) 2103 2115 { 2104 2116 int rc; 2105 2117 2106 if ( (pInfo->u32OrMask | pInfo->u32NotMask) 2107 & ~VMMDEV_GUEST_CAPABILITIES_MASK) 2118 if ((pInfo->u32OrMask | pInfo->u32NotMask) & ~VMMDEV_GUEST_CAPABILITIES_MASK) 2108 2119 return VERR_INVALID_PARAMETER; 2109 2120 RTSpinlockAcquire(pDevExt->SessionSpinlock); … … 2126 2137 * @param fFeatures New bitmap of enabled features. 2127 2138 */ 2128 static int vboxGuestCommonIOCtl_SetMouseStatus(PVBOXGUESTDEVEXT pDevExt, 2129 PVBOXGUESTSESSION pSession, 2130 uint32_t fFeatures) 2139 static int vboxGuestCommonIOCtl_SetMouseStatus(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession, uint32_t fFeatures) 2131 2140 { 2132 2141 int rc; … … 2248 2257 true /* fInterruptible */, 2249 2258 u32User /* cMillies */ ); 2250 2251 2259 } 2252 2260 … … 2689 2697 * VBOXGUESTCAPSACQUIRE_FLAGS_CONFIG_ACQUIRE_MODE, also try to acquire those 2690 2698 * capabilities for the current session and release those in @a fNotFlag. */ 2691 static int VBoxGuestCommonGuestCapsAcquire(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession, uint32_t fOrMask, uint32_t fNotMask, VBOXGUESTCAPSACQUIRE_FLAGS enmFlags) 2699 static int VBoxGuestCommonGuestCapsAcquire(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession, 2700 uint32_t fOrMask, uint32_t fNotMask, VBOXGUESTCAPSACQUIRE_FLAGS enmFlags) 2692 2701 { 2693 2702 uint32_t fSetCaps = 0; … … 2777 2786 * this is generally bad since e.g. failure to release the caps may result in other sessions not being able to use it 2778 2787 * so we are not trying to restore the caps back to their values before the VBoxGuestCommonGuestCapsAcquire call, 2779 * but just pretend everithing is OK. 2780 * @todo:better failure handling mechanism? */2788 * but just pretend everithing is OK. */ 2789 /** @todo better failure handling mechanism? */ 2781 2790 } 2782 2791 … … 2974 2983 2975 2984 case VBOXGUEST_IOCTL_CTL_FILTER_MASK: 2976 CHECKRET_MIN_SIZE("CTL_FILTER_MASK", 2977 sizeof(VBoxGuestFilterMaskInfo)); 2978 rc = VBoxGuestCommonIOCtl_CtlFilterMask(pDevExt, pSession, 2979 (VBoxGuestFilterMaskInfo *)pvData); 2985 CHECKRET_MIN_SIZE("CTL_FILTER_MASK", sizeof(VBoxGuestFilterMaskInfo)); 2986 rc = VBoxGuestCommonIOCtl_CtlFilterMask(pDevExt, pSession, (VBoxGuestFilterMaskInfo *)pvData); 2980 2987 break; 2981 2988 … … 2994 3001 # endif 2995 3002 CHECKRET_MIN_SIZE("HGCM_DISCONNECT", sizeof(VBoxGuestHGCMDisconnectInfo)); 2996 rc = VBoxGuestCommonIOCtl_HGCMDisconnect(pDevExt, pSession, (VBoxGuestHGCMDisconnectInfo *)pvData, pcbDataReturned); 3003 rc = VBoxGuestCommonIOCtl_HGCMDisconnect(pDevExt, pSession, (VBoxGuestHGCMDisconnectInfo *)pvData, 3004 pcbDataReturned); 2997 3005 break; 2998 3006 #endif /* VBOX_WITH_HGCM */ … … 3000 3008 case VBOXGUEST_IOCTL_CHECK_BALLOON: 3001 3009 CHECKRET_MIN_SIZE("CHECK_MEMORY_BALLOON", sizeof(VBoxGuestCheckBalloonInfo)); 3002 rc = VBoxGuestCommonIOCtl_CheckMemoryBalloon(pDevExt, pSession, (VBoxGuestCheckBalloonInfo *)pvData, pcbDataReturned); 3010 rc = VBoxGuestCommonIOCtl_CheckMemoryBalloon(pDevExt, pSession, (VBoxGuestCheckBalloonInfo *)pvData, 3011 pcbDataReturned); 3003 3012 break; 3004 3013 3005 3014 case VBOXGUEST_IOCTL_CHANGE_BALLOON: 3006 3015 CHECKRET_MIN_SIZE("CHANGE_MEMORY_BALLOON", sizeof(VBoxGuestChangeBalloonInfo)); 3007 rc = VBoxGuestCommonIOCtl_ChangeMemoryBalloon(pDevExt, pSession, (VBoxGuestChangeBalloonInfo *)pvData, pcbDataReturned); 3016 rc = VBoxGuestCommonIOCtl_ChangeMemoryBalloon(pDevExt, pSession, (VBoxGuestChangeBalloonInfo *)pvData, 3017 pcbDataReturned); 3008 3018 break; 3009 3019 … … 3015 3025 case VBOXGUEST_IOCTL_SET_MOUSE_STATUS: 3016 3026 CHECKRET_SIZE("SET_MOUSE_STATUS", sizeof(uint32_t)); 3017 rc = vboxGuestCommonIOCtl_SetMouseStatus(pDevExt, pSession, 3018 *(uint32_t *)pvData); 3027 rc = vboxGuestCommonIOCtl_SetMouseStatus(pDevExt, pSession, *(uint32_t *)pvData); 3019 3028 break; 3020 3029 … … 3033 3042 3034 3043 case VBOXGUEST_IOCTL_SET_GUEST_CAPABILITIES: 3035 CHECKRET_MIN_SIZE("SET_GUEST_CAPABILITIES", 3036 sizeof(VBoxGuestSetCapabilitiesInfo)); 3037 rc = VBoxGuestCommonIOCtl_SetCapabilities(pDevExt, pSession, 3038 (VBoxGuestSetCapabilitiesInfo *)pvData); 3044 CHECKRET_MIN_SIZE("SET_GUEST_CAPABILITIES", sizeof(VBoxGuestSetCapabilitiesInfo)); 3045 rc = VBoxGuestCommonIOCtl_SetCapabilities(pDevExt, pSession, (VBoxGuestSetCapabilitiesInfo *)pvData); 3039 3046 break; 3040 3047
Note:
See TracChangeset
for help on using the changeset viewer.