Changeset 40806 in vbox for trunk/src/VBox/Additions/common/VBoxGuest
- Timestamp:
- Apr 6, 2012 9:05:19 PM (13 years ago)
- svn:sync-xref-src-repo-rev:
- 77321
- Location:
- trunk/src/VBox/Additions/common/VBoxGuest
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-os2.cpp
r33540 r40806 164 164 * Initialize the session hash table. 165 165 */ 166 rc = RTSpinlockCreate(&g_Spinlock );166 rc = RTSpinlockCreate(&g_Spinlock, RTSPINLOCK_FLAGS_INTERRUPT_SAFE, "VBoxGuestOS2"); 167 167 if (RT_SUCCESS(rc)) 168 168 { … … 370 370 */ 371 371 unsigned iHash = SESSION_HASH(sfn); 372 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 373 RTSpinlockAcquireNoInts(g_Spinlock, &Tmp); 372 RTSpinlockAcquire(g_Spinlock); 374 373 pSession->pNextHash = g_apSessionHashTab[iHash]; 375 374 g_apSessionHashTab[iHash] = pSession; 376 RTSpinlockReleaseNoInts(g_Spinlock , &Tmp);375 RTSpinlockReleaseNoInts(g_Spinlock); 377 376 } 378 377 … … 392 391 const RTPROCESS Process = RTProcSelf(); 393 392 const unsigned iHash = SESSION_HASH(sfn); 394 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 395 RTSpinlockAcquireNoInts(g_Spinlock, &Tmp); 393 RTSpinlockAcquire(g_Spinlock); 396 394 397 395 pSession = g_apSessionHashTab[iHash]; … … 424 422 } 425 423 } 426 RTSpinlockReleaseNoInts(g_Spinlock , &Tmp);424 RTSpinlockReleaseNoInts(g_Spinlock); 427 425 if (!pSession) 428 426 { … … 444 442 * Find the session. 445 443 */ 446 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;447 444 const RTPROCESS Process = RTProcSelf(); 448 445 const unsigned iHash = SESSION_HASH(sfn); 449 446 PVBOXGUESTSESSION pSession; 450 447 451 RTSpinlockAcquire NoInts(g_Spinlock, &Tmp);448 RTSpinlockAcquire(g_Spinlock); 452 449 pSession = g_apSessionHashTab[iHash]; 453 450 if (pSession && pSession->Process != Process) … … 458 455 || pSession->Process != Process)); 459 456 } 460 RTSpinlockReleaseNoInts(g_Spinlock , &Tmp);457 RTSpinlockReleaseNoInts(g_Spinlock); 461 458 if (RT_UNLIKELY(!pSession)) 462 459 { … … 536 533 * Find the session. 537 534 */ 538 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;539 535 const RTPROCESS Process = RTProcSelf(); 540 536 const unsigned iHash = SESSION_HASH(sfn); 541 537 PVBOXGUESTSESSION pSession; 542 538 543 RTSpinlockAcquire NoInts(g_Spinlock, &Tmp);539 RTSpinlockAcquire(g_Spinlock); 544 540 pSession = g_apSessionHashTab[iHash]; 545 541 if (pSession && pSession->Process != Process) … … 550 546 || pSession->Process != Process)); 551 547 } 552 RTSpinlockReleaseNoInts(g_Spinlock , &Tmp);548 RTSpinlockReleaseNoInts(g_Spinlock); 553 549 if (!pSession) 554 550 { -
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest.cpp
r40483 r40806 747 747 * Create the wait and session spinlocks as well as the ballooning mutex. 748 748 */ 749 rc = RTSpinlockCreate(&pDevExt->EventSpinlock );749 rc = RTSpinlockCreate(&pDevExt->EventSpinlock, RTSPINLOCK_FLAGS_INTERRUPT_SAFE, "VBoxGuestEvent"); 750 750 if (RT_SUCCESS(rc)) 751 rc = RTSpinlockCreate(&pDevExt->SessionSpinlock );751 rc = RTSpinlockCreate(&pDevExt->SessionSpinlock, RTSPINLOCK_FLAGS_INTERRUPT_SAFE, "VBoxGuestSession"); 752 752 if (RT_FAILURE(rc)) 753 753 { … … 1011 1011 if (pWait) 1012 1012 { 1013 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 1014 RTSpinlockAcquireNoInts(pDevExt->EventSpinlock, &Tmp); 1013 RTSpinlockAcquire(pDevExt->EventSpinlock); 1015 1014 1016 1015 pWait = RTListGetFirst(&pDevExt->FreeList, VBOXGUESTWAIT, ListNode); … … 1018 1017 RTListNodeRemove(&pWait->ListNode); 1019 1018 1020 RTSpinlockReleaseNoInts(pDevExt->EventSpinlock , &Tmp);1019 RTSpinlockReleaseNoInts(pDevExt->EventSpinlock); 1021 1020 } 1022 1021 if (!pWait) … … 1101 1100 static void VBoxGuestWaitFreeUnlocked(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTWAIT pWait) 1102 1101 { 1103 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 1104 RTSpinlockAcquireNoInts(pDevExt->EventSpinlock, &Tmp); 1102 RTSpinlockAcquire(pDevExt->EventSpinlock); 1105 1103 VBoxGuestWaitFreeLocked(pDevExt, pWait); 1106 RTSpinlockReleaseNoInts(pDevExt->EventSpinlock , &Tmp);1104 RTSpinlockReleaseNoInts(pDevExt->EventSpinlock); 1107 1105 } 1108 1106 … … 1121 1119 if (!RTListIsEmpty(&pDevExt->WakeUpList)) 1122 1120 { 1123 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 1124 RTSpinlockAcquireNoInts(pDevExt->EventSpinlock, &Tmp); 1121 RTSpinlockAcquire(pDevExt->EventSpinlock); 1125 1122 for (;;) 1126 1123 { … … 1130 1127 break; 1131 1128 pWait->fPendingWakeUp = true; 1132 RTSpinlockReleaseNoInts(pDevExt->EventSpinlock , &Tmp);1129 RTSpinlockReleaseNoInts(pDevExt->EventSpinlock); 1133 1130 1134 1131 rc = RTSemEventMultiSignal(pWait->Event); 1135 1132 AssertRC(rc); 1136 1133 1137 RTSpinlockAcquire NoInts(pDevExt->EventSpinlock, &Tmp);1134 RTSpinlockAcquire(pDevExt->EventSpinlock); 1138 1135 pWait->fPendingWakeUp = false; 1139 1136 if (!pWait->fFreeMe) … … 1148 1145 } 1149 1146 } 1150 RTSpinlockReleaseNoInts(pDevExt->EventSpinlock , &Tmp);1147 RTSpinlockReleaseNoInts(pDevExt->EventSpinlock); 1151 1148 } 1152 1149 } … … 1234 1231 */ 1235 1232 DECLINLINE(int) WaitEventCheckCondition(PVBOXGUESTDEVEXT pDevExt, VBoxGuestWaitEventInfo *pInfo, 1236 int iEvent, const uint32_t fReqEvents , PRTSPINLOCKTMP pTmp)1233 int iEvent, const uint32_t fReqEvents) 1237 1234 { 1238 1235 uint32_t fMatches = pDevExt->f32PendingEvents & fReqEvents; … … 1240 1237 { 1241 1238 ASMAtomicAndU32(&pDevExt->f32PendingEvents, ~fMatches); 1242 RTSpinlockReleaseNoInts(pDevExt->EventSpinlock , pTmp);1239 RTSpinlockReleaseNoInts(pDevExt->EventSpinlock); 1243 1240 1244 1241 pInfo->u32EventFlagsOut = fMatches; … … 1250 1247 return VINF_SUCCESS; 1251 1248 } 1252 RTSpinlockReleaseNoInts(pDevExt->EventSpinlock , pTmp);1249 RTSpinlockReleaseNoInts(pDevExt->EventSpinlock); 1253 1250 return VERR_TIMEOUT; 1254 1251 } … … 1258 1255 VBoxGuestWaitEventInfo *pInfo, size_t *pcbDataReturned, bool fInterruptible) 1259 1256 { 1260 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;1261 1257 const uint32_t fReqEvents = pInfo->u32EventMaskIn; 1262 1258 uint32_t fResEvents; … … 1283 1279 * Check the condition up front, before doing the wait-for-event allocations. 1284 1280 */ 1285 RTSpinlockAcquire NoInts(pDevExt->EventSpinlock, &Tmp);1286 rc = WaitEventCheckCondition(pDevExt, pInfo, iEvent, fReqEvents , &Tmp);1281 RTSpinlockAcquire(pDevExt->EventSpinlock); 1282 rc = WaitEventCheckCondition(pDevExt, pInfo, iEvent, fReqEvents); 1287 1283 if (rc == VINF_SUCCESS) 1288 1284 return rc; … … 1305 1301 * Otherwise enter into the list and go to sleep waiting for the ISR to signal us. 1306 1302 */ 1307 RTSpinlockAcquire NoInts(pDevExt->EventSpinlock, &Tmp);1303 RTSpinlockAcquire(pDevExt->EventSpinlock); 1308 1304 RTListAppend(&pDevExt->WaitList, &pWait->ListNode); 1309 rc = WaitEventCheckCondition(pDevExt, pInfo, iEvent, fReqEvents , &Tmp);1305 rc = WaitEventCheckCondition(pDevExt, pInfo, iEvent, fReqEvents); 1310 1306 if (rc == VINF_SUCCESS) 1311 1307 { … … 1332 1328 * Unlink the wait item and dispose of it. 1333 1329 */ 1334 RTSpinlockAcquire NoInts(pDevExt->EventSpinlock, &Tmp);1330 RTSpinlockAcquire(pDevExt->EventSpinlock); 1335 1331 fResEvents = pWait->fResEvents; 1336 1332 VBoxGuestWaitFreeLocked(pDevExt, pWait); 1337 RTSpinlockReleaseNoInts(pDevExt->EventSpinlock , &Tmp);1333 RTSpinlockReleaseNoInts(pDevExt->EventSpinlock); 1338 1334 1339 1335 /* … … 1382 1378 static int VBoxGuestCommonIOCtl_CancelAllWaitEvents(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession) 1383 1379 { 1384 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;1385 1380 PVBOXGUESTWAIT pWait; 1386 1381 PVBOXGUESTWAIT pSafe; … … 1392 1387 * Walk the event list and wake up anyone with a matching session. 1393 1388 */ 1394 RTSpinlockAcquire NoInts(pDevExt->EventSpinlock, &Tmp);1389 RTSpinlockAcquire(pDevExt->EventSpinlock); 1395 1390 RTListForEachSafe(&pDevExt->WaitList, pWait, pSafe, VBOXGUESTWAIT, ListNode) 1396 1391 { … … 1407 1402 } 1408 1403 } 1409 RTSpinlockReleaseNoInts(pDevExt->EventSpinlock , &Tmp);1404 RTSpinlockReleaseNoInts(pDevExt->EventSpinlock); 1410 1405 Assert(rc == 0); 1411 1406 … … 1692 1687 * us returning too early. 1693 1688 */ 1694 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;1695 1689 PVBOXGUESTWAIT pWait; 1696 1690 for (;;) 1697 1691 { 1698 RTSpinlockAcquire NoInts(pDevExt->EventSpinlock, &Tmp);1692 RTSpinlockAcquire(pDevExt->EventSpinlock); 1699 1693 if ((pHdr->fu32Flags & VBOX_HGCM_REQ_DONE) != 0) 1700 1694 { 1701 RTSpinlockReleaseNoInts(pDevExt->EventSpinlock , &Tmp);1695 RTSpinlockReleaseNoInts(pDevExt->EventSpinlock); 1702 1696 return VINF_SUCCESS; 1703 1697 } 1704 RTSpinlockReleaseNoInts(pDevExt->EventSpinlock , &Tmp);1698 RTSpinlockReleaseNoInts(pDevExt->EventSpinlock); 1705 1699 1706 1700 pWait = VBoxGuestWaitAlloc(pDevExt, NULL); … … 1719 1713 * Otherwise link us into the HGCM wait list and go to sleep. 1720 1714 */ 1721 RTSpinlockAcquire NoInts(pDevExt->EventSpinlock, &Tmp);1715 RTSpinlockAcquire(pDevExt->EventSpinlock); 1722 1716 RTListAppend(&pDevExt->HGCMWaitList, &pWait->ListNode); 1723 1717 if ((pHdr->fu32Flags & VBOX_HGCM_REQ_DONE) != 0) 1724 1718 { 1725 1719 VBoxGuestWaitFreeLocked(pDevExt, pWait); 1726 RTSpinlockReleaseNoInts(pDevExt->EventSpinlock , &Tmp);1720 RTSpinlockReleaseNoInts(pDevExt->EventSpinlock); 1727 1721 return VINF_SUCCESS; 1728 1722 } 1729 RTSpinlockReleaseNoInts(pDevExt->EventSpinlock , &Tmp);1723 RTSpinlockReleaseNoInts(pDevExt->EventSpinlock); 1730 1724 1731 1725 if (fInterruptible) … … 1810 1804 */ 1811 1805 unsigned i; 1812 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 1813 RTSpinlockAcquireNoInts(pDevExt->SessionSpinlock, &Tmp); 1806 RTSpinlockAcquire(pDevExt->SessionSpinlock); 1814 1807 for (i = 0; i < RT_ELEMENTS(pSession->aHGCMClientIds); i++) 1815 1808 if (!pSession->aHGCMClientIds[i]) … … 1818 1811 break; 1819 1812 } 1820 RTSpinlockReleaseNoInts(pDevExt->SessionSpinlock , &Tmp);1813 RTSpinlockReleaseNoInts(pDevExt->SessionSpinlock); 1821 1814 if (i >= RT_ELEMENTS(pSession->aHGCMClientIds)) 1822 1815 { … … 1849 1842 const uint32_t u32ClientId = pInfo->u32ClientID; 1850 1843 unsigned i; 1851 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 1852 RTSpinlockAcquireNoInts(pDevExt->SessionSpinlock, &Tmp); 1844 RTSpinlockAcquire(pDevExt->SessionSpinlock); 1853 1845 for (i = 0; i < RT_ELEMENTS(pSession->aHGCMClientIds); i++) 1854 1846 if (pSession->aHGCMClientIds[i] == u32ClientId) … … 1857 1849 break; 1858 1850 } 1859 RTSpinlockReleaseNoInts(pDevExt->SessionSpinlock , &Tmp);1851 RTSpinlockReleaseNoInts(pDevExt->SessionSpinlock); 1860 1852 if (i >= RT_ELEMENTS(pSession->aHGCMClientIds)) 1861 1853 { … … 1881 1873 1882 1874 /* Update the client id array according to the result. */ 1883 RTSpinlockAcquire NoInts(pDevExt->SessionSpinlock, &Tmp);1875 RTSpinlockAcquire(pDevExt->SessionSpinlock); 1884 1876 if (pSession->aHGCMClientIds[i] == UINT32_MAX) 1885 1877 pSession->aHGCMClientIds[i] = RT_SUCCESS(rc) && RT_SUCCESS(pInfo->result) ? 0 : u32ClientId; 1886 RTSpinlockReleaseNoInts(pDevExt->SessionSpinlock , &Tmp);1878 RTSpinlockReleaseNoInts(pDevExt->SessionSpinlock); 1887 1879 1888 1880 return rc; … … 1897 1889 { 1898 1890 const uint32_t u32ClientId = pInfo->u32ClientID; 1899 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;1900 1891 uint32_t fFlags; 1901 1892 size_t cbActual; … … 1929 1920 * Validate the client id. 1930 1921 */ 1931 RTSpinlockAcquire NoInts(pDevExt->SessionSpinlock, &Tmp);1922 RTSpinlockAcquire(pDevExt->SessionSpinlock); 1932 1923 for (i = 0; i < RT_ELEMENTS(pSession->aHGCMClientIds); i++) 1933 1924 if (pSession->aHGCMClientIds[i] == u32ClientId) 1934 1925 break; 1935 RTSpinlockReleaseNoInts(pDevExt->SessionSpinlock , &Tmp);1926 RTSpinlockReleaseNoInts(pDevExt->SessionSpinlock); 1936 1927 if (RT_UNLIKELY(i >= RT_ELEMENTS(pSession->aHGCMClientIds))) 1937 1928 { … … 2222 2213 static int VBoxGuestCommonIOCtl_SetMouseStatus(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession, uint32_t fFeatures) 2223 2214 { 2224 unsigned i; 2225 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 2226 uint32_t fNewDevExtStatus = 0; 2227 int rc; 2215 uint32_t fNewDevExtStatus = 0; 2216 unsigned i; 2217 int rc; 2228 2218 /* Exit early if nothing has changed - hack to work around the 2229 2219 * Windows Additions not using the common code. */ 2230 bool fNoAction; 2231 2232 RTSpinlockAcquireNoInts(pDevExt->SessionSpinlock, &Tmp); 2233 for (i = 0; i < sizeof(fFeatures) * 8; ++i) 2220 bool fNoAction; 2221 2222 RTSpinlockAcquire(pDevExt->SessionSpinlock); 2223 2224 for (i = 0; i < sizeof(fFeatures) * 8; i++) 2234 2225 { 2235 2226 if (RT_BIT_32(i) & VMMDEV_MOUSE_GUEST_MASK) … … 2237 2228 if ( (RT_BIT_32(i) & fFeatures) 2238 2229 && !(RT_BIT_32(i) & pSession->fMouseStatus)) 2239 ++pDevExt->cMouseFeatureUsage[i];2230 pDevExt->cMouseFeatureUsage[i]++; 2240 2231 else if ( !(RT_BIT_32(i) & fFeatures) 2241 2232 && (RT_BIT_32(i) & pSession->fMouseStatus)) 2242 --pDevExt->cMouseFeatureUsage[i];2233 pDevExt->cMouseFeatureUsage[i]--; 2243 2234 } 2244 2235 if (pDevExt->cMouseFeatureUsage[i] > 0) 2245 2236 fNewDevExtStatus |= RT_BIT_32(i); 2246 2237 } 2238 2247 2239 pSession->fMouseStatus = fFeatures & VMMDEV_MOUSE_GUEST_MASK; 2248 2240 fNoAction = (pDevExt->fMouseStatus == fNewDevExtStatus); 2249 2241 pDevExt->fMouseStatus = fNewDevExtStatus; 2250 RTSpinlockReleaseNoInts(pDevExt->SessionSpinlock, &Tmp); 2242 2243 RTSpinlockReleaseNoInts(pDevExt->SessionSpinlock); 2251 2244 if (fNoAction) 2252 2245 return VINF_SUCCESS; 2246 2253 2247 do 2254 2248 { 2255 2249 fNewDevExtStatus = pDevExt->fMouseStatus; 2256 2250 rc = vboxguestcommonSetMouseStatus(fNewDevExtStatus); 2257 } while(RT_SUCCESS(rc) && fNewDevExtStatus != pDevExt->fMouseStatus); 2251 } while ( RT_SUCCESS(rc) 2252 && fNewDevExtStatus != pDevExt->fMouseStatus); 2253 2258 2254 return rc; 2259 2255 } … … 2271 2267 2272 2268 g_test_fSetMouseStatus = true; 2273 rc = RTSpinlockCreate(&Spinlock );2269 rc = RTSpinlockCreate(&Spinlock, RTSPINLOCK_FLAGS_INTERRUPT_SAFE, "VBoxGuestTest"); 2274 2270 AssertRCReturnVoid(rc); 2275 2271 { … … 2596 2592 { 2597 2593 bool fMousePositionChanged = false; 2598 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;2599 2594 VMMDevEvents volatile *pReq = pDevExt->pIrqAckEvents; 2600 2595 int rc = 0; … … 2610 2605 * Enter the spinlock and check if it's our IRQ or not. 2611 2606 */ 2612 RTSpinlockAcquire NoInts(pDevExt->EventSpinlock, &Tmp);2607 RTSpinlockAcquire(pDevExt->EventSpinlock); 2613 2608 fOurIrq = pDevExt->pVMMDevMemory->V.V1_04.fHaveEvents; 2614 2609 if (fOurIrq) … … 2695 2690 LogFlow(("VBoxGuestCommonISR: not ours\n")); 2696 2691 2697 RTSpinlockReleaseNoInts(pDevExt->EventSpinlock , &Tmp);2692 RTSpinlockReleaseNoInts(pDevExt->EventSpinlock); 2698 2693 2699 2694 #if defined(VBOXGUEST_USE_DEFERRED_WAKE_UP) && !defined(RT_OS_WINDOWS)
Note:
See TracChangeset
for help on using the changeset viewer.