Changeset 25891 in vbox for trunk/src/VBox/VMM/PDMDriver.cpp
- Timestamp:
- Jan 18, 2010 1:07:21 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 56701
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/PDMDriver.cpp
r25528 r25891 76 76 AssertPtr(pDrvIns); \ 77 77 Assert(pDrvIns->u32Version == PDM_DRVINS_VERSION); \ 78 Assert(pDrvIns->pvInstanceData == (void *)&pDrvIns->achInstanceData[0]); \78 Assert(pDrvIns->pvInstanceDataR3 == (void *)&pDrvIns->achInstanceData[0]); \ 79 79 } while (0) 80 80 #else … … 346 346 347 347 /** 348 * Instantiate a driver. 349 * 350 * @returns VBox status code, including informational statuses. 351 * 352 * @param pVM The VM handle. 353 * @param pNode The CFGM node for the driver. 354 * @param pBaseInterface The base interface. 355 * @param pDrvAbove The driver above it. NULL if it's the top-most 356 * driver. 357 * @param pLun The LUN the driver is being attached to. NULL 358 * if we're instantiating a driver chain before 359 * attaching it - untested. 360 * @param ppBaseInterface Where to return the pointer to the base 361 * interface of the newly created driver. 362 * 363 * @remarks Recursive calls to this function is normal as the drivers will 364 * attach to anything below them during the pfnContruct call. 365 */ 366 int pdmR3DrvInstantiate(PVM pVM, PCFGMNODE pNode, PPDMIBASE pBaseInterface, PPDMDRVINS pDrvAbove, 367 PPDMLUN pLun, PPDMIBASE *ppBaseInterface) 368 { 369 Assert(!pDrvAbove || !pDrvAbove->Internal.s.pDown); 370 Assert(!pDrvAbove || !pDrvAbove->pDownBase); 371 372 /* 373 * Find the driver. 374 */ 375 char *pszName; 376 int rc = CFGMR3QueryStringAlloc(pNode, "Driver", &pszName); 377 if (RT_SUCCESS(rc)) 378 { 379 PPDMDRV pDrv = pdmR3DrvLookup(pVM, pszName); 380 MMR3HeapFree(pszName); 381 if ( pDrv 382 && pDrv->cInstances < pDrv->pDrvReg->cMaxInstances) 383 { 384 /* config node */ 385 PCFGMNODE pConfigNode = CFGMR3GetChild(pNode, "Config"); 386 if (!pConfigNode) 387 rc = CFGMR3InsertNode(pNode, "Config", &pConfigNode); 388 if (RT_SUCCESS(rc)) 389 { 390 CFGMR3SetRestrictedRoot(pConfigNode); 391 392 /* 393 * Allocate the driver instance. 394 */ 395 size_t cb = RT_OFFSETOF(PDMDRVINS, achInstanceData[pDrv->pDrvReg->cbInstance]); 396 cb = RT_ALIGN_Z(cb, 16); 397 bool const fHyperHeap = !!(pDrv->pDrvReg->fFlags & (PDM_DRVREG_FLAGS_R0 | PDM_DRVREG_FLAGS_RC)); 398 PPDMDRVINS pNew; 399 if (fHyperHeap) 400 rc = MMHyperAlloc(pVM, cb, 64, MM_TAG_PDM_DRIVER, (void **)&pNew); 401 else 402 rc = MMR3HeapAllocZEx(pVM, MM_TAG_PDM_DRIVER, cb, (void **)&pNew); 403 if (pNew) 404 { 405 /* 406 * Initialize the instance structure (declaration order). 407 */ 408 pNew->u32Version = PDM_DRVINS_VERSION; 409 pNew->Internal.s.pUp = pDrvAbove ? pDrvAbove : NULL; 410 //pNew->Internal.s.pDown = NULL; 411 pNew->Internal.s.pLun = pLun; 412 pNew->Internal.s.pDrv = pDrv; 413 pNew->Internal.s.pVMR3 = pVM; 414 pNew->Internal.s.pVMR0 = pDrv->pDrvReg->fFlags & PDM_DRVREG_FLAGS_R0 ? pVM->pVMR0 : NIL_RTR0PTR; 415 pNew->Internal.s.pVMRC = pDrv->pDrvReg->fFlags & PDM_DRVREG_FLAGS_RC ? pVM->pVMRC : NIL_RTRCPTR; 416 //pNew->Internal.s.fDetaching = false; 417 pNew->Internal.s.fVMSuspended = true; 418 //pNew->Internal.s.fVMReset = false; 419 pNew->Internal.s.fHyperHeap = fHyperHeap; 420 //pNew->Internal.s.pfnAsyncNotify = NULL; 421 pNew->Internal.s.pCfgHandle = pNode; 422 pNew->pDrvReg = pDrv->pDrvReg; 423 pNew->pCfgHandle = pConfigNode; 424 pNew->iInstance = pDrv->iNextInstance; 425 pNew->pUpBase = pBaseInterface; 426 Assert(!pDrvAbove || pBaseInterface == &pDrvAbove->IBase); 427 //pNew->pDownBase = NULL; 428 //pNew->IBase.pfnQueryInterface = NULL; 429 pNew->pDrvHlpR3 = &g_pdmR3DrvHlp; 430 pNew->pvInstanceDataR3 = &pNew->achInstanceData[0]; 431 if (pDrv->pDrvReg->fFlags & PDM_DRVREG_FLAGS_R0) 432 { 433 pNew->pvInstanceDataR0 = MMHyperR3ToR0(pVM, &pNew->achInstanceData[0]); 434 rc = PDMR3LdrGetSymbolR0(pVM, NULL, "g_pdmR0DrvHlp", &pNew->pDrvHlpR0); 435 AssertReleaseRCReturn(rc, rc); 436 437 } 438 if (pDrv->pDrvReg->fFlags & PDM_DRVREG_FLAGS_RC) 439 { 440 pNew->pvInstanceDataR0 = MMHyperR3ToRC(pVM, &pNew->achInstanceData[0]); 441 rc = PDMR3LdrGetSymbolRC(pVM, NULL, "g_pdmRCDrvHlp", &pNew->pDrvHlpRC); 442 AssertReleaseRCReturn(rc, rc); 443 } 444 445 pDrv->iNextInstance++; 446 pDrv->cInstances++; 447 448 /* 449 * Link with it with the driver above / LUN. 450 */ 451 if (pDrvAbove) 452 { 453 pDrvAbove->pDownBase = &pNew->IBase; 454 pDrvAbove->Internal.s.pDown = pNew; 455 } 456 else if (pLun) 457 pLun->pTop = pNew; 458 if (pLun) 459 pLun->pBottom = pNew; 460 461 /* 462 * Invoke the constructor. 463 */ 464 rc = pDrv->pDrvReg->pfnConstruct(pNew, pNew->pCfgHandle, 0 /*fFlags*/); 465 if (RT_SUCCESS(rc)) 466 { 467 AssertPtr(pNew->IBase.pfnQueryInterface); 468 469 /* Success! */ 470 *ppBaseInterface = &pNew->IBase; 471 if (pLun) 472 Log(("PDM: Attached driver %p:'%s'/%d to LUN#%d on device '%s'/%d, pDrvAbove=%p:'%s'/%d\n", 473 pNew, pDrv->pDrvReg->szDriverName, pNew->iInstance, 474 pLun->iLun, pLun->pDevIns->pDevReg->szDeviceName, pLun->pDevIns->iInstance, 475 pDrvAbove, pDrvAbove ? pDrvAbove->pDrvReg->szDriverName : "", pDrvAbove ? pDrvAbove->iInstance : -1)); 476 else 477 Log(("PDM: Attached driver %p:'%s'/%d, pDrvAbove=%p:'%s'/%d\n", 478 pNew, pDrv->pDrvReg->szDriverName, pNew->iInstance, 479 pDrvAbove, pDrvAbove ? pDrvAbove->pDrvReg->szDriverName : "", pDrvAbove ? pDrvAbove->iInstance : -1)); 480 } 481 else 482 pdmR3DrvDestroyChain(pNew, PDM_TACH_FLAGS_NO_CALLBACKS); 483 } 484 else 485 { 486 AssertMsgFailed(("Failed to allocate %d bytes for instantiating driver '%s'\n", cb, pszName)); 487 rc = VERR_NO_MEMORY; 488 } 489 } 490 else 491 AssertMsgFailed(("Failed to create Config node! rc=%Rrc\n", rc)); 492 } 493 else if (pDrv) 494 { 495 AssertMsgFailed(("Too many instances of driver '%s', max is %u\n", pszName, pDrv->pDrvReg->cMaxInstances)); 496 rc = VERR_PDM_TOO_MANY_DRIVER_INSTANCES; 497 } 498 else 499 { 500 AssertMsgFailed(("Driver '%s' wasn't found!\n", pszName)); 501 rc = VERR_PDM_DRIVER_NOT_FOUND; 502 } 503 } 504 else 505 { 506 AssertMsgFailed(("Query for string value of \"Driver\" -> %Rrc\n", rc)); 507 if (rc == VERR_CFGM_VALUE_NOT_FOUND) 508 rc = VERR_PDM_CFG_MISSING_DRIVER_NAME; 509 } 510 return rc; 511 } 512 513 514 /** 348 515 * Detaches a driver from whatever it's attached to. 349 516 * This will of course lead to the destruction of the driver and all drivers below it in the chain. … … 357 524 PDMDRV_ASSERT_DRVINS(pDrvIns); 358 525 LogFlow(("pdmR3DrvDetach: pDrvIns=%p '%s'/%d\n", pDrvIns, pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance)); 359 VM_ASSERT_EMT(pDrvIns->Internal.s.pVM );526 VM_ASSERT_EMT(pDrvIns->Internal.s.pVMR3); 360 527 361 528 /* … … 365 532 { 366 533 AssertMsgFailed(("Recursive detach! '%s'/%d\n", pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance)); 367 return VINF_SUCCESS; 368 } 534 return VINF_SUCCESS; } 369 535 370 536 /* … … 394 560 * 395 561 * @param pDrvIns Pointer to the driver instance to start with. 396 * @param fFlags PDM_TACH_FLAGS_NOT_HOT_PLUG or 0. 562 * @param fFlags PDM_TACH_FLAGS_NOT_HOT_PLUG, PDM_TACH_FLAGS_NO_CALLBACKS 563 * or 0. 397 564 */ 398 565 void pdmR3DrvDestroyChain(PPDMDRVINS pDrvIns, uint32_t fFlags) 399 566 { 400 VM_ASSERT_EMT(pDrvIns->Internal.s.pVM); 567 PVM pVM = pDrvIns->Internal.s.pVMR3; 568 VM_ASSERT_EMT(pVM); 401 569 402 570 /* … … 411 579 while (pCur->Internal.s.pDown) 412 580 pCur = pCur->Internal.s.pDown; 413 LogFlow(("pdmR3DrvDe tach: pCur=%p '%s'/%d\n", pCur, pCur->pDrvReg->szDriverName, pCur->iInstance));581 LogFlow(("pdmR3DrvDestroyChain: pCur=%p '%s'/%d\n", pCur, pCur->pDrvReg->szDriverName, pCur->iInstance)); 414 582 415 583 /* … … 429 597 pParent->Internal.s.pDown = NULL; 430 598 431 if ( pParent->pDrvReg->pfnDetach)599 if (!(fFlags & PDM_TACH_FLAGS_NO_CALLBACKS) && pParent->pDrvReg->pfnDetach) 432 600 pParent->pDrvReg->pfnDetach(pParent, fFlags); 433 601 … … 439 607 Assert(pLun->pTop == pCur); 440 608 pLun->pTop = NULL; 441 if ( pLun->pDevIns->pDevReg->pfnDetach)609 if (!(fFlags & PDM_TACH_FLAGS_NO_CALLBACKS) && pLun->pDevIns->pDevReg->pfnDetach) 442 610 pLun->pDevIns->pDevReg->pfnDetach(pLun->pDevIns, pLun->iLun, fFlags); 443 611 } … … 455 623 */ 456 624 /* Queues. */ 457 int rc = PDMR3QueueDestroyDriver(p Cur->Internal.s.pVM, pCur);625 int rc = PDMR3QueueDestroyDriver(pVM, pCur); 458 626 AssertRC(rc); 627 459 628 /* Timers. */ 460 rc = TMR3TimerDestroyDriver(p Cur->Internal.s.pVM, pCur);629 rc = TMR3TimerDestroyDriver(pVM, pCur); 461 630 AssertRC(rc); 631 462 632 /* SSM data units. */ 463 rc = SSMR3DeregisterDriver(p Cur->Internal.s.pVM, pCur, NULL, 0);633 rc = SSMR3DeregisterDriver(pVM, pCur, NULL, 0); 464 634 AssertRC(rc); 635 465 636 /* PDM threads. */ 466 rc = pdmR3ThreadDestroyDriver(p Cur->Internal.s.pVM, pCur);637 rc = pdmR3ThreadDestroyDriver(pVM, pCur); 467 638 AssertRC(rc); 639 468 640 /* Finally, the driver it self. */ 641 bool fHyperHeap = pCur->Internal.s.fHyperHeap; 469 642 ASMMemFill32(pCur, RT_OFFSETOF(PDMDRVINS, achInstanceData[pCur->pDrvReg->cbInstance]), 0xdeadd0d0); 470 MMR3HeapFree(pCur); 643 if (fHyperHeap) 644 MMHyperFree(pVM, pCur); 645 else 646 MMR3HeapFree(pCur); 471 647 472 648 } while (pCur != pDrvIns); … … 484 660 { 485 661 PDMDRV_ASSERT_DRVINS(pDrvIns); 486 VM_ASSERT_EMT(pDrvIns->Internal.s.pVM);487 LogFlow(("pdmR3DrvHlp_Attach: caller='%s'/%d:\n",488 pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance));662 PVM pVM = pDrvIns->Internal.s.pVMR3; 663 VM_ASSERT_EMT(pVM); 664 LogFlow(("pdmR3DrvHlp_Attach: caller='%s'/%d: fFlags=%#x\n", pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance, fFlags)); 489 665 Assert(!(fFlags & ~(PDM_TACH_FLAGS_NOT_HOT_PLUG))); 490 666 … … 502 678 PCFGMNODE pNode = CFGMR3GetChild(pDrvIns->Internal.s.pCfgHandle, "AttachedDriver"); 503 679 if (pNode) 504 { 505 char *pszName; 506 rc = CFGMR3QueryStringAlloc(pNode, "Driver", &pszName); 507 if (RT_SUCCESS(rc)) 508 { 509 /* 510 * Find the driver and allocate instance data. 511 */ 512 PVM pVM = pDrvIns->Internal.s.pVM; 513 PPDMDRV pDrv = pdmR3DrvLookup(pVM, pszName); 514 if ( pDrv 515 && pDrv->cInstances < pDrv->pDrvReg->cMaxInstances) 516 { 517 /* config node */ 518 PCFGMNODE pConfigNode = CFGMR3GetChild(pNode, "Config"); 519 if (!pConfigNode) 520 rc = CFGMR3InsertNode(pNode, "Config", &pConfigNode); 521 if (RT_SUCCESS(rc)) 522 { 523 CFGMR3SetRestrictedRoot(pConfigNode); 524 525 size_t cb = RT_OFFSETOF(PDMDRVINS, achInstanceData[pDrv->pDrvReg->cbInstance]); 526 cb = RT_ALIGN_Z(cb, 16); 527 PPDMDRVINS pNew = (PPDMDRVINS)MMR3HeapAllocZ(pVM, MM_TAG_PDM_DRIVER, cb); 528 if (pNew) 529 { 530 /* 531 * Initialize the instance structure (declaration order). 532 */ 533 pNew->u32Version = PDM_DRVINS_VERSION; 534 pNew->Internal.s.pUp = pDrvIns; 535 pNew->Internal.s.pDown = NULL; 536 pNew->Internal.s.pLun = pDrvIns->Internal.s.pLun; 537 pNew->Internal.s.pDrv = pDrv; 538 pNew->Internal.s.pVM = pVM; 539 pNew->Internal.s.fDetaching = false; 540 pNew->Internal.s.fVMSuspended = true; 541 pNew->Internal.s.pfnAsyncNotify = NULL; 542 pNew->Internal.s.pCfgHandle = pNode; 543 pNew->pDrvHlp = &g_pdmR3DrvHlp; 544 pNew->pDrvReg = pDrv->pDrvReg; 545 pNew->pCfgHandle = pConfigNode; 546 pNew->iInstance = pDrv->iNextInstance; 547 pNew->pUpBase = &pDrvIns->IBase; /* This ain't safe, you can calc the pDrvIns of the up/down driver! */ 548 pNew->pDownBase = NULL; 549 pNew->IBase.pfnQueryInterface = NULL; 550 pNew->pvInstanceData = &pNew->achInstanceData[0]; 551 552 pDrv->iNextInstance++; 553 pDrv->cInstances++; 554 555 /* 556 * Hook it onto the chain and call the constructor. 557 */ 558 pDrvIns->Internal.s.pDown = pNew; 559 pDrvIns->Internal.s.pLun->pBottom = pNew; 560 561 Log(("PDM: Constructing driver '%s' instance %d...\n", pNew->pDrvReg->szDriverName, pNew->iInstance)); 562 rc = pDrv->pDrvReg->pfnConstruct(pNew, pNew->pCfgHandle, 0 /*fFlags*/); 563 if (RT_SUCCESS(rc)) 564 { 565 *ppBaseInterface = &pNew->IBase; 566 rc = VINF_SUCCESS; 567 } 568 else 569 { 570 /* 571 * Unlink and free the data. 572 */ 573 Assert(pDrvIns->Internal.s.pLun->pBottom == pNew); 574 pDrvIns->Internal.s.pLun->pBottom = pDrvIns; 575 pDrvIns->Internal.s.pDown = NULL; 576 ASMMemFill32(pNew, cb, 0xdeadd0d0); 577 MMR3HeapFree(pNew); 578 pDrv->cInstances--; 579 } 580 } 581 else 582 { 583 AssertMsgFailed(("Failed to allocate %d bytes for instantiating driver '%s'\n", cb, pszName)); 584 rc = VERR_NO_MEMORY; 585 } 586 } 587 else 588 AssertMsgFailed(("Failed to create Config node! rc=%Rrc\n", rc)); 589 } 590 else if (pDrv) 591 { 592 AssertMsgFailed(("Too many instances of driver '%s', max is %u\n", pszName, pDrv->pDrvReg->cMaxInstances)); 593 rc = VERR_PDM_TOO_MANY_DRIVER_INSTANCES; 594 } 595 else 596 { 597 AssertMsgFailed(("Driver '%s' wasn't found!\n", pszName)); 598 rc = VERR_PDM_DRIVER_NOT_FOUND; 599 } 600 MMR3HeapFree(pszName); 601 } 602 else 603 { 604 AssertMsgFailed(("Query for string value of \"Driver\" -> %Rrc\n", rc)); 605 if (rc == VERR_CFGM_VALUE_NOT_FOUND) 606 rc = VERR_PDM_CFG_MISSING_DRIVER_NAME; 607 } 608 } 680 rc = pdmR3DrvInstantiate(pVM, pNode, &pDrvIns->IBase, pDrvIns, pDrvIns->Internal.s.pLun, ppBaseInterface); 609 681 else 610 682 rc = VERR_PDM_NO_ATTACHED_DRIVER; … … 628 700 LogFlow(("pdmR3DrvHlp_Detach: caller='%s'/%d: fFlags=%#x\n", 629 701 pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance, fFlags)); 630 VM_ASSERT_EMT(pDrvIns->Internal.s.pVM );702 VM_ASSERT_EMT(pDrvIns->Internal.s.pVMR3); 631 703 632 704 /* … … 654 726 LogFlow(("pdmR3DrvHlp_DetachSelf: caller='%s'/%d: fFlags=%#x\n", 655 727 pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance, fFlags)); 656 VM_ASSERT_EMT(pDrvIns->Internal.s.pVM );728 VM_ASSERT_EMT(pDrvIns->Internal.s.pVMR3); 657 729 658 730 int rc = pdmR3DrvDetach(pDrvIns, fFlags); … … 669 741 LogFlow(("pdmR3DrvHlp_MountPrepare: caller='%s'/%d: pszFilename=%p:{%s} pszCoreDriver=%p:{%s}\n", 670 742 pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance, pszFilename, pszFilename, pszCoreDriver, pszCoreDriver)); 671 VM_ASSERT_EMT(pDrvIns->Internal.s.pVM );743 VM_ASSERT_EMT(pDrvIns->Internal.s.pVMR3); 672 744 673 745 /* … … 741 813 { 742 814 PDMDRV_ASSERT_DRVINS(pDrvIns); 743 if (VM_IS_EMT(pDrvIns->Internal.s.pVM ))815 if (VM_IS_EMT(pDrvIns->Internal.s.pVMR3)) 744 816 return true; 745 817 … … 748 820 RTAssertMsg1Weak(szMsg, iLine, pszFile, pszFunction); 749 821 AssertBreakpoint(); 750 VM_ASSERT_EMT(pDrvIns->Internal.s.pVM );822 VM_ASSERT_EMT(pDrvIns->Internal.s.pVMR3); 751 823 return false; 752 824 } … … 757 829 { 758 830 PDMDRV_ASSERT_DRVINS(pDrvIns); 759 if (!VM_IS_EMT(pDrvIns->Internal.s.pVM ))831 if (!VM_IS_EMT(pDrvIns->Internal.s.pVMR3)) 760 832 return true; 761 833 … … 764 836 RTAssertMsg1Weak(szMsg, iLine, pszFile, pszFunction); 765 837 AssertBreakpoint(); 766 VM_ASSERT_EMT(pDrvIns->Internal.s.pVM );838 VM_ASSERT_EMT(pDrvIns->Internal.s.pVMR3); 767 839 return false; 768 840 } … … 775 847 va_list args; 776 848 va_start(args, pszFormat); 777 int rc2 = VMSetErrorV(pDrvIns->Internal.s.pVM , rc, RT_SRC_POS_ARGS, pszFormat, args); Assert(rc2 == rc); NOREF(rc2);849 int rc2 = VMSetErrorV(pDrvIns->Internal.s.pVMR3, rc, RT_SRC_POS_ARGS, pszFormat, args); Assert(rc2 == rc); NOREF(rc2); 778 850 va_end(args); 779 851 return rc; … … 785 857 { 786 858 PDMDRV_ASSERT_DRVINS(pDrvIns); 787 int rc2 = VMSetErrorV(pDrvIns->Internal.s.pVM , rc, RT_SRC_POS_ARGS, pszFormat, va); Assert(rc2 == rc); NOREF(rc2);859 int rc2 = VMSetErrorV(pDrvIns->Internal.s.pVMR3, rc, RT_SRC_POS_ARGS, pszFormat, va); Assert(rc2 == rc); NOREF(rc2); 788 860 return rc; 789 861 } … … 796 868 va_list args; 797 869 va_start(args, pszFormat); 798 int rc = VMSetRuntimeErrorV(pDrvIns->Internal.s.pVM , fFlags, pszErrorId, pszFormat, args);870 int rc = VMSetRuntimeErrorV(pDrvIns->Internal.s.pVMR3, fFlags, pszErrorId, pszFormat, args); 799 871 va_end(args); 800 872 return rc; … … 806 878 { 807 879 PDMDRV_ASSERT_DRVINS(pDrvIns); 808 int rc = VMSetRuntimeErrorV(pDrvIns->Internal.s.pVM , fFlags, pszErrorId, pszFormat, va);880 int rc = VMSetRuntimeErrorV(pDrvIns->Internal.s.pVMR3, fFlags, pszErrorId, pszFormat, va); 809 881 return rc; 810 882 } … … 816 888 PDMDRV_ASSERT_DRVINS(pDrvIns); 817 889 818 VMSTATE enmVMState = VMR3GetState(pDrvIns->Internal.s.pVM );890 VMSTATE enmVMState = VMR3GetState(pDrvIns->Internal.s.pVMR3); 819 891 820 892 LogFlow(("pdmR3DrvHlp_VMState: caller='%s'/%d: returns %d (%s)\n", pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance, … … 829 901 PDMDRV_ASSERT_DRVINS(pDrvIns); 830 902 831 bool fRc = VMR3TeleportedAndNotFullyResumedYet(pDrvIns->Internal.s.pVM );903 bool fRc = VMR3TeleportedAndNotFullyResumedYet(pDrvIns->Internal.s.pVMR3); 832 904 833 905 LogFlow(("pdmR3DrvHlp_VMState: caller='%s'/%d: returns %RTbool)\n", pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance, … … 844 916 LogFlow(("pdmR3DrvHlp_PDMQueueCreate: caller='%s'/%d: cbItem=%d cItems=%d cMilliesInterval=%d pfnCallback=%p pszName=%p:{%s} ppQueue=%p\n", 845 917 pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance, cbItem, cItems, cMilliesInterval, pfnCallback, pszName, pszName, ppQueue, ppQueue)); 846 PVM pVM = pDrvIns->Internal.s.pVM ;918 PVM pVM = pDrvIns->Internal.s.pVMR3; 847 919 VM_ASSERT_EMT(pVM); 848 920 … … 865 937 PDMDRV_ASSERT_DRVINS(pDrvIns); 866 938 867 return TMVirtualGetFreq(pDrvIns->Internal.s.pVM );939 return TMVirtualGetFreq(pDrvIns->Internal.s.pVMR3); 868 940 } 869 941 … … 874 946 PDMDRV_ASSERT_DRVINS(pDrvIns); 875 947 876 return TMVirtualGet(pDrvIns->Internal.s.pVM );948 return TMVirtualGet(pDrvIns->Internal.s.pVMR3); 877 949 } 878 950 … … 885 957 pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance, enmClock, pfnCallback, pvUser, fFlags, pszDesc, pszDesc, ppTimer)); 886 958 887 int rc = TMR3TimerCreateDriver(pDrvIns->Internal.s.pVM , pDrvIns, enmClock, pfnCallback, pvUser, fFlags, pszDesc, ppTimer);959 int rc = TMR3TimerCreateDriver(pDrvIns->Internal.s.pVMR3, pDrvIns, enmClock, pfnCallback, pvUser, fFlags, pszDesc, ppTimer); 888 960 889 961 LogFlow(("pdmR3DrvHlp_TMTimerCreate: caller='%s'/%d: returns %Rrc *ppTimer=%p\n", pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance, rc, *ppTimer)); … … 900 972 { 901 973 PDMDRV_ASSERT_DRVINS(pDrvIns); 902 VM_ASSERT_EMT(pDrvIns->Internal.s.pVM );974 VM_ASSERT_EMT(pDrvIns->Internal.s.pVMR3); 903 975 LogFlow(("pdmR3DrvHlp_SSMRegister: caller='%s'/%d: uVersion=#x cbGuess=%#x \n" 904 976 " pfnLivePrep=%p pfnLiveExec=%p pfnLiveVote=%p pfnSavePrep=%p pfnSaveExec=%p pfnSaveDone=%p pszLoadPrep=%p pfnLoadExec=%p pfnLoaddone=%p\n", … … 907 979 pfnSavePrep, pfnSaveExec, pfnSaveDone, pfnLoadPrep, pfnLoadExec, pfnLoadDone)); 908 980 909 int rc = SSMR3RegisterDriver(pDrvIns->Internal.s.pVM , pDrvIns, pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance,981 int rc = SSMR3RegisterDriver(pDrvIns->Internal.s.pVMR3, pDrvIns, pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance, 910 982 uVersion, cbGuess, 911 983 pfnLivePrep, pfnLiveExec, pfnLiveVote, … … 922 994 { 923 995 PDMDRV_ASSERT_DRVINS(pDrvIns); 924 VM_ASSERT_EMT(pDrvIns->Internal.s.pVM );996 VM_ASSERT_EMT(pDrvIns->Internal.s.pVMR3); 925 997 LogFlow(("pdmR3DrvHlp_SSMDeregister: caller='%s'/%d: pszName=%p:{%s} u32Instance=%#x\n", 926 998 pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance, pszName, pszName, u32Instance)); 927 999 928 int rc = SSMR3DeregisterDriver(pDrvIns->Internal.s.pVM , pDrvIns, pszName, u32Instance);1000 int rc = SSMR3DeregisterDriver(pDrvIns->Internal.s.pVMR3, pDrvIns, pszName, u32Instance); 929 1001 930 1002 LogFlow(("pdmR3DrvHlp_SSMDeregister: caller='%s'/%d: returns %Rrc\n", pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance, rc)); … … 937 1009 { 938 1010 PDMDRV_ASSERT_DRVINS(pDrvIns); 939 VM_ASSERT_EMT(pDrvIns->Internal.s.pVM );940 941 STAM_REG(pDrvIns->Internal.s.pVM , pvSample, enmType, pszName, enmUnit, pszDesc);1011 VM_ASSERT_EMT(pDrvIns->Internal.s.pVMR3); 1012 1013 STAM_REG(pDrvIns->Internal.s.pVMR3, pvSample, enmType, pszName, enmUnit, pszDesc); 942 1014 /** @todo track the samples so they can be dumped & deregistered when the driver instance is destroyed. 943 1015 * For now we just have to be careful not to use this call for drivers which can be unloaded. */ … … 950 1022 { 951 1023 PDMDRV_ASSERT_DRVINS(pDrvIns); 952 VM_ASSERT_EMT(pDrvIns->Internal.s.pVM );1024 VM_ASSERT_EMT(pDrvIns->Internal.s.pVMR3); 953 1025 954 1026 va_list args; 955 1027 va_start(args, pszName); 956 int rc = STAMR3RegisterV(pDrvIns->Internal.s.pVM , pvSample, enmType, enmVisibility, enmUnit, pszDesc, pszName, args);1028 int rc = STAMR3RegisterV(pDrvIns->Internal.s.pVMR3, pvSample, enmType, enmVisibility, enmUnit, pszDesc, pszName, args); 957 1029 va_end(args); 958 1030 AssertRC(rc); … … 965 1037 { 966 1038 PDMDRV_ASSERT_DRVINS(pDrvIns); 967 VM_ASSERT_EMT(pDrvIns->Internal.s.pVM );968 969 int rc = STAMR3RegisterV(pDrvIns->Internal.s.pVM , pvSample, enmType, enmVisibility, enmUnit, pszDesc, pszName, args);1039 VM_ASSERT_EMT(pDrvIns->Internal.s.pVMR3); 1040 1041 int rc = STAMR3RegisterV(pDrvIns->Internal.s.pVMR3, pvSample, enmType, enmVisibility, enmUnit, pszDesc, pszName, args); 970 1042 AssertRC(rc); 971 1043 } … … 976 1048 { 977 1049 PDMDRV_ASSERT_DRVINS(pDrvIns); 978 VM_ASSERT_EMT(pDrvIns->Internal.s.pVM );979 980 int rc = STAMR3DeregisterU(pDrvIns->Internal.s.pVM ->pUVM, pvSample);1050 VM_ASSERT_EMT(pDrvIns->Internal.s.pVMR3); 1051 1052 int rc = STAMR3DeregisterU(pDrvIns->Internal.s.pVMR3->pUVM, pvSample); 981 1053 AssertRC(rc); 982 1054 return rc; … … 993 1065 if ( uOperation >= VMMR0_DO_SRV_START 994 1066 && uOperation < VMMR0_DO_SRV_END) 995 rc = SUPR3CallVMMR0Ex(pDrvIns->Internal.s.pVM ->pVMR0, NIL_VMCPUID, uOperation, 0, (PSUPVMMR0REQHDR)pvArg);1067 rc = SUPR3CallVMMR0Ex(pDrvIns->Internal.s.pVMR3->pVMR0, NIL_VMCPUID, uOperation, 0, (PSUPVMMR0REQHDR)pvArg); 996 1068 else 997 1069 { … … 1009 1081 { 1010 1082 PDMDRV_ASSERT_DRVINS(pDrvIns); 1011 VM_ASSERT_EMT(pDrvIns->Internal.s.pVM );1083 VM_ASSERT_EMT(pDrvIns->Internal.s.pVMR3); 1012 1084 LogFlow(("pdmR3DrvHlp_USBRegisterHub: caller='%s'/%d: fVersions=%#x cPorts=%#x pUsbHubReg=%p ppUsbHubHlp=%p\n", 1013 1085 pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance, fVersions, cPorts, pUsbHubReg, ppUsbHubHlp)); 1014 1086 1015 1087 #ifdef VBOX_WITH_USB 1016 int rc = pdmR3UsbRegisterHub(pDrvIns->Internal.s.pVM , pDrvIns, fVersions, cPorts, pUsbHubReg, ppUsbHubHlp);1088 int rc = pdmR3UsbRegisterHub(pDrvIns->Internal.s.pVMR3, pDrvIns, fVersions, cPorts, pUsbHubReg, ppUsbHubHlp); 1017 1089 #else 1018 1090 int rc = VERR_NOT_SUPPORTED; … … 1028 1100 { 1029 1101 PDMDRV_ASSERT_DRVINS(pDrvIns); 1030 VM_ASSERT_EMT0(pDrvIns->Internal.s.pVM );1102 VM_ASSERT_EMT0(pDrvIns->Internal.s.pVMR3); 1031 1103 LogFlow(("pdmR3DrvHlp_SetAsyncNotification: caller='%s'/%d: pfnAsyncNotify=%p\n", pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance, pfnAsyncNotify)); 1032 1104 … … 1035 1107 AssertStmt(!pDrvIns->Internal.s.pfnAsyncNotify, rc = VERR_WRONG_ORDER); 1036 1108 AssertStmt(pDrvIns->Internal.s.fVMSuspended || pDrvIns->Internal.s.fVMReset, rc = VERR_WRONG_ORDER); 1037 VMSTATE enmVMState = VMR3GetState(pDrvIns->Internal.s.pVM );1109 VMSTATE enmVMState = VMR3GetState(pDrvIns->Internal.s.pVMR3); 1038 1110 AssertStmt( enmVMState == VMSTATE_SUSPENDING 1039 1111 || enmVMState == VMSTATE_SUSPENDING_EXT_LS … … 1057 1129 { 1058 1130 PDMDRV_ASSERT_DRVINS(pDrvIns); 1059 PVM pVM = pDrvIns->Internal.s.pVM ;1131 PVM pVM = pDrvIns->Internal.s.pVMR3; 1060 1132 1061 1133 VMSTATE enmVMState = VMR3GetState(pVM); … … 1081 1153 { 1082 1154 PDMDRV_ASSERT_DRVINS(pDrvIns); 1083 VM_ASSERT_EMT(pDrvIns->Internal.s.pVM );1155 VM_ASSERT_EMT(pDrvIns->Internal.s.pVMR3); 1084 1156 LogFlow(("pdmR3DrvHlp_PDMThreadCreate: caller='%s'/%d: ppThread=%p pvUser=%p pfnThread=%p pfnWakeup=%p cbStack=%#zx enmType=%d pszName=%p:{%s}\n", 1085 1157 pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance, ppThread, pvUser, pfnThread, pfnWakeup, cbStack, enmType, pszName, pszName)); 1086 1158 1087 int rc = pdmR3ThreadCreateDriver(pDrvIns->Internal.s.pVM , pDrvIns, ppThread, pvUser, pfnThread, pfnWakeup, cbStack, enmType, pszName);1159 int rc = pdmR3ThreadCreateDriver(pDrvIns->Internal.s.pVMR3, pDrvIns, ppThread, pvUser, pfnThread, pfnWakeup, cbStack, enmType, pszName); 1088 1160 1089 1161 LogFlow(("pdmR3DrvHlp_PDMThreadCreate: caller='%s'/%d: returns %Rrc *ppThread=%RTthrd\n", pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance, … … 1100 1172 { 1101 1173 PDMDRV_ASSERT_DRVINS(pDrvIns); 1102 VM_ASSERT_EMT(pDrvIns->Internal.s.pVM );1174 VM_ASSERT_EMT(pDrvIns->Internal.s.pVMR3); 1103 1175 LogFlow(("pdmR3DrvHlp_PDMAsyncCompletionTemplateCreate: caller='%s'/%d: ppTemplate=%p pfnCompleted=%p pszDesc=%p:{%s}\n", 1104 1176 pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance, ppTemplate, pfnCompleted, pszDesc, pszDesc)); 1105 1177 1106 int rc = PDMR3AsyncCompletionTemplateCreateDriver(pDrvIns->Internal.s.pVM , pDrvIns, ppTemplate, pfnCompleted, pvTemplateUser, pszDesc);1178 int rc = PDMR3AsyncCompletionTemplateCreateDriver(pDrvIns->Internal.s.pVMR3, pDrvIns, ppTemplate, pfnCompleted, pvTemplateUser, pszDesc); 1107 1179 1108 1180 LogFlow(("pdmR3DrvHlp_PDMAsyncCompletionTemplateCreate: caller='%s'/%d: returns %Rrc *ppThread=%p\n", pDrvIns->pDrvReg->szDriverName, … … 1116 1188 * The driver helper structure. 1117 1189 */ 1118 const PDMDRVHLP g_pdmR3DrvHlp =1119 { 1120 PDM_DRVHLP _VERSION,1190 const PDMDRVHLPR3 g_pdmR3DrvHlp = 1191 { 1192 PDM_DRVHLPR3_VERSION, 1121 1193 pdmR3DrvHlp_Attach, 1122 1194 pdmR3DrvHlp_Detach, … … 1149 1221 pdmR3DrvHlp_PDMAsyncCompletionTemplateCreate, 1150 1222 #endif 1151 PDM_DRVHLP _VERSION /* u32TheEnd */1223 PDM_DRVHLPR3_VERSION /* u32TheEnd */ 1152 1224 }; 1153 1225
Note:
See TracChangeset
for help on using the changeset viewer.