Changeset 41640 in vbox for trunk/src/VBox/Additions/common
- Timestamp:
- Jun 11, 2012 9:17:49 AM (13 years ago)
- svn:sync-xref-src-repo-rev:
- 78440
- Location:
- trunk/src/VBox/Additions/common/VBoxGuest
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest.cpp
r41639 r41640 727 727 pDevExt->acMouseFeatureUsage[i] = 0; 728 728 pDevExt->fMouseStatus = 0; 729 pDevExt->MouseSetNotifyCallback.pfnNotify = NULL; 730 pDevExt->MouseSetNotifyCallback.pvNotify = NULL; 731 pDevExt->cISR = 0; 729 732 730 733 /* … … 1225 1228 return VINF_SUCCESS; 1226 1229 } 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 */ 1247 int 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 1227 1262 1228 1263 … … 2504 2539 break; 2505 2540 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 2506 2550 case VBOXGUEST_IOCTL_WAITEVENT: 2507 2551 CHECKRET_MIN_SIZE("WAITEVENT", sizeof(VBoxGuestWaitEventInfo)); … … 2607 2651 2608 2652 /* 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. 2610 2655 */ 2611 2656 RTSpinlockAcquire(pDevExt->EventSpinlock); 2657 ASMAtomicIncU32(&pDevExt->cISR); 2612 2658 fOurIrq = pDevExt->pVMMDevMemory->V.V1_04.fHaveEvents; 2613 2659 if (fOurIrq) … … 2713 2759 ASMAtomicIncU32(&pDevExt->u32MousePosChangedSeq); 2714 2760 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); 2717 2768 Assert(rc == 0); 2718 2769 return fOurIrq; -
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuestInternal.h
r41619 r41640 167 167 * together inside the session spinlock. */ 168 168 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; 169 174 170 175 /** Windows part. */
Note:
See TracChangeset
for help on using the changeset viewer.