Changeset 41852 in vbox for trunk/src/VBox/Additions/common/VBoxGuestLib
- Timestamp:
- Jun 20, 2012 3:59:57 PM (13 years ago)
- Location:
- trunk/src/VBox/Additions/common/VBoxGuestLib
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuestLib/Init.cpp
r41783 r41852 33 33 #include <iprt/string.h> 34 34 #include <iprt/assert.h> 35 #include <iprt/semaphore.h> 35 36 36 37 /******************************************************************************* … … 41 42 42 43 /** 43 * Used by vbglQuery VMMDevPortand VbglInit to try get the host feature mask and44 * Used by vbglQueryDriverInfo and VbglInit to try get the host feature mask and 44 45 * version information (g_vbgldata::hostVersion). 45 46 * … … 78 79 * 79 80 */ 80 static void vbglQuery VMMDevPort(void)81 static void vbglQueryDriverInfo (void) 81 82 { 82 83 int rc = VINF_SUCCESS; 83 84 84 VBGLDRIVER driver; 85 86 rc = vbglDriverOpen (&driver); 85 rc = RTSemFastMutexRequest(g_vbgldata.mutexDriverInit); 86 87 if (RT_FAILURE(rc)) 88 return; 89 90 if (g_vbgldata.status == VbglStatusReady) 91 { 92 RTSemFastMutexRelease(g_vbgldata.mutexDriverInit); 93 return; 94 } 95 96 rc = vbglDriverOpen(&g_vbgldata.driver); 87 97 88 98 if (RT_SUCCESS(rc)) … … 93 103 VBoxGuestPortInfo port; 94 104 95 rc = vbglDriverIOCtl (&driver, VBOXGUEST_IOCTL_GETVMMDEVPORT, &port, sizeof (port)); 105 rc = vbglDriverIOCtl (&g_vbgldata.driver, 106 VBOXGUEST_IOCTL_GETVMMDEVPORT, &port, 107 sizeof (port)); 96 108 97 109 if (RT_SUCCESS (rc)) … … 106 118 vbglR0QueryHostVersion(); 107 119 } 108 109 vbglDriverClose (&driver); 110 } 111 112 dprintf (("vbglQueryVMMDevPort rc = %d\n", rc)); 120 } 121 RTSemFastMutexRelease(g_vbgldata.mutexDriverInit); 122 dprintf (("vbglQueryDriverInfo rc = %d\n", rc)); 113 123 } 114 124 #endif /* !VBGL_VBOXGUEST */ … … 128 138 if (g_vbgldata.status == VbglStatusInitializing) 129 139 { 130 vbglQuery VMMDevPort();140 vbglQueryDriverInfo (); 131 141 } 132 142 #endif … … 234 244 if (RT_SUCCESS(rc)) 235 245 { 236 /* Try to obtain VMMDev port via IOCTL to VBoxGuest main driver. */ 237 vbglQueryVMMDevPort (); 246 rc = RTSemFastMutexCreate(&g_vbgldata.mutexDriverInit); 247 if (RT_SUCCESS(rc)) 248 { 249 /* Try to obtain VMMDev port via IOCTL to VBoxGuest main driver. */ 250 vbglQueryDriverInfo (); 238 251 239 252 # ifdef VBOX_WITH_HGCM 240 rc = vbglR0HGCMInit ();253 rc = vbglR0HGCMInit (); 241 254 # endif /* VBOX_WITH_HGCM */ 255 256 if (RT_FAILURE(rc)) 257 { 258 RTSemFastMutexDestroy(g_vbgldata.mutexDriverInit); 259 g_vbgldata.mutexDriverInit = NIL_RTSEMFASTMUTEX; 260 } 261 } 242 262 243 263 if (RT_FAILURE(rc)) … … 245 265 vbglTerminateCommon (); 246 266 } 267 247 268 } 248 269 249 270 return rc; 271 } 272 273 DECLVBGL(bool) VbglIsReady(void) 274 { 275 return(g_vbgldata.status == VbglStatusReady); 250 276 } 251 277 … … 257 283 258 284 vbglTerminateCommon (); 285 vbglDriverClose(&g_vbgldata.driver); 286 RTSemFastMutexDestroy(g_vbgldata.mutexDriverInit); 287 g_vbgldata.mutexDriverInit = NIL_RTSEMFASTMUTEX; 259 288 260 289 return; 261 290 } 262 291 292 int vbglGetDriver(VBGLDRIVER **ppDriver) 293 { 294 if (g_vbgldata.status != VbglStatusReady) 295 { 296 vbglQueryDriverInfo(); 297 if (g_vbgldata.status != VbglStatusReady) 298 return VERR_TRY_AGAIN; 299 } 300 *ppDriver = &g_vbgldata.driver; 301 return VINF_SUCCESS; 302 } 303 263 304 #endif /* !VBGL_VBOXGUEST */ 264 -
trunk/src/VBox/Additions/common/VBoxGuestLib/Makefile.kmk
r41477 r41852 61 61 PhysHeap.cpp \ 62 62 Init.cpp \ 63 Mouse.cpp \ 63 64 VMMDev.cpp \ 64 65 HGCM.cpp \ -
trunk/src/VBox/Additions/common/VBoxGuestLib/VBGLInternal.h
r40901 r41852 101 101 #ifndef VBGL_VBOXGUEST 102 102 /** 103 * Handle for the main driver instance. 104 * @{ 105 */ 106 107 RTSEMFASTMUTEX mutexDriverInit; 108 109 VBGLDRIVER driver; 110 111 /** @} */ 112 113 /** 103 114 * Fast heap for HGCM handles data. 104 115 * @{ … … 156 167 #endif /* VBOX_WITH_HGCM */ 157 168 169 #ifndef VBGL_VBOXGUEST 170 /** 171 * Get a handle to the main VBoxGuest driver. 172 * @returns VERR_TRY_AGAIN if the main driver has not yet been loaded. 173 */ 174 int vbglGetDriver(VBGLDRIVER **ppDriver); 175 #endif 176 158 177 #endif /* !___VBoxGuestLib_VBGLInternal_h */ 159 178
Note:
See TracChangeset
for help on using the changeset viewer.