VirtualBox

Ignore:
Timestamp:
Jan 26, 2022 6:01:15 PM (3 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
149556
Message:

VMM,Main,HostServices: Use a function table for accessing the VBoxVMM.dll/so/dylib functionality, and load it dynamically when the Console object is initialized. Also converted a few drivers in Main to use device helpers to get config values and such. bugref:10074

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-client/AudioDriver.cpp

    r93115 r93444  
    2828#include <VBox/vmm/pdmapi.h>
    2929#include <VBox/vmm/pdmdrv.h>
     30#include <VBox/vmm/vmmr3vtable.h>
    3031
    3132#include "AudioDriver.h"
     
    8081 *
    8182 * @returns VBox status code.
    82  * @param   pUVM                The user mode VM handle for talking to EMT.
    83  * @param   pAutoLock           The callers auto lock instance.  Can be NULL if
    84  *                              not locked.
    85  */
    86 int AudioDriver::doAttachDriverViaEmt(PUVM pUVM, util::AutoWriteLock *pAutoLock)
     83 * @param   pUVM        The user mode VM handle for talking to EMT.
     84 * @param   pVMM        The VMM ring-3 vtable.
     85 * @param   pAutoLock   The callers auto lock instance.  Can be NULL if not
     86 *                      locked.
     87 */
     88int AudioDriver::doAttachDriverViaEmt(PUVM pUVM, PCVMMR3VTABLE pVMM, util::AutoWriteLock *pAutoLock)
    8789{
    8890    if (!isConfigured())
     
    9092
    9193    PVMREQ pReq;
    92     int vrc = VMR3ReqCallU(pUVM, VMCPUID_ANY, &pReq, 0 /* no wait! */, VMREQFLAGS_VBOX_STATUS,
    93                            (PFNRT)attachDriverOnEmt, 1, this);
     94    int vrc = pVMM->pfnVMR3ReqCallU(pUVM, VMCPUID_ANY, &pReq, 0 /* no wait! */, VMREQFLAGS_VBOX_STATUS,
     95                                    (PFNRT)attachDriverOnEmt, 1, this);
    9496    if (vrc == VERR_TIMEOUT)
    9597    {
     
    98100            pAutoLock->release();
    99101
    100         vrc = VMR3ReqWait(pReq, RT_INDEFINITE_WAIT);
     102        vrc = pVMM->pfnVMR3ReqWait(pReq, RT_INDEFINITE_WAIT);
    101103
    102104        if (pAutoLock)
     
    105107
    106108    AssertRC(vrc);
    107     VMR3ReqFree(pReq);
     109    pVMM->pfnVMR3ReqFree(pReq);
    108110
    109111    return vrc;
     
    138140
    139141    /* Detach the driver chain from the audio device first. */
    140     int rc = PDMR3DeviceDetach(ptrVM.rawUVM(), pCfg->strDev.c_str(), pCfg->uInst, pCfg->uLUN, 0 /* fFlags */);
     142    int rc = ptrVM.vtable()->pfnPDMR3DeviceDetach(ptrVM.rawUVM(), pCfg->strDev.c_str(), pCfg->uInst, pCfg->uLUN, 0 /* fFlags */);
    141143    if (RT_SUCCESS(rc))
    142144    {
    143145        rc = pThis->configure(pCfg->uLUN, true /* Attach */);
    144146        if (RT_SUCCESS(rc))
    145             rc = PDMR3DriverAttach(ptrVM.rawUVM(), pCfg->strDev.c_str(), pCfg->uInst, pCfg->uLUN, 0 /* fFlags */,
    146                                    NULL /* ppBase */);
     147            rc = ptrVM.vtable()->pfnPDMR3DriverAttach(ptrVM.rawUVM(), pCfg->strDev.c_str(), pCfg->uInst, pCfg->uLUN,
     148                                                      0 /* fFlags */, NULL /* ppBase */);
    147149    }
    148150
     
    164166 *
    165167 * @returns VBox status code.
    166  * @param   pUVM                The user mode VM handle for talking to EMT.
    167  * @param   pAutoLock           The callers auto lock instance.  Can be NULL if
    168  *                              not locked.
    169  */
    170 int AudioDriver::doDetachDriverViaEmt(PUVM pUVM, util::AutoWriteLock *pAutoLock)
     168 * @param   pUVM        The user mode VM handle for talking to EMT.
     169 * @param   pVMM        The VMM ring-3 vtable.
     170 * @param   pAutoLock   The callers auto lock instance.  Can be NULL if not
     171 *                      locked.
     172 */
     173int AudioDriver::doDetachDriverViaEmt(PUVM pUVM, PCVMMR3VTABLE pVMM, util::AutoWriteLock *pAutoLock)
    171174{
    172175    if (!isConfigured())
     
    174177
    175178    PVMREQ pReq;
    176     int vrc = VMR3ReqCallU(pUVM, VMCPUID_ANY, &pReq, 0 /* no wait! */, VMREQFLAGS_VBOX_STATUS,
    177                            (PFNRT)detachDriverOnEmt, 1, this);
     179    int vrc = pVMM->pfnVMR3ReqCallU(pUVM, VMCPUID_ANY, &pReq, 0 /* no wait! */, VMREQFLAGS_VBOX_STATUS,
     180                                    (PFNRT)detachDriverOnEmt, 1, this);
    178181    if (vrc == VERR_TIMEOUT)
    179182    {
     
    182185            pAutoLock->release();
    183186
    184         vrc = VMR3ReqWait(pReq, RT_INDEFINITE_WAIT);
     187        vrc = pVMM->pfnVMR3ReqWait(pReq, RT_INDEFINITE_WAIT);
    185188
    186189        if (pAutoLock)
     
    189192
    190193    AssertRC(vrc);
    191     VMR3ReqFree(pReq);
     194    pVMM->pfnVMR3ReqFree(pReq);
    192195
    193196    return vrc;
     
    227230     * Start with the "AUDIO" driver, as this driver serves as the audio connector between
    228231     * the device emulation and the select backend(s). */
    229     int rc = PDMR3DriverDetach(ptrVM.rawUVM(), pCfg->strDev.c_str(), pCfg->uInst, pCfg->uLUN,
    230                                "AUDIO", 0 /* iOccurrence */,  0 /* fFlags */);
     232    int rc = ptrVM.vtable()->pfnPDMR3DriverDetach(ptrVM.rawUVM(), pCfg->strDev.c_str(), pCfg->uInst, pCfg->uLUN,
     233                                                  "AUDIO", 0 /* iOccurrence */,  0 /* fFlags */);
    231234    if (RT_SUCCESS(rc))
    232235        rc = pThis->configure(pCfg->uLUN, false /* Detach */);/** @todo r=bird: Illogical and from what I can tell pointless! */
     
    256259{
    257260    Console::SafeVMPtrQuiet ptrVM(mpConsole);
    258     Assert(ptrVM.isOk());
    259 
    260     PUVM pUVM = ptrVM.rawUVM();
    261     AssertPtr(pUVM);
    262 
    263     PCFGMNODE pRoot = CFGMR3GetRootU(pUVM);
     261    AssertReturn(ptrVM.isOk(), VERR_INVALID_STATE);
     262
     263    PCFGMNODE pRoot = ptrVM.vtable()->pfnCFGMR3GetRootU(ptrVM.rawUVM());
    264264    AssertPtr(pRoot);
    265     PCFGMNODE pDev0 = CFGMR3GetChildF(pRoot, "Devices/%s/%u/", mCfg.strDev.c_str(), mCfg.uInst);
     265    PCFGMNODE pDev0 = ptrVM.vtable()->pfnCFGMR3GetChildF(pRoot, "Devices/%s/%u/", mCfg.strDev.c_str(), mCfg.uInst);
    266266
    267267    if (!pDev0) /* No audio device configured? Bail out. */
     
    273273    int rc = VINF_SUCCESS;
    274274
    275     PCFGMNODE pDevLun = CFGMR3GetChildF(pDev0, "LUN#%u/", uLUN);
     275    PCFGMNODE pDevLun = ptrVM.vtable()->pfnCFGMR3GetChildF(pDev0, "LUN#%u/", uLUN);
    276276
    277277    if (fAttach)
    278278    {
    279         do
     279        do  /* break "loop" */
    280280        {
    281281            AssertMsgBreakStmt(pDevLun, ("%s: Device LUN #%u not found\n", mCfg.strName.c_str(), uLUN), rc = VERR_NOT_FOUND);
     
    283283            LogRel2(("%s: Configuring audio driver (to LUN #%u)\n", mCfg.strName.c_str(), uLUN));
    284284
    285             CFGMR3RemoveNode(pDevLun); /* Remove LUN completely first. */
     285            ptrVM.vtable()->pfnCFGMR3RemoveNode(pDevLun); /* Remove LUN completely first. */
    286286
    287287            /* Insert new LUN configuration and build up the new driver chain. */
    288             rc = CFGMR3InsertNodeF(pDev0, &pDevLun, "LUN#%u/", uLUN);                               AssertRCBreak(rc);
    289             rc = CFGMR3InsertString(pDevLun, "Driver", "AUDIO");                                    AssertRCBreak(rc);
     288            rc = ptrVM.vtable()->pfnCFGMR3InsertNodeF(pDev0, &pDevLun, "LUN#%u/", uLUN);                        AssertRCBreak(rc);
     289            rc = ptrVM.vtable()->pfnCFGMR3InsertString(pDevLun, "Driver", "AUDIO");                             AssertRCBreak(rc);
    290290
    291291            PCFGMNODE pLunCfg;
    292             rc = CFGMR3InsertNode(pDevLun, "Config", &pLunCfg);                                     AssertRCBreak(rc);
    293 
    294             rc = CFGMR3InsertStringF(pLunCfg, "DriverName",    "%s", mCfg.strName.c_str());         AssertRCBreak(rc);
    295             rc = CFGMR3InsertInteger(pLunCfg, "InputEnabled",  mCfg.fEnabledIn);                    AssertRCBreak(rc);
    296             rc = CFGMR3InsertInteger(pLunCfg, "OutputEnabled", mCfg.fEnabledOut);                   AssertRCBreak(rc);
     292            rc = ptrVM.vtable()->pfnCFGMR3InsertNode(pDevLun, "Config", &pLunCfg);                              AssertRCBreak(rc);
     293
     294            rc = ptrVM.vtable()->pfnCFGMR3InsertStringF(pLunCfg, "DriverName",    "%s", mCfg.strName.c_str());  AssertRCBreak(rc);
     295            rc = ptrVM.vtable()->pfnCFGMR3InsertInteger(pLunCfg, "InputEnabled",  mCfg.fEnabledIn);             AssertRCBreak(rc);
     296            rc = ptrVM.vtable()->pfnCFGMR3InsertInteger(pLunCfg, "OutputEnabled", mCfg.fEnabledOut);            AssertRCBreak(rc);
    297297
    298298            PCFGMNODE pAttachedDriver;
    299             rc = CFGMR3InsertNode(pDevLun, "AttachedDriver", &pAttachedDriver);                     AssertRCBreak(rc);
    300             rc = CFGMR3InsertStringF(pAttachedDriver, "Driver", "%s", mCfg.strName.c_str());        AssertRCBreak(rc);
     299            rc = ptrVM.vtable()->pfnCFGMR3InsertNode(pDevLun, "AttachedDriver", &pAttachedDriver);              AssertRCBreak(rc);
     300            rc = ptrVM.vtable()->pfnCFGMR3InsertStringF(pAttachedDriver, "Driver", "%s", mCfg.strName.c_str()); AssertRCBreak(rc);
    301301            PCFGMNODE pAttachedDriverCfg;
    302             rc = CFGMR3InsertNode(pAttachedDriver, "Config", &pAttachedDriverCfg);                  AssertRCBreak(rc);
     302            rc = ptrVM.vtable()->pfnCFGMR3InsertNode(pAttachedDriver, "Config", &pAttachedDriverCfg);           AssertRCBreak(rc);
    303303
    304304            /* Call the (virtual) method for driver-specific configuration. */
    305             rc = configureDriver(pAttachedDriverCfg);                                               AssertRCBreak(rc);
     305            rc = configureDriver(pAttachedDriverCfg, ptrVM.vtable());                                           AssertRCBreak(rc);
    306306
    307307        } while (0);
     
    316316#ifdef LOG_ENABLED
    317317        LogFunc(("%s: fAttach=%RTbool\n", mCfg.strName.c_str(), fAttach));
    318         CFGMR3Dump(pDevLun);
     318        ptrVM.vtable()->pfnCFGMR3Dump(pDevLun);
    319319#endif
    320320    }
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