VirtualBox

Changeset 2452 in vbox


Ignore:
Timestamp:
May 2, 2007 1:07:23 PM (18 years ago)
Author:
vboxsync
Message:

Treat the instance node name as the instance number to make it simpler to address the devices using PDMR3QueryDeviceLun().

File:
1 edited

Legend:

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

    r2291 r2452  
    683683        /** Pointer to device. */
    684684        PPDMDEV     pDev;
    685         /** VBox instance number. */
    686         RTUINT      iInstance;
    687685        /** Init order. */
    688686        uint32_t    u32Order;
     687        /** VBox instance number. */
     688        uint32_t    iInstance;
    689689    } *paDevs = (struct DEVORDER *)alloca(sizeof(paDevs[0]) * (cDevs + 1)); /* (One extra for swapping) */
    690690    Assert(paDevs);
     
    692692    for (pCur = CFGMR3GetFirstChild(pDevicesNode); pCur; pCur = CFGMR3GetNextChild(pCur))
    693693    {
    694         RTUINT iInstance = 0;
     694        /* Get the device name. */
     695        char szName[sizeof(paDevs[0].pDev->pDevReg->szDeviceName)];
     696        rc = CFGMR3GetName(pCur, szName, sizeof(szName));
     697        AssertMsgRCReturn(rc, ("Configuration error: device name is too long (or something)! rc=%Vrc\n", rc), rc);
     698
     699        /* Find the device. */
     700        PPDMDEV pDev = pdmR3DevLookup(pVM, szName);
     701        AssertMsgReturn(pDev, ("Configuration error: device '%s' not found!\n", szName), VERR_PDM_DEVICE_NOT_FOUND);
     702
     703        /* Configured priority or use default based on device class? */
     704        uint32_t u32Order;
     705        rc = CFGMR3QueryU32(pCur, "Priority", &u32Order);
     706        if (rc == VERR_CFGM_VALUE_NOT_FOUND)
     707        {
     708            uint32_t u32 = pDev->pDevReg->fClass;
     709            for (u32Order = 1; !(u32 & u32Order); u32Order <<= 1)
     710                /* nop */;
     711        }
     712        else
     713            AssertMsgRCReturn(rc, ("Configuration error: reading \"Priority\" for the '%s' device failed rc=%Vrc!\n", szName, rc), rc);
     714
     715        /* Enumerate the device instances. */
    695716        for (pInstanceNode = CFGMR3GetFirstChild(pCur); pInstanceNode; pInstanceNode = CFGMR3GetNextChild(pInstanceNode))
    696717        {
    697             /* basics */
    698718            paDevs[i].pNode = pInstanceNode;
    699             paDevs[i].iInstance = iInstance;
    700 
    701             /* Get the device name. */
    702             char szName[sizeof(paDevs[0].pDev->pDevReg->szDeviceName)];
    703             rc = CFGMR3GetName(pCur, szName, sizeof(szName));
    704             if (VBOX_FAILURE(rc))
    705             {
    706                 AssertMsgFailed(("Configuration error: device name is too long (or something)! rc=%Vrc\n", rc));
    707                 return rc;
    708             }
    709 
    710             /* Get the device. */
    711             paDevs[i].pDev = pdmR3DevLookup(pVM, szName);
    712             if (!paDevs[i].pDev)
    713             {
    714                 AssertMsgFailed(("Configuration error: device '%s' not found!\n", szName));
    715                 return VERR_PDM_DEVICE_NOT_FOUND;
    716             }
    717 
    718             /* Configured priority or use default based on device class? */
    719             rc = CFGMR3QueryU32(pCur, "Priority", &paDevs[i].u32Order);
    720             if (rc == VERR_CFGM_VALUE_NOT_FOUND)
    721             {
    722                 uint32_t u32 = paDevs[i].pDev->pDevReg->fClass;
    723                 for (paDevs[i].u32Order = 1; !(u32 & paDevs[i].u32Order); paDevs[i].u32Order <<= 1)
    724                     /* nop */;
    725             }
    726             else if (VBOX_FAILURE(rc))
    727             {
    728                 AssertMsgFailed(("Configuration error: reading \"Priority\" for the '%s' device failed rc=%Vrc!\n", szName, rc));
    729                 return rc;
    730             }
     719            paDevs[i].pDev = pDev;
     720            paDevs[i].u32Order = u32Order;
     721
     722            /* Get the instance number. */
     723            char szInstance[32];
     724            rc = CFGMR3GetName(pInstanceNode, szInstance, sizeof(szInstance));
     725            AssertMsgRCReturn(rc, ("Configuration error: instance name is too long (or something)! rc=%Vrc\n", rc), rc);
     726            char *pszNext = NULL;
     727            rc = RTStrToUInt32Ex(szInstance, &pszNext, 0, &paDevs[i].iInstance);
     728            AssertMsgRCReturn(rc, ("Configuration error: RTStrToInt32Ex failed on the instance name '%s'! rc=%Vrc\n", szInstance, rc), rc);
     729            AssertMsgReturn(!*pszNext, ("Configuration error: the instance name '%s' isn't all digits. (%s)\n", szInstance, pszNext), VERR_INVALID_PARAMETER);
    731730
    732731            /* next instance */
    733             iInstance++;
    734732            i++;
    735         } /* instances */
     733        }
    736734    } /* devices */
    737735    Assert(i == cDevs);
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