Changeset 87391 in vbox for trunk/src/VBox/Main/src-client
- Timestamp:
- Jan 22, 2021 11:47:33 PM (4 years ago)
- Location:
- trunk/src/VBox/Main/src-client
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-client/ConsoleImpl.cpp
r85745 r87391 422 422 LogFlowThisFunc(("\n")); 423 423 424 RT_ZERO(mapStorageLeds); 425 RT_ZERO(mapNetworkLeds); 426 RT_ZERO(mapUSBLed); 427 RT_ZERO(mapSharedFolderLed); 428 RT_ZERO(mapCrOglLed); 429 430 for (unsigned i = 0; i < RT_ELEMENTS(maStorageDevType); ++i) 431 maStorageDevType[i] = DeviceType_Null; 424 mcLedSets = 0; 425 RT_ZERO(maLedSets); 432 426 433 427 MYVMM2USERMETHODS *pVmm2UserMethods = (MYVMM2USERMETHODS *)RTMemAllocZ(sizeof(*mpVmm2UserMethods) + sizeof(Console *)); … … 822 816 unconst(mptrExtPackManager).setNull(); 823 817 #endif 818 819 /* Release memory held by the LED sets. */ 820 for (size_t idxSet = 0; idxSet < mcLedSets; idxSet++) 821 { 822 RTMemFree(maLedSets[idxSet].papLeds); 823 RTMemFree(maLedSets[idxSet].paSubTypes); 824 maLedSets[idxSet].papLeds = NULL; 825 maLedSets[idxSet].paSubTypes = NULL; 826 } 827 mcLedSets = 0; 824 828 825 829 LogFlowThisFuncLeave(); … … 2689 2693 2690 2694 /** read the value of a LED. */ 2691 inline uint32_treadAndClearLed(PPDMLED pLed)2695 DECLINLINE(uint32_t) readAndClearLed(PPDMLED pLed) 2692 2696 { 2693 2697 if (!pLed) … … 2706 2710 */ 2707 2711 2712 std::vector<bool> aWanted; 2713 std::vector<PDMLEDCORE> aLED; 2714 DeviceType_T maxWanted = (DeviceType_T) 0; 2715 DeviceType_T enmType; 2716 2717 /* Make a roadmap of which DeviceType_T LED types are wanted */ 2718 for (size_t iType = 0; iType < aType.size(); ++iType) 2719 { 2720 enmType = aType[iType]; 2721 if (enmType > maxWanted) 2722 { 2723 maxWanted = enmType; 2724 aWanted.resize(maxWanted + 1); 2725 } 2726 aWanted[enmType] = true; 2727 } 2728 aLED.resize(maxWanted + 1); 2729 2730 /* Collect all the LEDs in a single sweep through all drivers' sets */ 2731 for (uint32_t idxSet = 0; idxSet < mcLedSets; ++idxSet) 2732 { 2733 /* Look inside this driver's set of LEDs */ 2734 PLEDSET pLS = &maLedSets[idxSet]; 2735 2736 /* Multi-type drivers (e.g. SCSI) have a subtype array which must be matched. */ 2737 if (pLS->paSubTypes) 2738 { 2739 for (uint32_t inSet = 0; inSet < pLS->cLeds; ++inSet) 2740 { 2741 enmType = pLS->paSubTypes[inSet]; 2742 if (enmType < maxWanted && aWanted[enmType]) 2743 aLED[enmType].u32 |= readAndClearLed(pLS->papLeds[inSet]); 2744 } 2745 } 2746 /* Single-type drivers (e.g. floppy) have the type in ->enmType */ 2747 else 2748 { 2749 enmType = pLS->enmType; 2750 if (enmType < maxWanted && aWanted[enmType]) 2751 for (uint32_t inSet = 0; inSet < pLS->cLeds; ++inSet) 2752 aLED[enmType].u32 |= readAndClearLed(pLS->papLeds[inSet]); 2753 } 2754 } 2755 2708 2756 aActivity.resize(aType.size()); 2709 2710 size_t iType; 2711 for (iType = 0; iType < aType.size(); ++iType) 2712 { 2713 /* Get LED array to read */ 2714 PDMLEDCORE SumLed = {0}; 2715 switch (aType[iType]) 2716 { 2717 case DeviceType_Floppy: 2718 case DeviceType_DVD: 2719 case DeviceType_HardDisk: 2720 { 2721 for (unsigned i = 0; i < RT_ELEMENTS(mapStorageLeds); ++i) 2722 if (maStorageDevType[i] == aType[iType]) 2723 SumLed.u32 |= readAndClearLed(mapStorageLeds[i]); 2724 break; 2725 } 2726 2727 case DeviceType_Network: 2728 { 2729 for (unsigned i = 0; i < RT_ELEMENTS(mapNetworkLeds); ++i) 2730 SumLed.u32 |= readAndClearLed(mapNetworkLeds[i]); 2731 break; 2732 } 2733 2734 case DeviceType_USB: 2735 { 2736 for (unsigned i = 0; i < RT_ELEMENTS(mapUSBLed); ++i) 2737 SumLed.u32 |= readAndClearLed(mapUSBLed[i]); 2738 break; 2739 } 2740 2741 case DeviceType_SharedFolder: 2742 { 2743 SumLed.u32 |= readAndClearLed(mapSharedFolderLed); 2744 break; 2745 } 2746 2747 case DeviceType_Graphics3D: 2748 { 2749 SumLed.u32 |= readAndClearLed(mapCrOglLed); 2750 break; 2751 } 2752 2753 default: 2754 return setError(E_INVALIDARG, tr("Invalid device type: %d"), aType[iType]); 2755 } 2756 2757 for (size_t iType = 0; iType < aActivity.size(); ++iType) 2758 { 2757 2759 /* Compose the result */ 2758 switch ( SumLed.u32 & (PDMLED_READING | PDMLED_WRITING))2760 switch (aLED[aType[iType]].u32 & (PDMLED_READING | PDMLED_WRITING)) 2759 2761 { 2760 2762 case 0: … … 10864 10866 PPDMLED pLed; 10865 10867 int rc = pThis->pLedPorts->pfnQueryStatusLed(pThis->pLedPorts, iLUN, &pLed); 10868 /* 10869 * pLed now points directly to the per-unit struct PDMLED field 10870 * inside the target device struct owned by the hardware driver. 10871 */ 10866 10872 if (RT_FAILURE(rc)) 10867 10873 pLed = NULL; 10868 10874 ASMAtomicWritePtr(&pThis->papLeds[iLUN - pThis->iFirstLUN], pLed); 10875 /* 10876 * papLeds[] points to the struct PDMLED of each of this driver's 10877 * units. The entries are initialized here, called out of a loop 10878 * in Console::i_drvStatus_Construct(), which previously called 10879 * Console::i_attachStatusDriver() to allocate the array itself. 10880 * 10881 * The arrays (and thus individual LEDs) are eventually read out 10882 * by Console::getDeviceActivity(), which is itself called from 10883 * src/VBox/Frontends/VirtualBox/src/runtime/UIIndicatorsPool.cpp 10884 */ 10869 10885 Log(("drvStatus_UnitChanged: iLUN=%d pLed=%p\n", iLUN, pLed)); 10870 10886 } -
trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp
r87374 r87391 653 653 654 654 655 void Console::i_attachStatusDriver(PCFGMNODE pCtlInst, PPDMLED *papLeds, 656 uint64_t uFirst, uint64_t uLast, 655 /** 656 * Allocate a set of LEDs. 657 * 658 * This grabs a maLedSets entry and populates it with @a cLeds. 659 * 660 * @param cLeds The number of LEDs in the set. 661 * @param enmType The device type. 662 * @param ppSubTypes When not NULL, subtypes for each LED and return the array pointer here. 663 * @throws HRESULT or ConfigError on trouble 664 */ 665 Console::PLEDSET Console::i_allocateDriverLeds(uint32_t cLeds, DeviceType_T enmType, DeviceType_T **ppaSubTypes) 666 { 667 Assert(cLeds > 0); 668 Assert(cLeds < 1024); /* Adjust if any driver supports >=1024 units! */ 669 670 /* Grab a LED set entry before we start allocating anything so the destructor can do the cleanups. */ 671 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); /* Caller should have this already. Need protect mcLedSets check and update. */ 672 AssertStmt(mcLedSets < RT_ELEMENTS(maLedSets), 673 throw ConfigError("AllocateDriverPapLeds", VERR_OUT_OF_RANGE, "Too many LED sets")); 674 PLEDSET pLS = &maLedSets[mcLedSets++]; 675 pLS->papLeds = (PPDMLED *)RTMemAllocZ(sizeof(PPDMLED) * cLeds); 676 AssertStmt(pLS->papLeds, throw E_OUTOFMEMORY); 677 pLS->cLeds = cLeds; 678 pLS->enmType = enmType; 679 pLS->paSubTypes = NULL; 680 681 if (ppaSubTypes) 682 { 683 *ppaSubTypes = pLS->paSubTypes = (DeviceType_T *)RTMemAlloc(sizeof(DeviceType_T) * cLeds); 684 AssertStmt(pLS->paSubTypes, throw E_OUTOFMEMORY); 685 for (size_t idxSub = 0; idxSub < cLeds; ++idxSub) 686 pLS->paSubTypes[idxSub] = DeviceType_Null; 687 } 688 689 LogRel(("mcLedSets = %d, RT_ELEMENTS(maLedSets) = %d\n", mcLedSets, RT_ELEMENTS(maLedSets))); 690 return pLS; 691 } 692 693 694 /** @todo r=bird: Drop uFirst as it's always zero? Then s/uLast/cLeds/g. */ 695 void Console::i_attachStatusDriver(PCFGMNODE pCtlInst, DeviceType_T enmType, 696 uint32_t uFirst, uint32_t uLast, 697 DeviceType_T **ppaSubTypes, 657 698 Console::MediumAttachmentMap *pmapMediumAttachments, 658 699 const char *pcszDevice, unsigned uInstance) 659 700 { 701 Assert(uFirst <= uLast); 660 702 PCFGMNODE pLunL0, pCfg; 661 703 InsertConfigNode(pCtlInst, "LUN#999", &pLunL0); 662 704 InsertConfigString(pLunL0, "Driver", "MainStatus"); 663 705 InsertConfigNode(pLunL0, "Config", &pCfg); 664 InsertConfigInteger(pCfg, "papLeds", (uintptr_t)papLeds); 706 PLEDSET pLS = i_allocateDriverLeds(uLast - uFirst + 1, enmType, ppaSubTypes); 707 InsertConfigInteger(pCfg, "papLeds", (uintptr_t)pLS->papLeds); 665 708 if (pmapMediumAttachments) 666 709 { … … 1988 2031 * Attach the status driver. 1989 2032 */ 1990 i_attachStatusDriver(pInst, &mapUSBLed[0], 0, 0, NULL, NULL, 0);2033 i_attachStatusDriver(pInst, DeviceType_USB, 0, 0, NULL, NULL, NULL, 0); 1991 2034 } 1992 2035 #ifdef VBOX_WITH_EHCI … … 2019 2062 * Attach the status driver. 2020 2063 */ 2021 i_attachStatusDriver(pInst, &mapUSBLed[1], 0, 0, NULL, NULL, 0);2064 i_attachStatusDriver(pInst, DeviceType_USB, 0, 0, NULL, NULL, NULL, 0); 2022 2065 } 2023 2066 # ifdef VBOX_WITH_EXTPACK … … 2071 2114 * Attach the status driver. 2072 2115 */ 2073 i_attachStatusDriver(pInst, &mapUSBLed[0], 0, 1, NULL, NULL, 0);2116 i_attachStatusDriver(pInst, DeviceType_USB, 0, 1, NULL, NULL, NULL, 0); 2074 2117 } 2075 2118 # ifdef VBOX_WITH_EXTPACK … … 2272 2315 2273 2316 /* Attach the status driver */ 2274 Assert(cLedScsi >= 16); 2275 i_attachStatusDriver(pCtlInst, &mapStorageLeds[iLedScsi], 0, 15, 2276 &mapMediumAttachments, pszCtrlDev, ulInstance); 2277 paLedDevType = &maStorageDevType[iLedScsi]; 2317 i_attachStatusDriver(pCtlInst, DeviceType_HardDisk, 0, 15, &paLedDevType, 2318 &mapMediumAttachments, pszCtrlDev, ulInstance); 2278 2319 break; 2279 2320 } … … 2296 2337 2297 2338 /* Attach the status driver */ 2298 Assert(cLedScsi >= 16); 2299 i_attachStatusDriver(pCtlInst, &mapStorageLeds[iLedScsi], 0, 15, 2300 &mapMediumAttachments, pszCtrlDev, ulInstance); 2301 paLedDevType = &maStorageDevType[iLedScsi]; 2339 i_attachStatusDriver(pCtlInst, DeviceType_HardDisk, 0, 15, &paLedDevType, 2340 &mapMediumAttachments, pszCtrlDev, ulInstance); 2302 2341 break; 2303 2342 } … … 2346 2385 2347 2386 /* Attach the status driver */ 2348 AssertRelease(cPorts <= cLedSata); 2349 i_attachStatusDriver(pCtlInst, &mapStorageLeds[iLedSata], 0, cPorts - 1, 2350 &mapMediumAttachments, pszCtrlDev, ulInstance); 2351 paLedDevType = &maStorageDevType[iLedSata]; 2387 i_attachStatusDriver(pCtlInst, DeviceType_HardDisk, 0, cPorts - 1, &paLedDevType, 2388 &mapMediumAttachments, pszCtrlDev, ulInstance); 2352 2389 break; 2353 2390 } … … 2363 2400 InsertConfigString(pCfg, "Type", controllerString(enmCtrlType)); 2364 2401 /* Attach the status driver */ 2365 Assert(cLedIde >= 4); 2366 i_attachStatusDriver(pCtlInst, &mapStorageLeds[iLedIde], 0, 3, 2367 &mapMediumAttachments, pszCtrlDev, ulInstance); 2368 paLedDevType = &maStorageDevType[iLedIde]; 2402 i_attachStatusDriver(pCtlInst, DeviceType_HardDisk, 0, 3, &paLedDevType, 2403 &mapMediumAttachments, pszCtrlDev, ulInstance); 2369 2404 2370 2405 /* IDE flavors */ … … 2387 2422 2388 2423 /* Attach the status driver */ 2389 Assert(cLedFloppy >= 2); 2390 i_attachStatusDriver(pCtlInst, &mapStorageLeds[iLedFloppy], 0, 1, 2391 &mapMediumAttachments, pszCtrlDev, ulInstance); 2392 paLedDevType = &maStorageDevType[iLedFloppy]; 2424 i_attachStatusDriver(pCtlInst, DeviceType_Floppy, 0, 1, NULL, 2425 &mapMediumAttachments, pszCtrlDev, ulInstance); 2393 2426 break; 2394 2427 } … … 2416 2449 2417 2450 /* Attach the status driver */ 2418 Assert(cLedSas >= 8); 2419 i_attachStatusDriver(pCtlInst, &mapStorageLeds[iLedSas], 0, 7, 2420 &mapMediumAttachments, pszCtrlDev, ulInstance); 2421 paLedDevType = &maStorageDevType[iLedSas]; 2451 i_attachStatusDriver(pCtlInst, DeviceType_HardDisk, 0, 7, &paLedDevType, 2452 &mapMediumAttachments, pszCtrlDev, ulInstance); 2422 2453 break; 2423 2454 } … … 2452 2483 2453 2484 /* Attach the status driver */ 2454 AssertRelease(cPorts <= cLedSata); 2455 i_attachStatusDriver(pCtlInst, &mapStorageLeds[iLedNvme], 0, cPorts - 1, 2456 &mapMediumAttachments, pszCtrlDev, ulInstance); 2457 paLedDevType = &maStorageDevType[iLedNvme]; 2485 i_attachStatusDriver(pCtlInst, DeviceType_HardDisk, 0, cPorts - 1, NULL, 2486 &mapMediumAttachments, pszCtrlDev, ulInstance); 2458 2487 break; 2459 2488 } … … 2469 2498 2470 2499 /* Attach the status driver */ 2471 AssertRelease(cPorts <= cLedSata); 2472 i_attachStatusDriver(pCtlInst, &mapStorageLeds[iLedVirtio], 0, cPorts - 1, 2473 &mapMediumAttachments, pszCtrlDev, ulInstance); 2474 paLedDevType = &maStorageDevType[iLedVirtio]; 2500 i_attachStatusDriver(pCtlInst, DeviceType_HardDisk, 0, cPorts - 1, &paLedDevType, 2501 &mapMediumAttachments, pszCtrlDev, ulInstance); 2475 2502 break; 2476 2503 } … … 2737 2764 * Attach the status driver. 2738 2765 */ 2739 i_attachStatusDriver(pInst, &mapNetworkLeds[uInstance], 0, 0, NULL, NULL, 0);2766 i_attachStatusDriver(pInst, DeviceType_Network, 0, 0, NULL, NULL, NULL, 0); 2740 2767 2741 2768 /* … … 2912 2939 * Attach the status driver. 2913 2940 */ 2914 i_attachStatusDriver(pInst, &mapSharedFolderLed, 0, 0, NULL, NULL, 0);2941 i_attachStatusDriver(pInst, DeviceType_SharedFolder, 0, 0, NULL, NULL, NULL, 0); 2915 2942 2916 2943 /* … … 3947 3974 InsertConfigInteger(pCfg, "3DEnabled", f3DEnabled); 3948 3975 3949 i_attachStatusDriver(pInst, &mapCrOglLed, 0, 0, NULL, NULL, 0);3976 i_attachStatusDriver(pInst, DeviceType_Graphics3D, 0, 0, NULL, NULL, NULL, 0); 3950 3977 3951 3978 #ifdef VBOX_WITH_VMSVGA … … 4584 4611 /** @todo No LED after hotplugging. */ 4585 4612 /* Attach the status driver */ 4586 Assert(cLedUsb >= 8); 4587 i_attachStatusDriver(pCtlInst, &mapStorageLeds[iLedUsb], 0, 7, 4588 &mapMediumAttachments, pcszDevice, 0); 4589 paLedDevType = &maStorageDevType[iLedUsb]; 4613 i_attachStatusDriver(pCtlInst, DeviceType_HardDisk, 0, 7, &paLedDevType, 4614 &mapMediumAttachments, pcszDevice, 0); 4590 4615 } 4591 4616 }
Note:
See TracChangeset
for help on using the changeset viewer.