Changeset 40483 in vbox for trunk/src/VBox/GuestHost/OpenGL/util
- Timestamp:
- Mar 15, 2012 2:20:20 PM (13 years ago)
- svn:sync-xref-src-repo-rev:
- 76853
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/GuestHost/OpenGL/util/vboxhgcm.c
r39288 r40483 596 596 */ 597 597 /** @todo use vbglR3DoIOCtl here instead */ 598 static int crVBoxHGCMCall( void *pvData, unsigned cbData)598 static int crVBoxHGCMCall(CRConnection *conn, void *pvData, unsigned cbData) 599 599 { 600 600 #ifdef IN_GUEST 601 601 PCRVBOXHGSMI_CLIENT pClient = _crVBoxHGSMIClientGet(conn); 602 if (pClient) 603 { 604 return VBoxCrHgsmiCtlConCall(pClient->pHgsmi, (struct VBoxGuestHGCMCallInfo *)pvData, cbData); 605 } 606 else 607 { 602 608 # ifdef RT_OS_WINDOWS 603 609 DWORD cbReturned, lerr; … … 683 689 return VERR_NOT_SUPPORTED; 684 690 # endif /*#ifdef RT_OS_WINDOWS*/ 685 691 } 686 692 #else /*#ifdef IN_GUEST*/ 687 693 crError("crVBoxHGCMCall called on host side!"); … … 853 859 parms.pBuffer.u.Pointer.u.linearAddr = (uintptr_t) buf; 854 860 855 rc = crVBoxHGCMCall( &parms, sizeof(parms));861 rc = crVBoxHGCMCall(conn, &parms, sizeof(parms)); 856 862 callRes = parms.hdr.result; 857 863 } … … 870 876 parms.pBuffer.u.Pointer.u.linearAddr = (uintptr_t) buf; 871 877 872 rc = crVBoxHGCMCall( &parms, sizeof(parms));878 rc = crVBoxHGCMCall(conn, &parms, sizeof(parms)); 873 879 callRes = parms.hdr.result; 874 880 } … … 911 917 parms.cbBuffer.u.value32 = 0; 912 918 913 rc = crVBoxHGCMCall( &parms, sizeof(parms));919 rc = crVBoxHGCMCall(conn, &parms, sizeof(parms)); 914 920 915 921 if (RT_FAILURE(rc) || RT_FAILURE(parms.hdr.result)) … … 967 973 parms.cbWriteback.u.value32 = 0; 968 974 969 rc = crVBoxHGCMCall( &parms, sizeof(parms));975 rc = crVBoxHGCMCall(conn, &parms, sizeof(parms)); 970 976 971 977 #if defined(RT_OS_LINUX) || defined(RT_OS_WINDOWS) … … 1003 1009 crDebug("SHCRGL_GUEST_FN_WRITE_BUFFER, offset=%u, size=%u", wbParms.ui32Offset.u.value32, wbParms.pBuffer.u.Pointer.size); 1004 1010 1005 rc = crVBoxHGCMCall( &wbParms, sizeof(wbParms));1011 rc = crVBoxHGCMCall(conn, &wbParms, sizeof(wbParms)); 1006 1012 if (RT_FAILURE(rc) || RT_FAILURE(wbParms.hdr.result)) 1007 1013 { … … 1028 1034 crMemcpy(&wrbParms.cbWriteback, &parms.cbWriteback, sizeof(HGCMFunctionParameter)); 1029 1035 1030 rc = crVBoxHGCMCall( &wrbParms, sizeof(wrbParms));1036 rc = crVBoxHGCMCall(conn, &wrbParms, sizeof(wrbParms)); 1031 1037 1032 1038 /*bit of hack to reuse code below*/ … … 1164 1170 parms.cbBuffer.u.value32 = 0; 1165 1171 1166 rc = crVBoxHGCMCall( &parms, sizeof(parms));1172 rc = crVBoxHGCMCall(conn, &parms, sizeof(parms)); 1167 1173 1168 1174 if (RT_FAILURE(rc) || RT_FAILURE(parms.hdr.result)) … … 1372 1378 parms.vMinor.u.value32 = CR_PROTOCOL_VERSION_MINOR; 1373 1379 1374 rc = crVBoxHGCMCall( &parms, sizeof(parms));1380 rc = crVBoxHGCMCall(conn, &parms, sizeof(parms)); 1375 1381 1376 1382 if (RT_FAILURE(rc) || RT_FAILURE(parms.hdr.result)) … … 1400 1406 parms.u64PID.u.value64 = pid; 1401 1407 1402 rc = crVBoxHGCMCall( &parms, sizeof(parms));1408 rc = crVBoxHGCMCall(conn, &parms, sizeof(parms)); 1403 1409 1404 1410 if (RT_FAILURE(rc) || RT_FAILURE(parms.hdr.result)) … … 1442 1448 { 1443 1449 crDebug("could not open VBox Guest Additions driver! rc = %d\n", GetLastError()); 1450 CRASSERT(0); 1444 1451 VBOXCRHGSMIPROFILE_FUNC_EPILOGUE(); 1445 1452 return FALSE; … … 1533 1540 } 1534 1541 1542 static bool _crVBoxCommonDoDisconnectLocked( CRConnection *conn ) 1543 { 1544 int i; 1545 if (conn->pHostBuffer) 1546 { 1547 crFree(conn->pHostBuffer); 1548 conn->pHostBuffer = NULL; 1549 conn->cbHostBuffer = 0; 1550 conn->cbHostBufferAllocated = 0; 1551 } 1552 1553 conn->pBuffer = NULL; 1554 conn->cbBuffer = 0; 1555 1556 if (conn->type == CR_VBOXHGCM) 1557 { 1558 --g_crvboxhgcm.num_conns; 1559 1560 if (conn->index < g_crvboxhgcm.num_conns) 1561 { 1562 g_crvboxhgcm.conns[conn->index] = g_crvboxhgcm.conns[g_crvboxhgcm.num_conns]; 1563 g_crvboxhgcm.conns[conn->index]->index = conn->index; 1564 } 1565 else g_crvboxhgcm.conns[conn->index] = NULL; 1566 1567 conn->type = CR_NO_CONNECTION; 1568 } 1569 1570 for (i = 0; i < g_crvboxhgcm.num_conns; i++) 1571 if (g_crvboxhgcm.conns[i] && g_crvboxhgcm.conns[i]->type != CR_NO_CONNECTION) 1572 return true; 1573 return false; 1574 } 1575 1535 1576 /*@todo same, replace DeviceIoControl with vbglR3DoIOCtl */ 1536 1577 static void crVBoxHGCMDoDisconnect( CRConnection *conn ) … … 1541 1582 DWORD cbReturned; 1542 1583 # endif 1543 int i; 1544 #endif 1584 #endif 1585 bool fHasActiveCons = false; 1545 1586 1546 1587 if (!g_crvboxhgcm.initialized) return; … … 1552 1593 VBOXCRHGSMIPROFILE_FUNC_PROLOGUE(); 1553 1594 1554 if (conn->pHostBuffer) 1555 { 1556 crFree(conn->pHostBuffer); 1557 conn->pHostBuffer = NULL; 1558 conn->cbHostBuffer = 0; 1559 conn->cbHostBufferAllocated = 0; 1560 } 1561 1562 conn->pBuffer = NULL; 1563 conn->cbBuffer = 0; 1564 1565 if (conn->type == CR_VBOXHGCM) 1566 { 1567 --g_crvboxhgcm.num_conns; 1568 1569 if (conn->index < g_crvboxhgcm.num_conns) 1570 { 1571 g_crvboxhgcm.conns[conn->index] = g_crvboxhgcm.conns[g_crvboxhgcm.num_conns]; 1572 g_crvboxhgcm.conns[conn->index]->index = conn->index; 1573 } 1574 else g_crvboxhgcm.conns[conn->index] = NULL; 1575 1576 conn->type = CR_NO_CONNECTION; 1577 } 1595 fHasActiveCons = _crVBoxCommonDoDisconnectLocked(conn); 1578 1596 1579 1597 #ifndef IN_GUEST … … 1613 1631 } 1614 1632 1615 /* see if any connections remain */1616 for (i = 0; i < g_crvboxhgcm.num_conns; i++)1617 if (g_crvboxhgcm.conns[i] && g_crvboxhgcm.conns[i]->type != CR_NO_CONNECTION)1618 break;1619 1620 1633 /* close guest additions driver*/ 1621 if ( i>=g_crvboxhgcm.num_conns)1634 if (!fHasActiveCons) 1622 1635 { 1623 1636 # ifdef RT_OS_WINDOWS … … 1672 1685 int rc; 1673 1686 #ifndef VBOX_CRHGSMI_WITH_D3DDEV 1674 rc = VBoxCrHgsmiInit( );1687 rc = VBoxCrHgsmiInit(CR_PROTOCOL_VERSION_MAJOR, CR_PROTOCOL_VERSION_MINOR); 1675 1688 #else 1676 1689 VBOXCRHGSMI_CALLBACKS Callbacks; … … 2305 2318 static int crVBoxHGSMIDoConnect( CRConnection *conn ) 2306 2319 { 2307 return crVBoxHGCMDoConnect(conn); 2320 PCRVBOXHGSMI_CLIENT pClient; 2321 int rc = VINF_SUCCESS; 2322 2323 #ifdef CHROMIUM_THREADSAFE 2324 crLockMutex(&g_crvboxhgcm.mutex); 2325 #endif 2326 2327 VBOXCRHGSMIPROFILE_FUNC_PROLOGUE(); 2328 2329 pClient = _crVBoxHGSMIClientGet(conn); 2330 CRASSERT(pClient); 2331 if (pClient) 2332 { 2333 rc = VBoxCrHgsmiCtlConGetClientID(pClient->pHgsmi, &conn->u32ClientID); 2334 CRASSERT(RT_SUCCESS(rc)); 2335 } 2336 2337 VBOXCRHGSMIPROFILE_FUNC_EPILOGUE(); 2338 2339 #ifdef CHROMIUM_THREADSAFE 2340 crUnlockMutex(&g_crvboxhgcm.mutex); 2341 #endif 2342 return RT_SUCCESS(rc); 2308 2343 } 2309 2344 2310 2345 static void crVBoxHGSMIDoDisconnect( CRConnection *conn ) 2311 2346 { 2347 bool fHasActiveCons = false; 2348 2349 if (!g_crvboxhgcm.initialized) return; 2350 2351 VBOXCRHGSMIPROFILE_FUNC_PROLOGUE(); 2352 2312 2353 #ifdef CHROMIUM_THREADSAFE 2313 2354 crLockMutex(&g_crvboxhgcm.mutex); 2314 2355 #endif 2356 2357 fHasActiveCons = _crVBoxCommonDoDisconnectLocked(conn); 2358 2315 2359 #ifndef VBOX_CRHGSMI_WITH_D3DDEV 2316 2360 if (conn->HgsmiClient.pHgsmi) … … 2321 2365 VBoxCrHgsmiDestroy(pHgsmi); 2322 2366 } 2323 #endif 2324 crVBoxHGCMDoDisconnect(conn); 2367 #else 2368 # error "port me!" 2369 #endif 2370 2371 VBOXCRHGSMIPROFILE_FUNC_EPILOGUE(); 2372 2325 2373 #ifdef CHROMIUM_THREADSAFE 2326 2374 crUnlockMutex(&g_crvboxhgcm.mutex);
Note:
See TracChangeset
for help on using the changeset viewer.