Changeset 28258 in vbox for trunk/src/VBox
- Timestamp:
- Apr 13, 2010 2:51:16 PM (15 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Input/DrvKeyboardQueue.cpp
r26173 r28258 307 307 } 308 308 309 rc = PDMDrvHlp PDMQueueCreate(pDrvIns, sizeof(DRVKBDQUEUEITEM), cItems, cMilliesInterval, drvKbdQueueConsumer, "Keyboard", &pDrv->pQueue);309 rc = PDMDrvHlpQueueCreate(pDrvIns, sizeof(DRVKBDQUEUEITEM), cItems, cMilliesInterval, drvKbdQueueConsumer, "Keyboard", &pDrv->pQueue); 310 310 if (RT_FAILURE(rc)) 311 311 { -
trunk/src/VBox/Devices/Input/DrvMouseQueue.cpp
r26935 r28258 344 344 } 345 345 346 rc = PDMDrvHlp PDMQueueCreate(pDrvIns, sizeof(DRVMOUSEQUEUEITEM), cItems, cMilliesInterval, drvMouseQueueConsumer, "Mouse", &pDrv->pQueue);346 rc = PDMDrvHlpQueueCreate(pDrvIns, sizeof(DRVMOUSEQUEUEITEM), cItems, cMilliesInterval, drvMouseQueueConsumer, "Mouse", &pDrv->pQueue); 347 347 if (RT_FAILURE(rc)) 348 348 { -
trunk/src/VBox/Devices/Network/DevINIP.cpp
r28213 r28258 305 305 * @param cMillies Number of milliseconds to wait. 0 means return immediately. 306 306 */ 307 static DECLCALLBACK(int) devINIP WaitInputAvail(PPDMINETWORKDOWN pInterface, RTMSINTERVAL cMillies)307 static DECLCALLBACK(int) devINIPNetworkDown_WaitInputAvail(PPDMINETWORKDOWN pInterface, RTMSINTERVAL cMillies) 308 308 { 309 309 LogFlow(("%s: pInterface=%p\n", __FUNCTION__, pInterface)); … … 320 320 * @param cb Frame size. 321 321 */ 322 static DECLCALLBACK(int) devINIP Input(PPDMINETWORKDOWN pInterface,323 const void *pvBuf, size_t cb)322 static DECLCALLBACK(int) devINIPNetworkDown_Input(PPDMINETWORKDOWN pInterface, 323 const void *pvBuf, size_t cb) 324 324 { 325 325 const uint8_t *pbBuf = (const uint8_t *)pvBuf; … … 385 385 386 386 /** 387 * @interface_method_impl{PDMINETWORKDOWN,pfnDoTransmitWork} 388 */ 389 static DECLCALLBACK(void) devINIPNetworkDown_DoTransmitWork(PPDMINETWORKDOWN pInterface) 390 { 391 NOREF(pInterface); 392 } 393 394 395 /** 387 396 * Signals the end of lwIP TCPIP initialization. 388 397 * … … 483 492 pThis->IBase.pfnQueryInterface = devINIPQueryInterface; 484 493 /* INetworkDown */ 485 pThis->INetworkDown.pfnWaitReceiveAvail = devINIPWaitInputAvail; 486 pThis->INetworkDown.pfnReceive = devINIPInput; 494 pThis->INetworkDown.pfnWaitReceiveAvail = devINIPNetworkDown_WaitInputAvail; 495 pThis->INetworkDown.pfnReceive = devINIPNetworkDown_Input; 496 pThis->INetworkDown.pfnDoTransmitWork = devINIPNetworkDown_DoTransmitWork; 487 497 488 498 /* -
trunk/src/VBox/Devices/Network/DrvIntNet.cpp
r28213 r28258 1 #define VBOX_WITH_R0_AND_RC_DRIVERS 1 2 /* $Id$ */ 2 3 /** @file … … 111 112 /** Base interface for ring-0. */ 112 113 PDMIBASERC IBaseRC; 114 115 /** The transmit lock. */ 116 PDMCRITSECT XmitLock; 113 117 114 118 #ifdef LOG_ENABLED … … 190 194 } 191 195 196 197 192 198 /* -=-=-=-=- PDMINETWORKUP -=-=-=-=- */ 199 200 /** 201 * @interface_method_impl{PDMINETWORKUP,pfnBeginXmit} 202 */ 203 static DECLCALLBACK(int) drvR3IntNetUp_BeginXmit(PPDMINETWORKUP pInterface) 204 { 205 PDRVINTNET pThis = RT_FROM_MEMBER(pInterface, DRVINTNET, INetworkUpR3); 206 int rc = PDMCritSectTryEnter(&pThis->XmitLock); 207 if (RT_UNLIKELY(rc == VERR_SEM_BUSY)) 208 rc = VERR_TRY_AGAIN; 209 return rc; 210 } 211 193 212 194 213 /** … … 201 220 int rc = VINF_SUCCESS; 202 221 Assert(cbMin < UINT32_MAX / 2); 222 // Assert(PDMCritSectIsOwner(&pThis->XmitLock)); 203 223 204 224 /* … … 277 297 Assert( pHdr->u16Type == INTNETHDR_TYPE_FRAME 278 298 || pHdr->u16Type == INTNETHDR_TYPE_GSO); 299 // Assert(PDMCritSectIsOwner(&pThis->XmitLock)); 279 300 280 301 /** @todo LATER: try unalloc the frame. */ … … 298 319 Assert(pSgBuf->fFlags == (PDMSCATTERGATHER_FLAGS_MAGIC | PDMSCATTERGATHER_FLAGS_OWNER_1)); 299 320 Assert(pSgBuf->cbUsed <= pSgBuf->cbAvailable); 321 // Assert(PDMCritSectIsOwner(&pThis->XmitLock)); 300 322 301 323 if (pSgBuf->pvUser) … … 319 341 STAM_PROFILE_STOP(&pThis->StatTransmit, a); 320 342 return VINF_SUCCESS; 343 } 344 345 346 /** 347 * @interface_method_impl{PDMINETWORKUP,pfnEndXmit} 348 */ 349 static DECLCALLBACK(void) drvR3IntNetUp_EndXmit(PPDMINETWORKUP pInterface) 350 { 351 PDRVINTNET pThis = RT_FROM_MEMBER(pInterface, DRVINTNET, INetworkUpR3); 352 PDMCritSectLeave(&pThis->XmitLock); 321 353 } 322 354 … … 762 794 Frame.Hdr.DstMac.au16[1] = 0xffff; 763 795 Frame.Hdr.DstMac.au16[2] = 0xffff; 764 Frame.Hdr.EtherType = RT_H2BE_U16 (0x801e);796 Frame.Hdr.EtherType = RT_H2BE_U16_C(0x801e); 765 797 int rc = pThis->pIAboveConfigR3->pfnGetMac(pThis->pIAboveConfigR3, &Frame.Hdr.SrcMac); 766 798 if (RT_SUCCESS(rc)) … … 805 837 drvR3IntNetSetActive(pThis, true /* fActive */); 806 838 } 839 } 840 841 842 /** 843 * @interface_method_impl{PDMDRVREG,pfnRelocate} 844 */ 845 static DECLCALLBACK(void) drvR3IntNetRelocate(PPDMDRVINS pDrvIns, RTGCINTPTR offDelta) 846 { 847 /* nothing to do here yet */ 807 848 } 808 849 … … 858 899 859 900 /* 860 * Destroy the semaphore and S/G cache.901 * Destroy the semaphore, S/G cache and xmit lock. 861 902 */ 862 903 if (hEvtSuspended != NIL_RTSEMEVENT) … … 865 906 RTMemCacheDestroy(pThis->hSgCache); 866 907 pThis->hSgCache = NIL_RTMEMCACHE; 908 909 if (PDMCritSectIsInitialized(&pThis->XmitLock)) 910 PDMR3CritSectDelete(&pThis->XmitLock); 867 911 868 912 if (pThis->pBufR3) … … 917 961 pThis->IBaseRC.pfnQueryInterface = drvR3IntNetIBaseRC_QueryInterface; 918 962 /* INetworkUp */ 963 pThis->INetworkUpR3.pfnBeginXmit = drvR3IntNetUp_BeginXmit; 919 964 pThis->INetworkUpR3.pfnAllocBuf = drvR3IntNetUp_AllocBuf; 920 965 pThis->INetworkUpR3.pfnFreeBuf = drvR3IntNetUp_FreeBuf; 921 966 pThis->INetworkUpR3.pfnSendBuf = drvR3IntNetUp_SendBuf; 967 pThis->INetworkUpR3.pfnEndXmit = drvR3IntNetUp_EndXmit; 922 968 pThis->INetworkUpR3.pfnSetPromiscuousMode = drvR3IntNetUp_SetPromiscuousMode; 923 969 pThis->INetworkUpR3.pfnNotifyLinkChanged = drvR3IntNetUp_NotifyLinkChanged; … … 1186 1232 1187 1233 /* 1188 * Create the event semaphore and S/G cache.1234 * Create the event semaphore, S/G cache and xmit critsect. 1189 1235 */ 1190 1236 rc = RTSemEventCreate(&pThis->hEvtSuspended); … … 1194 1240 if (RT_FAILURE(rc)) 1195 1241 return rc; 1242 rc = PDMDrvHlpCritSectInit(pDrvIns, &pThis->XmitLock, RT_SRC_POS, "IntNetXmit"); 1243 if (RT_FAILURE(rc)) 1244 return rc; 1245 1196 1246 1197 1247 /* … … 1276 1326 "IntNet", 1277 1327 /* szRCMod */ 1278 "VBoxDD ",1328 "VBoxDDRC", 1279 1329 /* szR0Mod */ 1280 "VBoxDD ",1330 "VBoxDDR0", 1281 1331 /* pszDescription */ 1282 1332 "Internal Networking Transport Driver", … … 1298 1348 drvR3IntNetDestruct, 1299 1349 /* pfnRelocate */ 1300 NULL,1350 drvR3IntNetRelocate, 1301 1351 /* pfnIOCtl */ 1302 1352 NULL, -
trunk/src/VBox/Devices/Network/DrvNAT.cpp
r28216 r28258 151 151 /** tftp server name to provide in the DHCP server response. */ 152 152 char *pszNextServer; 153 /* polling thread*/153 /** Polling thread. */ 154 154 PPDMTHREAD pSlirpThread; 155 155 /** Queue for NAT-thread-external events. */ … … 193 193 194 194 /** makes access to device func RecvAvail and Recv atomical. */ 195 RTCRITSECT csDevAccess; 196 volatile uint32_t cUrgPkt; 197 volatile uint32_t cPkt; 195 RTCRITSECT DevAccessLock; 196 /** Number of in-flight urgent packets. */ 197 volatile uint32_t cUrgPkts; 198 /** Number of in-flight regular packets. */ 199 volatile uint32_t cPkts; 200 201 /** Transmit lock taken by BeginXmit and released by EndXmit. */ 202 RTCRITSECT XmitLock; 198 203 } DRVNAT; 199 204 AssertCompileMemberAlignment(DRVNAT, StatNATRecvWakeups, 8); … … 235 240 { 236 241 RTReqProcess(pThis->pRecvReqQueue, 0); 237 if (ASMAtomicReadU32(&pThis->cPkt ) == 0)242 if (ASMAtomicReadU32(&pThis->cPkts) == 0) 238 243 RTSemEventWait(pThis->EventRecv, RT_INDEFINITE_WAIT); 239 244 } … … 262 267 { 263 268 RTReqProcess(pThis->pUrgRecvReqQueue, 0); 264 if (ASMAtomicReadU32(&pThis->cUrgPkt ) == 0)269 if (ASMAtomicReadU32(&pThis->cUrgPkts) == 0) 265 270 { 266 271 int rc = RTSemEventWait(pThis->EventUrgRecv, RT_INDEFINITE_WAIT); … … 282 287 static DECLCALLBACK(void) drvNATUrgRecvWorker(PDRVNAT pThis, uint8_t *pu8Buf, int cb, struct mbuf *m) 283 288 { 284 int rc = RTCritSectEnter(&pThis-> csDevAccess);289 int rc = RTCritSectEnter(&pThis->DevAccessLock); 285 290 AssertRC(rc); 286 291 rc = pThis->pIAboveNet->pfnWaitReceiveAvail(pThis->pIAboveNet, RT_INDEFINITE_WAIT); … … 297 302 } 298 303 299 rc = RTCritSectLeave(&pThis-> csDevAccess);304 rc = RTCritSectLeave(&pThis->DevAccessLock); 300 305 AssertRC(rc); 301 306 … … 304 309 RTMemFree(pu8Buf); 305 310 #endif 306 if (ASMAtomicDecU32(&pThis->cUrgPkt ) == 0)311 if (ASMAtomicDecU32(&pThis->cUrgPkts) == 0) 307 312 { 308 313 drvNATRecvWakeup(pThis->pDrvIns, pThis->pRecvThread); … … 319 324 STAM_PROFILE_START(&pThis->StatNATRecvWait, b); 320 325 321 while (ASMAtomicReadU32(&pThis->cUrgPkt ) != 0)326 while (ASMAtomicReadU32(&pThis->cUrgPkts) != 0) 322 327 { 323 328 rc = RTSemEventWait(pThis->EventRecv, RT_INDEFINITE_WAIT); … … 328 333 } 329 334 330 rc = RTCritSectEnter(&pThis-> csDevAccess);335 rc = RTCritSectEnter(&pThis->DevAccessLock); 331 336 AssertRC(rc); 332 337 … … 344 349 } 345 350 346 rc = RTCritSectLeave(&pThis-> csDevAccess);351 rc = RTCritSectLeave(&pThis->DevAccessLock); 347 352 AssertRC(rc); 348 353 … … 352 357 RTMemFree(pu8Buf); 353 358 #endif 354 ASMAtomicDecU32(&pThis->cPkt );359 ASMAtomicDecU32(&pThis->cPkts); 355 360 356 361 drvNATNotifyNATThread(pThis, "drvNATRecvWorker"); … … 451 456 452 457 /** 458 * @interface_method_impl{PDMINETWORKUP,pfnBeginXmit} 459 */ 460 static DECLCALLBACK(int) drvNATNetworkUp_BeginXmit(PPDMINETWORKUP pInterface) 461 { 462 PDRVNAT pThis = RT_FROM_MEMBER(pInterface, DRVNAT, INetworkUp); 463 int rc = RTCritSectTryEnter(&pThis->XmitLock); 464 if (RT_FAILURE(rc)) 465 { 466 /** @todo Kick the worker thread when we have one... */ 467 rc = VERR_TRY_AGAIN; 468 } 469 return rc; 470 } 471 472 /** 453 473 * @interface_method_impl{PDMINETWORKUP,pfnAllocBuf} 454 474 */ … … 457 477 { 458 478 PDRVNAT pThis = RT_FROM_MEMBER(pInterface, DRVNAT, INetworkUp); 479 // Assert(RTCritSectIsOwner(&pThis->XmitLock); 459 480 460 481 /* … … 522 543 { 523 544 PDRVNAT pThis = RT_FROM_MEMBER(pInterface, DRVNAT, INetworkUp); 545 // Assert(RTCritSectIsOwner(&pThis->XmitLock); 524 546 drvNATFreeSgBuf(pThis, pSgBuf); 525 547 return VINF_SUCCESS; … … 533 555 PDRVNAT pThis = RT_FROM_MEMBER(pInterface, DRVNAT, INetworkUp); 534 556 Assert((pSgBuf->fFlags & PDMSCATTERGATHER_FLAGS_OWNER_MASK) == PDMSCATTERGATHER_FLAGS_OWNER_1); 557 // Assert(RTCritSectIsOwner(&pThis->XmitLock); 535 558 536 559 int rc; … … 556 579 drvNATFreeSgBuf(pThis, pSgBuf); 557 580 return rc; 581 } 582 583 /** 584 * @interface_method_impl{PDMINETWORKUP,pfnEndXmit} 585 */ 586 static DECLCALLBACK(void) drvNATNetworkUp_EndXmit(PPDMINETWORKUP pInterface) 587 { 588 PDRVNAT pThis = RT_FROM_MEMBER(pInterface, DRVNAT, INetworkUp); 589 RTCritSectLeave(&pThis->XmitLock); 558 590 } 559 591 … … 841 873 return; 842 874 843 ASMAtomicIncU32(&pThis->cUrgPkt );875 ASMAtomicIncU32(&pThis->cUrgPkts); 844 876 int rc = RTReqCallEx(pThis->pUrgRecvReqQueue, NULL /*ppReq*/, 0 /*cMillies*/, RTREQFLAGS_VOID | RTREQFLAGS_NO_WAIT, 845 877 (PFNRT)drvNATUrgRecvWorker, 4, pThis, pu8Buf, cb, m); … … 865 897 return; 866 898 867 ASMAtomicIncU32(&pThis->cPkt );899 ASMAtomicIncU32(&pThis->cPkts); 868 900 int rc = RTReqCallEx(pThis->pRecvReqQueue, NULL /*ppReq*/, 0 /*cMillies*/, RTREQFLAGS_VOID | RTREQFLAGS_NO_WAIT, 869 901 (PFNRT)drvNATRecvWorker, 4, pThis, pu8Buf, cb, m); … … 1030 1062 pThis->pNATState = NULL; 1031 1063 } 1064 1065 RTReqDestroyQueue(pThis->pSlirpReqQueue); 1066 pThis->pSlirpReqQueue = NULL; 1067 1068 RTReqDestroyQueue(pThis->pUrgRecvReqQueue); 1069 pThis->pUrgRecvReqQueue = NULL; 1070 1071 RTSemEventDestroy(pThis->EventRecv); 1072 pThis->EventRecv = NIL_RTSEMEVENT; 1073 1074 RTSemEventDestroy(pThis->EventUrgRecv); 1075 pThis->EventUrgRecv = NIL_RTSEMEVENT; 1076 1077 if (RTCritSectIsInitialized(&pThis->DevAccessLock)) 1078 RTCritSectDelete(&pThis->DevAccessLock); 1079 1080 if (RTCritSectIsInitialized(&pThis->XmitLock)) 1081 RTCritSectDelete(&pThis->XmitLock); 1032 1082 } 1033 1083 … … 1064 1114 pThis->pszBootFile = NULL; 1065 1115 pThis->pszNextServer = NULL; 1116 pThis->pSlirpReqQueue = NULL; 1117 pThis->pUrgRecvReqQueue = NULL; 1118 pThis->EventRecv = NIL_RTSEMEVENT; 1119 pThis->EventUrgRecv = NIL_RTSEMEVENT; 1120 1066 1121 /* IBase */ 1067 1122 pDrvIns->IBase.pfnQueryInterface = drvNATQueryInterface; 1123 1068 1124 /* INetwork */ 1125 pThis->INetworkUp.pfnBeginXmit = drvNATNetworkUp_BeginXmit; 1069 1126 pThis->INetworkUp.pfnAllocBuf = drvNATNetworkUp_AllocBuf; 1070 1127 pThis->INetworkUp.pfnFreeBuf = drvNATNetworkUp_FreeBuf; 1071 1128 pThis->INetworkUp.pfnSendBuf = drvNATNetworkUp_SendBuf; 1129 pThis->INetworkUp.pfnEndXmit = drvNATNetworkUp_EndXmit; 1072 1130 pThis->INetworkUp.pfnSetPromiscuousMode = drvNATNetworkUp_SetPromiscuousMode; 1073 1131 pThis->INetworkUp.pfnNotifyLinkChanged = drvNATNetworkUp_NotifyLinkChanged; … … 1170 1228 #endif 1171 1229 1172 int rc2= drvNATConstructRedir(pDrvIns->iInstance, pThis, pCfg, Network);1173 if (RT_SUCCESS(rc 2))1230 rc = drvNATConstructRedir(pDrvIns->iInstance, pThis, pCfg, Network); 1231 if (RT_SUCCESS(rc)) 1174 1232 { 1175 1233 /* … … 1177 1235 * engine after we loaded a guest state. 1178 1236 */ 1179 rc2 = PDMDrvHlpSSMRegisterLoadDone(pDrvIns, drvNATLoadDone); 1180 AssertRC(rc2); 1237 rc = PDMDrvHlpSSMRegisterLoadDone(pDrvIns, drvNATLoadDone); 1238 AssertRCReturn(rc, rc); 1239 1181 1240 rc = RTReqCreateQueue(&pThis->pSlirpReqQueue); 1182 1241 if (RT_FAILURE(rc)) … … 1193 1252 return rc; 1194 1253 } 1254 1195 1255 rc = RTReqCreateQueue(&pThis->pUrgRecvReqQueue); 1196 1256 if (RT_FAILURE(rc)) … … 1199 1259 return rc; 1200 1260 } 1201 rc = PDMDrvHlpPDMThreadCreate(pDrvIns, &pThis->pRecvThread, pThis, drvNATRecv, 1202 drvNATRecvWakeup, 128 * _1K, RTTHREADTYPE_IO, "NATRX"); 1203 AssertRC(rc); 1261 1262 rc = PDMDrvHlpThreadCreate(pDrvIns, &pThis->pRecvThread, pThis, drvNATRecv, 1263 drvNATRecvWakeup, 128 * _1K, RTTHREADTYPE_IO, "NATRX"); 1264 AssertRCReturn(rc, rc); 1265 1204 1266 rc = RTSemEventCreate(&pThis->EventRecv); 1205 1206 rc = PDMDrvHlpPDMThreadCreate(pDrvIns, &pThis->pUrgRecvThread, pThis, drvNATUrgRecv, 1207 drvNATUrgRecvWakeup, 128 * _1K, RTTHREADTYPE_IO, "NATURGRX"); 1208 AssertRC(rc); 1267 AssertRCReturn(rc, rc); 1268 1269 rc = PDMDrvHlpThreadCreate(pDrvIns, &pThis->pUrgRecvThread, pThis, drvNATUrgRecv, 1270 drvNATUrgRecvWakeup, 128 * _1K, RTTHREADTYPE_IO, "NATURGRX"); 1271 AssertRCReturn(rc, rc); 1272 1209 1273 rc = RTSemEventCreate(&pThis->EventRecv); 1274 AssertRCReturn(rc, rc); 1275 1210 1276 rc = RTSemEventCreate(&pThis->EventUrgRecv); 1211 rc = RTCritSectInit(&pThis->csDevAccess); 1277 AssertRCReturn(rc, rc); 1278 1279 rc = RTCritSectInit(&pThis->DevAccessLock); 1280 AssertRCReturn(rc, rc); 1281 1282 rc = RTCritSectInit(&pThis->XmitLock); 1283 AssertRCReturn(rc, rc); 1212 1284 1213 1285 #ifndef RT_OS_WINDOWS … … 1230 1302 #endif 1231 1303 1232 rc = PDMDrvHlp PDMThreadCreate(pDrvIns, &pThis->pSlirpThread, pThis, drvNATAsyncIoThread,1233 1304 rc = PDMDrvHlpThreadCreate(pDrvIns, &pThis->pSlirpThread, pThis, drvNATAsyncIoThread, 1305 drvNATAsyncIoWakeup, 128 * _1K, RTTHREADTYPE_IO, "NAT"); 1234 1306 AssertRC(rc); 1235 1307 1236 1308 #ifdef VBOX_WITH_SLIRP_MT 1237 rc = PDMDrvHlp PDMThreadCreate(pDrvIns, &pThis->pGuestThread, pThis, drvNATAsyncIoGuest,1238 1309 rc = PDMDrvHlpThreadCreate(pDrvIns, &pThis->pGuestThread, pThis, drvNATAsyncIoGuest, 1310 drvNATAsyncIoGuestWakeup, 128 * _1K, RTTHREADTYPE_IO, "NATGUEST"); 1239 1311 AssertRC(rc); 1240 1312 #endif … … 1245 1317 return rc; 1246 1318 } 1319 1247 1320 /* failure path */ 1248 rc = rc2;1249 1321 slirp_term(pThis->pNATState); 1250 1322 pThis->pNATState = NULL; -
trunk/src/VBox/Devices/Network/DrvNetSniffer.cpp
r28213 r28258 77 77 /** Pointer to the driver instance. */ 78 78 PPDMDRVINS pDrvIns; 79 /** For when we're the leaf driver. */ 80 RTCRITSECT XmitLock; 79 81 80 82 } DRVNETSNIFFER, *PDRVNETSNIFFER; 81 83 84 85 86 /** 87 * @interface_method_impl{PDMINETWORKUP,pfnBeginXmit} 88 */ 89 static DECLCALLBACK(int) drvNetSnifferUp_BeginXmit(PPDMINETWORKUP pInterface) 90 { 91 PDRVNETSNIFFER pThis = RT_FROM_MEMBER(pInterface, DRVNETSNIFFER, INetworkUp); 92 if (RT_UNLIKELY(!pThis->pIBelowNet)) 93 { 94 int rc = RTCritSectTryEnter(&pThis->XmitLock); 95 if (RT_UNLIKELY(rc == VERR_SEM_BUSY)) 96 rc = VERR_TRY_AGAIN; 97 return rc; 98 } 99 return pThis->pIBelowNet->pfnBeginXmit(pThis->pIBelowNet); 100 } 82 101 83 102 … … 135 154 136 155 /** 156 * @interface_method_impl{PDMINETWORKUP,pfnEndXmit} 157 */ 158 static DECLCALLBACK(void) drvNetSnifferUp_EndXmit(PPDMINETWORKUP pInterface) 159 { 160 LogFlow(("drvNetSnifferUp_EndXmit:\n")); 161 PDRVNETSNIFFER pThis = RT_FROM_MEMBER(pInterface, DRVNETSNIFFER, INetworkUp); 162 if (RT_LIKELY(pThis->pIBelowNet)) 163 pThis->pIBelowNet->pfnEndXmit(pThis->pIBelowNet); 164 else 165 RTCritSectLeave(&pThis->XmitLock); 166 } 167 168 169 /** 137 170 * @interface_method_impl{PDMINETWORKUP,pfnSetPromiscuousMode} 138 171 */ … … 159 192 160 193 /** 161 * @ copydoc PDMINETWORKDOWN::pfnWaitReceiveAvail194 * @interface_method_impl{PDMINETWORKDOWN,pfnWaitReceiveAvail} 162 195 */ 163 196 static DECLCALLBACK(int) drvNetSnifferDown_WaitReceiveAvail(PPDMINETWORKDOWN pInterface, RTMSINTERVAL cMillies) … … 169 202 170 203 /** 171 * @ copydoc PDMINETWORKDOWN::pfnReceive204 * @interface_method_impl{PDMINETWORKDOWN,pfnReceive} 172 205 */ 173 206 static DECLCALLBACK(int) drvNetSnifferDown_Receive(PPDMINETWORKDOWN pInterface, const void *pvBuf, size_t cb) … … 196 229 197 230 /** 198 * @ copydoc PDMINETWORKDOWN::pfnNotifyBufAvailable199 */ 200 static DECLCALLBACK(void) drvNetSnifferDown_ NotifyBufAvailable(PPDMINETWORKDOWN pInterface)231 * @interface_method_impl{PDMINETWORKDOWN,pfnDoTransmitWork} 232 */ 233 static DECLCALLBACK(void) drvNetSnifferDown_DoTransmitWork(PPDMINETWORKDOWN pInterface) 201 234 { 202 235 PDRVNETSNIFFER pThis = RT_FROM_MEMBER(pInterface, DRVNETSNIFFER, INetworkDown); 203 pThis->pIAboveNet->pfn NotifyBufAvailable(pThis->pIAboveNet);236 pThis->pIAboveNet->pfnDoTransmitWork(pThis->pIAboveNet); 204 237 } 205 238 … … 263 296 264 297 /** 265 * Detach a driver instance. 266 * 267 * @param pDrvIns The driver instance. 268 * @param fFlags Flags, combination of the PDM_TACH_FLAGS_* \#defines. 298 * @interface_method_impl{PDMDRVREG,pfnDetach} 269 299 */ 270 300 static DECLCALLBACK(void) drvNetSnifferDetach(PPDMDRVINS pDrvIns, uint32_t fFlags) … … 273 303 274 304 LogFlow(("drvNetSnifferDetach: pDrvIns: %p, fFlags: %u\n", pDrvIns, fFlags)); 275 305 RTCritSectEnter(&pThis->XmitLock); 276 306 pThis->pIBelowNet = NULL; 277 } 278 279 280 /** 281 * Attach a driver instance. 282 * 283 * @returns VBox status code. 284 * @param pDrvIns The driver instance. 285 * @param fFlags Flags, combination of the PDM_TACH_FLAGS_* \#defines. 307 RTCritSectLeave(&pThis->XmitLock); 308 } 309 310 311 /** 312 * @interface_method_impl{PDMDRVREG,pfnAttach} 286 313 */ 287 314 static DECLCALLBACK(int) drvNetSnifferAttach(PPDMDRVINS pDrvIns, uint32_t fFlags) 288 315 { 289 316 PDRVNETSNIFFER pThis = PDMINS_2_DATA(pDrvIns, PDRVNETSNIFFER); 290 291 LogFlow(("drvNetSnifferAttach: pDrvIns: %p, fFlags: %u\n", pDrvIns, fFlags));317 LogFlow(("drvNetSnifferAttach/#%#x: fFlags=%#x\n", pDrvIns->iInstance, fFlags)); 318 RTCritSectEnter(&pThis->XmitLock); 292 319 293 320 /* … … 298 325 if ( rc == VERR_PDM_NO_ATTACHED_DRIVER 299 326 || rc == VERR_PDM_CFG_MISSING_DRIVER_NAME) 327 { 300 328 pThis->pIBelowNet = NULL; 329 rc = VINF_SUCCESS; 330 } 301 331 else if (RT_SUCCESS(rc)) 302 332 { 303 333 pThis->pIBelowNet = PDMIBASE_QUERY_INTERFACE(pBaseDown, PDMINETWORKUP); 304 if (!pThis->pIBelowNet) 334 if (pThis->pIBelowNet) 335 rc = VINF_SUCCESS; 336 else 305 337 { 306 338 AssertMsgFailed(("Configuration error: the driver below didn't export the network connector interface!\n")); 307 r eturnVERR_PDM_MISSING_INTERFACE_BELOW;339 rc = VERR_PDM_MISSING_INTERFACE_BELOW; 308 340 } 309 341 } 310 342 else 311 {312 343 AssertMsgFailed(("Failed to attach to driver below! rc=%Rrc\n", rc)); 313 return rc; 314 } 315 344 345 RTCritSectLeave(&pThis->XmitLock); 316 346 return VINF_SUCCESS; 317 347 } … … 319 349 320 350 /** 321 * Destruct a driver instance. 322 * 323 * Most VM resources are freed by the VM. This callback is provided so that any non-VM 324 * resources can be freed correctly. 325 * 326 * @param pDrvIns The driver instance data. 351 * @interface_method_impl{PDMDRVREG,pfnDestruct} 327 352 */ 328 353 static DECLCALLBACK(void) drvNetSnifferDestruct(PPDMDRVINS pDrvIns) … … 334 359 RTCritSectDelete(&pThis->Lock); 335 360 361 if (RTCritSectIsInitialized(&pThis->XmitLock)) 362 RTCritSectDelete(&pThis->XmitLock); 363 336 364 if (pThis->File != NIL_RTFILE) 337 365 { … … 343 371 344 372 /** 345 * Construct a NAT network transport driver instance. 346 * 347 * @copydoc FNPDMDRVCONSTRUCT 373 * @interface_method_impl{Construct a NAT network transport driver instance, 374 * PDMDRVREG,pfnDestruct} 348 375 */ 349 376 static DECLCALLBACK(int) drvNetSnifferConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags) … … 352 379 LogFlow(("drvNetSnifferConstruct:\n")); 353 380 PDMDRV_CHECK_VERSIONS_RETURN(pDrvIns); 354 355 /*356 * Validate the config.357 */358 if (!CFGMR3AreValuesValid(pCfg, "File\0"))359 return VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES;360 361 if (CFGMR3GetFirstChild(pCfg))362 LogRel(("NetSniffer: Found child config entries -- are you trying to redirect ports?\n"));363 381 364 382 /* … … 372 390 pDrvIns->IBase.pfnQueryInterface = drvNetSnifferQueryInterface; 373 391 /* INetworkUp */ 392 pThis->INetworkUp.pfnBeginXmit = drvNetSnifferUp_BeginXmit; 374 393 pThis->INetworkUp.pfnAllocBuf = drvNetSnifferUp_AllocBuf; 375 394 pThis->INetworkUp.pfnFreeBuf = drvNetSnifferUp_FreeBuf; 376 395 pThis->INetworkUp.pfnSendBuf = drvNetSnifferUp_SendBuf; 396 pThis->INetworkUp.pfnEndXmit = drvNetSnifferUp_EndXmit; 377 397 pThis->INetworkUp.pfnSetPromiscuousMode = drvNetSnifferUp_SetPromiscuousMode; 378 398 pThis->INetworkUp.pfnNotifyLinkChanged = drvNetSnifferUp_NotifyLinkChanged; … … 380 400 pThis->INetworkDown.pfnWaitReceiveAvail = drvNetSnifferDown_WaitReceiveAvail; 381 401 pThis->INetworkDown.pfnReceive = drvNetSnifferDown_Receive; 382 pThis->INetworkDown.pfn NotifyBufAvailable = drvNetSnifferDown_NotifyBufAvailable;402 pThis->INetworkDown.pfnDoTransmitWork = drvNetSnifferDown_DoTransmitWork; 383 403 /* INetworkConfig */ 384 404 pThis->INetworkConfig.pfnGetMac = drvNetSnifferDownCfg_GetMac; … … 387 407 388 408 /* 409 * Create the locks. 410 */ 411 int rc = RTCritSectInit(&pThis->Lock); 412 AssertRCReturn(rc, rc); 413 rc = RTCritSectInit(&pThis->XmitLock); 414 AssertRCReturn(rc, rc); 415 416 /* 417 * Validate the config. 418 */ 419 if (!CFGMR3AreValuesValid(pCfg, "File\0")) 420 return VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES; 421 422 if (CFGMR3GetFirstChild(pCfg)) 423 LogRel(("NetSniffer: Found child config entries -- are you trying to redirect ports?\n")); 424 425 /* 389 426 * Get the filename. 390 427 */ 391 intrc = CFGMR3QueryString(pCfg, "File", pThis->szFilename, sizeof(pThis->szFilename));428 rc = CFGMR3QueryString(pCfg, "File", pThis->szFilename, sizeof(pThis->szFilename)); 392 429 if (rc == VERR_CFGM_VALUE_NOT_FOUND) 393 430 { … … 446 483 return rc; 447 484 } 448 449 /*450 * Create the lock.451 */452 rc = RTCritSectInit(&pThis->Lock);453 if (RT_FAILURE(rc))454 return rc;455 485 456 486 /* -
trunk/src/VBox/Devices/Network/DrvTAP.cpp
r28213 r28258 1116 1116 * Create the async I/O thread. 1117 1117 */ 1118 rc = PDMDrvHlp PDMThreadCreate(pDrvIns, &pThis->pThread, pThis, drvTAPAsyncIoThread, drvTapAsyncIoWakeup, 128 * _1K, RTTHREADTYPE_IO, "TAP");1118 rc = PDMDrvHlpThreadCreate(pDrvIns, &pThis->pThread, pThis, drvTAPAsyncIoThread, drvTapAsyncIoWakeup, 128 * _1K, RTTHREADTYPE_IO, "TAP"); 1119 1119 AssertRCReturn(rc, rc); 1120 1120 -
trunk/src/VBox/Devices/PC/DrvACPI.cpp
r27327 r28258 982 982 * Start the poller thread. 983 983 */ 984 rc = PDMDrvHlp PDMThreadCreate(pDrvIns, &pThis->pPollerThread, pThis, drvACPIPoller,985 984 rc = PDMDrvHlpThreadCreate(pDrvIns, &pThis->pPollerThread, pThis, drvACPIPoller, 985 drvACPIPollerWakeup, 0, RTTHREADTYPE_INFREQUENT_POLLER, "ACPI Poller"); 986 986 if (RT_FAILURE(rc)) 987 987 return rc; -
trunk/src/VBox/Devices/Parallel/DrvHostParallel.cpp
r26173 r28258 379 379 * Start waiting for interrupts. 380 380 */ 381 rc = PDMDrvHlp PDMThreadCreate(pDrvIns, &pThis->pMonitorThread, pThis, drvHostParallelMonitorThread, drvHostParallelWakeupMonitorThread, 0,382 381 rc = PDMDrvHlpThreadCreate(pDrvIns, &pThis->pMonitorThread, pThis, drvHostParallelMonitorThread, drvHostParallelWakeupMonitorThread, 0, 382 RTTHREADTYPE_IO, "ParMon"); 383 383 if (RT_FAILURE(rc)) 384 384 return PDMDrvHlpVMSetError(pDrvIns, rc, RT_SRC_POS, N_("HostParallel#%d cannot create monitor thread"), pDrvIns->iInstance); -
trunk/src/VBox/Devices/Serial/DrvHostSerial.cpp
r27394 r28258 1435 1435 * Create the receive, send and monitor threads pluss the related send semaphore. 1436 1436 */ 1437 rc = PDMDrvHlp PDMThreadCreate(pDrvIns, &pThis->pRecvThread, pThis, drvHostSerialRecvThread, drvHostSerialWakeupRecvThread, 0, RTTHREADTYPE_IO, "SerRecv");1437 rc = PDMDrvHlpThreadCreate(pDrvIns, &pThis->pRecvThread, pThis, drvHostSerialRecvThread, drvHostSerialWakeupRecvThread, 0, RTTHREADTYPE_IO, "SerRecv"); 1438 1438 if (RT_FAILURE(rc)) 1439 1439 return PDMDrvHlpVMSetError(pDrvIns, rc, RT_SRC_POS, N_("HostSerial#%d cannot create receive thread"), pDrvIns->iInstance); … … 1442 1442 AssertRC(rc); 1443 1443 1444 rc = PDMDrvHlp PDMThreadCreate(pDrvIns, &pThis->pSendThread, pThis, drvHostSerialSendThread, drvHostSerialWakeupSendThread, 0, RTTHREADTYPE_IO, "SerSend");1444 rc = PDMDrvHlpThreadCreate(pDrvIns, &pThis->pSendThread, pThis, drvHostSerialSendThread, drvHostSerialWakeupSendThread, 0, RTTHREADTYPE_IO, "SerSend"); 1445 1445 if (RT_FAILURE(rc)) 1446 1446 return PDMDrvHlpVMSetError(pDrvIns, rc, RT_SRC_POS, N_("HostSerial#%d cannot create send thread"), pDrvIns->iInstance); … … 1451 1451 ioctl(pThis->DeviceFile, TIOCMGET, &pThis->fStatusLines); 1452 1452 # endif 1453 rc = PDMDrvHlp PDMThreadCreate(pDrvIns, &pThis->pMonitorThread, pThis, drvHostSerialMonitorThread, drvHostSerialWakeupMonitorThread, 0, RTTHREADTYPE_IO, "SerMon");1453 rc = PDMDrvHlpThreadCreate(pDrvIns, &pThis->pMonitorThread, pThis, drvHostSerialMonitorThread, drvHostSerialWakeupMonitorThread, 0, RTTHREADTYPE_IO, "SerMon"); 1454 1454 if (RT_FAILURE(rc)) 1455 1455 return PDMDrvHlpVMSetError(pDrvIns, rc, RT_SRC_POS, N_("HostSerial#%d cannot create monitor thread"), pDrvIns->iInstance); -
trunk/src/VBox/Devices/Storage/DrvSCSI.cpp
r28065 r28258 697 697 698 698 /* Create I/O thread. */ 699 rc = PDMDrvHlp PDMThreadCreate(pDrvIns, &pThis->pAsyncIOThread, pThis, drvscsiAsyncIOLoop,700 699 rc = PDMDrvHlpThreadCreate(pDrvIns, &pThis->pAsyncIOThread, pThis, drvscsiAsyncIOLoop, 700 drvscsiAsyncIOLoopWakeup, 0, RTTHREADTYPE_IO, "SCSI async IO"); 701 701 AssertMsgReturn(RT_SUCCESS(rc), ("Failed to create async I/O thread rc=%Rrc\n"), rc); 702 702 -
trunk/src/VBox/Devices/Storage/DrvSCSIHost.cpp
r28065 r28258 484 484 485 485 /* Create I/O thread. */ 486 rc = PDMDrvHlp PDMThreadCreate(pDrvIns, &pThis->pAsyncIOThread, pThis, drvscsihostAsyncIOLoop,487 486 rc = PDMDrvHlpThreadCreate(pDrvIns, &pThis->pAsyncIOThread, pThis, drvscsihostAsyncIOLoop, 487 drvscsihostAsyncIOLoopWakeup, 0, RTTHREADTYPE_IO, "SCSI async IO"); 488 488 AssertMsgReturn(RT_SUCCESS(rc), ("Failed to create async I/O thread rc=%Rrc\n"), rc); 489 489 -
trunk/src/VBox/Devices/Storage/DrvVD.cpp
r28065 r28258 344 344 if (RT_SUCCESS(rc)) 345 345 { 346 rc = PDMDrvHlp PDMAsyncCompletionTemplateCreate(pThis->pDrvIns, &pStorageBackend->pTemplate,347 346 rc = PDMDrvHlpAsyncCompletionTemplateCreate(pThis->pDrvIns, &pStorageBackend->pTemplate, 347 drvvdAsyncTaskCompleted, pStorageBackend, "AsyncTaskCompleted"); 348 348 if (RT_SUCCESS(rc)) 349 349 { -
trunk/src/VBox/VMM/PDM.cpp
r27936 r28258 307 307 AssertCompile(sizeof(pUVM->pdm.s) <= sizeof(pUVM->pdm.padding)); 308 308 AssertRelease(sizeof(pUVM->pdm.s) <= sizeof(pUVM->pdm.padding)); 309 pUVM->pdm.s.pModules = NULL; 310 return VINF_SUCCESS; 309 pUVM->pdm.s.pModules = NULL; 310 pUVM->pdm.s.pCritSects = NULL; 311 return RTCritSectInit(&pUVM->pdm.s.ListCritSect); 311 312 } 312 313 … … 337 338 * Initialize sub compontents. 338 339 */ 339 int rc = RTCritSectInit(&pVM->pdm.s.MiscCritSect); 340 if (RT_SUCCESS(rc)) 341 rc = pdmR3CritSectInit(pVM); 340 int rc = pdmR3CritSectInitStats(pVM); 342 341 if (RT_SUCCESS(rc)) 343 342 rc = PDMR3CritSectInit(pVM, &pVM->pdm.s.CritSect, RT_SRC_POS, "PDM"); … … 649 648 */ 650 649 pdmR3LdrTermU(pUVM); 650 651 Assert(pUVM->pdm.s.pCritSects == NULL); 652 RTCritSectDelete(&pUVM->pdm.s.ListCritSect); 651 653 } 652 654 -
trunk/src/VBox/VMM/PDMCritSect.cpp
r25748 r28258 29 29 #include <VBox/mm.h> 30 30 #include <VBox/vm.h> 31 #include <VBox/uvm.h> 31 32 32 33 #include <VBox/err.h> … … 43 44 * Internal Functions * 44 45 *******************************************************************************/ 45 static int pdmR3CritSectDeleteOne(PVM pVM, P PDMCRITSECTINT pCritSect, PPDMCRITSECTINT pPrev, bool fFinal);46 47 48 49 /** 50 * Initializes the critical section subcomponent.46 static int pdmR3CritSectDeleteOne(PVM pVM, PUVM pUVM, PPDMCRITSECTINT pCritSect, PPDMCRITSECTINT pPrev, bool fFinal); 47 48 49 50 /** 51 * Register statistics related to the critical sections. 51 52 * 52 53 * @returns VBox status code. 53 54 * @param pVM The VM handle. 54 * @remark Not to be confused with PDMR3CritSectInit and pdmR3CritSectInitDevice which are 55 * for initializing a critical section. 56 */ 57 int pdmR3CritSectInit(PVM pVM) 55 */ 56 int pdmR3CritSectInitStats(PVM pVM) 58 57 { 59 58 STAM_REG(pVM, &pVM->pdm.s.StatQueuedCritSectLeaves, STAMTYPE_COUNTER, "/PDM/QueuedCritSectLeaves", STAMUNIT_OCCURENCES, … … 70 69 void pdmR3CritSectRelocate(PVM pVM) 71 70 { 72 RTCritSectEnter(&pVM->pdm.s.MiscCritSect); 73 for (PPDMCRITSECTINT pCur = pVM->pdm.s.pCritSects; 71 PUVM pUVM = pVM->pUVM; 72 RTCritSectEnter(&pUVM->pdm.s.ListCritSect); 73 74 for (PPDMCRITSECTINT pCur = pUVM->pdm.s.pCritSects; 74 75 pCur; 75 76 pCur = pCur->pNext) 76 77 pCur->pVMRC = pVM->pVMRC; 77 RTCritSectLeave(&pVM->pdm.s.MiscCritSect); 78 79 RTCritSectLeave(&pUVM->pdm.s.ListCritSect); 78 80 } 79 81 … … 82 84 * Deletes all remaining critical sections. 83 85 * 84 * This is called at the end of the termination process. 86 * This is called at the very end of the termination process. It is also called 87 * at the end of vmR3CreateU failure cleanup, which may cause it to be called 88 * twice depending on hwere vmR3CreateU actually failed. We have to do the 89 * latter call because other components expect the critical sections to be 90 * automatically deleted. 85 91 * 86 92 * @returns VBox status. 87 93 * First error code, rest is lost. 88 * @param pVM The VM handle.94 * @param pVMU The user mode VM handle. 89 95 * @remark Don't confuse this with PDMR3CritSectDelete. 90 96 */ 91 97 VMMDECL(int) PDMR3CritSectTerm(PVM pVM) 92 98 { 93 int rc = VINF_SUCCESS; 94 RTCritSectEnter(&pVM->pdm.s.MiscCritSect); 95 while (pVM->pdm.s.pCritSects) 96 { 97 int rc2 = pdmR3CritSectDeleteOne(pVM, pVM->pdm.s.pCritSects, NULL, true /* final */); 99 PUVM pUVM = pVM->pUVM; 100 int rc = VINF_SUCCESS; 101 RTCritSectEnter(&pUVM->pdm.s.ListCritSect); 102 103 while (pUVM->pdm.s.pCritSects) 104 { 105 int rc2 = pdmR3CritSectDeleteOne(pVM, pUVM, pUVM->pdm.s.pCritSects, NULL, true /* final */); 98 106 AssertRC(rc2); 99 107 if (RT_FAILURE(rc2) && RT_SUCCESS(rc)) 100 108 rc = rc2; 101 109 } 102 RTCritSectLeave(&pVM->pdm.s.MiscCritSect); 103 RTCritSect Delete(&pVM->pdm.s.MiscCritSect);110 111 RTCritSectLeave(&pUVM->pdm.s.ListCritSect); 104 112 return rc; 105 113 } 106 107 114 108 115 … … 162 169 pCritSect->pvKey = pvKey; 163 170 pCritSect->EventToSignal = NIL_RTSEMEVENT; 164 pCritSect->pNext = pVM->p dm.s.pCritSects;171 pCritSect->pNext = pVM->pUVM->pdm.s.pCritSects; 165 172 pCritSect->pszName = pszName; 166 pVM->p dm.s.pCritSects = pCritSect;173 pVM->pUVM->pdm.s.pCritSects = pCritSect; 167 174 STAMR3RegisterF(pVM, &pCritSect->StatContentionRZLock, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, NULL, "/PDM/CritSects/%s/ContentionRZLock", pCritSect->pszName); 168 175 STAMR3RegisterF(pVM, &pCritSect->StatContentionRZUnlock,STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, NULL, "/PDM/CritSects/%s/ContentionRZUnlock", pCritSect->pszName); … … 215 222 216 223 /** 217 * Initializes a PDM critical section .224 * Initializes a PDM critical section for a device. 218 225 * 219 226 * The PDM critical sections are derived from the IPRT critical sections, but … … 224 231 * @param pDevIns Device instance. 225 232 * @param pCritSect Pointer to the critical section. 226 * @param pszNameFmt Format string for nam ging the critical section. For233 * @param pszNameFmt Format string for naming the critical section. For 227 234 * statistics and lock validation. 228 235 * @param va Arguments for the format string. … … 232 239 { 233 240 return pdmR3CritSectInitOne(pVM, &pCritSect->s, pDevIns, RT_SRC_POS_ARGS, pszNameFmt, va); 241 } 242 243 244 /** 245 * Initializes a PDM critical section for a driver. 246 * 247 * @returns VBox status code. 248 * @param pVM The VM handle. 249 * @param pDrvIns Driver instance. 250 * @param pCritSect Pointer to the critical section. 251 * @param pszNameFmt Format string for naming the critical section. For 252 * statistics and lock validation. 253 * @param ... Arguments for the format string. 254 */ 255 int pdmR3CritSectInitDriver(PVM pVM, PPDMDRVINS pDrvIns, PPDMCRITSECT pCritSect, RT_SRC_POS_DECL, 256 const char *pszNameFmt, ...) 257 { 258 va_list va; 259 va_start(va, pszNameFmt); 260 int rc = pdmR3CritSectInitOne(pVM, &pCritSect->s, pDrvIns, RT_SRC_POS_ARGS, pszNameFmt, va); 261 va_end(va); 262 return rc; 234 263 } 235 264 … … 245 274 * @param fFinal Set if this is the final call and statistics shouldn't be deregistered. 246 275 * 247 * @remarks Caller must've entered the MiscCritSect.248 */ 249 static int pdmR3CritSectDeleteOne(PVM pVM, P PDMCRITSECTINT pCritSect, PPDMCRITSECTINT pPrev, bool fFinal)276 * @remarks Caller must've entered the ListCritSect. 277 */ 278 static int pdmR3CritSectDeleteOne(PVM pVM, PUVM pUVM, PPDMCRITSECTINT pCritSect, PPDMCRITSECTINT pPrev, bool fFinal) 250 279 { 251 280 /* … … 256 285 Assert(pCritSect->Core.cLockers == -1); 257 286 Assert(pCritSect->Core.NativeThreadOwner == NIL_RTNATIVETHREAD); 258 Assert(RTCritSectIsOwner(&p VM->pdm.s.MiscCritSect));287 Assert(RTCritSectIsOwner(&pUVM->pdm.s.ListCritSect)); 259 288 260 289 /* … … 264 293 pPrev->pNext = pCritSect->pNext; 265 294 else 266 p VM->pdm.s.pCritSects = pCritSect->pNext;295 pUVM->pdm.s.pCritSects = pCritSect->pNext; 267 296 268 297 /* … … 314 343 * Iterate the list and match key. 315 344 */ 345 PUVM pUVM = pVM->pUVM; 316 346 int rc = VINF_SUCCESS; 317 347 PPDMCRITSECTINT pPrev = NULL; 318 RTCritSectEnter(&p VM->pdm.s.MiscCritSect);319 PPDMCRITSECTINT pCur = p VM->pdm.s.pCritSects;348 RTCritSectEnter(&pUVM->pdm.s.ListCritSect); 349 PPDMCRITSECTINT pCur = pUVM->pdm.s.pCritSects; 320 350 while (pCur) 321 351 { 322 352 if (pCur->pvKey == pvKey) 323 353 { 324 int rc2 = pdmR3CritSectDeleteOne(pVM, p Cur, pPrev, false /* not final */);354 int rc2 = pdmR3CritSectDeleteOne(pVM, pUVM, pCur, pPrev, false /* not final */); 325 355 AssertRC(rc2); 326 356 if (RT_FAILURE(rc2) && RT_SUCCESS(rc)) … … 332 362 pCur = pCur->pNext; 333 363 } 334 RTCritSectLeave(&p VM->pdm.s.MiscCritSect);364 RTCritSectLeave(&pUVM->pdm.s.ListCritSect); 335 365 return rc; 336 366 } … … 351 381 352 382 /** 383 * Deletes all undeleted critical sections initalized by a given driver. 384 * 385 * @returns VBox status code. 386 * @param pVM The VM handle. 387 * @param pDrvIns The driver handle. 388 */ 389 int pdmR3CritSectDeleteDriver(PVM pVM, PPDMDRVINS pDrvIns) 390 { 391 return pdmR3CritSectDeleteByKey(pVM, pDrvIns); 392 } 393 394 395 /** 353 396 * Deletes the critical section. 354 397 * … … 365 408 */ 366 409 PVM pVM = pCritSect->s.pVMR3; 410 PUVM pUVM = pVM->pUVM; 367 411 AssertReleaseReturn(pVM, VERR_INTERNAL_ERROR); 368 412 PPDMCRITSECTINT pPrev = NULL; 369 RTCritSectEnter(&p VM->pdm.s.MiscCritSect);370 PPDMCRITSECTINT pCur = p VM->pdm.s.pCritSects;413 RTCritSectEnter(&pUVM->pdm.s.ListCritSect); 414 PPDMCRITSECTINT pCur = pUVM->pdm.s.pCritSects; 371 415 while (pCur) 372 416 { 373 417 if (pCur == &pCritSect->s) 374 418 { 375 int rc = pdmR3CritSectDeleteOne(pVM, p Cur, pPrev, false /* not final */);376 RTCritSectLeave(&p VM->pdm.s.MiscCritSect);419 int rc = pdmR3CritSectDeleteOne(pVM, pUVM, pCur, pPrev, false /* not final */); 420 RTCritSectLeave(&pUVM->pdm.s.ListCritSect); 377 421 return rc; 378 422 } … … 382 426 pCur = pCur->pNext; 383 427 } 384 RTCritSectLeave(&p VM->pdm.s.MiscCritSect);428 RTCritSectLeave(&pUVM->pdm.s.ListCritSect); 385 429 AssertReleaseMsgFailed(("pCritSect=%p wasn't found!\n", pCritSect)); 386 430 return VERR_INTERNAL_ERROR; … … 519 563 RTNATIVETHREAD const hNativeThread = RTThreadNativeSelf(); 520 564 uint32_t cCritSects = 0; 521 for (PPDMCRITSECTINT pCur = pVM->p dm.s.pCritSects;565 for (PPDMCRITSECTINT pCur = pVM->pUVM->pdm.s.pCritSects; 522 566 pCur; 523 567 pCur = pCur->pNext) … … 583 627 { 584 628 RTNATIVETHREAD const hNativeSelf = RTThreadNativeSelf(); 585 586 RTCritSectEnter(&pVM->pdm.s.MiscCritSect); 587 for (PPDMCRITSECTINT pCur = pVM->pdm.s.pCritSects; 629 PUVM pUVM = pVM->pUVM; 630 631 RTCritSectEnter(&pUVM->pdm.s.ListCritSect); 632 for (PPDMCRITSECTINT pCur = pUVM->pdm.s.pCritSects; 588 633 pCur; 589 634 pCur = pCur->pNext) … … 593 638 PDMCritSectLeave((PPDMCRITSECT)pCur); 594 639 } 595 RTCritSectLeave(&p VM->pdm.s.MiscCritSect);596 } 597 640 RTCritSectLeave(&pUVM->pdm.s.ListCritSect); 641 } 642 -
trunk/src/VBox/VMM/PDMDriver.cpp
r26264 r28258 5 5 6 6 /* 7 * Copyright (C) 2006-20 07Sun Microsystems, Inc.7 * Copyright (C) 2006-2010 Sun Microsystems, Inc. 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 654 654 AssertRC(rc); 655 655 656 /* PDM critsects. */ 657 rc = pdmR3CritSectDeleteDriver(pVM, pCur); 658 AssertRC(rc); 659 656 660 /* Finally, the driver it self. */ 657 661 bool fHyperHeap = pCur->Internal.s.fHyperHeap; … … 925 929 926 930 927 /** @interface_method_impl{PDMDRVHLP,pfn PDMQueueCreate} */928 static DECLCALLBACK(int) pdmR3DrvHlp_ PDMQueueCreate(PPDMDRVINS pDrvIns, uint32_t cbItem, uint32_t cItems, uint32_t cMilliesInterval,929 931 /** @interface_method_impl{PDMDRVHLP,pfnQueueCreate} */ 932 static DECLCALLBACK(int) pdmR3DrvHlp_QueueCreate(PPDMDRVINS pDrvIns, uint32_t cbItem, uint32_t cItems, uint32_t cMilliesInterval, 933 PFNPDMQUEUEDRV pfnCallback, const char *pszName, PPDMQUEUE *ppQueue) 930 934 { 931 935 PDMDRV_ASSERT_DRVINS(pDrvIns); … … 1164 1168 1165 1169 1166 /** @interface_method_impl{PDMDRVHLP,pfn PDMThreadCreate} */1167 static DECLCALLBACK(int) pdmR3DrvHlp_ PDMThreadCreate(PPDMDRVINS pDrvIns, PPPDMTHREAD ppThread, void *pvUser, PFNPDMTHREADDRV pfnThread,1168 1169 { 1170 PDMDRV_ASSERT_DRVINS(pDrvIns); 1171 VM_ASSERT_EMT(pDrvIns->Internal.s.pVMR3); 1172 LogFlow(("pdmR3DrvHlp_ PDMThreadCreate: caller='%s'/%d: ppThread=%p pvUser=%p pfnThread=%p pfnWakeup=%p cbStack=%#zx enmType=%d pszName=%p:{%s}\n",1170 /** @interface_method_impl{PDMDRVHLP,pfnThreadCreate} */ 1171 static DECLCALLBACK(int) pdmR3DrvHlp_ThreadCreate(PPDMDRVINS pDrvIns, PPPDMTHREAD ppThread, void *pvUser, PFNPDMTHREADDRV pfnThread, 1172 PFNPDMTHREADWAKEUPDRV pfnWakeup, size_t cbStack, RTTHREADTYPE enmType, const char *pszName) 1173 { 1174 PDMDRV_ASSERT_DRVINS(pDrvIns); 1175 VM_ASSERT_EMT(pDrvIns->Internal.s.pVMR3); 1176 LogFlow(("pdmR3DrvHlp_ThreadCreate: caller='%s'/%d: ppThread=%p pvUser=%p pfnThread=%p pfnWakeup=%p cbStack=%#zx enmType=%d pszName=%p:{%s}\n", 1173 1177 pDrvIns->pReg->szName, pDrvIns->iInstance, ppThread, pvUser, pfnThread, pfnWakeup, cbStack, enmType, pszName, pszName)); 1174 1178 1175 1179 int rc = pdmR3ThreadCreateDriver(pDrvIns->Internal.s.pVMR3, pDrvIns, ppThread, pvUser, pfnThread, pfnWakeup, cbStack, enmType, pszName); 1176 1180 1177 LogFlow(("pdmR3DrvHlp_ PDMThreadCreate: caller='%s'/%d: returns %Rrc *ppThread=%RTthrd\n", pDrvIns->pReg->szName, pDrvIns->iInstance,1181 LogFlow(("pdmR3DrvHlp_ThreadCreate: caller='%s'/%d: returns %Rrc *ppThread=%RTthrd\n", pDrvIns->pReg->szName, pDrvIns->iInstance, 1178 1182 rc, *ppThread)); 1179 1183 return rc; … … 1181 1185 1182 1186 1183 /** @interface_method_impl{PDMDRVHLP,pfn PDMAsyncCompletionTemplateCreate} */1184 static DECLCALLBACK(int) pdmR3DrvHlp_ PDMAsyncCompletionTemplateCreate(PPDMDRVINS pDrvIns, PPPDMASYNCCOMPLETIONTEMPLATE ppTemplate,1185 1186 1187 { 1188 PDMDRV_ASSERT_DRVINS(pDrvIns); 1189 VM_ASSERT_EMT(pDrvIns->Internal.s.pVMR3); 1190 LogFlow(("pdmR3DrvHlp_ PDMAsyncCompletionTemplateCreate: caller='%s'/%d: ppTemplate=%p pfnCompleted=%p pszDesc=%p:{%s}\n",1187 /** @interface_method_impl{PDMDRVHLP,pfnAsyncCompletionTemplateCreate} */ 1188 static DECLCALLBACK(int) pdmR3DrvHlp_AsyncCompletionTemplateCreate(PPDMDRVINS pDrvIns, PPPDMASYNCCOMPLETIONTEMPLATE ppTemplate, 1189 PFNPDMASYNCCOMPLETEDRV pfnCompleted, void *pvTemplateUser, 1190 const char *pszDesc) 1191 { 1192 PDMDRV_ASSERT_DRVINS(pDrvIns); 1193 VM_ASSERT_EMT(pDrvIns->Internal.s.pVMR3); 1194 LogFlow(("pdmR3DrvHlp_AsyncCompletionTemplateCreate: caller='%s'/%d: ppTemplate=%p pfnCompleted=%p pszDesc=%p:{%s}\n", 1191 1195 pDrvIns->pReg->szName, pDrvIns->iInstance, ppTemplate, pfnCompleted, pszDesc, pszDesc)); 1192 1196 1193 1197 int rc = PDMR3AsyncCompletionTemplateCreateDriver(pDrvIns->Internal.s.pVMR3, pDrvIns, ppTemplate, pfnCompleted, pvTemplateUser, pszDesc); 1194 1198 1195 LogFlow(("pdmR3DrvHlp_ PDMAsyncCompletionTemplateCreate: caller='%s'/%d: returns %Rrc *ppThread=%p\n", pDrvIns->pReg->szName,1199 LogFlow(("pdmR3DrvHlp_AsyncCompletionTemplateCreate: caller='%s'/%d: returns %Rrc *ppThread=%p\n", pDrvIns->pReg->szName, 1196 1200 pDrvIns->iInstance, rc, *ppTemplate)); 1197 1201 return rc; … … 1199 1203 1200 1204 1201 /** @interface_method_impl{PDMDRVHLP,pfn PDMLdrGetRCInterfaceSymbols} */1202 static DECLCALLBACK(int) pdmR3DrvHlp_ PDMLdrGetRCInterfaceSymbols(PPDMDRVINS pDrvIns, void *pvInterface, size_t cbInterface,1203 1204 { 1205 PDMDRV_ASSERT_DRVINS(pDrvIns); 1206 VM_ASSERT_EMT(pDrvIns->Internal.s.pVMR3); 1207 LogFlow(("pdmR3DrvHlp_ PDMLdrGetRCInterfaceSymbols: caller='%s'/%d: pvInterface=%p cbInterface=%zu pszSymPrefix=%p:{%s} pszSymList=%p:{%s}\n",1205 /** @interface_method_impl{PDMDRVHLP,pfnLdrGetRCInterfaceSymbols} */ 1206 static DECLCALLBACK(int) pdmR3DrvHlp_LdrGetRCInterfaceSymbols(PPDMDRVINS pDrvIns, void *pvInterface, size_t cbInterface, 1207 const char *pszSymPrefix, const char *pszSymList) 1208 { 1209 PDMDRV_ASSERT_DRVINS(pDrvIns); 1210 VM_ASSERT_EMT(pDrvIns->Internal.s.pVMR3); 1211 LogFlow(("pdmR3DrvHlp_LdrGetRCInterfaceSymbols: caller='%s'/%d: pvInterface=%p cbInterface=%zu pszSymPrefix=%p:{%s} pszSymList=%p:{%s}\n", 1208 1212 pDrvIns->pReg->szName, pDrvIns->iInstance, pvInterface, cbInterface, pszSymPrefix, pszSymPrefix, pszSymList, pszSymList)); 1209 1213 … … 1229 1233 } 1230 1234 1231 LogFlow(("pdmR3DrvHlp_ PDMLdrGetRCInterfaceSymbols: caller='%s'/%d: returns %Rrc\n", pDrvIns->pReg->szName,1235 LogFlow(("pdmR3DrvHlp_LdrGetRCInterfaceSymbols: caller='%s'/%d: returns %Rrc\n", pDrvIns->pReg->szName, 1232 1236 pDrvIns->iInstance, rc)); 1233 1237 return rc; … … 1235 1239 1236 1240 1237 /** @interface_method_impl{PDMDRVHLP,pfn PDMLdrGetR0InterfaceSymbols} */1238 static DECLCALLBACK(int) pdmR3DrvHlp_ PDMLdrGetR0InterfaceSymbols(PPDMDRVINS pDrvIns, void *pvInterface, size_t cbInterface,1239 1240 { 1241 PDMDRV_ASSERT_DRVINS(pDrvIns); 1242 VM_ASSERT_EMT(pDrvIns->Internal.s.pVMR3); 1243 LogFlow(("pdmR3DrvHlp_ PDMLdrGetR0InterfaceSymbols: caller='%s'/%d: pvInterface=%p cbInterface=%zu pszSymPrefix=%p:{%s} pszSymList=%p:{%s}\n",1241 /** @interface_method_impl{PDMDRVHLP,pfnLdrGetR0InterfaceSymbols} */ 1242 static DECLCALLBACK(int) pdmR3DrvHlp_LdrGetR0InterfaceSymbols(PPDMDRVINS pDrvIns, void *pvInterface, size_t cbInterface, 1243 const char *pszSymPrefix, const char *pszSymList) 1244 { 1245 PDMDRV_ASSERT_DRVINS(pDrvIns); 1246 VM_ASSERT_EMT(pDrvIns->Internal.s.pVMR3); 1247 LogFlow(("pdmR3DrvHlp_LdrGetR0InterfaceSymbols: caller='%s'/%d: pvInterface=%p cbInterface=%zu pszSymPrefix=%p:{%s} pszSymList=%p:{%s}\n", 1244 1248 pDrvIns->pReg->szName, pDrvIns->iInstance, pvInterface, cbInterface, pszSymPrefix, pszSymPrefix, pszSymList, pszSymList)); 1245 1249 … … 1265 1269 } 1266 1270 1267 LogFlow(("pdmR3DrvHlp_PDMLdrGetR0InterfaceSymbols: caller='%s'/%d: returns %Rrc\n", pDrvIns->pReg->szName, 1271 LogFlow(("pdmR3DrvHlp_LdrGetR0InterfaceSymbols: caller='%s'/%d: returns %Rrc\n", pDrvIns->pReg->szName, 1272 pDrvIns->iInstance, rc)); 1273 return rc; 1274 } 1275 1276 1277 /** @interface_method_impl{PDMDRVHLP,pfnCritSectInit} */ 1278 static DECLCALLBACK(int) pdmR3DrvHlp_CritSectInit(PPDMDRVINS pDrvIns, PPDMCRITSECT pCritSect, 1279 RT_SRC_POS_DECL, const char *pszName) 1280 { 1281 PDMDRV_ASSERT_DRVINS(pDrvIns); 1282 PVM pVM = pDrvIns->Internal.s.pVMR3; 1283 VM_ASSERT_EMT(pVM); 1284 LogFlow(("pdmR3DrvHlp_CritSectInit: caller='%s'/%d: pCritSect=%p pszName=%s\n", 1285 pDrvIns->pReg->szName, pDrvIns->iInstance, pCritSect, pszName)); 1286 1287 int rc = pdmR3CritSectInitDriver(pVM, pDrvIns, pCritSect, RT_SRC_POS_ARGS, "%s_%u", pszName, pDrvIns->iInstance); 1288 1289 LogFlow(("pdmR3DrvHlp_CritSectInit: caller='%s'/%d: returns %Rrc\n", pDrvIns->pReg->szName, 1268 1290 pDrvIns->iInstance, rc)); 1269 1291 return rc; … … 1289 1311 pdmR3DrvHlp_VMState, 1290 1312 pdmR3DrvHlp_VMTeleportedAndNotFullyResumedYet, 1291 pdmR3DrvHlp_ PDMQueueCreate,1313 pdmR3DrvHlp_QueueCreate, 1292 1314 pdmR3DrvHlp_TMGetVirtualFreq, 1293 1315 pdmR3DrvHlp_TMGetVirtualTime, … … 1303 1325 pdmR3DrvHlp_SetAsyncNotification, 1304 1326 pdmR3DrvHlp_AsyncNotificationCompleted, 1305 pdmR3DrvHlp_PDMThreadCreate, 1306 pdmR3DrvHlp_PDMAsyncCompletionTemplateCreate, 1307 pdmR3DrvHlp_PDMLdrGetRCInterfaceSymbols, 1308 pdmR3DrvHlp_PDMLdrGetR0InterfaceSymbols, 1327 pdmR3DrvHlp_ThreadCreate, 1328 pdmR3DrvHlp_AsyncCompletionTemplateCreate, 1329 pdmR3DrvHlp_LdrGetRCInterfaceSymbols, 1330 pdmR3DrvHlp_LdrGetR0InterfaceSymbols, 1331 pdmR3DrvHlp_CritSectInit, 1309 1332 PDM_DRVHLPR3_VERSION /* u32TheEnd */ 1310 1333 }; -
trunk/src/VBox/VMM/PDMInternal.h
r26175 r28258 940 940 /** List of registered drivers. (FIFO) */ 941 941 R3PTRTYPE(PPDMDRV) pDrvs; 942 /** List of initialized critical sections. (LIFO) */943 R3PTRTYPE(PPDMCRITSECTINT) pCritSects;944 942 /** PCI Buses. */ 945 943 PDMPCIBUS aPciBuses[PDM_PCI_BUSSES_MAX]; … … 965 963 RTRCPTR uPadding1; /**< Alignment padding. */ 966 964 965 /** @name Move to PDMUSERPERVM 966 * @{ 967 */ 967 968 /** Linked list of timer driven PDM queues. */ 968 969 R3PTRTYPE(struct PDMQUEUE *) pQueuesTimer; … … 983 984 /** Tail of the PDM Thread list. (singly linked) */ 984 985 R3PTRTYPE(PPDMTHREAD) pThreadsTail; 986 /** @} */ 985 987 986 988 /** @name PDM Async Completion 989 * @todo Move to PDMUSERPERVM 987 990 * @{ */ 988 991 /** Pointer to the array of supported endpoint classes. */ … … 1012 1015 * the PIC, APIC, IOAPIC and PCI devices pluss some PDM functions. */ 1013 1016 PDMCRITSECT CritSect; 1014 /** The PDM miscellancous lock.1015 * This is used to protect things like critsect init/delete that formerly was1016 * serialized by there only being one EMT.1017 */1018 RTCRITSECT MiscCritSect;1019 1017 1020 1018 /** Number of times a critical section leave requesed needed to be queued for ring-3 execution. */ … … 1033 1031 typedef struct PDMUSERPERVM 1034 1032 { 1033 /** @todo move more stuff over here. */ 1034 1035 /** Lock protecting the lists below it. */ 1036 RTCRITSECT ListCritSect; 1035 1037 /** Pointer to list of loaded modules. */ 1036 1038 PPDMMOD pModules; 1037 /** @todo move more stuff over here. */ 1039 /** List of initialized critical sections. (LIFO) */ 1040 R3PTRTYPE(PPDMCRITSECTINT) pCritSects; 1041 1038 1042 } PDMUSERPERVM; 1039 1043 /** Pointer to the PDM data kept in the UVM. */ … … 1095 1099 *******************************************************************************/ 1096 1100 #ifdef IN_RING3 1097 int pdmR3CritSectInit(PVM pVM); 1098 int pdmR3CritSectTerm(PVM pVM); 1101 int pdmR3CritSectInitStats(PVM pVM); 1099 1102 void pdmR3CritSectRelocate(PVM pVM); 1100 1103 int pdmR3CritSectInitDevice(PVM pVM, PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect, RT_SRC_POS_DECL, const char *pszNameFmt, va_list va); 1101 1104 int pdmR3CritSectDeleteDevice(PVM pVM, PPDMDEVINS pDevIns); 1105 int pdmR3CritSectInitDriver(PVM pVM, PPDMDRVINS pDrvIns, PPDMCRITSECT pCritSect, RT_SRC_POS_DECL, const char *pszNameFmt, ...); 1106 int pdmR3CritSectDeleteDriver(PVM pVM, PPDMDRVINS pDrvIns); 1102 1107 1103 1108 int pdmR3DevInit(PVM pVM); -
trunk/src/VBox/VMM/VM.cpp
r27789 r28258 707 707 AssertRC(rc2); 708 708 } 709 710 /* 711 * Do automatic cleanups while the VM structure is still alive and all 712 * references to it are still working. 713 */ 714 PDMR3CritSectTerm(pVM); 709 715 710 716 /* -
trunk/src/VBox/VMM/testcase/tstVMStructRC.cpp
r26172 r28258 274 274 GEN_CHECK_OFF(PDM, pUsbInstances); 275 275 GEN_CHECK_OFF(PDM, pDrvs); 276 GEN_CHECK_OFF(PDM, pCritSects);277 276 GEN_CHECK_OFF(PDM, aPciBuses); 278 277 GEN_CHECK_OFF(PDM, aPciBuses[0].iBus);
Note:
See TracChangeset
for help on using the changeset viewer.