VirtualBox

Changeset 22334 in vbox for trunk/src/VBox/VMM


Ignore:
Timestamp:
Aug 18, 2009 8:56:06 PM (15 years ago)
Author:
vboxsync
Message:

PDMR3DriverAttach: implemented, but untested.

File:
1 edited

Legend:

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

    r22325 r22334  
    786786 * @param   iInstance       Device instance.
    787787 * @param   iLun            The Logical Unit to obtain the interface of.
     788 * @param   fFlags          Flags, combination of the PDMDEVATT_FLAGS_* \#defines.
    788789 * @param   ppBase          Where to store the base interface pointer. Optional.
    789  * @param   fFlags          Flags, combination of the PDMDEVATT_FLAGS_* \#defines.
    790790 * @thread  EMT
    791791 */
     
    812812            {
    813813                rc = pDevIns->pDevReg->pfnAttach(pDevIns, iLun, fFlags);
    814 
    815814            }
    816815            else
     
    849848VMMR3DECL(int) PDMR3DeviceDetach(PVM pVM, const char *pszDevice, unsigned iInstance, unsigned iLun, uint32_t fFlags)
    850849{
     850    return PDMR3DriverDetach(pVM, pszDevice, iInstance, iLun, NULL, 0, fFlags);
     851}
     852
     853
     854/**
     855 * Attaches a preconfigured driver to an existing device or driver instance.
     856 *
     857 * This is used to change drivers and suchlike at runtime.  The driver or device
     858 * at the end of the chain will be told to attach to whatever is configured
     859 * below it.
     860 *
     861 * @returns VBox status code.
     862 * @param   pVM             VM Handle.
     863 * @param   pszDevice       Device name.
     864 * @param   iInstance       Device instance.
     865 * @param   iLun            The Logical Unit to obtain the interface of.
     866 * @param   fFlags          Flags, combination of the PDMDEVATT_FLAGS_* \#defines.
     867 * @param   ppBase          Where to store the base interface pointer. Optional.
     868 *
     869 * @thread  EMT
     870 */
     871VMMR3DECL(int) PDMR3DriverAttach(PVM pVM, const char *pszDevice, unsigned iInstance, unsigned iLun, uint32_t fFlags, PPDMIBASE *ppBase)
     872{
    851873    VM_ASSERT_EMT(pVM);
    852     LogFlow(("PDMR3DeviceDetach: pszDevice=%p:{%s} iInstance=%d iLun=%d\n",
    853              pszDevice, pszDevice, iInstance, iLun));
     874    LogFlow(("PDMR3DriverAttach: pszDevice=%p:{%s} iInstance=%d iLun=%d fFlags=%#x ppBase=%p\n",
     875             pszDevice, pszDevice, iInstance, iLun, fFlags, ppBase));
     876
     877    if (ppBase)
     878        *ppBase = NULL;
    854879
    855880    /*
     
    861886    {
    862887        /*
    863          * Can we detach anything at runtime?
     888         * Anything attached to the LUN?
    864889         */
    865         PPDMDEVINS pDevIns = pLun->pDevIns;
    866         if (pDevIns->pDevReg->pfnDetach)
    867         {
    868             if (pLun->pTop)
    869                 rc = pdmR3DrvDetach(pLun->pTop, fFlags);
     890        PPDMDRVINS pDrvIns = pLun->pTop;
     891        if (!pDrvIns)
     892        {
     893            /* No, ask the device to attach to the new stuff. */
     894            PPDMDEVINS pDevIns = pLun->pDevIns;
     895            if (pDevIns->pDevReg->pfnAttach)
     896            {
     897                rc = pDevIns->pDevReg->pfnAttach(pDevIns, iLun, fFlags);
     898                if (RT_SUCCESS(rc) && ppBase)
     899                    *ppBase = pLun->pTop ? &pLun->pTop->IBase : NULL;
     900            }
    870901            else
    871                 rc = VINF_PDM_NO_DRIVER_ATTACHED_TO_LUN;
    872         }
    873     }
    874 
    875     LogFlow(("PDMR3DeviceDetach: returns %Rrc\n", rc));
     902                rc = VERR_PDM_DEVICE_NO_RT_ATTACH;
     903        }
     904        else
     905        {
     906            /* Yes, find the bottom most driver and ask it to attach to the new stuff. */
     907            while (pDrvIns->Internal.s.pDown)
     908                pDrvIns = pDrvIns->Internal.s.pDown;
     909            if (pDrvIns->pDrvReg->pfnAttach)
     910            {
     911                rc = pDrvIns->pDrvReg->pfnAttach(pDrvIns, fFlags);
     912                if (RT_SUCCESS(rc) && ppBase)
     913                    *ppBase = pDrvIns->Internal.s.pDown
     914                            ? &pDrvIns->Internal.s.pDown->IBase
     915                            : NULL;
     916            }
     917            else
     918                rc = VERR_PDM_DRIVER_NO_RT_ATTACH;
     919        }
     920    }
     921
     922    if (ppBase)
     923        LogFlow(("PDMR3DriverAttach: returns %Rrc *ppBase=%p\n", rc, *ppBase));
     924    else
     925        LogFlow(("PDMR3DriverAttach: returns %Rrc\n", rc));
    876926    return rc;
    877927}
     
    9511001}
    9521002
     1003
     1004/**
     1005 * Runtime detach and reattach of a new driver chain or sub chain.
     1006 *
     1007 * This is intended to be called on a non-EMT thread, this will instantiate the
     1008 * new driver (sub-)chain, and then the EMTs will do the actual replumbing.  The
     1009 * destruction of the old driver chain will be taken care of on the calling
     1010 * thread.
     1011 *
     1012 * @returns VBox status code.
     1013 * @param   pVM             VM Handle.
     1014 * @param   pszDevice       Device name.
     1015 * @param   iDevIns         Device instance.
     1016 * @param   iLun            The Logical Unit in which to look for the driver.
     1017 * @param   pszDriver       The name of the driver which to detach and replace.
     1018 *                          If NULL then the entire driver chain is to be
     1019 *                          reattached.
     1020 * @param   iOccurance      The occurance of that driver in the chain.  This is
     1021 *                          usually 0.
     1022 * @param   fFlags          Flags, combination of the PDMDEVATT_FLAGS_* \#defines.
     1023 * @param   pCfg            The configuration of the new driver chain that is
     1024 *                          going to be attached.  The subtree starts with the
     1025 *                          node containing a Driver key, a Config subtree and
     1026 *                          optionally an AttachedDriver subtree.
     1027 *                          If this parameter is NULL, then this call will work
     1028 *                          like at a non-pause version of PDMR3DriverDetach.
     1029 * @param   ppBase          Where to store the base interface pointer to the new
     1030 *                          driver.  Optional.
     1031 *
     1032 * @thread  Any thread. The EMTs will be involved at some point though.
     1033 */
     1034VMMR3DECL(int)  PDMR3DriverReattach(PVM pVM, const char *pszDevice, unsigned iDevIns, unsigned iLun,
     1035                                    const char *pszDriver, unsigned iOccurance, uint32_t fFlags,
     1036                                    PCFGMNODE pCfg, PPPDMIBASE *ppBase)
     1037{
     1038    return VERR_NOT_IMPLEMENTED;
     1039}
     1040
Note: See TracChangeset for help on using the changeset viewer.

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