VirtualBox

Changeset 98091 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
Jan 16, 2023 10:18:24 AM (2 years ago)
Author:
vboxsync
Message:

Main/Console: LED related cleanups. bugref:9892

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

Legend:

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

    r98088 r98091  
    809809    struct LEDSET;
    810810    typedef struct LEDSET *PLEDSET;
    811     PPDMLED *i_getLedSet(uint32_t iLedSet);
     811    PPDMLED volatile *i_getLedSet(uint32_t iLedSet);
    812812    uint32_t i_allocateDriverLeds(uint32_t cLeds, uint32_t fTypes, DeviceType_T **ppSubTypes);
    813813    void i_attachStatusDriver(PCFGMNODE pCtlInst, DeviceType_T enmType);
     
    10691069     * @{ */
    10701070    /** Read/write lock separating LED allocations (write) from queries (read). */
    1071     RWLockHandle mLedLock;
     1071    RWLockHandle            mLedLock;
    10721072    /** Number of LED sets in use in maLedSets. */
    1073     uint32_t          mcLedSets;
     1073    uint32_t                mcLedSets;
    10741074    /** LED sets. */
    10751075    struct LEDSET
    10761076    {
    1077         PPDMLED        *papLeds;
    1078         uint32_t        cLeds;
    1079         uint32_t        fTypes;     /**< Bitmask of possible DeviceType_T values (e.g. RT_BIT_32(DeviceType_Network)). */
    1080         DeviceType_T   *paSubTypes; /**< Optionally, device types for each individual LED. Runs parallel to papLeds. */
    1081     }                 maLedSets[32];
     1077        /** Bitmask of possible DeviceType_T values (e.g. RT_BIT_32(DeviceType_Network)). */
     1078        uint32_t            fTypes;
     1079        /** Number of LEDs.   */
     1080        uint32_t            cLeds;
     1081        /** Array of PDMLED pointers.  The pointers in the array can be changed at any
     1082         *  time by Console::i_drvStatus_UnitChanged(). */
     1083        PPDMLED volatile   *papLeds;
     1084        /** Optionally, device types for each individual LED. Runs parallel to papLeds. */
     1085        DeviceType_T       *paSubTypes;
     1086    } maLedSets[32];
    10821087    /** @} */
    10831088
  • trunk/src/VBox/Main/src-client/ConsoleImpl.cpp

    r98088 r98091  
    883883    for (size_t idxSet = 0; idxSet < mcLedSets; idxSet++)
    884884    {
    885         RTMemFree(maLedSets[idxSet].papLeds);
     885        RTMemFree((void *)maLedSets[idxSet].papLeds);
    886886        maLedSets[idxSet].papLeds = NULL;
    887887        maLedSets[idxSet].paSubTypes = NULL;
     
    28622862            if (pLS->fTypes & fWanted)
    28632863            {
    2864                 uint32_t const        cLeds      = pLS->cLeds;
    2865                 PPDMLED const * const papSrcLeds = pLS->papLeds;
     2864                uint32_t const           cLeds      = pLS->cLeds;
     2865                PPDMLED volatile * const papSrcLeds = pLS->papLeds;
    28662866
    28672867                /* Multi-type drivers (e.g. SCSI) have a subtype array which must be matched. */
     
    1151511515 * @param   iLedSet      Index of LED set to fetch
    1151611516 */
    11517 PPDMLED *
     11517PPDMLED volatile *
    1151811518Console::i_getLedSet(uint32_t iLedSet)
    1151911519{
     
    1168111681    PPDMILEDPORTS       pLedPorts;
    1168211682    /** Pointer to the array of LED pointers. */
    11683     PPDMLED            *papLeds;
     11683    PPDMLED volatile   *papLeds;
    1168411684    /** The unit number corresponding to the first entry in the LED array. */
    1168511685    uint32_t            iFirstLUN;
     
    1169711697    /** Pointer to the Console object, for driver triggered activities. */
    1169811698    Console             *pConsole;
    11699 } DRVMAINSTATUS, *PDRVMAINSTATUS;
     11699} DRVMAINSTATUS;
     11700/** Pointer the instance data for a Main status driver. */
     11701typedef DRVMAINSTATUS *PDRVMAINSTATUS;
    1170011702
    1170111703
     
    1171411716    if (iLUN >= pThis->iFirstLUN && iLUN <= pThis->iLastLUN)
    1171511717    {
     11718        /*
     11719         * Query the pointer to the PDMLED field inside the target device
     11720         * structure (owned by the virtual hardware device).
     11721         */
    1171611722        PPDMLED pLed;
    1171711723        int rc = pThis->pLedPorts->pfnQueryStatusLed(pThis->pLedPorts, iLUN, &pLed);
    11718         /*
    11719          * pLed now points directly to the per-unit struct PDMLED field
    11720          * inside the target device struct owned by the hardware driver.
    11721          */
    1172211724        if (RT_FAILURE(rc))
    1172311725            pLed = NULL;
    11724         ASMAtomicWritePtr(&pThis->papLeds[iLUN - pThis->iFirstLUN], pLed);
     11726
    1172511727        /*
     11728         * Update the corresponding papLeds[] entry.
     11729         *
    1172611730         * papLeds[] points to the struct PDMLED of each of this driver's
    1172711731         * units.  The entries are initialized here, called out of a loop
     
    1173311737         * src/VBox/Frontends/VirtualBox/src/runtime/UIIndicatorsPool.cpp
    1173411738         */
     11739        /** @todo acquire Console::mLedLock here in exclusive mode? */
     11740        ASMAtomicWritePtr(&pThis->papLeds[iLUN - pThis->iFirstLUN], pLed);
    1173511741        Log(("drvStatus_UnitChanged: iLUN=%d pLed=%p\n", iLUN, pLed));
    1173611742    }
  • trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp

    r98088 r98091  
    676676    /* Preallocate the arrays we need, bunching them together. */
    677677    AssertCompile((unsigned)DeviceType_Null == 0);
    678     PPDMLED *papLeds = (PPDMLED *)RTMemAllocZ((sizeof(PPDMLED) + (ppaSubTypes ? sizeof(**ppaSubTypes) : 0)) * cLeds);
     678    PPDMLED volatile *papLeds = (PPDMLED volatile *)RTMemAllocZ(  (sizeof(PPDMLED) + (ppaSubTypes ? sizeof(**ppaSubTypes) : 0))
     679                                                                * cLeds);
    679680    AssertStmt(papLeds, throw E_OUTOFMEMORY);
    680681
     
    701702    }
    702703
    703     RTMemFree(papLeds);
     704    RTMemFree((void *)papLeds);
    704705    AssertFailed();
    705706    throw ConfigError("AllocateDriverPapLeds", VERR_OUT_OF_RANGE, "Too many LED sets");
     
    707708
    708709
     710/**
     711 * @throws ConfigError and std::bad_alloc.
     712 */
    709713void Console::i_attachStatusDriver(PCFGMNODE pCtlInst, uint32_t fTypes, uint32_t cLeds, DeviceType_T **ppaSubTypes,
    710714                                   Console::MediumAttachmentMap *pmapMediumAttachments,
     
    731735
    732736
     737/**
     738 * @throws ConfigError and std::bad_alloc.
     739 */
    733740void Console::i_attachStatusDriver(PCFGMNODE pCtlInst, DeviceType_T enmType)
    734741{
     
    48804887        LONG lPort;
    48814888        hrc = pMediumAtt->COMGETTER(Port)(&lPort);                                          H();
    4882         DeviceType_T lType;
    4883         hrc = pMediumAtt->COMGETTER(Type)(&lType);                                          H();
     4889        DeviceType_T enmType;
     4890        hrc = pMediumAtt->COMGETTER(Type)(&enmType);                                        H();
    48844891        BOOL fNonRotational;
    48854892        hrc = pMediumAtt->COMGETTER(NonRotational)(&fNonRotational);                        H();
     
    48874894        hrc = pMediumAtt->COMGETTER(Discard)(&fDiscard);                                    H();
    48884895
    4889         if (lType == DeviceType_DVD)
     4896        if (enmType == DeviceType_DVD)
    48904897            fInsertDiskIntegrityDrv = false;
    48914898
     
    49484955
    49494956        vrc = i_removeMediumDriverFromVm(pCtlInst, pcszDevice, uInstance, uLUN, enmBus, fAttachDetach,
    4950                                          fHotplug, fForceUnmount, pUVM, pVMM, lType, &pLunL0);
     4957                                         fHotplug, fForceUnmount, pUVM, pVMM, enmType, &pLunL0);
    49514958        if (RT_FAILURE(vrc))
    49524959            return vrc;
     
    49654972         *    taking an online snapshot!
    49664973         */
    4967         if (   lType == DeviceType_HardDisk
     4974        if (   enmType == DeviceType_HardDisk
    49684975            && (   aMachineState == MachineState_Starting
    49694976                || aMachineState == MachineState_Restoring))
     
    49794986            BOOL fHostDrive;
    49804987            hrc = ptrMedium->COMGETTER(HostDrive)(&fHostDrive);                             H();
    4981             if (  (   lType == DeviceType_DVD
    4982                    || lType == DeviceType_Floppy)
     4988            if (  (   enmType == DeviceType_DVD
     4989                   || enmType == DeviceType_Floppy)
    49834990                && !fHostDrive)
    49844991            {
     
    49924999                (void)RTFsQueryType(strFile.c_str(), &enmFsTypeFile);
    49935000                LogRel(("File system of '%s' (%s) is %s\n",
    4994                        strFile.c_str(), lType == DeviceType_DVD ? "DVD" : "Floppy", RTFsTypeName(enmFsTypeFile)));
     5001                       strFile.c_str(), enmType == DeviceType_DVD ? "DVD" : "Floppy", RTFsTypeName(enmFsTypeFile)));
    49955002            }
    49965003
     
    50165023        if (   (fHotplug || !fAttachDetach)
    50175024            && (   (enmBus == StorageBus_SCSI || enmBus == StorageBus_SAS || enmBus == StorageBus_USB || enmBus == StorageBus_VirtioSCSI)
    5018                 || (enmBus == StorageBus_SATA && lType == DeviceType_DVD && !fPassthrough)))
     5025                || (enmBus == StorageBus_SATA && enmType == DeviceType_DVD && !fPassthrough)))
    50195026        {
    50205027            InsertConfigString(pLunL0, "Driver", "SCSI");
     
    50245031        vrc = i_configMedium(pLunL0,
    50255032                             !!fPassthrough,
    5026                              lType,
     5033                             enmType,
    50275034                             fUseHostIOCache,
    50285035                             fBuiltinIOCache,
     
    50605067            else if (   !fHotplug
    50615068                     && (   (enmBus == StorageBus_SAS || enmBus == StorageBus_SCSI || enmBus == StorageBus_VirtioSCSI)
    5062                          || (enmBus == StorageBus_SATA && lType == DeviceType_DVD)))
     5069                         || (enmBus == StorageBus_SATA && enmType == DeviceType_DVD)))
    50635070                vrc = pVMM->pfnPDMR3DriverAttach(pUVM, pcszDevice, uInstance, uLUN,
    50645071                                                 fHotplug ? 0 : PDM_TACH_FLAGS_NOT_HOT_PLUG, NULL /*ppBase*/);
     
    50905097
    50915098        if (paLedDevType)
    5092             paLedDevType[uLUN] = lType;
     5099            paLedDevType[uLUN] = enmType;
    50935100
    50945101        /* Dump the changed LUN if possible, dump the complete device otherwise */
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