VirtualBox

Changeset 47401 in vbox for trunk/src/VBox/Main/src-client


Ignore:
Timestamp:
Jul 25, 2013 7:12:24 PM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
87551
Message:

Main,Frontends: Second step of USB controller rework. There is one controller instance for every USB controller now. Adapt frontends and testsuite to work with the changed API

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp

    r47342 r47401  
    22662266
    22672267        /*
    2268          * The USB Controller.
     2268         * The USB Controllers.
    22692269         */
    2270         ComPtr<IUSBController> USBCtlPtr;
    2271         hrc = pMachine->COMGETTER(USBController)(USBCtlPtr.asOutParam());
    2272         if (USBCtlPtr)
    2273         {
    2274             BOOL fOhciEnabled;
    2275             hrc = USBCtlPtr->COMGETTER(Enabled)(&fOhciEnabled);                             H();
    2276             if (fOhciEnabled)
    2277             {
    2278                 InsertConfigNode(pDevices, "usb-ohci", &pDev);
    2279                 InsertConfigNode(pDev,     "0", &pInst);
    2280                 InsertConfigNode(pInst,    "Config", &pCfg);
    2281                 InsertConfigInteger(pInst, "Trusted",              1); /* boolean */
    2282                 hrc = pBusMgr->assignPCIDevice("usb-ohci", pInst);                          H();
    2283                 InsertConfigNode(pInst,    "LUN#0", &pLunL0);
    2284                 InsertConfigString(pLunL0, "Driver",               "VUSBRootHub");
    2285                 InsertConfigNode(pLunL0,   "Config", &pCfg);
    2286 
    2287                 /*
    2288                  * Attach the status driver.
    2289                  */
    2290                 attachStatusDriver(pInst, &mapUSBLed[0], 0, 0, NULL, NULL, 0);
    2291 
    2292                 mfVMHasUsbController = true;
     2270        com::SafeIfaceArray<IUSBController> usbCtrls;
     2271        hrc = pMachine->COMGETTER(USBControllers)(ComSafeArrayAsOutParam(usbCtrls));        H();
     2272        bool fOhciPresent = false; /**< Flag whether at least one OHCI controller is presnet. */
     2273
     2274        for (size_t i = 0; i < usbCtrls.size(); ++i)
     2275        {
     2276            USBControllerType_T enmCtrlType;
     2277            rc = usbCtrls[i]->COMGETTER(Type)(&enmCtrlType);                                   H();
     2278            if (enmCtrlType == USBControllerType_OHCI)
     2279            {
     2280                fOhciPresent = true;
     2281                break;
     2282            }
     2283        }
     2284
     2285        /*
     2286         * Currently EHCI is only enabled when a OHCI controller is present too.
     2287         * This might change when XHCI is supported.
     2288         */
     2289        if (fOhciPresent)
     2290            mfVMHasUsbController = true;
     2291
     2292        if (mfVMHasUsbController)
     2293        {
     2294            for (size_t i = 0; i < usbCtrls.size(); ++i)
     2295            {
     2296                USBControllerType_T enmCtrlType;
     2297                rc = usbCtrls[i]->COMGETTER(Type)(&enmCtrlType);                                   H();
     2298
     2299                if (enmCtrlType == USBControllerType_OHCI)
     2300                {
     2301                    InsertConfigNode(pDevices, "usb-ohci", &pDev);
     2302                    InsertConfigNode(pDev,     "0", &pInst);
     2303                    InsertConfigNode(pInst,    "Config", &pCfg);
     2304                    InsertConfigInteger(pInst, "Trusted",              1); /* boolean */
     2305                    hrc = pBusMgr->assignPCIDevice("usb-ohci", pInst);                          H();
     2306                    InsertConfigNode(pInst,    "LUN#0", &pLunL0);
     2307                    InsertConfigString(pLunL0, "Driver",               "VUSBRootHub");
     2308                    InsertConfigNode(pLunL0,   "Config", &pCfg);
     2309
     2310                    /*
     2311                     * Attach the status driver.
     2312                     */
     2313                    attachStatusDriver(pInst, &mapUSBLed[0], 0, 0, NULL, NULL, 0);
     2314                }
    22932315#ifdef VBOX_WITH_EHCI
    2294                 BOOL fEHCIEnabled;
    2295                 hrc = USBCtlPtr->COMGETTER(EnabledEHCI)(&fEHCIEnabled);                     H();
    2296                 if (fEHCIEnabled)
     2316                else if (enmCtrlType == USBControllerType_EHCI)
    22972317                {
    22982318                    /*
     
    23402360                }
    23412361#endif
    2342 
     2362            } /* for every USB controller. */
     2363
     2364
     2365            /*
     2366             * Virtual USB Devices.
     2367             */
     2368            PCFGMNODE pUsbDevices = NULL;
     2369            InsertConfigNode(pRoot, "USB", &pUsbDevices);
     2370
     2371#ifdef VBOX_WITH_USB
     2372            {
    23432373                /*
    2344                  * Virtual USB Devices.
     2374                 * Global USB options, currently unused as we'll apply the 2.0 -> 1.1 morphing
     2375                 * on a per device level now.
    23452376                 */
    2346                 PCFGMNODE pUsbDevices = NULL;
    2347                 InsertConfigNode(pRoot, "USB", &pUsbDevices);
    2348 
    2349 #ifdef VBOX_WITH_USB
    2350                 {
    2351                     /*
    2352                     * Global USB options, currently unused as we'll apply the 2.0 -> 1.1 morphing
    2353                     * on a per device level now.
    2354                     */
    2355                     InsertConfigNode(pUsbDevices, "USBProxy", &pCfg);
    2356                     InsertConfigNode(pCfg, "GlobalConfig", &pCfg);
    2357                     // This globally enables the 2.0 -> 1.1 device morphing of proxied devices to keep windows quiet.
    2358                     //InsertConfigInteger(pCfg, "Force11Device", true);
    2359                     // The following breaks stuff, but it makes MSDs work in vista. (I include it here so
    2360                     // that it's documented somewhere.) Users needing it can use:
    2361                     //      VBoxManage setextradata "myvm" "VBoxInternal/USB/USBProxy/GlobalConfig/Force11PacketSize" 1
    2362                     //InsertConfigInteger(pCfg, "Force11PacketSize", true);
    2363                 }
     2377                InsertConfigNode(pUsbDevices, "USBProxy", &pCfg);
     2378                InsertConfigNode(pCfg, "GlobalConfig", &pCfg);
     2379                // This globally enables the 2.0 -> 1.1 device morphing of proxied devices to keep windows quiet.
     2380                //InsertConfigInteger(pCfg, "Force11Device", true);
     2381                // The following breaks stuff, but it makes MSDs work in vista. (I include it here so
     2382                // that it's documented somewhere.) Users needing it can use:
     2383                //      VBoxManage setextradata "myvm" "VBoxInternal/USB/USBProxy/GlobalConfig/Force11PacketSize" 1
     2384                //InsertConfigInteger(pCfg, "Force11PacketSize", true);
     2385            }
    23642386#endif
    23652387
    23662388#ifdef VBOX_WITH_USB_VIDEO
    2367                 BOOL aEmulatedUSBWebcamEnabled = FALSE;
    2368                 hrc = pMachine->COMGETTER(EmulatedUSBWebcameraEnabled)(&aEmulatedUSBWebcamEnabled);    H();
    2369                 if (aEmulatedUSBWebcamEnabled)
    2370                 {
    2371                     InsertConfigNode(pUsbDevices, "Webcam", &pDev);
    2372                     InsertConfigNode(pDev,     "0", &pInst);
    2373                     InsertConfigNode(pInst,    "Config", &pCfg);
    2374                     InsertConfigNode(pInst,    "LUN#0", &pLunL0);
    2375                     InsertConfigString(pLunL0, "Driver", "EmWebcam");
    2376                     InsertConfigNode(pLunL0,   "Config", &pCfg);
    2377                     InsertConfigInteger(pCfg,  "Object", (uintptr_t)mEmWebcam);
    2378                 }
    2379 #endif
    2380 
    2381 #ifdef VBOX_WITH_USB_CARDREADER
    2382                 BOOL aEmulatedUSBCardReaderEnabled = FALSE;
    2383                 hrc = pMachine->COMGETTER(EmulatedUSBCardReaderEnabled)(&aEmulatedUSBCardReaderEnabled);    H();
    2384                 if (aEmulatedUSBCardReaderEnabled)
    2385                 {
    2386                     InsertConfigNode(pUsbDevices, "CardReader", &pDev);
    2387                     InsertConfigNode(pDev,     "0", &pInst);
    2388                     InsertConfigNode(pInst,    "Config", &pCfg);
    2389 
    2390                     InsertConfigNode(pInst,    "LUN#0", &pLunL0);
    2391 # ifdef VBOX_WITH_USB_CARDREADER_TEST
    2392                     InsertConfigString(pLunL0, "Driver", "DrvDirectCardReader");
    2393                     InsertConfigNode(pLunL0,   "Config", &pCfg);
    2394 # else
    2395                     InsertConfigString(pLunL0, "Driver", "UsbCardReader");
    2396                     InsertConfigNode(pLunL0,   "Config", &pCfg);
    2397                     InsertConfigInteger(pCfg,  "Object", (uintptr_t)mUsbCardReader);
    2398 # endif
    2399                 }
    2400 #endif
    2401 
    2402 # if 0  /* Virtual MSD*/
    2403 
    2404                 InsertConfigNode(pUsbDevices, "Msd", &pDev);
     2389            BOOL aEmulatedUSBWebcamEnabled = FALSE;
     2390            hrc = pMachine->COMGETTER(EmulatedUSBWebcameraEnabled)(&aEmulatedUSBWebcamEnabled);    H();
     2391            if (aEmulatedUSBWebcamEnabled)
     2392            {
     2393                InsertConfigNode(pUsbDevices, "Webcam", &pDev);
    24052394                InsertConfigNode(pDev,     "0", &pInst);
    24062395                InsertConfigNode(pInst,    "Config", &pCfg);
    24072396                InsertConfigNode(pInst,    "LUN#0", &pLunL0);
    2408 
    2409                 InsertConfigString(pLunL0, "Driver", "SCSI");
     2397                InsertConfigString(pLunL0, "Driver", "EmWebcam");
    24102398                InsertConfigNode(pLunL0,   "Config", &pCfg);
     2399                InsertConfigInteger(pCfg,  "Object", (uintptr_t)mEmWebcam);
     2400            }
     2401#endif
     2402
     2403#ifdef VBOX_WITH_USB_CARDREADER
     2404            BOOL aEmulatedUSBCardReaderEnabled = FALSE;
     2405            hrc = pMachine->COMGETTER(EmulatedUSBCardReaderEnabled)(&aEmulatedUSBCardReaderEnabled);    H();
     2406            if (aEmulatedUSBCardReaderEnabled)
     2407            {
     2408                InsertConfigNode(pUsbDevices, "CardReader", &pDev);
     2409                InsertConfigNode(pDev,     "0", &pInst);
     2410                InsertConfigNode(pInst,    "Config", &pCfg);
     2411
     2412                InsertConfigNode(pInst,    "LUN#0", &pLunL0);
     2413# ifdef VBOX_WITH_USB_CARDREADER_TEST
     2414                InsertConfigString(pLunL0, "Driver", "DrvDirectCardReader");
     2415                InsertConfigNode(pLunL0,   "Config", &pCfg);
     2416# else
     2417                InsertConfigString(pLunL0, "Driver", "UsbCardReader");
     2418                InsertConfigNode(pLunL0,   "Config", &pCfg);
     2419                InsertConfigInteger(pCfg,  "Object", (uintptr_t)mUsbCardReader);
     2420# endif
     2421             }
     2422#endif
     2423
     2424# if 0  /* Virtual MSD*/
     2425            InsertConfigNode(pUsbDevices, "Msd", &pDev);
     2426            InsertConfigNode(pDev,     "0", &pInst);
     2427            InsertConfigNode(pInst,    "Config", &pCfg);
     2428            InsertConfigNode(pInst,    "LUN#0", &pLunL0);
     2429
     2430            InsertConfigString(pLunL0, "Driver", "SCSI");
     2431            InsertConfigNode(pLunL0,   "Config", &pCfg);
     2432
     2433            InsertConfigNode(pLunL0,   "AttachedDriver", &pLunL1);
     2434            InsertConfigString(pLunL1, "Driver", "Block");
     2435            InsertConfigNode(pLunL1,   "Config", &pCfg);
     2436            InsertConfigString(pCfg,   "Type", "HardDisk");
     2437            InsertConfigInteger(pCfg,  "Mountable", 0);
     2438
     2439            InsertConfigNode(pLunL1,   "AttachedDriver", &pLunL2);
     2440            InsertConfigString(pLunL2, "Driver", "VD");
     2441            InsertConfigNode(pLunL2,   "Config", &pCfg);
     2442            InsertConfigString(pCfg,   "Path", "/Volumes/DataHFS/bird/VDIs/linux.vdi");
     2443            InsertConfigString(pCfg,   "Format", "VDI");
     2444# endif
     2445
     2446            /* Virtual USB Mouse/Tablet */
     2447            if (   aPointingHID == PointingHIDType_USBMouse
     2448                || aPointingHID == PointingHIDType_ComboMouse
     2449                || aPointingHID == PointingHIDType_USBTablet
     2450                || aPointingHID == PointingHIDType_USBMultiTouch)
     2451            {
     2452                InsertConfigNode(pUsbDevices, "HidMouse", &pDev);
     2453                InsertConfigNode(pDev,     "0", &pInst);
     2454                InsertConfigNode(pInst,    "Config", &pCfg);
     2455
     2456                InsertConfigString(pCfg,   "Mode", "relative");
     2457                InsertConfigNode(pInst,    "LUN#0", &pLunL0);
     2458                InsertConfigString(pLunL0, "Driver",        "MouseQueue");
     2459                InsertConfigNode(pLunL0,   "Config", &pCfg);
     2460                InsertConfigInteger(pCfg,  "QueueSize",            128);
    24112461
    24122462                InsertConfigNode(pLunL0,   "AttachedDriver", &pLunL1);
    2413                 InsertConfigString(pLunL1, "Driver", "Block");
     2463                InsertConfigString(pLunL1, "Driver",        "MainMouse");
    24142464                InsertConfigNode(pLunL1,   "Config", &pCfg);
    2415                 InsertConfigString(pCfg,   "Type", "HardDisk");
    2416                 InsertConfigInteger(pCfg,  "Mountable", 0);
    2417 
    2418                 InsertConfigNode(pLunL1,   "AttachedDriver", &pLunL2);
    2419                 InsertConfigString(pLunL2, "Driver", "VD");
    2420                 InsertConfigNode(pLunL2,   "Config", &pCfg);
    2421                 InsertConfigString(pCfg,   "Path", "/Volumes/DataHFS/bird/VDIs/linux.vdi");
    2422                 InsertConfigString(pCfg,   "Format", "VDI");
    2423 # endif
    2424 
    2425                 /* Virtual USB Mouse/Tablet */
    2426                 if (   aPointingHID == PointingHIDType_USBMouse
    2427                     || aPointingHID == PointingHIDType_ComboMouse
    2428                     || aPointingHID == PointingHIDType_USBTablet
    2429                     || aPointingHID == PointingHIDType_USBMultiTouch)
    2430                 {
    2431                     InsertConfigNode(pUsbDevices, "HidMouse", &pDev);
    2432                     InsertConfigNode(pDev,     "0", &pInst);
    2433                     InsertConfigNode(pInst,    "Config", &pCfg);
    2434 
    2435                     InsertConfigString(pCfg,   "Mode", "relative");
    2436                     InsertConfigNode(pInst,    "LUN#0", &pLunL0);
    2437                     InsertConfigString(pLunL0, "Driver",        "MouseQueue");
    2438                     InsertConfigNode(pLunL0,   "Config", &pCfg);
    2439                     InsertConfigInteger(pCfg,  "QueueSize",            128);
    2440 
    2441                     InsertConfigNode(pLunL0,   "AttachedDriver", &pLunL1);
    2442                     InsertConfigString(pLunL1, "Driver",        "MainMouse");
    2443                     InsertConfigNode(pLunL1,   "Config", &pCfg);
    2444                     InsertConfigInteger(pCfg,  "Object",     (uintptr_t)pMouse);
    2445                 }
    2446                 if (   aPointingHID == PointingHIDType_USBTablet
    2447                     || aPointingHID == PointingHIDType_USBMultiTouch)
    2448                 {
    2449                     InsertConfigNode(pDev,     "1", &pInst);
    2450                     InsertConfigNode(pInst,    "Config", &pCfg);
    2451 
    2452                     InsertConfigString(pCfg,   "Mode", "absolute");
    2453                     InsertConfigNode(pInst,    "LUN#0", &pLunL0);
    2454                     InsertConfigString(pLunL0, "Driver",        "MouseQueue");
    2455                     InsertConfigNode(pLunL0,   "Config", &pCfg);
    2456                     InsertConfigInteger(pCfg,  "QueueSize",            128);
    2457 
    2458                     InsertConfigNode(pLunL0,   "AttachedDriver", &pLunL1);
    2459                     InsertConfigString(pLunL1, "Driver",        "MainMouse");
    2460                     InsertConfigNode(pLunL1,   "Config", &pCfg);
    2461                     InsertConfigInteger(pCfg,  "Object",     (uintptr_t)pMouse);
    2462                 }
    2463                 if (aPointingHID == PointingHIDType_USBMultiTouch)
    2464                 {
    2465                     InsertConfigNode(pDev,     "2", &pInst);
    2466                     InsertConfigNode(pInst,    "Config", &pCfg);
    2467 
    2468                     InsertConfigString(pCfg,   "Mode", "multitouch");
    2469                     InsertConfigNode(pInst,    "LUN#0", &pLunL0);
    2470                     InsertConfigString(pLunL0, "Driver",        "MouseQueue");
    2471                     InsertConfigNode(pLunL0,   "Config", &pCfg);
    2472                     InsertConfigInteger(pCfg,  "QueueSize",            128);
    2473 
    2474                     InsertConfigNode(pLunL0,   "AttachedDriver", &pLunL1);
    2475                     InsertConfigString(pLunL1, "Driver",        "MainMouse");
    2476                     InsertConfigNode(pLunL1,   "Config", &pCfg);
    2477                     InsertConfigInteger(pCfg,  "Object",     (uintptr_t)pMouse);
    2478                 }
    2479 
    2480                 /* Virtual USB Keyboard */
    2481                 KeyboardHIDType_T aKbdHID;
    2482                 hrc = pMachine->COMGETTER(KeyboardHIDType)(&aKbdHID);                       H();
    2483                 if (aKbdHID == KeyboardHIDType_USBKeyboard)
    2484                 {
    2485                     InsertConfigNode(pUsbDevices, "HidKeyboard", &pDev);
    2486                     InsertConfigNode(pDev,     "0", &pInst);
    2487                     InsertConfigNode(pInst,    "Config", &pCfg);
    2488 
    2489                     InsertConfigNode(pInst,    "LUN#0", &pLunL0);
    2490                     InsertConfigString(pLunL0, "Driver",               "KeyboardQueue");
    2491                     InsertConfigNode(pLunL0,   "Config", &pCfg);
    2492                     InsertConfigInteger(pCfg,  "QueueSize",            64);
    2493 
    2494                     InsertConfigNode(pLunL0,   "AttachedDriver", &pLunL1);
    2495                     InsertConfigString(pLunL1, "Driver",               "MainKeyboard");
    2496                     InsertConfigNode(pLunL1,   "Config", &pCfg);
    2497                     pKeyboard = mKeyboard;
    2498                     InsertConfigInteger(pCfg,  "Object",     (uintptr_t)pKeyboard);
    2499                 }
     2465                InsertConfigInteger(pCfg,  "Object",     (uintptr_t)pMouse);
     2466            }
     2467            if (   aPointingHID == PointingHIDType_USBTablet
     2468                || aPointingHID == PointingHIDType_USBMultiTouch)
     2469            {
     2470                InsertConfigNode(pDev,     "1", &pInst);
     2471                InsertConfigNode(pInst,    "Config", &pCfg);
     2472
     2473                InsertConfigString(pCfg,   "Mode", "absolute");
     2474                InsertConfigNode(pInst,    "LUN#0", &pLunL0);
     2475                InsertConfigString(pLunL0, "Driver",        "MouseQueue");
     2476                InsertConfigNode(pLunL0,   "Config", &pCfg);
     2477                InsertConfigInteger(pCfg,  "QueueSize",            128);
     2478
     2479                InsertConfigNode(pLunL0,   "AttachedDriver", &pLunL1);
     2480                InsertConfigString(pLunL1, "Driver",        "MainMouse");
     2481                InsertConfigNode(pLunL1,   "Config", &pCfg);
     2482                InsertConfigInteger(pCfg,  "Object",     (uintptr_t)pMouse);
     2483            }
     2484            if (aPointingHID == PointingHIDType_USBMultiTouch)
     2485            {
     2486                InsertConfigNode(pDev,     "2", &pInst);
     2487                InsertConfigNode(pInst,    "Config", &pCfg);
     2488
     2489                InsertConfigString(pCfg,   "Mode", "multitouch");
     2490                InsertConfigNode(pInst,    "LUN#0", &pLunL0);
     2491                InsertConfigString(pLunL0, "Driver",        "MouseQueue");
     2492                InsertConfigNode(pLunL0,   "Config", &pCfg);
     2493                InsertConfigInteger(pCfg,  "QueueSize",            128);
     2494
     2495                InsertConfigNode(pLunL0,   "AttachedDriver", &pLunL1);
     2496                InsertConfigString(pLunL1, "Driver",        "MainMouse");
     2497                InsertConfigNode(pLunL1,   "Config", &pCfg);
     2498                InsertConfigInteger(pCfg,  "Object",     (uintptr_t)pMouse);
     2499            }
     2500
     2501            /* Virtual USB Keyboard */
     2502            KeyboardHIDType_T aKbdHID;
     2503            hrc = pMachine->COMGETTER(KeyboardHIDType)(&aKbdHID);                       H();
     2504            if (aKbdHID == KeyboardHIDType_USBKeyboard)
     2505            {
     2506                InsertConfigNode(pUsbDevices, "HidKeyboard", &pDev);
     2507                InsertConfigNode(pDev,     "0", &pInst);
     2508                InsertConfigNode(pInst,    "Config", &pCfg);
     2509
     2510                InsertConfigNode(pInst,    "LUN#0", &pLunL0);
     2511                InsertConfigString(pLunL0, "Driver",               "KeyboardQueue");
     2512                InsertConfigNode(pLunL0,   "Config", &pCfg);
     2513                InsertConfigInteger(pCfg,  "QueueSize",            64);
     2514
     2515                InsertConfigNode(pLunL0,   "AttachedDriver", &pLunL1);
     2516                InsertConfigString(pLunL1, "Driver",               "MainKeyboard");
     2517                InsertConfigNode(pLunL1,   "Config", &pCfg);
     2518                pKeyboard = mKeyboard;
     2519                InsertConfigInteger(pCfg,  "Object",     (uintptr_t)pKeyboard);
    25002520            }
    25012521        }
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette