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

📄 usbhubbusmanager.c

📁 usb2 driver for vxwokrs
💻 C
📖 第 1 页 / 共 2 页
字号:
                    0,                    0);                /*                 * a.Call HUB_PortEventHandler() with the pHub and the port                 * number if this call fails, set the pHub::StateOfHub as                 * MARKED_FOR_DELETION and go to step 5.                 */                Result=usbHubPortEventHandler(pHub,uPortCount);                if (USBHST_SUCCESS != Result)                {                    /* Debug Message */                    OS_LOG_MESSAGE_HIGH(                        HUB,                        "usbHubStatusChangeHandler:Port Evnt failed:"                        "0x%x:port=%d:0x%x\n",                        pHub->uDeviceHandle,                        uPortCount,                        Result,                        0);                    /* Mark the hub for deletion */                    pHub->StateOfHub=USB_MARKED_FOR_DELETION;                    break;                } /* End of if (USBHST_SUCCESS != Result) */            } /* End of if (TRUE==bResult) */            /*             * iv. Retrieve the HUB_PORT_INFO structure from the             *     pHub::pPortList[port number]. If this port is enabled,             */            /* retrive the Port info */            pPort=pHub->pPortList[uPortCount];            /* Check if the port is enabled */            if (NULL != pPort)            {                /*                 * a.If the HUB_PORT_INFO::StateOfPort is HUB_DEBOUNCE_PENDING                 *  then call HUB_PortDebounceHandler(). If this call fails,                 *  then set the pHub::StateOfHub as MARKED_FOR_DELETION and                 *  go to step 5.                 */                if (USB_HUB_DEBOUNCE_PENDING == pPort->StateOfPort)                {                    /* Debug Message */                                        OS_LOG_MESSAGE_LOW(                        HUB,                        "usbHubStatusChangeHandler:Debounce detect:0x%x:"                        "port=%d\n",                        pHub->uDeviceHandle,                        uPortCount,                        0,                        0);                    /* handle the debounce */                    Result =usbHubPortDebounceHandler(pHub,uPortCount);                    if (USBHST_SUCCESS != Result)                    {                        /* Debug Message */                        OS_LOG_MESSAGE_HIGH(                            HUB,                            "usbHubStatusChangeHandler:Debounce failed:"                            "0x%x:port=%d:0x%x\n",                            pHub->uDeviceHandle,                            uPortCount,                            Result,                            0);                        /* Mark the hub for deletion */                        pHub->StateOfHub=USB_MARKED_FOR_DELETION;                        /* break off from the loop */                        break;                    } /* End of if (USBHST_SUCCESS != Result) */                }/* End of HUB_DEBOUNCE... */                /*                 * b.If the HUB_PORT_INFO::StateOfPort is HUB_RESET_PENDING then                 * call the HUB_HandleDeviceConnection(). If this call fails,                 * then set the pHub::StateOfHub as MARKED_FOR_DELETION                 * and go to step 5.                 */                if (USB_HUB_RESET_PENDING == pPort->StateOfPort)                {                    /* Debug Message */                    OS_LOG_MESSAGE_LOW(                        HUB,                        "usbHubStatusChangeHandler:reset pending detect:0x%x:"                        "port=%d\n",                        pHub->uDeviceHandle,                        uPortCount,                        0,                        0);                    Result=usbHubHandleDeviceConnection(pHub,uPortCount);                    if (USBHST_SUCCESS != Result)                    {                        /* Debug Message */                        OS_LOG_MESSAGE_HIGH(                            HUB,                            "usbHubStatusChangeHandler:Hndl devcon failed:0x%x:"                            "port=%d:0x%x\n",                            pHub->uDeviceHandle,                            uPortCount,                            Result,                            0);                        /* Mark the hub for deletion */                        pHub->StateOfHub=USB_MARKED_FOR_DELETION;                        break;                    } /* End of if (USBHST_SUCCESS != Result) */                }/* End of HUB_RESET... */                /*                 * c.If the HUB_PORT_INFO::StateOfPort is not                 * MARKED_FOR_DELETION then go to next iteration of for loop                 */                if (USB_MARKED_FOR_DELETION != pPort->StateOfPort)                {                    continue;                }/* End of MARKED_FOR_DELETION... */                /* Debug Message */                OS_LOG_MESSAGE_HIGH(                    HUB,                    "usbHubStatusChangeHandler:Port to be deleted:"                    "0x%x:port=%d:\n",                    pHub->uDeviceHandle,                    uPortCount,                    0,                    0);                /*                 * If HUB_PORT_INFO::pHub is NULL then call                 * HUB_RemoveDevice() and free HUB_PORT_INFO and set the                 * pHub::pPortList[port count] as NULL.                 * 9/5/2k3:NM: Changed here to centralise the effect                 */               usbHubRemoveDevice(pHub,uPortCount);                /* Set the port variable to NULL */                pPort = NULL;                /*                 * f. Call HUB_CLEAR_PORT_FEATURE() with the PORT_ENABLE as the                 * feature. If this call fails then set the pHub::StateOfHub                 * as MARKED_FOR_DELETION and go to step 5.                 * Note: the actual port number is the port count + 1                 */                Result = USB_HUB_CLEAR_PORT_FEATURE(pHub,uPortCount,USB_PORT_ENABLE);                if (USBHST_SUCCESS != Result)                {                    /* Debug Message */                    OS_LOG_MESSAGE_HIGH(                        HUB,                        "usbHubStatusChangeHandler:Port disable failed:"                        "0x%x:port=%d:0x%x\n",                        pHub->uDeviceHandle,                        uPortCount,                        Result,                        0);                    /* Mark the hub for deletion */                    pHub->StateOfHub = USB_MARKED_FOR_DELETION;                    break;                }/* End of if (USBHST_SUCCESS!=Result) */            } /* End of If (NULL != pPort) */        } /* End of for (uPortCount.... */        /* if the hub is marked for deletion fall thru to step 5 */        if (USB_MARKED_FOR_DELETION != pHub->StateOfHub)        {            /*             * For all enabled ports in pHub::pPortList, if the status change             * has been cleared,             * i. Call HUB_SubmitInterruptRequest() with the pHub if this             *    call fails,set the pHub::StateOfHub             *    as MARKED_FOR_DELETION.             */            bResult=FALSE;            for (uPortCount = 0;                 uPortCount < pHub->HubDescriptor.bNbrPorts;                 uPortCount++)            {                /*                 * Check if the port events have been cleared                 * Note: The port number is port count +1                 */                     bResult = USB_HUB_IS_PORT_EVENT(pHub->pStatus, uPortCount+1);                     if (TRUE == bResult)                     {                         /* Debug Message */                         OS_LOG_MESSAGE_HIGH(                             HUB,                             "usbHubStatusChangeHandler:Port Evnt not cleared:"                             "0x%x: port=%d:\n",                             pHub->uDeviceHandle,                             uPortCount,                             0,                             0);                         break;                     }/* End of if (TRUE==.. */                 } /* End of for (uPortCount.... */                 /* Submit the URB is we have not already submitted one. */                 if ( (TRUE !=bResult)&&                      (FALSE == pHub->bURBSubmitted  ) )                 {                     /* Debug Message */                                          OS_LOG_MESSAGE_LOW(                         HUB,                         "usbHubStatusChangeHandler:Submitting IN request:0x%x\n",                         pHub->uDeviceHandle,                         0,                         0,                         0);                     /* Call HUB_SubmitInterruptRequest() with the pHub  */                     Result=usbHubSubmitInterruptRequest(pHub);                     /* If failed, delete the hub */                     if (USBHST_SUCCESS !=Result)                     {                         /* Debug Message */                         OS_LOG_MESSAGE_MEDIUM(                             HUB,                             "usbHubStatusChangeHandler:SubmitRequest Failed:"                             "0x%x:0x%x\n",                             pHub->uDeviceHandle,                             Result,                             0,                             0);                         /* Mark the hub for deletion */                         pHub->StateOfHub=USB_MARKED_FOR_DELETION;                     } /* End of if (USBHST_SUCCESS !=Result) */                 }/* End of if TRUE != bResult*/        }/* End of if (MARKED_FOR_DELETION != pHub->StateOfHub) */    } /* End of (MARKED_FOR_DELETION != pHub->StateOfHub) */    /*     * 5:     * If pHub::StateOfHub is MARKED_FOR_DELETION then     * i.    Call the USBHST_RemoveDevice() function to remove the hub device.     * ii.    Return  USBHST_SUCCESS.     */     if (USB_MARKED_FOR_DELETION == pHub->StateOfHub)     {         /* Debug Message */         OS_LOG_MESSAGE_HIGH(             HUB,             "usbHubStatusChangeHandler:Hub Being deleted 0x%x\n",             pHub->uDeviceHandle,             0,             0,             0);                 /* Call the USBHST function to remove the hub */         g_usbHstFunctionList.UsbdToHubFunctionList.removeDevice(pHub->uDeviceHandle);         return;     } /* End of if (MARKED_FOR_DELETION ==pHub->StateOfHub) */   /*    * For all enabled ports in pHub::pPortList,    * i.    Retrieve the HUB_PORT_INFO structure from the    *       pHub::pPortList[port number].    * ii.   If HUB_PORT_INFO::pHub is not NULL then call    *       HUB_StatusChangeHandler() with HUB_PORT_INFO::pHub.    */    for (uPortCount = 0;         uPortCount < pHub->HubDescriptor.bNbrPorts;         uPortCount++)         {             /* Retrieve the HUB_PORT_INFO structure */             pUSB_HUB_PORT_INFO pPort = pHub->pPortList[uPortCount];                          /* Check if the port is enabled */             if (NULL != pPort)             {                 /* Check if this is a hub */                 if (NULL != pPort->pHub)                 {                     /* Debug Message */                     OS_LOG_MESSAGE_LOW(                         HUB,                         "usbHubStatusChangeHandler:detected hub:0x%x:%d\n",                         pHub->uDeviceHandle,                         uPortCount,                         0,                         0);                      /*                      * we could have events on this hb device too.. so call                      * the handler                      */                    usbHubStatusChangeHandler(pPort->pHub);                 }/* End of if (NULL != pPort->pHub) */             } /* End of If (NULL != pPort) */         } /* End of for (uPortCount.... */         return;}/* End of HUB_StatusChangehandler() *//**************************** End of File HUB_BusManager.c ********************/

⌨️ 快捷键说明

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