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

📄 usbhubmisc.c

📁 usb2 driver for vxwokrs
💻 C
📖 第 1 页 / 共 2 页
字号:
    {        /* The bus List pointer to be used for browsing the list */        pUSB_HUB_BUS_INFO pBusList = gpGlobalBus;        /* While the pbusList is not null */        while ( NULL != pBusList )        {            /* Check if we have a root hub info */            if ( NULL != pBusList->pRootHubInfo)            {                /* Check if the device handles match */                if (uHubId == pBusList->pRootHubInfo->uDeviceHandle)                {                    /* we got the hub */                    pHub = pBusList->pRootHubInfo;                    break;                }            } /* End of if ( NULL != pBusList->pRootHubInfo) */            /* Move the pointer to the next bus */            pBusList=pBusList->pNextBus;        }/* End of while (pBus... */        /* Check if we found the root hub */        if (NULL == pBusList)        {            /* Debug Message */            OS_LOG_MESSAGE_HIGH(                HUB,                "usbdHubPortCountGet: parent hub not found\n",                0,                0,                0,                0);            return USBHST_INVALID_PARAMETER;        }/* End of if NULL... */    }/* End of if (NULL == pParentHub ) */    else    {        /*         * HUB_FindPortNumber() to find the port number for this device handle.         * If this is not found, then return USBHST_INVALID_PARAMETER.         */        uPortCount = usbHubFindPortNumber(pParentHub,uHubId);        /* Check  if the port is found */        if (USB_PORT_NUMBER_NOT_FOUND == uPortCount)        {            /* Debug Message */            OS_LOG_MESSAGE_HIGH(                HUB,                "usbdNodeIdGet: parent port num not found\n",                0,                0,                0,                0);            return USBHST_INVALID_PARAMETER;        } /* End of if (PORT_NUM.. */        /* Check if the port number is within limits */        if (uPortCount >= (pParentHub->HubDescriptor.bNbrPorts))        {            /* Debug Message */            OS_LOG_MESSAGE_HIGH(                HUB,                "usbdNodeIdGet: port=%d >parent port=%d\n",                uPortCount,                pParentHub->HubDescriptor.bNbrPorts,                0,                0);            return USBHST_INVALID_PARAMETER;        } /* End of (uPortCount > (pParentHub->.... */        /*         * Retrieve HUB_INFO structure from         * parentHub::pPortList[uPortCount]::pHub.         */        pPort = pParentHub->pPortList[uPortCount];        OS_ASSERT(pPort != NULL);                                       /* Verify */        /* retrieve the pHub */        pHub= pPort->pHub;        /*         * Check if the port is actually a hub. if not, return failure.         */        if (NULL == pHub)        {            /* Debug Message */            OS_LOG_MESSAGE_MEDIUM(                HUB,                "usbdNodeIdGet: Hub Handle 0x%x is not a hub!\n",                uHubId,                0,                0,                0);            return USBHST_FAILURE;        } /* End of if (NULL == pHub) */    } /* End of else of if (NULL == pParentHub) */    /* Check if the port Index parameter is within limits */    if (uPortIndex >= (pHub->HubDescriptor.bNbrPorts))    {        /* Debug Message */        OS_LOG_MESSAGE_HIGH(            HUB,            "usbdNodeIdGet: portIndex=%d > Hub Ports=%d\n",            uPortIndex,            pHub->HubDescriptor.bNbrPorts,            0,            0);        return USBHST_INVALID_PARAMETER;    } /* End of (uPortCount > (pHub->.... */    /*     * Retrieve HUB_PORT_INFO structure from     * pHub::pPortList[uPortIndex].     */    pPort = pHub->pPortList[uPortIndex];    /* Check if the port is having a device connection */    if (NULL == pPort)    {        /* Debug Message */        OS_LOG_MESSAGE_LOW(            HUB,            "usbdNodeIdGet: No Dev connection\n",            0,            0,            0,            0);        /* no device connected */        * pNodeType = USBHUB_NODETYPE_NONE;        * pNodeId = 0 ;        /* return success */        return USBHST_SUCCESS;    } /* End of if (NULL == pPort..)*/    *pNodeId = pPort->uDeviceHandle;    /* Check if the port is having a valid device handle detected by usb stack*/    if (0 == pPort->uDeviceHandle )    {        /* Debug Message */        OS_LOG_MESSAGE_LOW(            HUB,            "usbdNodeIdGet: No Dev connection-\n",            0,            0,            0,            0);        * pNodeType = USBHUB_NODETYPE_NONE;        /* return success */        return USBHST_SUCCESS;    } /* End of if (0 == pPort->uDeviceHandle ) */    /* Check if the port is having a device */    if (NULL == pPort->pHub )    {        /* Debug Message */        OS_LOG_MESSAGE_LOW(            HUB,            "usbdNodeIdGet: Normal Dev connection\n",            0,            0,            0,            0);        * pNodeType = USBHUB_NODETYPE_DEVICE;        /* return success */        return USBHST_SUCCESS;    } /* if (NULL == pPort->pHub ) */    /* the port is having a Hub connected to it */    * pNodeType = USBHUB_NODETYPE_HUB;    /* Debug Message */    OS_LOG_MESSAGE_LOW(        HUB,        "usbdNodeIdGet: Hub connection\n",        0,        0,        0,        0);    /* return success */    return USBHST_SUCCESS;} /* End of usbdNodeIdGet *//***************************************************************************** usbHubGetRootHubHandle - Finding the root hub handle of a Bus.** This routine is called by the USB Host Software Stack for finding the root * hub handle of a bus.*** RETURNS: USBHST_SUCCESS, USBHST_FAILURE if error occured.** ERRNO: None** \NOMANUAL*/USBHST_STATUS usbHubGetRootHubHandle    (    UINT8 uBusHandle,     PUINT32 pRootHubHandle    )    {    /* Bus List pointer */    pUSB_HUB_BUS_INFO pBusList = gpGlobalBus;    /* Root hub structure */    pUSB_HUB_INFO pRootHub = NULL;    /* Debug Message */    OS_LOG_MESSAGE_LOW(        HUB,        "HUB_GetRootHubHandle: Called BusHandle =0x%x\n",        uBusHandle,        0,        0,        0);    /* Validate the parameters */    if (NULL == pRootHubHandle)    {        /* Debug Message */        OS_LOG_MESSAGE_HIGH(            HUB,            "HUB_GetRootHubHandle: NULL parameter RootHubHandle= 0x0 \n",            0,            0,            0,            0);        /* return USBHST_INVALID_PARAMETER */        return USBHST_INVALID_PARAMETER;    } /* End of if (NULL == pRootHubHandle) */    /*     * Scan through the g_pGlobalBus to find the matching HUB_BUS_INFO structure     * for the uBusHandle. If not found return.     */    while (NULL != pBusList)    {        /* Check for duplicate entries */        if (pBusList->uBusHandle == uBusHandle)        {            /* Jump out of the loop */            break;        } /* End of if (pBusList->....*/        /* Move the pointer to the next bus */        pBusList=pBusList->pNextBus;    } /* End of While (NULL != pBusList) */    /* Check if we found the bus */    if (NULL==pBusList)    {        /* Debug Message */        OS_LOG_MESSAGE_MEDIUM(            HUB,"HUB_GetRootHubHandle: BUS NOT FOUND \n",0,0,0,0);        /* nope.. we did not find the bus, so we return  failure*/        return USBHST_FAILURE;    } /* End of if (NULL==pBusList) */    /* Retrieve the HUB_INFO structure from the HUB_BUS_INFO structure.*/    pRootHub = pBusList->pRootHubInfo;    /* Check if the root hub is present */    if (NULL == pRootHub)    {        /* Debug Message */        OS_LOG_MESSAGE_HIGH(            HUB,"HUB_GetRootHubHandle: root hub NOT FOUND \n",0,0,0,0);        /* nope.. we did not find the root hub, so we return  failure*/        return USBHST_FAILURE;    } /* End of if if (NULL == pRootHub) */    /* Retrieve the device handle */    *pRootHubHandle = pRootHub->uDeviceHandle;    /* Check if the root hub handle is valid */    if (0 == *pRootHubHandle)    {        /* Debug Message */        OS_LOG_MESSAGE_HIGH(            HUB,"HUB_GetRootHubHandle: root hub NOT FOUND- \n",0,0,0,0);        /* nope.. we did not find the root hub, so we return  failure*/        return USBHST_FAILURE;    } /* End of if if (0 == pRootHub->uDeviceHandle) */   /* return success */   return USBHST_SUCCESS;}/* End of usbHubGetRootHubHandle() *//**************************** End of File usbHubMisc.c *************************/

⌨️ 快捷键说明

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