⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 usbd.c

📁 usb2 driver for vxwokrs
💻 C
📖 第 1 页 / 共 5 页
字号:
                0);            return USBHST_FAILURE;            }        }    else        {        /* Class specific device Case */        /*         * If the device class is not zero then the device info contains         * class details to load the driver         */        if (0 != pUSBDeviceInfo->uDeviceClass)            {            /* Find the matching driver for the device */            nStatus = usbdMatchDriver(FALSE,                                       pUSBDeviceInfo->uDeviceClass,                                       pUSBDeviceInfo->uDeviceSubClass,                                       pUSBDeviceInfo->uDeviceProtocol,                                       &pDeviceDriverInfo);            /* Check the status returned */            if (USBHST_FAILURE == nStatus)                {                OS_LOG_MESSAGE_HIGH(                    USBD,                    "USBD_FindDriver() Failed: Matching Driver not found.\n",                    0,                    0,                    0,                    0);                return USBHST_FAILURE;                }            /* Check if pDeviceDriverInfo returned is  valid */            if (NULL == pDeviceDriverInfo)                {                OS_LOG_MESSAGE_HIGH(                    USBD,                    "USBD_FindDriver() Failed: Matching Driver\                        returned null driver.\n",                    0,                    0,                    0,                    0);                return USBHST_FAILURE;                }            /* Check if the device info contains the hub class info */            if ((USBHST_HUB_CLASS == pUSBDeviceInfo->uDeviceClass) &&                (1 == pUSBDeviceInfo->uDeviceAddress))                {                /* For root hub call addRootHub function for the device */                nStatus =                    gpHubFunctionList->addRootHub(                        pUSBDeviceInfo->hDevice,                        pUSBDeviceInfo->uBusIndex,                        pUSBDeviceInfo->uDeviceSpeed);                /* Check the status returned */                if (USBHST_FAILURE == nStatus)                    {                    OS_LOG_MESSAGE_HIGH(                        USBD,                        "usbdFindDriver() Failed: addRootHub failed.\n",                        0,                        0,                        0,                        0);                    return USBHST_FAILURE;                    }                }            else                {                /*                 * For devices other than root hub call class driver's                 * addDevice                 */                nStatus =                    pDeviceDriverInfo->addDevice(                        pUSBDeviceInfo->hDevice,                        0,                        pUSBDeviceInfo->uDeviceSpeed,                        &(pUSBDeviceInfo->pDriverData));                /* Check the status returned */                if (USBHST_SUCCESS == nStatus)                    {                    /* Increment the functional device count in the bus */                    USBD_INCREMENT_FUNCTIONAL_DEVICE_COUNT(                            pUSBDeviceInfo->uBusIndex);                    /* Store the driver info in the device info*/                    pUSBDeviceInfo->pDriver = pDeviceDriverInfo;                    }                else                    {                    OS_LOG_MESSAGE_HIGH(                        USBD,                        "usbdFindDriver() Failed: Device info addDevice \                            failed.\n",                        0,                        0,                        0,                        0);                    return USBHST_FAILURE;                    }                } /* End of if device is hub */            } /* End of If device is not equal to zero */        /*         * If the device class is zero then the class details for the device         * is given in the interface.         */        if ( 0 == pUSBDeviceInfo->uDeviceClass )            {            UINT32 uIndex = 0;	            BOOLEAN bIsDriverLoaded = FALSE;             /* Get the interface info for the device */            pInterfaceInfo = pUSBDeviceInfo->pInterfacesInfo;            /* Check for each interface if the class details match */            for ( uInterfaceCount = 0;                uInterfaceCount < pUSBDeviceInfo->uInterfaceCount;                uInterfaceCount++ )                {                /* check if the interface is vendor specific */                if ( USBHST_VENDOR_SPECIFIC ==                     pUSBDeviceInfo->pInterfacesInfo[uInterfaceCount].uInterfaceClass )                    {                    /* Find the matching driver for the device */                    nStatus =                    usbdMatchDriver(                                    TRUE,                                    pUSBDeviceInfo->uVendorID,                                    pUSBDeviceInfo->uDeviceID,                                    pUSBDeviceInfo->uBCDDevice,                                    &pDeviceDriverInfo);                    }                else                    {                    /* Find the matching driver for the device */                    nStatus =                    usbdMatchDriver(                                    FALSE,                                    pInterfaceInfo[uInterfaceCount].uInterfaceClass,                                    pInterfaceInfo[uInterfaceCount].uInterfaceSubClass,                                    pInterfaceInfo[uInterfaceCount].uInterfaceProtocol,                                    &pDeviceDriverInfo);                    }                /* Check the status returned */                if ( USBHST_FAILURE == nStatus )                    {                    /*                     * If the matching driver for the interface could                     * not be found then continue with the next interface.                     */                    continue;                    }                /* Check if pDeviceDriverInfo returned is  valid */                if ( NULL == pDeviceDriverInfo )                    {                    /* if the driver info is null continue with next interface*/                    continue;                    }                /* If multiple interfaces support the same class, notify only once.                  * This ensures that a class driver callback is called only once even if                  * multiple interfaces support the same class                 */                for (uIndex = 0;uIndex < uInterfaceCount ; uIndex++)			            {                    if (pInterfaceInfo[uIndex].pDriver == pDeviceDriverInfo)                        {		        bIsDriverLoaded = TRUE;                        break;                        }                    }                                    if (bIsDriverLoaded == TRUE)                    continue;                               /* Call the add device function to add the device */                nStatus =                pDeviceDriverInfo->addDevice(                                            pUSBDeviceInfo->hDevice,                                            pInterfaceInfo[uInterfaceCount].uInterfaceNum,                                            pUSBDeviceInfo->uDeviceSpeed,                                            &(pInterfaceInfo[uInterfaceCount].pDriverData));                /* Check the status returned */                if ( USBHST_SUCCESS == nStatus )                    {                    /* Increment the functional device count in the bus */                    USBD_INCREMENT_FUNCTIONAL_DEVICE_COUNT(                                                          pUSBDeviceInfo->uBusIndex);                    /* Store the driver info in the interface info*/                    pInterfaceInfo[uInterfaceCount].pDriver = pDeviceDriverInfo;                    }                else                    {                    OS_LOG_MESSAGE_HIGH(                                       USBD,                                       "USBD_FindDriver(): Interface's addDevice failed.\n",                                       0,                                       0,                                       0,                                       0);                    }                } /* End of for loop for interface info */            } /* END of IF device class is zero */        } /* End of ELSE vendor class specific case */    OS_LOG_MESSAGE_LOW(USBD, "Exiting usbdFindDriver() Function.\n",0,0,0,0);    return USBHST_SUCCESS;    } /* End of function USBD_FindDriver() *//***************************************************************************** usbHstDriverRegister - register class driver** This routine registers the class driver with the USB Host Stack.** RETURNS: USBHST_INVALID_PARAMETER, USBHST_SUCCESS,* USBHST_FAILURE if Driver is already registered** ERRNO: None*/USBHST_STATUS usbHstDriverRegister    (    pUSBHST_DEVICE_DRIVER pDeviceDriverInfo,  /* Ptr to Device Driver info  */    VOID                 **pContext           /* Ptr to context information */    )    {    pUSBD_DEVICE_DRIVER_LIST pOldDriverList = NULL;/* To store the old driver                                                    * list                                                    */    pUSBD_DEVICE_DRIVER_LIST pNewDriverList = NULL; /* To store the new  driver                                                     * list                                                     */    pUSBHST_HUB_FUNCTION_LIST pHubFunctionList = NULL; /* To temporarily store                                                        * the Hub Function                                                        * List                                                        */			/* WindView Instrumentation */			USB_USBD_LOG_EVENT(				USB_USBD_WV_REGISTER,				"Entering usbHstRegisterDriver() Function.",				USB_USBD_WV_FILTER);    OS_LOG_MESSAGE_LOW(USBD,                       "Entering usbHstRegisterDriver() Function.\n",                       0,                       0,                       0,                       0);    /*     * Check if pDeviceDriverInfo and all its funtion pointer entries     * are valid     */    if ((NULL == pDeviceDriverInfo) ||        (NULL == pDeviceDriverInfo->addDevice) ||        (NULL == pDeviceDriverInfo->removeDevice) ||        (NULL == pDeviceDriverInfo->resumeDevice) ||        (NULL == pDeviceDriverInfo->suspendDevice))        {        OS_LOG_MESSAGE_MEDIUM(            USBD,            "usbHstRegisterDriver() Failed: Invalid parameter Driver info.\n",            0,            0,            0,            0);        return USBHST_INVALID_PARAMETER;        }    /* If the device is a hub then check if pContext contains hub info */    if ((FALSE == pDeviceDriverInfo->bFlagVendorSpecific) &&        (USBHST_HUB_CLASS == pDeviceDriverInfo->uVendorIDorClass))        {        /* If pContext is null return invalid parameter */        if ((NULL == pContext) || ( NULL == *pContext) )            {            OS_LOG_MESSAGE_MEDIUM(                USBD,                "usbHstRegisterDriver() Failed: Invalid parameter pContext.\n",                0,                0,                0,                0);            return USBHST_INVALID_PARAMETER;            }        else            {            /* Store the function list passed by the hub */            pHubFunctionList = &(((pUSBHST_FUNCTION_LIST)(*pContext))->HubFunctionList);            /* Check if hub function pointer entries are valid */            if ((NULL == (pHubFunctionList->addRootHub)) ||                (NULL == (pHubFunctionList->removeRootHub)) ||                (NULL == (pHubFunctionList->checkForPower)) ||                (NULL == (pHubFunctionList->selectiveSuspendDevice)) ||                (NULL == (pHubFunctionList->selectiveResumeDevice)) ||                (NULL == (pHubFunctionList->resetDevice)))                {                OS_LOG_MESSAGE_MEDIUM(                    USBD,                    "usbHstRegisterDriver() Failed: Invalid parameter\                        pContext.\n",                    0,                    0,                    0,                    0);                return USBHST_INVALID_PARAMETER;                }            if ((NULL == (pHubFunctionList->clearTT)) ||                (NULL == (pHubFunctionList->resetTT)))                {                OS_LOG_MESSAGE_MEDIUM(                    USBD,                    "usbHstRegisterDriver() Failed: Invalid parameter\                        pContext.\n",                    0,                    0,                    0,                    0);                return USBHST_INVALID_PARAMETER;                }            }        }    /*     * Check if the driver is already registered in the global driver list     * by matching the FlagClass, VendorId/Class and ProductId/Subclass     */    /* Store the global driver list in pOldDriverList*/    pOldDriverList  = gpDeviceDriverList;    while (NULL != pOldDriverList)        {        /*         * Check if the bFlagVendorSpecific, VendorIDorClass,         * uProductIDorSubClass are same.         */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -