Changeset 82209 in vbox
- Timestamp:
- Nov 25, 2019 11:50:16 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/GIMDev/GIMDev.cpp
r81591 r82209 29 29 #include <iprt/uuid.h> 30 30 31 32 /********************************************************************************************************************************* 33 * Defined Constants And Macros * 34 *********************************************************************************************************************************/ 31 35 #define GIMDEV_DEBUG_LUN 998 32 36 37 38 /********************************************************************************************************************************* 39 * Structures and Typedefs * 40 *********************************************************************************************************************************/ 33 41 /** 34 42 * GIM device. … … 36 44 typedef struct GIMDEV 37 45 { 38 /** Pointer to the device instance - R3 Ptr. */ 39 PPDMDEVINSR3 pDevInsR3; 40 /** Pointer to the device instance - R0 Ptr. */ 41 PPDMDEVINSR0 pDevInsR0; 42 /** Pointer to the device instance - RC Ptr. */ 43 PPDMDEVINSRC pDevInsRC; 44 /** Alignment. */ 45 RTRCPTR Alignment0; 46 /** Pointer to the device instance. 47 * @note Only for getting our bearings when arriving in an interface method. */ 48 PPDMDEVINSR3 pDevIns; 46 49 47 50 /** LUN\#998: The debug interface. */ … … 55 58 /** Flag to indicate shutdown of the debug receive thread. */ 56 59 bool volatile fDbgRecvThreadShutdown; 60 bool afAlignment1[ARCH_BITS / 8 - 1]; 57 61 /** The debug setup parameters. */ 58 62 GIMDEBUGSETUP DbgSetup; … … 196 200 197 201 /** 202 * @interface_method_impl{PDMDEVREG,pfnDestruct} 203 */ 204 static DECLCALLBACK(int) gimdevR3Destruct(PPDMDEVINS pDevIns) 205 { 206 PDMDEV_CHECK_VERSIONS_RETURN_QUIET(pDevIns); 207 PGIMDEV pThis = PDMDEVINS_2_DATA(pDevIns, PGIMDEV); 208 PVM pVM = PDMDevHlpGetVM(pDevIns); 209 210 uint32_t cRegions = 0; 211 PGIMMMIO2REGION pCur = GIMR3GetMmio2Regions(pVM, &cRegions); 212 for (uint32_t i = 0; i < cRegions; i++, pCur++) 213 { 214 int rc = PDMDevHlpMMIOExDeregister(pDevIns, NULL, pCur->iRegion); 215 if (RT_FAILURE(rc)) 216 return rc; 217 } 218 219 /* 220 * Signal and wait for the debug thread to terminate. 221 */ 222 if (pThis->hDbgRecvThread != NIL_RTTHREAD) 223 { 224 pThis->fDbgRecvThreadShutdown = true; 225 if (pThis->Dbg.hDbgRecvThreadSem != NIL_RTSEMEVENT) 226 RTSemEventMultiSignal(pThis->Dbg.hDbgRecvThreadSem); 227 228 int rc = RTThreadWait(pThis->hDbgRecvThread, 20000, NULL /*prc*/); 229 if (RT_SUCCESS(rc)) 230 pThis->hDbgRecvThread = NIL_RTTHREAD; 231 else 232 { 233 LogRel(("GIMDev: Debug thread did not terminate, rc=%Rrc!\n", rc)); 234 return VERR_RESOURCE_BUSY; 235 } 236 } 237 238 /* 239 * Now clean up the semaphore & buffer now that the thread is gone. 240 */ 241 if (pThis->Dbg.hDbgRecvThreadSem != NIL_RTSEMEVENT) 242 { 243 RTSemEventMultiDestroy(pThis->Dbg.hDbgRecvThreadSem); 244 pThis->Dbg.hDbgRecvThreadSem = NIL_RTSEMEVENTMULTI; 245 } 246 if (pThis->Dbg.pvDbgRecvBuf) 247 { 248 RTMemFree(pThis->Dbg.pvDbgRecvBuf); 249 pThis->Dbg.pvDbgRecvBuf = NULL; 250 } 251 252 return VINF_SUCCESS; 253 } 254 255 256 /** 198 257 * @interface_method_impl{PDMDEVREG,pfnConstruct} 199 258 */ … … 208 267 * Initialize relevant state bits. 209 268 */ 210 pThis->pDevIns R3= pDevIns;211 pThis-> pDevInsR0 = PDMDEVINS_2_R0PTR(pDevIns);212 pThis-> pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns);269 pThis->pDevIns = pDevIns; 270 pThis->hDbgRecvThread = NIL_RTTHREAD; 271 pThis->Dbg.hDbgRecvThreadSem = NIL_RTSEMEVENT; 213 272 214 273 /* … … 266 325 267 326 /* 268 * Create the sem pahore and the debug receive thread itself.327 * Create the semaphore and the debug receive thread itself. 269 328 */ 270 329 rc = RTSemEventMultiCreate(&pThis->Dbg.hDbgRecvThreadSem); 271 if (RT_SUCCESS(rc)) 272 { 273 rc = RTThreadCreate(&pThis->hDbgRecvThread, gimDevR3DbgRecvThread, pDevIns, 0 /*cbStack*/, RTTHREADTYPE_IO, 274 RTTHREADFLAGS_WAITABLE, "GIMDebugRecv"); 275 if (RT_FAILURE(rc)) 276 { 277 RTSemEventMultiDestroy(pThis->Dbg.hDbgRecvThreadSem); 278 pThis->Dbg.hDbgRecvThreadSem = NIL_RTSEMEVENTMULTI; 279 280 RTMemFree(pThis->Dbg.pvDbgRecvBuf); 281 pThis->Dbg.pvDbgRecvBuf = NULL; 282 return rc; 283 } 284 } 285 else 330 AssertRCReturn(rc, rc); 331 rc = RTThreadCreate(&pThis->hDbgRecvThread, gimDevR3DbgRecvThread, pDevIns, 0 /*cbStack*/, RTTHREADTYPE_IO, 332 RTTHREADFLAGS_WAITABLE, "GIMDebugRecv"); 333 if (RT_FAILURE(rc)) 334 { 335 RTSemEventMultiDestroy(pThis->Dbg.hDbgRecvThreadSem); 336 pThis->Dbg.hDbgRecvThreadSem = NIL_RTSEMEVENTMULTI; 337 338 RTMemFree(pThis->Dbg.pvDbgRecvBuf); 339 pThis->Dbg.pvDbgRecvBuf = NULL; 286 340 return rc; 341 } 287 342 } 288 343 … … 351 406 } 352 407 353 354 /**355 * @interface_method_impl{PDMDEVREG,pfnDestruct}356 */357 static DECLCALLBACK(int) gimdevR3Destruct(PPDMDEVINS pDevIns)358 {359 PGIMDEV pThis = PDMDEVINS_2_DATA(pDevIns, PGIMDEV);360 PVM pVM = PDMDevHlpGetVM(pDevIns);361 uint32_t cRegions = 0;362 363 PGIMMMIO2REGION pCur = GIMR3GetMmio2Regions(pVM, &cRegions);364 for (uint32_t i = 0; i < cRegions; i++, pCur++)365 {366 int rc = PDMDevHlpMMIOExDeregister(pDevIns, NULL, pCur->iRegion);367 if (RT_FAILURE(rc))368 return rc;369 }370 371 /*372 * Signal and wait for the debug thread to terminate.373 */374 if (pThis->hDbgRecvThread != NIL_RTTHREAD)375 {376 pThis->fDbgRecvThreadShutdown = true;377 if (pThis->Dbg.hDbgRecvThreadSem != NIL_RTSEMEVENT)378 RTSemEventMultiSignal(pThis->Dbg.hDbgRecvThreadSem);379 380 int rc = RTThreadWait(pThis->hDbgRecvThread, 20000, NULL /*prc*/);381 if (RT_SUCCESS(rc))382 pThis->hDbgRecvThread = NIL_RTTHREAD;383 else384 {385 LogRel(("GIMDev: Debug thread did not terminate, rc=%Rrc!\n", rc));386 return VERR_RESOURCE_BUSY;387 }388 }389 390 /*391 * Now clean up the semaphore & buffer now that the thread is gone.392 */393 if (pThis->Dbg.hDbgRecvThreadSem != NIL_RTSEMEVENT)394 {395 RTSemEventMultiDestroy(pThis->Dbg.hDbgRecvThreadSem);396 pThis->Dbg.hDbgRecvThreadSem = NIL_RTSEMEVENTMULTI;397 }398 if (pThis->Dbg.pvDbgRecvBuf)399 {400 RTMemFree(pThis->Dbg.pvDbgRecvBuf);401 pThis->Dbg.pvDbgRecvBuf = NULL;402 }403 404 return VINF_SUCCESS;405 }406 408 407 409 #endif /* IN_RING3 */
Note:
See TracChangeset
for help on using the changeset viewer.