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

📄 usbd.c

📁 usb2 driver for vxwokrs
💻 C
📖 第 1 页 / 共 5 页
字号:
    /*     * If gpHubFunctionList is not null then release the memory allocated     * for it.     */    if (NULL != gpHubFunctionList)        {        OS_FREE(gpHubFunctionList);        }		/* WindView Instrumentation */		USB_USBD_LOG_EVENT(			USB_USBD_WV_INIT_EXIT,			"usbdExit() exits successfully.\n",			USB_USBD_WV_FILTER);    OS_LOG_MESSAGE_LOW(USBD, "Exiting usbdExit() Function..\n",0,0,0,0);    /* release the lock  variable by decrementing twice to make guUSBDInited 0 */    OS_LOCKED_DECREMENT(guUSBDInited);    OS_LOCKED_DECREMENT(guUSBDInited);        return USBHST_SUCCESS;    } /* End of function usbdExit() *//***************************************************************************** usbdMatchDriver - match USB drivers** This routine scans the class driver list for the driver ** RETURNS: USBHST_SUCCESS, USBHST_INVALID_PARAMETER,* USBHST_FAILURE if no matching driver is found** ERRNO: None** \NOMANUAL*/LOCAL USBHST_STATUS usbdMatchDriver    (    BOOL                  bFlagVendorSpecific,  /* Vendor Specific           */    UINT16                uParam1,              /* DeviceID or Class code    */    UINT16                uParam2,              /* VendorID or subClass code */      UINT16                uParam3,              /* USB revision number       */    pUSBHST_DEVICE_DRIVER *pDriver              /* Ptr to matched dev driver */    )    {    /* To store the driver list */    pUSBD_DEVICE_DRIVER_LIST pDriverList = NULL;    OS_LOG_MESSAGE_LOW(USBD, "Entering usbdMatchDriver() Function.\n",0,0,0,0);    /* Check if pDeviceDriverInfo parameter is not NULL */    if (NULL == pDriver)        {        OS_LOG_MESSAGE_MEDIUM(            USBD,            "usbdMatchDriver() Failed: Invalid parameter pDriver.\n",            0,            0,            0,            0);        return USBHST_INVALID_PARAMETER;        }    /* Initialize the pDriverList with the global driver list */    pDriverList = gpDeviceDriverList;        /*     * Check if the given parameter info matches with any driver in the global     * driver list. If it matches then populate pDriver with the matched driver     * and return USBHST_SUCCESS     */    while (NULL != pDriverList)    {        if (bFlagVendorSpecific ==             pDriverList->pDriver->bFlagVendorSpecific) 		{			/* Check if its HUB Class */			if ((uParam1 == pDriverList->pDriver->uVendorIDorClass) &&                (USBHST_HUB_CLASS == uParam1)&&				(uParam2 == pDriverList->pDriver->uProductIDorSubClass))			{				/*If the drivers match then store the driver in pDriver and return*/				*pDriver = pDriverList->pDriver;				/* Debug Message */				OS_LOG_MESSAGE_LOW(USBD,								   "Exiting usbdMatchDriver() Function.\n",								   0,								   0,								   0,								   0);				return USBHST_SUCCESS;         			}/* End of If (USBHST_HUB .....) */   		    /* Check for all the paramters */      		    else if ((uParam1 == pDriverList->pDriver->uVendorIDorClass) &&                     (uParam2 == pDriverList->pDriver->uProductIDorSubClass) &&                     (uParam3 == pDriverList->pDriver->uBCDUSBorProtocol))		        {                        /*If the drivers match then store the driver in pDriver and return*/                        *pDriver = pDriverList->pDriver;    			/* Debug Message */                        OS_LOG_MESSAGE_LOW(USBD,                                   "Exiting usbdMatchDriver() Function.\n",                                   0,                                   0,                                   0,                                   0);                        return USBHST_SUCCESS;					        }                     /* Check only the class and subclass fields */		    else if ((uParam1 == pDriverList->pDriver->uVendorIDorClass) &&                     (uParam2 == pDriverList->pDriver->uProductIDorSubClass) &&                     (USBD_NOTIFY_ALL == pDriverList->pDriver->uBCDUSBorProtocol))		        {                        /*If the drivers match then store the driver in pDriver and return*/                        *pDriver = pDriverList->pDriver;    			/* Debug Message */                        OS_LOG_MESSAGE_LOW(USBD,                                   "Exiting usbdMatchDriver() Function.\n",                                   0,                                   0,                                   0,                                   0);                        return USBHST_SUCCESS;					        }/* End of else if */                    /* Check only the class and protocol fields */		    else if ((uParam1 == pDriverList->pDriver->uVendorIDorClass) &&                     (USBD_NOTIFY_ALL == pDriverList->pDriver->uProductIDorSubClass) &&                     (uParam3 == pDriverList->pDriver->uBCDUSBorProtocol))		        {                        /*If the drivers match then store the driver in pDriver and return*/                        *pDriver = pDriverList->pDriver;    			/* Debug Message */                        OS_LOG_MESSAGE_LOW(USBD,                                   "Exiting usbdMatchDriver() Function.\n",                                   0,                                   0,                                   0,                                   0);                        return USBHST_SUCCESS;		        }/* End of else if */                    /* Check only the class fields */		    else if ((uParam1 == pDriverList->pDriver->uVendorIDorClass) &&                     (USBD_NOTIFY_ALL == pDriverList->pDriver->uProductIDorSubClass) &&                     (USBD_NOTIFY_ALL == pDriverList->pDriver->uBCDUSBorProtocol))		        {                        /*If the drivers match then store the driver in pDriver and return*/                        *pDriver = pDriverList->pDriver;    			/* Debug Message */                        OS_LOG_MESSAGE_LOW(USBD,                                   "Exiting usbdMatchDriver() Function.\n",                                   0,                                   0,                                   0,                                   0);                        return USBHST_SUCCESS;		        }/* End of else if */		}/* End of Vendor specific flag check */        /* Get the next driver in the list */        pDriverList = pDriverList->pNextDriver;    }    /* If no match found then store NULL in pDriver */    *pDriver = NULL;    OS_LOG_MESSAGE_HIGH(        USBD,        "usbdMatchDriver() Failed: Driver could not be found.\n",        0,        0,        0,        0);    return USBHST_FAILURE;    } /* End of function usbdMatchDriver() *//***************************************************************************** usbdFindDevices - find USB device** This function scans the USB bus for the devices that can be supported for* the specified class driver. The class driver is loaded for all the devices * identified.** RETURNS: USBHST_INVALID_PARAMETER, USBHST_SUCCESS if supported devices * by this driver if any, are added successfully** ERRNO: None*/LOCAL USBHST_STATUS usbdFindDevices    (    pUSBHST_DEVICE_DRIVER pDeviceDriverInfo    /* Ptr to Device Driver info */    )    {    /* To store device info */    pUSBD_DEVICE_INFO       pUSBDeviceInfo = NULL;    /* To store interface info */    pUSBD_INTERFACE_INFO    pInterfaceInfo = NULL;    /* To hold the loop index */    UINT8                   uIndex = 0;    /* To hold the loop index */    UINT8                   uInterfaceCount = 0;    /* To hold the return status */    USBHST_STATUS           nReturnStatus = USBHST_FAILURE;    OS_LOG_MESSAGE_LOW(USBD, "Entering usbdFindDevices() Function.\n",0,0,0,0);    /* Check if pDeviceDriverInfo parameter is not NULL */    if (NULL == pDeviceDriverInfo)    {        OS_LOG_MESSAGE_MEDIUM(            USBD,            "usbdFindDevices() Failed: Invalid parameter pDeviceDriverInfo.\n",            0,            0,            0,            0);        return USBHST_INVALID_PARAMETER;    }    /* Check if the driver is Class Specific */    if (FALSE == pDeviceDriverInfo->bFlagVendorSpecific)        {        /* Check the device info of all devices on all the buses */        for ( uIndex = 0; uIndex < USBD_MAX_BUS_NUM; uIndex++ )            {            /* Get the device list for the uIndex bus */            pUSBDeviceInfo = gUSBBusInfoList[uIndex].pUSBDeviceInfoList;            /* Check if the device info is NULL */            while ( NULL != pUSBDeviceInfo )                {                	                /*                 * If the device is vendor specific then obtain the next                 * device information                 */                if ( USBHST_VENDOR_SPECIFIC == pUSBDeviceInfo->uDeviceClass )                    {                    /* Obtain the device info of the next device in the list*/                    pUSBDeviceInfo = pUSBDeviceInfo->pNextUSBDeviceInfo;                    continue;                    }/* End of if (class is VENDOR_SPECIFIC) */                /* Check if the device info contains the hub class info */                if (( USBHST_HUB_CLASS == pUSBDeviceInfo->uDeviceClass ) &&                    ( USBHST_HUB_CLASS == pDeviceDriverInfo->uVendorIDorClass ) )                {                    /* Check if it is Root Hub */                    if ( 1 == pUSBDeviceInfo->uDeviceAddress )                        {                        /* Call the addRootHub */                        nReturnStatus =                        gpHubFunctionList->addRootHub(                                                          pUSBDeviceInfo->hDevice,                                                          pUSBDeviceInfo->uBusIndex,                                                          pUSBDeviceInfo->uDeviceSpeed);                        /* If  addRootHub failed */                        if ( USBHST_SUCCESS != nReturnStatus )                            {                            /* Debug Message */                            OS_LOG_MESSAGE(                                          USBD,                                          "USBD_FindDevices(): addRootHub() Failed.\n",                                          0,                                          0);                            }/* End of Return status check */                        }/* End of if (1 == .... for device address) */                    /* Else the hub is not a root hub */                    else                        {                        /* Call the addDevice function for driver */                        nReturnStatus =                        pDeviceDriverInfo->addDevice(                                                    pUSBDeviceInfo->hDevice,                                                    USBHST_DEFAULT_INTERFACE_VALUE,                                                    pUSBDeviceInfo->uDeviceSpeed,                                                    &(pUSBDeviceInfo->pDriverData));                        /* If calling the addDevice is passed */                        if ( USBHST_SUCCESS == nReturnStatus )                            {                            /* Increment functional device count in the bus */                            USBD_INCREMENT_FUNCTIONAL_DEVICE_COUNT(                                                                  pUSBDeviceInfo->uBusIndex);                            /* Store the driver info in the device info*/                            pUSBDeviceInfo->pDriver = pDeviceDriverInfo;                            }/* End of if (USBHST_SUCCESS == nReturnStatus) */                        }/* End of else for root hub check */                    /* Continue the match with the next device in the list */                    pUSBDeviceInfo = pUSBDeviceInfo->pNextUSBDeviceInfo;                    continue;                    }/* End of if (USBHST_HUB_CLASS == pUSBDeviceInfo.....) */                /*                 * If it is not HUB Class, then match the device with the                 * class driver based on devcie class,Subclass and protocol id                 */                /* Ensure that it is not interface based device */                else if ( 0 != pUSBDeviceInfo->uDeviceClass )                    {                    /* Check if the device matches with the driver */                    if ((pUSBDeviceInfo->uDeviceClass !=                          pDeviceDriverInfo->uVendorIDorClass) ||                        ((pDeviceDriverInfo->uProductIDorSubClass !=                        USBD_NOTIFY_ALL) && (pUSBDeviceInfo->uDeviceSubClass !=                        pDeviceDriverInfo->uProductIDorSubClass)) ||                        ((pDeviceDriverInfo->uBCDUSBorProtocol != USBD_NOTIFY_ALL) &&                         (pUSBDeviceInfo->uDeviceProtocol !=                          pDeviceDriverInfo->uBCDUSBorProtocol)))                        {                        /* Continue the match with the next device in the list*/                        pUSBDeviceInfo = pUSBDeviceInfo->pNextUSBDeviceInfo;                        continue;                        }                    /*                     * The driver matches with the device. Load the driver for                     * the device                     */

⌨️ 快捷键说明

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