VirtualBox

Changeset 53097 in vbox for trunk/src


Ignore:
Timestamp:
Oct 20, 2014 5:37:27 PM (10 years ago)
Author:
vboxsync
Message:

USB: Beginnings of emulated USB3 devices.

Location:
trunk/src/VBox
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Storage/UsbMsd.cpp

    r49814 r53097  
    143143    USBMSDREQSTATE      enmState;
    144144    /** The size of the data buffer. */
    145     size_t              cbBuf;
     145    uint32_t            cbBuf;
    146146    /** Pointer to the data buffer. */
    147147    uint8_t            *pbBuf;
     
    342342};
    343343
     344static const VUSBDESCENDPOINTEX g_aUsbMsdEndpointDescsSS[2] =
     345{
     346    {
     347        {
     348            /* .bLength = */            sizeof(VUSBDESCENDPOINT),
     349            /* .bDescriptorType = */    VUSB_DT_ENDPOINT,
     350            /* .bEndpointAddress = */   0x81 /* ep=1, in */,
     351            /* .bmAttributes = */       2 /* bulk */,
     352            /* .wMaxPacketSize = */     1024 /* SS bulk packet size */,
     353            /* .bInterval = */          0 /* no NAKs */
     354        },
     355        /* .pvMore = */     NULL,
     356        /* .pvClass = */    NULL,
     357        /* .cbClass = */    0
     358    },
     359    {
     360        {
     361            /* .bLength = */            sizeof(VUSBDESCENDPOINT),
     362            /* .bDescriptorType = */    VUSB_DT_ENDPOINT,
     363            /* .bEndpointAddress = */   0x02 /* ep=2, out */,
     364            /* .bmAttributes = */       2 /* bulk */,
     365            /* .wMaxPacketSize = */     1024 /* SS bulk packet size */,
     366            /* .bInterval = */          0 /* no NAKs */
     367        },
     368        /* .pvMore = */     NULL,
     369        /* .pvClass = */    NULL,
     370        /* .cbClass = */    0
     371    }
     372};
     373
    344374static const VUSBDESCINTERFACEEX g_UsbMsdInterfaceDescFS =
    345375{
     
    384414};
    385415
     416static const VUSBDESCINTERFACEEX g_UsbMsdInterfaceDescSS =
     417{
     418    {
     419        /* .bLength = */                sizeof(VUSBDESCINTERFACE),
     420        /* .bDescriptorType = */        VUSB_DT_INTERFACE,
     421        /* .bInterfaceNumber = */       0,
     422        /* .bAlternateSetting = */      0,
     423        /* .bNumEndpoints = */          2,
     424        /* .bInterfaceClass = */        8 /* Mass Storage */,
     425        /* .bInterfaceSubClass = */     6 /* SCSI transparent command set */,
     426        /* .bInterfaceProtocol = */     0x50 /* Bulk-Only Transport */,
     427        /* .iInterface = */             0
     428    },
     429    /* .pvMore = */     NULL,
     430    /* .pvClass = */    NULL,
     431    /* .cbClass = */    0,
     432    &g_aUsbMsdEndpointDescsSS[0],
     433    /* .pIAD = */ NULL,
     434    /* .cbIAD = */ 0
     435};
     436
    386437static const VUSBINTERFACE g_aUsbMsdInterfacesFS[] =
    387438{
     
    392443{
    393444    { &g_UsbMsdInterfaceDescHS, /* .cSettings = */ 1 },
     445};
     446
     447static const VUSBINTERFACE g_aUsbMsdInterfacesSS[] =
     448{
     449    { &g_UsbMsdInterfaceDescSS, /* .cSettings = */ 1 },
    394450};
    395451
     
    428484};
    429485
    430 static const VUSBDESCDEVICE g_UsbMsdDeviceDesc =
    431 {
    432     /* .bLength = */                sizeof(g_UsbMsdDeviceDesc),
     486static const VUSBDESCCONFIGEX g_UsbMsdConfigDescSS =
     487{
     488    {
     489        /* .bLength = */            sizeof(VUSBDESCCONFIG),
     490        /* .bDescriptorType = */    VUSB_DT_CONFIG,
     491        /* .wTotalLength = */       0 /* recalculated on read */,
     492        /* .bNumInterfaces = */     RT_ELEMENTS(g_aUsbMsdInterfacesSS),
     493        /* .bConfigurationValue =*/ 1,
     494        /* .iConfiguration = */     0,
     495        /* .bmAttributes = */       RT_BIT(7),
     496        /* .MaxPower = */           50 /* 100mA */
     497    },
     498    NULL,                           /* pvMore */
     499    &g_aUsbMsdInterfacesSS[0],
     500    NULL                            /* pvOriginal */
     501};
     502
     503static const VUSBDESCDEVICE g_UsbMsdDeviceDesc20 =
     504{
     505    /* .bLength = */                sizeof(g_UsbMsdDeviceDesc20),
    433506    /* .bDescriptorType = */        VUSB_DT_DEVICE,
    434507    /* .bcdUsb = */                 0x200, /* USB 2.0 */
     
    446519};
    447520
     521static const VUSBDESCDEVICE g_UsbMsdDeviceDesc30 =
     522{
     523    /* .bLength = */                sizeof(g_UsbMsdDeviceDesc30),
     524    /* .bDescriptorType = */        VUSB_DT_DEVICE,
     525    /* .bcdUsb = */                 0x300, /* USB 2.0 */
     526    /* .bDeviceClass = */           0 /* Class specified in the interface desc. */,
     527    /* .bDeviceSubClass = */        0 /* Subclass specified in the interface desc. */,
     528    /* .bDeviceProtocol = */        0 /* Protocol specified in the interface desc. */,
     529    /* .bMaxPacketSize0 = */        9 /* 512, the only option for USB3. */,
     530    /* .idVendor = */               VBOX_USB_VENDOR,
     531    /* .idProduct = */              USBMSD_PID_HD,
     532    /* .bcdDevice = */              0x0110, /* 1.10 */
     533    /* .iManufacturer = */          USBMSD_STR_ID_MANUFACTURER,
     534    /* .iProduct = */               USBMSD_STR_ID_PRODUCT_HD,
     535    /* .iSerialNumber = */          0,
     536    /* .bNumConfigurations = */     1
     537};
     538
    448539static const VUSBDEVICEQUALIFIER g_UsbMsdDeviceQualifier =
    449540{
     
    461552static const PDMUSBDESCCACHE g_UsbMsdDescCacheFS =
    462553{
    463     /* .pDevice = */                &g_UsbMsdDeviceDesc,
     554    /* .pDevice = */                &g_UsbMsdDeviceDesc20,
    464555    /* .paConfigs = */              &g_UsbMsdConfigDescFS,
    465556    /* .paLanguages = */            g_aUsbMsdLanguages,
     
    471562static const PDMUSBDESCCACHE g_UsbMsdDescCacheHS =
    472563{
    473     /* .pDevice = */                &g_UsbMsdDeviceDesc,
     564    /* .pDevice = */                &g_UsbMsdDeviceDesc20,
    474565    /* .paConfigs = */              &g_UsbMsdConfigDescHS,
    475566    /* .paLanguages = */            g_aUsbMsdLanguages,
     
    479570};
    480571
     572static const PDMUSBDESCCACHE g_UsbMsdDescCacheSS =
     573{
     574    /* .pDevice = */                &g_UsbMsdDeviceDesc30,
     575    /* .paConfigs = */              &g_UsbMsdConfigDescSS,
     576    /* .paLanguages = */            g_aUsbMsdLanguages,
     577    /* .cLanguages = */             RT_ELEMENTS(g_aUsbMsdLanguages),
     578    /* .fUseCachedDescriptors = */  true,
     579    /* .fUseCachedStringsDescriptors = */ true
     580};
    481581
    482582/*******************************************************************************
     
    702802 * @param   cbBuf       The required buffer space.
    703803 */
    704 static int usbMsdReqEnsureBuffer(PUSBMSDREQ pReq, size_t cbBuf)
     804static int usbMsdReqEnsureBuffer(PUSBMSDREQ pReq, uint32_t cbBuf)
    705805{
    706806    if (RT_LIKELY(pReq->cbBuf >= cbBuf))
     
    10531153{
    10541154    PUSBMSD pThis = PDMINS_2_DATA(pUsbIns, PUSBMSD);
    1055     uint32_t i;
    10561155    int rc;
    10571156
     
    11421241                    {
    11431242                        AssertPtr(pReq->pbBuf);
    1144                         Assert(cbBuf = pReq->cbBuf);
     1243                        Assert(cbBuf == pReq->cbBuf);
    11451244                        SSMR3GetMem(pSSM, pReq->pbBuf, pReq->cbBuf);
    11461245                    }
     
    18741973    PUSBMSD pThis = PDMINS_2_DATA(pUsbIns, PUSBMSD);
    18751974    LogFlow(("usbMsdUsbGetDescriptorCache/#%u:\n", pUsbIns->iInstance));
    1876     if (pThis->pUsbIns->iUsbHubVersion & VUSB_STDVER_20)
     1975    if (pThis->pUsbIns->iUsbHubVersion & VUSB_STDVER_30)
     1976        return &g_UsbMsdDescCacheSS;
     1977    else if (pThis->pUsbIns->iUsbHubVersion & VUSB_STDVER_20)
    18771978        return &g_UsbMsdDescCacheHS;
    18781979    else
     
    21252226    "USB Mass Storage Device, one LUN.",
    21262227    /* fFlags */
    2127     PDM_USBREG_HIGHSPEED_CAPABLE | PDM_USBREG_EMULATED_DEVICE,
     2228    PDM_USBREG_HIGHSPEED_CAPABLE | PDM_USBREG_SUPERSPEED_CAPABLE | PDM_USBREG_EMULATED_DEVICE,
    21282229    /* cMaxInstances */
    21292230    ~0U,
  • trunk/src/VBox/VMM/VMMR3/PDMUsb.cpp

    r53062 r53097  
    227227                    ("Invalid name '%.s'\n", sizeof(pReg->szName), pReg->szName),
    228228                    VERR_PDM_INVALID_USB_REGISTRATION);
    229     AssertMsgReturn((pReg->fFlags & ~(PDM_USBREG_HIGHSPEED_CAPABLE | PDM_USBREG_EMULATED_DEVICE)) == 0,
     229    AssertMsgReturn((pReg->fFlags & ~(PDM_USBREG_HIGHSPEED_CAPABLE | PDM_USBREG_SUPERSPEED_CAPABLE | PDM_USBREG_EMULATED_DEVICE)) == 0,
    230230                    ("fFlags=%#x\n", pReg->fFlags), VERR_PDM_INVALID_USB_REGISTRATION);
    231231    AssertMsgReturn(pReg->cMaxInstances > 0,
     
    440440
    441441    for (PPDMUSBHUB pCur = pVM->pdm.s.pUsbHubs; pCur; pCur = pCur->pNext)
    442         if (    pCur->cAvailablePorts > 0
    443             &&  (   (pCur->fVersions & iUsbVersion)
    444                  || pCur->fVersions == VUSB_STDVER_11))
    445         {
    446             *ppHub = pCur;
     442        if (pCur->cAvailablePorts > 0)
     443        {
     444            /* First check for an exact match. */
    447445            if (pCur->fVersions & iUsbVersion)
     446            {
     447                *ppHub = pCur;
    448448                break;
     449            }
     450            /* For high-speed USB 2.0 devices only, allow USB 1.1 fallback. */
     451            if ((iUsbVersion & VUSB_STDVER_20) && (pCur->fVersions == VUSB_STDVER_11))
     452                *ppHub = pCur;
    449453        }
    450454    if (*ppHub)
     
    828832
    829833        /*
    830          * Every device must support USB 1.x hubs; optionally, high-speed USB 2.0 hubs
     834         * Every emulated device must support USB 1.x hubs; optionally, high-speed USB 2.0 hubs
    831835         * might be also supported. This determines where to attach the device.
    832836         */
     
    835839        if (paUsbDevs[i].pUsbDev->pReg->fFlags & PDM_USBREG_HIGHSPEED_CAPABLE)
    836840            iUsbVersion |= VUSB_STDVER_20;
     841        if (paUsbDevs[i].pUsbDev->pReg->fFlags & PDM_USBREG_SUPERSPEED_CAPABLE)
     842            iUsbVersion |= VUSB_STDVER_30;
    837843
    838844        /*
     
    911917    if (pUsbDev->pReg->fFlags & PDM_USBREG_HIGHSPEED_CAPABLE)
    912918        iUsbVersion |= VUSB_STDVER_20;
     919    if (pUsbDev->pReg->fFlags & PDM_USBREG_SUPERSPEED_CAPABLE)
     920        iUsbVersion |= VUSB_STDVER_30;
    913921
    914922    /*
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