VirtualBox

Changeset 98086 in vbox


Ignore:
Timestamp:
Jan 15, 2023 1:14:57 PM (23 months ago)
Author:
vboxsync
Message:

Main/ConsoleImpl: Modified the LED set enmType to a bitmap containing all possible types, thus allowing us to skip scanning the paSubTypes array when present. Also simplified i_attachStatusDriver a little. bugref:9892

Location:
trunk/src/VBox/Main
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/ConsoleImpl.h

    r96888 r98086  
    810810    typedef struct LEDSET *PLEDSET;
    811811    PPDMLED *i_getLedSet(uint32_t iLedSet);
    812     uint32_t i_allocateDriverLeds(uint32_t cLeds, DeviceType_T enmType, DeviceType_T **ppSubTypes);
    813     void i_attachStatusDriver(PCFGMNODE pCtlInst, DeviceType_T enmType,
    814                               uint32_t uFirst, uint32_t uLast,
    815                               DeviceType_T **ppaSubTypes,
     812    uint32_t i_allocateDriverLeds(uint32_t cLeds, uint32_t fTypes, DeviceType_T **ppSubTypes);
     813    void i_attachStatusDriver(PCFGMNODE pCtlInst, DeviceType_T enmType);
     814    void i_attachStatusDriver(PCFGMNODE pCtlInst, uint32_t fTypes, uint32_t cLeds, DeviceType_T **ppaSubTypes,
    816815                              Console::MediumAttachmentMap *pmapMediumAttachments,
    817816                              const char *pcszDevice, unsigned uInstance);
     
    10741073    struct LEDSET
    10751074    {
    1076         PPDMLED      *papLeds;
    1077         uint32_t      cLeds;
    1078         DeviceType_T  enmType;
    1079         DeviceType_T *paSubTypes; /**< Optionally, device types for each individual LED. Runs parallel to papLeds. */
     1075        PPDMLED        *papLeds;
     1076        uint32_t        cLeds;
     1077        uint32_t        fTypes;     /**< Bitmask of possible DeviceType_T values (e.g. RT_BIT_32(DeviceType_Network)). */
     1078        DeviceType_T   *paSubTypes; /**< Optionally, device types for each individual LED. Runs parallel to papLeds. */
    10801079    }                 maLedSets[32];
    10811080    /** @} */
  • trunk/src/VBox/Main/src-client/ConsoleImpl.cpp

    r98085 r98086  
    28572857    PDMLEDCORE aLEDs[DeviceType_End] = { {0} };
    28582858    Assert(aLEDs[1].u32 == 0 && aLEDs[DeviceType_End / 2].u32 == 0 && aLEDs[DeviceType_End - 1].u32 == 0); /* paranoia */
    2859     for (uint32_t idxSet = 0; idxSet < mcLedSets; ++idxSet)
    2860     {
    2861         /* Look inside this driver's set of LEDs */
     2859    uint32_t idxSet = mcLedSets;
     2860    while (idxSet-- > 0)
     2861    {
     2862        /* Look inside this driver's set of LEDs and check if the types mask overlap with the request: */
    28622863        PLEDSET pLS = &maLedSets[idxSet];
    2863 
    2864         /* Multi-type drivers (e.g. SCSI) have a subtype array which must be matched. */
    2865         if (pLS->paSubTypes)
    2866         {
    2867 /** @todo r=bird: This needs optimizing as it hurts to scan all units of all
    2868  * storage controllers when getting the activitiy of one or more non-storage
    2869  * devices.
    2870  *
    2871  * Perhaps add a type summary bitmap to the entry, or may just reuse the
    2872  * enmType for these. */
    2873             for (uint32_t inSet = 0; inSet < pLS->cLeds; ++inSet)
     2864        if (pLS->fTypes & fWanted)
     2865        {
     2866            uint32_t const        cLeds      = pLS->cLeds;
     2867            PPDMLED const * const papSrcLeds = pLS->papLeds;
     2868
     2869            /* Multi-type drivers (e.g. SCSI) have a subtype array which must be matched. */
     2870            DeviceType_T const *paSubTypes = pLS->paSubTypes;
     2871            if (paSubTypes)
     2872                for (uint32_t idxLed = 0; idxLed < cLeds; idxLed++)
     2873                {
     2874                    DeviceType_T const enmType = paSubTypes[idxLed];
     2875                    Assert((unsigned)enmType < (unsigned)DeviceType_End);
     2876                    if (fWanted & RT_BIT_32((unsigned)enmType))
     2877                        aLEDs[enmType].u32 |= readAndClearLed(papSrcLeds[idxLed]);
     2878                }
     2879            /* Single-type drivers (e.g. floppy) have the type in ->enmType */
     2880            else
    28742881            {
    2875                 DeviceType_T const enmType = pLS->paSubTypes[inSet];
    2876                 Assert((unsigned)enmType < (unsigned)DeviceType_End);
    2877                 if (fWanted & RT_BIT_32((unsigned)enmType))
    2878                     aLEDs[enmType].u32 |= readAndClearLed(pLS->papLeds[inSet]);
     2882                uint32_t const idxType = ASMBitFirstSetU32(pLS->fTypes) - 1;
     2883                for (uint32_t idxLed = 0; idxLed < cLeds; idxLed++)
     2884                    aLEDs[idxType].u32 |= readAndClearLed(papSrcLeds[idxLed]);
    28792885            }
    2880         }
    2881         /* Single-type drivers (e.g. floppy) have the type in ->enmType */
    2882         else
    2883         {
    2884             DeviceType_T const enmType = pLS->enmType;
    2885             Assert((unsigned)enmType < (unsigned)DeviceType_End);
    2886             if (fWanted & RT_BIT_32((unsigned)enmType))
    2887                 for (uint32_t inSet = 0; inSet < pLS->cLeds; ++inSet)
    2888                     aLEDs[enmType].u32 |= readAndClearLed(pLS->papLeds[inSet]);
    28892886        }
    28902887    }
  • trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp

    r98082 r98086  
    662662 *
    663663 * @returns Index into maLedSets.
    664  * @param   cLeds        The number of LEDs in the set.
    665  * @param   enmType      The device type.
    666  * @param   ppaSubTypes  When not NULL, subtypes for each LED and return the
    667  *                       array pointer here.
     664 * @param   cLeds       The number of LEDs in the set.
     665 * @param   fTypes      Bitmask of DeviceType_T values, e.g.
     666 *                      RT_BIT_32(DeviceType_Network).
     667 * @param   ppaSubTypes When not NULL, subtypes for each LED and return the
     668 *                      array pointer here.
    668669 */
    669 uint32_t Console::i_allocateDriverLeds(uint32_t cLeds, DeviceType_T enmType, DeviceType_T **ppaSubTypes)
     670uint32_t Console::i_allocateDriverLeds(uint32_t cLeds, uint32_t fTypes, DeviceType_T **ppaSubTypes)
    670671{
    671672    Assert(cLeds > 0);
    672673    Assert(cLeds < 1024);  /* Adjust if any driver supports >=1024 units! */
    673     Assert(enmType > DeviceType_Null && enmType < DeviceType_End);
     674    Assert(!(fTypes & (RT_BIT_32(DeviceType_Null) | ~(RT_BIT_32(DeviceType_End) - 1))));
    674675
    675676    /* Grab a LED set entry before we start allocating anything so the destructor can do the cleanups. */
     
    682683    AssertStmt(pLS->papLeds, throw E_OUTOFMEMORY);
    683684    pLS->cLeds = cLeds;
    684     pLS->enmType = enmType;
     685    pLS->fTypes = fTypes;
    685686    pLS->paSubTypes = NULL;
    686687
    687688    if (ppaSubTypes)
    688689    {
    689         *ppaSubTypes = pLS->paSubTypes = (DeviceType_T *)RTMemAlloc(sizeof(DeviceType_T) * cLeds);
     690        AssertCompile((unsigned)DeviceType_Null == 0);
     691        *ppaSubTypes = pLS->paSubTypes = (DeviceType_T *)RTMemAllocZ(sizeof(DeviceType_T) * cLeds);
    690692        AssertStmt(pLS->paSubTypes, throw E_OUTOFMEMORY);
    691         for (size_t idxSub = 0; idxSub < cLeds; ++idxSub)
    692             pLS->paSubTypes[idxSub] = DeviceType_Null;
    693693    }
    694694
     
    698698
    699699
    700 /** @todo r=bird: Drop uFirst as it's always zero? Then s/uLast/cLeds/g. */
    701 void Console::i_attachStatusDriver(PCFGMNODE pCtlInst, DeviceType_T enmType,
    702                                    uint32_t uFirst, uint32_t uLast,
    703                                    DeviceType_T **ppaSubTypes,
     700void Console::i_attachStatusDriver(PCFGMNODE pCtlInst, uint32_t fTypes, uint32_t cLeds, DeviceType_T **ppaSubTypes,
    704701                                   Console::MediumAttachmentMap *pmapMediumAttachments,
    705702                                   const char *pcszDevice, unsigned uInstance)
    706703{
    707     Assert(uFirst <= uLast);
    708704    PCFGMNODE pLunL0;
    709705    InsertConfigNode(pCtlInst,  "LUN#999", &pLunL0);
     
    711707    PCFGMNODE pCfg;
    712708    InsertConfigNode(pLunL0,    "Config", &pCfg);
    713     uint32_t const iLedSet = i_allocateDriverLeds(uLast - uFirst + 1, enmType, ppaSubTypes);
     709    uint32_t const iLedSet = i_allocateDriverLeds(cLeds, fTypes, ppaSubTypes);
    714710    InsertConfigInteger(pCfg,   "iLedSet", iLedSet);
    715711
     
    721717        InsertConfigString(pCfg,    "DeviceInstance", deviceInstance.c_str());
    722718    }
    723     InsertConfigInteger(pCfg,   "First",    uFirst);
    724     InsertConfigInteger(pCfg,   "Last",     uLast);
     719    InsertConfigInteger(pCfg,   "First",    0);
     720    InsertConfigInteger(pCfg,   "Last",     cLeds - 1);
     721}
     722
     723
     724void Console::i_attachStatusDriver(PCFGMNODE pCtlInst, DeviceType_T enmType)
     725{
     726    Assert(enmType > DeviceType_Null && enmType < DeviceType_End);
     727    i_attachStatusDriver(pCtlInst, RT_BIT_32(enmType), 1, NULL, NULL, NULL, 0);
    725728}
    726729
     
    21252128                     * Attach the status driver.
    21262129                     */
    2127                     i_attachStatusDriver(pInst, DeviceType_USB, 0, 0, NULL, NULL, NULL, 0);
     2130                    i_attachStatusDriver(pInst, DeviceType_USB);
    21282131                }
    21292132#ifdef VBOX_WITH_EHCI
     
    21432146                     * Attach the status driver.
    21442147                     */
    2145                     i_attachStatusDriver(pInst, DeviceType_USB, 0, 0, NULL, NULL, NULL, 0);
     2148                    i_attachStatusDriver(pInst, DeviceType_USB);
    21462149                }
    21472150#endif
     
    21652168                     * Attach the status driver.
    21662169                     */
    2167                     i_attachStatusDriver(pInst, DeviceType_USB, 0, 1, NULL, NULL, NULL, 0);
     2170                    i_attachStatusDriver(pInst, RT_BIT_32(DeviceType_USB), 2, NULL, NULL, NULL, 0);
    21682171                }
    21692172            } /* for every USB controller. */
     
    23582361
    23592362                    /* Attach the status driver */
    2360                     i_attachStatusDriver(pCtlInst, DeviceType_HardDisk, 0, 15, &paLedDevType,
    2361                                          &mapMediumAttachments, pszCtrlDev, ulInstance);
     2363                    i_attachStatusDriver(pCtlInst, RT_BIT_32(DeviceType_HardDisk) | RT_BIT_32(DeviceType_DVD),
     2364                                         16, &paLedDevType, &mapMediumAttachments, pszCtrlDev, ulInstance);
    23622365                    break;
    23632366                }
     
    23802383
    23812384                    /* Attach the status driver */
    2382                     i_attachStatusDriver(pCtlInst, DeviceType_HardDisk, 0, 15, &paLedDevType,
    2383                                          &mapMediumAttachments, pszCtrlDev, ulInstance);
     2385                    i_attachStatusDriver(pCtlInst, RT_BIT_32(DeviceType_HardDisk) | RT_BIT_32(DeviceType_DVD),
     2386                                         16, &paLedDevType, &mapMediumAttachments, pszCtrlDev, ulInstance);
    23842387                    break;
    23852388                }
     
    24282431
    24292432                    /* Attach the status driver */
    2430                     i_attachStatusDriver(pCtlInst, DeviceType_HardDisk, 0, cPorts - 1, &paLedDevType,
    2431                                          &mapMediumAttachments, pszCtrlDev, ulInstance);
     2433                    i_attachStatusDriver(pCtlInst, RT_BIT_32(DeviceType_HardDisk) | RT_BIT_32(DeviceType_DVD),
     2434                                         cPorts, &paLedDevType, &mapMediumAttachments, pszCtrlDev, ulInstance);
    24322435                    break;
    24332436                }
     
    24422445                    hrc = pBusMgr->assignPCIDevice("piix3ide", pCtlInst);                   H();
    24432446                    InsertConfigString(pCfg,   "Type", controllerString(enmCtrlType));
     2447
    24442448                    /* Attach the status driver */
    2445                     i_attachStatusDriver(pCtlInst, DeviceType_HardDisk, 0, 3, &paLedDevType,
    2446                                          &mapMediumAttachments, pszCtrlDev, ulInstance);
     2449                    i_attachStatusDriver(pCtlInst, RT_BIT_32(DeviceType_HardDisk) | RT_BIT_32(DeviceType_DVD),
     2450                                         4, &paLedDevType, &mapMediumAttachments, pszCtrlDev, ulInstance);
    24472451
    24482452                    /* IDE flavors */
     
    24652469
    24662470                    /* Attach the status driver */
    2467                     i_attachStatusDriver(pCtlInst, DeviceType_Floppy, 0, 1, NULL,
     2471                    i_attachStatusDriver(pCtlInst, DeviceType_Floppy, 2, NULL,
    24682472                                         &mapMediumAttachments, pszCtrlDev, ulInstance);
    24692473                    break;
     
    24922496
    24932497                    /* Attach the status driver */
    2494                     i_attachStatusDriver(pCtlInst, DeviceType_HardDisk, 0, 7, &paLedDevType,
    2495                                          &mapMediumAttachments, pszCtrlDev, ulInstance);
     2498                    i_attachStatusDriver(pCtlInst, RT_BIT_32(DeviceType_HardDisk) | RT_BIT_32(DeviceType_DVD) /*?*/,
     2499                                         8, &paLedDevType, &mapMediumAttachments, pszCtrlDev, ulInstance);
    24962500                    break;
    24972501                }
     
    25262530
    25272531                    /* Attach the status driver */
    2528                     i_attachStatusDriver(pCtlInst, DeviceType_HardDisk, 0, cPorts - 1, NULL,
    2529                                          &mapMediumAttachments, pszCtrlDev, ulInstance);
     2532                    i_attachStatusDriver(pCtlInst, RT_BIT_32(DeviceType_HardDisk),
     2533                                         cPorts, NULL, &mapMediumAttachments, pszCtrlDev, ulInstance);
    25302534                    break;
    25312535                }
     
    25412545
    25422546                    /* Attach the status driver */
    2543                     i_attachStatusDriver(pCtlInst, DeviceType_HardDisk, 0, cPorts - 1, &paLedDevType,
    2544                                          &mapMediumAttachments, pszCtrlDev, ulInstance);
     2547                    i_attachStatusDriver(pCtlInst, RT_BIT_32(DeviceType_HardDisk) | RT_BIT_32(DeviceType_DVD) /*?*/,
     2548                                         cPorts, &paLedDevType, &mapMediumAttachments, pszCtrlDev, ulInstance);
    25452549                    break;
    25462550                }
     
    28282832             * Attach the status driver.
    28292833             */
    2830             i_attachStatusDriver(pInst, DeviceType_Network, 0, 0, NULL, NULL, NULL, 0);
     2834            i_attachStatusDriver(pInst, DeviceType_Network);
    28312835
    28322836            /*
     
    30043008         * Attach the status driver.
    30053009         */
    3006         i_attachStatusDriver(pInst, DeviceType_SharedFolder, 0, 0, NULL, NULL, NULL, 0);
     3010        i_attachStatusDriver(pInst, DeviceType_SharedFolder);
    30073011
    30083012        /*
     
    42924296        InsertConfigInteger(pCfg,  "3DEnabled",            f3DEnabled);
    42934297
    4294         i_attachStatusDriver(pInst, DeviceType_Graphics3D, 0, 0, NULL, NULL, NULL, 0);
     4298        i_attachStatusDriver(pInst, DeviceType_Graphics3D);
    42954299
    42964300#ifdef VBOX_WITH_VMSVGA
     
    49144918            if (!fHotplug && !fAttachDetach)
    49154919            {
    4916                 char aszUuid[RTUUID_STR_LENGTH + 1];
    49174920                USBStorageDevice UsbMsd = USBStorageDevice();
    49184921
    4919                 memset(aszUuid, 0, sizeof(aszUuid));
     4922                UsbMsd.iPort = uInstance;
    49204923                vrc = RTUuidCreate(&UsbMsd.mUuid);
    49214924                AssertRCReturn(vrc, vrc);
    4922                 vrc = RTUuidToStr(&UsbMsd.mUuid, aszUuid, sizeof(aszUuid));
     4925
     4926                char szUuid[RTUUID_STR_LENGTH + 1];
     4927                vrc = RTUuidToStr(&UsbMsd.mUuid, szUuid, sizeof(szUuid));
    49234928                AssertRCReturn(vrc, vrc);
    4924 
    4925                 UsbMsd.iPort = uInstance;
    4926 
    4927                 InsertConfigString(pCtlInst, "UUID", aszUuid);
     4929                InsertConfigString(pCtlInst, "UUID", szUuid);
     4930
    49284931                mUSBStorageDevices.push_back(UsbMsd);
    49294932
    49304933                /** @todo No LED after hotplugging. */
    49314934                /* Attach the status driver */
    4932                 i_attachStatusDriver(pCtlInst, DeviceType_HardDisk, 0, 7, &paLedDevType,
    4933                                      &mapMediumAttachments, pcszDevice, 0);
     4935                i_attachStatusDriver(pCtlInst, RT_BIT_32(DeviceType_HardDisk),
     4936                                     8, &paLedDevType, &mapMediumAttachments, pcszDevice, 0);
    49344937            }
    49354938        }
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