Changeset 98086 in vbox
- Timestamp:
- Jan 15, 2023 1:14:57 PM (23 months ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/ConsoleImpl.h
r96888 r98086 810 810 typedef struct LEDSET *PLEDSET; 811 811 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, 816 815 Console::MediumAttachmentMap *pmapMediumAttachments, 817 816 const char *pcszDevice, unsigned uInstance); … … 1074 1073 struct LEDSET 1075 1074 { 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. */ 1080 1079 } maLedSets[32]; 1081 1080 /** @} */ -
trunk/src/VBox/Main/src-client/ConsoleImpl.cpp
r98085 r98086 2857 2857 PDMLEDCORE aLEDs[DeviceType_End] = { {0} }; 2858 2858 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: */ 2862 2863 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 2874 2881 { 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]); 2879 2885 } 2880 }2881 /* Single-type drivers (e.g. floppy) have the type in ->enmType */2882 else2883 {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]);2889 2886 } 2890 2887 } -
trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp
r98082 r98086 662 662 * 663 663 * @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. 668 669 */ 669 uint32_t Console::i_allocateDriverLeds(uint32_t cLeds, DeviceType_T enmType, DeviceType_T **ppaSubTypes)670 uint32_t Console::i_allocateDriverLeds(uint32_t cLeds, uint32_t fTypes, DeviceType_T **ppaSubTypes) 670 671 { 671 672 Assert(cLeds > 0); 672 673 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)))); 674 675 675 676 /* Grab a LED set entry before we start allocating anything so the destructor can do the cleanups. */ … … 682 683 AssertStmt(pLS->papLeds, throw E_OUTOFMEMORY); 683 684 pLS->cLeds = cLeds; 684 pLS-> enmType = enmType;685 pLS->fTypes = fTypes; 685 686 pLS->paSubTypes = NULL; 686 687 687 688 if (ppaSubTypes) 688 689 { 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); 690 692 AssertStmt(pLS->paSubTypes, throw E_OUTOFMEMORY); 691 for (size_t idxSub = 0; idxSub < cLeds; ++idxSub)692 pLS->paSubTypes[idxSub] = DeviceType_Null;693 693 } 694 694 … … 698 698 699 699 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, 700 void Console::i_attachStatusDriver(PCFGMNODE pCtlInst, uint32_t fTypes, uint32_t cLeds, DeviceType_T **ppaSubTypes, 704 701 Console::MediumAttachmentMap *pmapMediumAttachments, 705 702 const char *pcszDevice, unsigned uInstance) 706 703 { 707 Assert(uFirst <= uLast);708 704 PCFGMNODE pLunL0; 709 705 InsertConfigNode(pCtlInst, "LUN#999", &pLunL0); … … 711 707 PCFGMNODE pCfg; 712 708 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); 714 710 InsertConfigInteger(pCfg, "iLedSet", iLedSet); 715 711 … … 721 717 InsertConfigString(pCfg, "DeviceInstance", deviceInstance.c_str()); 722 718 } 723 InsertConfigInteger(pCfg, "First", uFirst); 724 InsertConfigInteger(pCfg, "Last", uLast); 719 InsertConfigInteger(pCfg, "First", 0); 720 InsertConfigInteger(pCfg, "Last", cLeds - 1); 721 } 722 723 724 void 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); 725 728 } 726 729 … … 2125 2128 * Attach the status driver. 2126 2129 */ 2127 i_attachStatusDriver(pInst, DeviceType_USB , 0, 0, NULL, NULL, NULL, 0);2130 i_attachStatusDriver(pInst, DeviceType_USB); 2128 2131 } 2129 2132 #ifdef VBOX_WITH_EHCI … … 2143 2146 * Attach the status driver. 2144 2147 */ 2145 i_attachStatusDriver(pInst, DeviceType_USB , 0, 0, NULL, NULL, NULL, 0);2148 i_attachStatusDriver(pInst, DeviceType_USB); 2146 2149 } 2147 2150 #endif … … 2165 2168 * Attach the status driver. 2166 2169 */ 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); 2168 2171 } 2169 2172 } /* for every USB controller. */ … … 2358 2361 2359 2362 /* 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); 2362 2365 break; 2363 2366 } … … 2380 2383 2381 2384 /* 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); 2384 2387 break; 2385 2388 } … … 2428 2431 2429 2432 /* 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); 2432 2435 break; 2433 2436 } … … 2442 2445 hrc = pBusMgr->assignPCIDevice("piix3ide", pCtlInst); H(); 2443 2446 InsertConfigString(pCfg, "Type", controllerString(enmCtrlType)); 2447 2444 2448 /* 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); 2447 2451 2448 2452 /* IDE flavors */ … … 2465 2469 2466 2470 /* Attach the status driver */ 2467 i_attachStatusDriver(pCtlInst, DeviceType_Floppy, 0, 1, NULL,2471 i_attachStatusDriver(pCtlInst, DeviceType_Floppy, 2, NULL, 2468 2472 &mapMediumAttachments, pszCtrlDev, ulInstance); 2469 2473 break; … … 2492 2496 2493 2497 /* 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); 2496 2500 break; 2497 2501 } … … 2526 2530 2527 2531 /* 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); 2530 2534 break; 2531 2535 } … … 2541 2545 2542 2546 /* 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); 2545 2549 break; 2546 2550 } … … 2828 2832 * Attach the status driver. 2829 2833 */ 2830 i_attachStatusDriver(pInst, DeviceType_Network , 0, 0, NULL, NULL, NULL, 0);2834 i_attachStatusDriver(pInst, DeviceType_Network); 2831 2835 2832 2836 /* … … 3004 3008 * Attach the status driver. 3005 3009 */ 3006 i_attachStatusDriver(pInst, DeviceType_SharedFolder , 0, 0, NULL, NULL, NULL, 0);3010 i_attachStatusDriver(pInst, DeviceType_SharedFolder); 3007 3011 3008 3012 /* … … 4292 4296 InsertConfigInteger(pCfg, "3DEnabled", f3DEnabled); 4293 4297 4294 i_attachStatusDriver(pInst, DeviceType_Graphics3D , 0, 0, NULL, NULL, NULL, 0);4298 i_attachStatusDriver(pInst, DeviceType_Graphics3D); 4295 4299 4296 4300 #ifdef VBOX_WITH_VMSVGA … … 4914 4918 if (!fHotplug && !fAttachDetach) 4915 4919 { 4916 char aszUuid[RTUUID_STR_LENGTH + 1];4917 4920 USBStorageDevice UsbMsd = USBStorageDevice(); 4918 4921 4919 memset(aszUuid, 0, sizeof(aszUuid));4922 UsbMsd.iPort = uInstance; 4920 4923 vrc = RTUuidCreate(&UsbMsd.mUuid); 4921 4924 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)); 4923 4928 AssertRCReturn(vrc, vrc); 4924 4925 UsbMsd.iPort = uInstance; 4926 4927 InsertConfigString(pCtlInst, "UUID", aszUuid); 4929 InsertConfigString(pCtlInst, "UUID", szUuid); 4930 4928 4931 mUSBStorageDevices.push_back(UsbMsd); 4929 4932 4930 4933 /** @todo No LED after hotplugging. */ 4931 4934 /* 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); 4934 4937 } 4935 4938 }
Note:
See TracChangeset
for help on using the changeset viewer.