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

📄 usbhubporteventhandler.c

📁 usb2 driver for vxwokrs
💻 C
📖 第 1 页 / 共 3 页
字号:
** usbHubPortResetChangeHandler - Handler for the reset change.** This routine handles the reset change.** RETURNS: USBHST_SUCCESS, USBHST_INVALID_PARAMETER, USBHST_FAILURE If any event* handler failed.** ERRNO: None** \NOMANUAL*/LOCAL USBHST_STATUS usbHubPortResetChangeHandler    (    pUSB_HUB_INFO        pHub,    UINT8            uPortIndex,    pUSB_HUB_PORT_STATUS pPortStatus    )    {    /* Storage for the port information */    pUSB_HUB_PORT_INFO pPort=NULL;    /* device handle for parent hub */    UINT32 uParentDeviceHandle =0;    /* storage for parent hub */    pUSB_HUB_INFO  pParentHub = NULL;    /* to store the result of submissions */    USBHST_STATUS Result;    /* Storage of the device Handle */    UINT32 uDeviceHandle = 0;    /* Port number on the hub */    UINT8 uPortNumber = 0;		/* WindView Instrumentation */		USB_HUB_LOG_EVENT(			USB_HUB_WV_EVENT_HANDLER,			"Entering usbHubPortResetChangeHandler() Function",			USB_HUB_WV_FILTER);    /* Debug Message */    OS_LOG_MESSAGE_LOW(        HUB,        "usbHubPortResetChangeHandler: Called "        "pHub=0x%x uPortIndex=%d pPortStatus=0x%x\n",        (UINT32)pHub,        uPortIndex,        (UINT32)pPortStatus,        0);    /* If the pHub is NULL then return USBHST_INVALID_PARAMETER */    if (NULL == pHub)    {        /* Debug Message */        OS_LOG_MESSAGE_MEDIUM(            HUB,"usbHubPortResetChangeHandler: pHub is NULL \n",0,0,0,0);        return USBHST_INVALID_PARAMETER;    }/* End of (NULL == pHub) */    /*     * If the uPortIndex greater than pHub::HubDescriptor::bNbrPorts then     * return USBHST_INVALID_PARAMETER.     * Note: the actual port number is the port index + 1     */    if (uPortIndex >= pHub->HubDescriptor.bNbrPorts)    {        /* Debug Message */        OS_LOG_MESSAGE_MEDIUM(            HUB,            "usbHubPortResetChangeHandler: port= %d >%d \n",            uPortIndex,            pHub->HubDescriptor.bNbrPorts,            0,            0);        return USBHST_INVALID_PARAMETER;    }/* End of if (uPortIndex >= pHub->HubDescriptor.bNbrPorts) */    /* Retrieve the HUB_PORT_INFO from pHub::pPortList[uPortIndex]. */    pPort = pHub->pPortList[uPortIndex];    /*     * Call HUB_CLEAR_PORT_FEATURE() to clear the C_PORT_RESET.     * If failed return result.     * Note: the actual port number is the port index + 1     */    Result = USB_HUB_CLEAR_PORT_FEATURE(pHub,uPortIndex,USB_C_PORT_RESET);    if (USBHST_SUCCESS != Result)    {        /* Debug Message */        OS_LOG_MESSAGE_HIGH(            HUB,            "usbHubPortResetChangeHandler: Clear port feature failed 0x%x\n",            Result,            0,            0,            0);        return Result;    }/* End of USBHST_SUCCESS != Result */    /*     * If the pPortStatus::wPortStatus is Port Disabled then,     * i.    Call HUB_RetryDeviceConfiguration (). If failed, return the result.     * ii.   Return USBHST_SUCCESS.     */    /*     * Sandeep 15/07/2003 Changed from PORT_CONNECTION_VALUE      * If the port has been disabled before the reset completion      * happens ,retry the device configuration     */    if (0 ==(pPortStatus->wPortStatus & USB_PORT_ENABLE_VALUE))    {        Result = usbHubRetryDeviceConfiguration(pHub,uPortIndex);        /* Debug Message */        OS_LOG_MESSAGE_HIGH(            HUB,            "usbHubPortResetChangeHandler: RetryDeviceConfig Result=0x%x\n",            Result,            0,            0,            0);        /* Return the result */        return Result;    } /* End of (0== (pPortStatus... */    OS_ASSERT(NULL != pPort);                                      /* Verify */    /* Update the HUB_PORT_INFO::StateOfPort to HUB_PORT_DEFAULT. */    pPort->StateOfPort = USB_HUB_PORT_DEFAULT;        if (USBHST_HIGH_SPEED != USB_HUB_DEVICE_SPEED(pPortStatus->wPortStatus))    {      /*port is  full speed*/     /* if this hub is a high speed hub then this is the      * hub handle and port number to be passed */        if(pHub->uHubTTInfo > 0)         {            uParentDeviceHandle = pHub->uDeviceHandle;            /* actual port number is port index +1 */            uPortNumber = uPortIndex  + 1;        /*         * Clear the last bit of uPortNumber and set it to One         * if the The hub is multiple TT hub         */        uPortNumber = (uPortNumber & 0x7F) | ((pHub->uHubTTInfo == 2)?0x80:0);        }/*endof if(pHub->uHubTTInfo   )*/        else         {               if(pHub->pBus->pRootHubInfo->uHubTTInfo > 0) /* this is a high speed bus */            {                 pParentHub = usbHubFindNearestParent(pHub->uDeviceHandle ,pHub->pBus->pRootHubInfo,&uPortNumber) ;                                  if( NULL == pParentHub )                 {                      /* Debug Message */                       OS_LOG_MESSAGE_MEDIUM(                             HUB,                             "usbHubPortResetChangeHandler: FindNearestHubFailed \n",                             0,                             0,                             0,                             0);                        return USBHST_INVALID_PARAMETER;                  }/* End of if if( NULL == pParentHub) */                          uParentDeviceHandle = pParentHub->uDeviceHandle;                 /* Actual port number is uPortNumber + 1 */                 uPortNumber = uPortNumber + 1 ;         /*          * Clear the last bit of uPortNumber and set it to One          * if the The hub is multiple TT hub          */         uPortNumber = (uPortNumber & 0x7F) | ((pHub->uHubTTInfo == 2)?0x80:0);            }/* end of if(pHub->pBus...)*/            else /* for full low speed bus pParentHub is amde NULL and port number is Zero*/            {                uParentDeviceHandle = 0;                uPortNumber =0;            }/* end of else */        }/*  end of else  */    }/*end of if( 0 == (pPortStatus->....) )*/    /*     * Call g_USBHSTFunctionList::USBHST_NewDevice(). If this call fails     * i.    Call HUB_RetryDeviceConfiguration (). If failed, return the result.     * ii.   Return USBHST_SUCCESS.     */        Result = g_usbHstFunctionList.UsbdToHubFunctionList.newDevice(                 USB_HUB_DEVICE_SPEED(pPortStatus->wPortStatus),                 pHub->pBus->uBusHandle,                 uParentDeviceHandle,                 uPortNumber,                 &uDeviceHandle);    if (USBHST_SUCCESS != Result)    {        /* Debug Message */        OS_LOG_MESSAGE_HIGH(            HUB,            "usbHubPortResetChangeHandler: New dev failed Result=0x%x\n",            Result,            0,            0,            0);        Result = usbHubRetryDeviceConfiguration(pHub,uPortIndex);#ifdef DEBUG/* Debug Helping code */        if (USBHST_SUCCESS != Result)        {            /* Debug Message */            OS_LOG_MESSAGE_HIGH(                HUB,                "usbHubPortResetChangeHandler: NewDev Failed, "                "RetryDeviceConfig Result=0x%x\n",                Result,                0,                0,                0);        }        else        {            /* Debug Message */            OS_LOG_MESSAGE_LOW(                HUB,                "usbHubPortResetChangeHandler: NewDev Success, RetryDeviceConfig"                "Result=0x%x\n",                Result,                0,                0,                0);        }        /* End of if (USBHST_SUCCESS != Result) */#endif /* of #ifdef DEBUG */        return Result;    } /* End of if (0 !=..  */         /* Update the HUB_PORT_INFO::PortState to HUB_PORT_ADDRESSED. */    pPort->StateOfPort = USB_HUB_PORT_ADDRESSED;    /*     * Update the HUB_PORT_INFO::uDeviceHandle with the device handle returned     * by the USBHST_NewDevice() call.     */    pPort->uDeviceHandle = uDeviceHandle;    /*     * Call the g_USBHSTFunctionList::USBHST_ConfigureDevice() function.     * If this call fails,     * i.    Call HUB_RetryDeviceConfiguration (). If failed, return the result.     * ii.   Return USBHST_SUCCESS.     */    Result= g_usbHstFunctionList.UsbdToHubFunctionList.configureDevice(uDeviceHandle);    if (USBHST_SUCCESS != Result)    {        /* Debug Message */        OS_LOG_MESSAGE_HIGH(            HUB,            "usbHubPortResetChangeHandler: ConfigDev Failed, Result=0x%x\n",            Result,            0,            0,            0);        /* TODO: Call the Remove device of the USBHST */        Result= usbHubRetryDeviceConfiguration(pHub,uPortIndex);#ifdef DEBUG/* Debug help */        if (USBHST_SUCCESS != Result)        {            /* Debug Message */            OS_LOG_MESSAGE_HIGH(                HUB,                "usbHubPortResetChangeHandler: ConfigDev Failed, "                "RetryDeviceConfig Result=0x%x\n",                Result,                0,                0,                0);        }        else        {            /* Debug Message */            OS_LOG_MESSAGE_LOW(                HUB,                "usbHubPortResetChangeHandler: ConfigDev Failed, "                "RetryDeviceConfig Result=0x%x\n",                Result,                0,                0,                0);        }/* End of if (USBHST_SUCCESS != Result) */#endif /* End of #ifdef DEBUG */        /* Return result */        return Result;    } /* End of if (USBHST_SUCCESS != Result) */        /* Update the HUB_PORT_INFO::PortState to HUB_PORT_CONFIGURED. */    pPort->StateOfPort= USB_HUB_PORT_CONFIGURED;    /* Update the pHub::bDeviceBeingConfigured to FALSE. */    pHub->pBus->bDeviceBeingConfigured = FALSE;		/* WindView Instrumentation */		USB_HUB_LOG_EVENT(			USB_HUB_WV_EVENT_HANDLER,			"Exiting usbHubPortResetChangeHandler() Function",			USB_HUB_WV_FILTER);    /* Debug Message */    OS_LOG_MESSAGE_LOW(        HUB,        "usbHubPortResetChangeHandler: Done pHub=0x%x "        "uPortIndex=%d pPortStatus=0x%x\n",        (UINT32)pHub,        uPortIndex,        (UINT32)pPortStatus,        0);    /* Return USBHST_SUCCESS. */    return USBHST_SUCCESS;    } /* End of HUB_PortResetChangeHandler() *//***************************************************************************** usbHubPortOverCurrentChangeHandler - Handler for the over current change.** This routine handles the over current change.** RETURNS: USBHST_SUCCESS, USBHST_INVALID_PARAMETER, USBHST_FAILURE If any event* handler failed.** ERRNO: None** \NOMANUAL*/LOCAL USBHST_STATUS usbHubPortOverCurrentChangeHandler    (    pUSB_HUB_INFO        pHub,    UINT8            uPortIndex,    pUSB_HUB_PORT_STATUS pPortStatus    )    {    /* To store the result of submissions */    USBHST_STATUS Result;		/* WindView Instrumentation */		USB_HUB_LOG_EVENT(			USB_HUB_WV_EVENT_HANDLER,			"Entering usbHubPortOverCurrentChangeHandler() Function",			USB_HUB_WV_FILTER);    /* Debug Message */    OS_LOG_MESSAGE_LOW(        HUB,        "usbHubPortOverCurrentChangeHandler: Called pHub=0x%x "        "uPortIndex=%d pPortStatus=0x%x\n",        (UINT32)pHub,        uPortIndex,        (UINT32)pPortStatus,        0);    /* If the pHub is NULL then return USBHST_INVALID_PARAMETER */    if (NULL == pHub)    {        /* Debug Message */        OS_LOG_MESSAGE_MEDIUM(            HUB,"usbHubPortOverCurrentChangeHandler:pHub is NULL \n",0,0,0,0);        return USBHST_INVALID_PARAMETER;    }/* End of (NULL == pHub) */    /*     * Call HUB_CLEAR_PORT_FEATURE() to clear the C_PORT_OVER_CURRENT.     * If failed return result.     * Note: the actual port number is the port index + 1     */    Result = USB_HUB_CLEAR_PORT_FEATURE(pHub, uPortIndex, USB_C_PORT_OVER_CURRENT);    if (USBHST_SUCCESS != Result)    {        /* Debug Message */        OS_LOG_MESSAGE_HIGH(            HUB,            "usbHubPortOverCurrentChangeHandler: Clear port "            "feature failed 0x%x\n",            Result,            0,            0,            0);        return Result;    }/* End of USBHST_SUCCESS != Result */    /*     * Call HUB_PowerOnPort() to re-enable the ports with the pHub     * and uPortIndex.     */    Result= usbHubPowerOnPort(pHub,uPortIndex);		/* WindView Instrumentation */		USB_HUB_LOG_EVENT(			USB_HUB_WV_EVENT_HANDLER,			"Exiting usbHubPortOverCurrentChangeHandler() Function",			USB_HUB_WV_FILTER);    /* Debug Message */    OS_LOG_MESSAGE_LOW(        HUB,        "usbHubPortOverCurrentChangeHandler:Done pHub=0x%x uPortIndex=%d "         "pPortStatus=0x%x Result=0x%x\n",        (UINT32)pHub,        uPortIndex,        (UINT32)pPortStatus,        Result);    /* Return result of the HUB_PowerOnPort() function call. */    return Result;    } /* End of HUB_PortOverCurrentChangeHandler () *//**************************** End of File HUB_PortEventHandler.c **************/

⌨️ 快捷键说明

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