VirtualBox

Changeset 25891 in vbox for trunk/src/VBox/VMM/PDMDriver.cpp


Ignore:
Timestamp:
Jan 18, 2010 1:07:21 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
56701
Message:

PDMDrv,*: multi context drivers, part 1.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/PDMDriver.cpp

    r25528 r25891  
    7676        AssertPtr(pDrvIns); \
    7777        Assert(pDrvIns->u32Version == PDM_DRVINS_VERSION); \
    78         Assert(pDrvIns->pvInstanceData == (void *)&pDrvIns->achInstanceData[0]); \
     78        Assert(pDrvIns->pvInstanceDataR3 == (void *)&pDrvIns->achInstanceData[0]); \
    7979    } while (0)
    8080#else
     
    346346
    347347/**
     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 */
     366int 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/**
    348515 * Detaches a driver from whatever it's attached to.
    349516 * This will of course lead to the destruction of the driver and all drivers below it in the chain.
     
    357524    PDMDRV_ASSERT_DRVINS(pDrvIns);
    358525    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);
    360527
    361528    /*
     
    365532    {
    366533        AssertMsgFailed(("Recursive detach! '%s'/%d\n", pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance));
    367         return VINF_SUCCESS;
    368     }
     534        return VINF_SUCCESS;           }
    369535
    370536    /*
     
    394560 *
    395561 * @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.
    397564 */
    398565void pdmR3DrvDestroyChain(PPDMDRVINS pDrvIns, uint32_t fFlags)
    399566{
    400     VM_ASSERT_EMT(pDrvIns->Internal.s.pVM);
     567    PVM pVM = pDrvIns->Internal.s.pVMR3;
     568    VM_ASSERT_EMT(pVM);
    401569
    402570    /*
     
    411579        while (pCur->Internal.s.pDown)
    412580            pCur = pCur->Internal.s.pDown;
    413         LogFlow(("pdmR3DrvDetach: 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));
    414582
    415583        /*
     
    429597            pParent->Internal.s.pDown = NULL;
    430598
    431             if (pParent->pDrvReg->pfnDetach)
     599            if (!(fFlags & PDM_TACH_FLAGS_NO_CALLBACKS) && pParent->pDrvReg->pfnDetach)
    432600                pParent->pDrvReg->pfnDetach(pParent, fFlags);
    433601
     
    439607            Assert(pLun->pTop == pCur);
    440608            pLun->pTop = NULL;
    441             if (pLun->pDevIns->pDevReg->pfnDetach)
     609            if (!(fFlags & PDM_TACH_FLAGS_NO_CALLBACKS) && pLun->pDevIns->pDevReg->pfnDetach)
    442610                pLun->pDevIns->pDevReg->pfnDetach(pLun->pDevIns, pLun->iLun, fFlags);
    443611        }
     
    455623         */
    456624        /* Queues. */
    457         int rc = PDMR3QueueDestroyDriver(pCur->Internal.s.pVM, pCur);
     625        int rc = PDMR3QueueDestroyDriver(pVM, pCur);
    458626        AssertRC(rc);
     627
    459628        /* Timers. */
    460         rc = TMR3TimerDestroyDriver(pCur->Internal.s.pVM, pCur);
     629        rc = TMR3TimerDestroyDriver(pVM, pCur);
    461630        AssertRC(rc);
     631
    462632        /* SSM data units. */
    463         rc = SSMR3DeregisterDriver(pCur->Internal.s.pVM, pCur, NULL, 0);
     633        rc = SSMR3DeregisterDriver(pVM, pCur, NULL, 0);
    464634        AssertRC(rc);
     635
    465636        /* PDM threads. */
    466         rc = pdmR3ThreadDestroyDriver(pCur->Internal.s.pVM, pCur);
     637        rc = pdmR3ThreadDestroyDriver(pVM, pCur);
    467638        AssertRC(rc);
     639
    468640        /* Finally, the driver it self. */
     641        bool fHyperHeap = pCur->Internal.s.fHyperHeap;
    469642        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);
    471647
    472648    } while (pCur != pDrvIns);
     
    484660{
    485661    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));
    489665    Assert(!(fFlags & ~(PDM_TACH_FLAGS_NOT_HOT_PLUG)));
    490666
     
    502678        PCFGMNODE pNode = CFGMR3GetChild(pDrvIns->Internal.s.pCfgHandle, "AttachedDriver");
    503679        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);
    609681        else
    610682            rc = VERR_PDM_NO_ATTACHED_DRIVER;
     
    628700    LogFlow(("pdmR3DrvHlp_Detach: caller='%s'/%d: fFlags=%#x\n",
    629701             pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance, fFlags));
    630     VM_ASSERT_EMT(pDrvIns->Internal.s.pVM);
     702    VM_ASSERT_EMT(pDrvIns->Internal.s.pVMR3);
    631703
    632704    /*
     
    654726    LogFlow(("pdmR3DrvHlp_DetachSelf: caller='%s'/%d: fFlags=%#x\n",
    655727             pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance, fFlags));
    656     VM_ASSERT_EMT(pDrvIns->Internal.s.pVM);
     728    VM_ASSERT_EMT(pDrvIns->Internal.s.pVMR3);
    657729
    658730    int rc = pdmR3DrvDetach(pDrvIns, fFlags);
     
    669741    LogFlow(("pdmR3DrvHlp_MountPrepare: caller='%s'/%d: pszFilename=%p:{%s} pszCoreDriver=%p:{%s}\n",
    670742             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);
    672744
    673745    /*
     
    741813{
    742814    PDMDRV_ASSERT_DRVINS(pDrvIns);
    743     if (VM_IS_EMT(pDrvIns->Internal.s.pVM))
     815    if (VM_IS_EMT(pDrvIns->Internal.s.pVMR3))
    744816        return true;
    745817
     
    748820    RTAssertMsg1Weak(szMsg, iLine, pszFile, pszFunction);
    749821    AssertBreakpoint();
    750     VM_ASSERT_EMT(pDrvIns->Internal.s.pVM);
     822    VM_ASSERT_EMT(pDrvIns->Internal.s.pVMR3);
    751823    return false;
    752824}
     
    757829{
    758830    PDMDRV_ASSERT_DRVINS(pDrvIns);
    759     if (!VM_IS_EMT(pDrvIns->Internal.s.pVM))
     831    if (!VM_IS_EMT(pDrvIns->Internal.s.pVMR3))
    760832        return true;
    761833
     
    764836    RTAssertMsg1Weak(szMsg, iLine, pszFile, pszFunction);
    765837    AssertBreakpoint();
    766     VM_ASSERT_EMT(pDrvIns->Internal.s.pVM);
     838    VM_ASSERT_EMT(pDrvIns->Internal.s.pVMR3);
    767839    return false;
    768840}
     
    775847    va_list args;
    776848    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);
    778850    va_end(args);
    779851    return rc;
     
    785857{
    786858    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);
    788860    return rc;
    789861}
     
    796868    va_list args;
    797869    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);
    799871    va_end(args);
    800872    return rc;
     
    806878{
    807879    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);
    809881    return rc;
    810882}
     
    816888    PDMDRV_ASSERT_DRVINS(pDrvIns);
    817889
    818     VMSTATE enmVMState = VMR3GetState(pDrvIns->Internal.s.pVM);
     890    VMSTATE enmVMState = VMR3GetState(pDrvIns->Internal.s.pVMR3);
    819891
    820892    LogFlow(("pdmR3DrvHlp_VMState: caller='%s'/%d: returns %d (%s)\n", pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance,
     
    829901    PDMDRV_ASSERT_DRVINS(pDrvIns);
    830902
    831     bool fRc = VMR3TeleportedAndNotFullyResumedYet(pDrvIns->Internal.s.pVM);
     903    bool fRc = VMR3TeleportedAndNotFullyResumedYet(pDrvIns->Internal.s.pVMR3);
    832904
    833905    LogFlow(("pdmR3DrvHlp_VMState: caller='%s'/%d: returns %RTbool)\n", pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance,
     
    844916    LogFlow(("pdmR3DrvHlp_PDMQueueCreate: caller='%s'/%d: cbItem=%d cItems=%d cMilliesInterval=%d pfnCallback=%p pszName=%p:{%s} ppQueue=%p\n",
    845917             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;
    847919    VM_ASSERT_EMT(pVM);
    848920
     
    865937    PDMDRV_ASSERT_DRVINS(pDrvIns);
    866938
    867     return TMVirtualGetFreq(pDrvIns->Internal.s.pVM);
     939    return TMVirtualGetFreq(pDrvIns->Internal.s.pVMR3);
    868940}
    869941
     
    874946    PDMDRV_ASSERT_DRVINS(pDrvIns);
    875947
    876     return TMVirtualGet(pDrvIns->Internal.s.pVM);
     948    return TMVirtualGet(pDrvIns->Internal.s.pVMR3);
    877949}
    878950
     
    885957             pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance, enmClock, pfnCallback, pvUser, fFlags, pszDesc, pszDesc, ppTimer));
    886958
    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);
    888960
    889961    LogFlow(("pdmR3DrvHlp_TMTimerCreate: caller='%s'/%d: returns %Rrc *ppTimer=%p\n", pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance, rc, *ppTimer));
     
    900972{
    901973    PDMDRV_ASSERT_DRVINS(pDrvIns);
    902     VM_ASSERT_EMT(pDrvIns->Internal.s.pVM);
     974    VM_ASSERT_EMT(pDrvIns->Internal.s.pVMR3);
    903975    LogFlow(("pdmR3DrvHlp_SSMRegister: caller='%s'/%d: uVersion=#x cbGuess=%#x \n"
    904976             "    pfnLivePrep=%p pfnLiveExec=%p pfnLiveVote=%p  pfnSavePrep=%p pfnSaveExec=%p pfnSaveDone=%p pszLoadPrep=%p pfnLoadExec=%p pfnLoaddone=%p\n",
     
    907979             pfnSavePrep, pfnSaveExec, pfnSaveDone, pfnLoadPrep, pfnLoadExec, pfnLoadDone));
    908980
    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,
    910982                                 uVersion, cbGuess,
    911983                                 pfnLivePrep, pfnLiveExec, pfnLiveVote,
     
    922994{
    923995    PDMDRV_ASSERT_DRVINS(pDrvIns);
    924     VM_ASSERT_EMT(pDrvIns->Internal.s.pVM);
     996    VM_ASSERT_EMT(pDrvIns->Internal.s.pVMR3);
    925997    LogFlow(("pdmR3DrvHlp_SSMDeregister: caller='%s'/%d: pszName=%p:{%s} u32Instance=%#x\n",
    926998             pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance, pszName, pszName, u32Instance));
    927999
    928     int rc = SSMR3DeregisterDriver(pDrvIns->Internal.s.pVM, pDrvIns, pszName, u32Instance);
     1000    int rc = SSMR3DeregisterDriver(pDrvIns->Internal.s.pVMR3, pDrvIns, pszName, u32Instance);
    9291001
    9301002    LogFlow(("pdmR3DrvHlp_SSMDeregister: caller='%s'/%d: returns %Rrc\n", pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance, rc));
     
    9371009{
    9381010    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);
    9421014    /** @todo track the samples so they can be dumped & deregistered when the driver instance is destroyed.
    9431015     * For now we just have to be careful not to use this call for drivers which can be unloaded. */
     
    9501022{
    9511023    PDMDRV_ASSERT_DRVINS(pDrvIns);
    952     VM_ASSERT_EMT(pDrvIns->Internal.s.pVM);
     1024    VM_ASSERT_EMT(pDrvIns->Internal.s.pVMR3);
    9531025
    9541026    va_list args;
    9551027    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);
    9571029    va_end(args);
    9581030    AssertRC(rc);
     
    9651037{
    9661038    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);
    9701042    AssertRC(rc);
    9711043}
     
    9761048{
    9771049    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);
    9811053    AssertRC(rc);
    9821054    return rc;
     
    9931065    if (    uOperation >= VMMR0_DO_SRV_START
    9941066        &&  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);
    9961068    else
    9971069    {
     
    10091081{
    10101082    PDMDRV_ASSERT_DRVINS(pDrvIns);
    1011     VM_ASSERT_EMT(pDrvIns->Internal.s.pVM);
     1083    VM_ASSERT_EMT(pDrvIns->Internal.s.pVMR3);
    10121084    LogFlow(("pdmR3DrvHlp_USBRegisterHub: caller='%s'/%d: fVersions=%#x cPorts=%#x pUsbHubReg=%p ppUsbHubHlp=%p\n",
    10131085             pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance, fVersions, cPorts, pUsbHubReg, ppUsbHubHlp));
    10141086
    10151087#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);
    10171089#else
    10181090    int rc = VERR_NOT_SUPPORTED;
     
    10281100{
    10291101    PDMDRV_ASSERT_DRVINS(pDrvIns);
    1030     VM_ASSERT_EMT0(pDrvIns->Internal.s.pVM);
     1102    VM_ASSERT_EMT0(pDrvIns->Internal.s.pVMR3);
    10311103    LogFlow(("pdmR3DrvHlp_SetAsyncNotification: caller='%s'/%d: pfnAsyncNotify=%p\n", pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance, pfnAsyncNotify));
    10321104
     
    10351107    AssertStmt(!pDrvIns->Internal.s.pfnAsyncNotify, rc = VERR_WRONG_ORDER);
    10361108    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);
    10381110    AssertStmt(   enmVMState == VMSTATE_SUSPENDING
    10391111               || enmVMState == VMSTATE_SUSPENDING_EXT_LS
     
    10571129{
    10581130    PDMDRV_ASSERT_DRVINS(pDrvIns);
    1059     PVM pVM = pDrvIns->Internal.s.pVM;
     1131    PVM pVM = pDrvIns->Internal.s.pVMR3;
    10601132
    10611133    VMSTATE enmVMState = VMR3GetState(pVM);
     
    10811153{
    10821154    PDMDRV_ASSERT_DRVINS(pDrvIns);
    1083     VM_ASSERT_EMT(pDrvIns->Internal.s.pVM);
     1155    VM_ASSERT_EMT(pDrvIns->Internal.s.pVMR3);
    10841156    LogFlow(("pdmR3DrvHlp_PDMThreadCreate: caller='%s'/%d: ppThread=%p pvUser=%p pfnThread=%p pfnWakeup=%p cbStack=%#zx enmType=%d pszName=%p:{%s}\n",
    10851157             pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance, ppThread, pvUser, pfnThread, pfnWakeup, cbStack, enmType, pszName, pszName));
    10861158
    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);
    10881160
    10891161    LogFlow(("pdmR3DrvHlp_PDMThreadCreate: caller='%s'/%d: returns %Rrc *ppThread=%RTthrd\n", pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance,
     
    11001172{
    11011173    PDMDRV_ASSERT_DRVINS(pDrvIns);
    1102     VM_ASSERT_EMT(pDrvIns->Internal.s.pVM);
     1174    VM_ASSERT_EMT(pDrvIns->Internal.s.pVMR3);
    11031175    LogFlow(("pdmR3DrvHlp_PDMAsyncCompletionTemplateCreate: caller='%s'/%d: ppTemplate=%p pfnCompleted=%p pszDesc=%p:{%s}\n",
    11041176             pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance, ppTemplate, pfnCompleted, pszDesc, pszDesc));
    11051177
    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);
    11071179
    11081180    LogFlow(("pdmR3DrvHlp_PDMAsyncCompletionTemplateCreate: caller='%s'/%d: returns %Rrc *ppThread=%p\n", pDrvIns->pDrvReg->szDriverName,
     
    11161188 * The driver helper structure.
    11171189 */
    1118 const PDMDRVHLP g_pdmR3DrvHlp =
    1119 {
    1120     PDM_DRVHLP_VERSION,
     1190const PDMDRVHLPR3 g_pdmR3DrvHlp =
     1191{
     1192    PDM_DRVHLPR3_VERSION,
    11211193    pdmR3DrvHlp_Attach,
    11221194    pdmR3DrvHlp_Detach,
     
    11491221    pdmR3DrvHlp_PDMAsyncCompletionTemplateCreate,
    11501222#endif
    1151     PDM_DRVHLP_VERSION /* u32TheEnd */
     1223    PDM_DRVHLPR3_VERSION /* u32TheEnd */
    11521224};
    11531225
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette