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

📄 usbehcdtransfermanagement.c

📁 usb2 driver for vxwokrs
💻 C
📖 第 1 页 / 共 5 页
字号:
    if (uDeviceSpeed != USBHST_HIGH_SPEED)        {        USB_EHCD_SET_BITFIELD(uBusIndex,                              QH,                              pHCDPipe->pQH->uEndPointCapabilities,                              ((uHighSpeedHubInfo &                                    USB_EHCD_PARENT_HUB_ADDRESS_MASK)>> 8),                              ENDPOINT_CAPABILITIES_HUB_ADDR );        USB_EHCD_SET_BITFIELD(uBusIndex,                              QH,                              pHCDPipe->pQH->uEndPointCapabilities,                              (uHighSpeedHubInfo &                                        USB_EHCD_HUB_PORT_NUMBER_MASK),                               ENDPOINT_CAPABILITIES_PORT_NUMBER);        }    else        {        USB_EHCD_SET_BITFIELD(uBusIndex,                              QH,                              pHCDPipe->pQH->uEndPointCapabilities,                              0,                              ENDPOINT_CAPABILITIES_HUB_ADDR );        USB_EHCD_SET_BITFIELD(uBusIndex,                              QH,                              pHCDPipe->pQH->uEndPointCapabilities,                              0,                              ENDPOINT_CAPABILITIES_PORT_NUMBER);        }    /*     * This field is to be set if it is not a high speed device and the     * endpoint is a control endpoint     */    if (USBHST_HIGH_SPEED != uDeviceSpeed)        {        USB_EHCD_SET_BITFIELD(uBusIndex,                              QH,                              pHCDPipe->pQH->uEndPointCharacteristics,                              1 ,                              ENDPOINT_CHARACTERISTICS_CONTROL_ENDPOINT_FLAG);        USB_EHCD_SET_BITFIELD(uBusIndex,                              QH,                              pHCDPipe->pQH->uEndPointCharacteristics,                              0,                              ENDPOINT_CHARACTERISTICS_RL);        }    else        {        USB_EHCD_SET_BITFIELD(uBusIndex,                              QH,                              pHCDPipe->pQH->uEndPointCharacteristics,                              USB_EHCD_MAX_NAK_RATE,                              ENDPOINT_CHARACTERISTICS_RL);        }    /* Modify the maximum packet size */    USB_EHCD_SET_BITFIELD(uBusIndex,                          QH,                          pHCDPipe->pQH->uEndPointCharacteristics,                          uMaxPacketSize,                          ENDPOINT_CHARACTERISTICS_MAXIMUM_PACKET_LENGTH);    /* Flush the contents of the QH to RAM */    CACHE_DMA_FLUSH (pHCDPipe->pQH, sizeof(USB_EHCD_QH));    /* Invalidate the cache */    CACHE_DMA_INVALIDATE (pHCDPipe->pQH, sizeof(USB_EHCD_QH));    OS_LOG_MESSAGE_LOW(EHCD,"usbEhcdModifyDefaultPipe - Exit\n",0,0,0,0);    return USBHST_SUCCESS;    }/* End of usbEhcdModifyDefaultPipe() *//***************************************************************************** usbEhcdIsBandwidthAvailable - checks the bandwidth availability** This function is used to check whether there is enough* bandwidth to support the new configuration or an alternate interface setting* of an interface.* <uBusIndex> specifies the host controller bus index.* <uDeviceAddress> specifies the device address. <uDeviceSpeed> is the speed* of the device which needs to be modified. <pCurrentDescriptor> is the pointer* to the current configuration or interface descriptor. If the pNewDescriptor* corresponds to a USB configuration descriptor, this parameter is ignored* (i.e. this parameter can be NULL). <pNewDescriptor> is the pointer to the new* configuration or interface descriptor.** RETURNS: *   USBHST_SUCCESS - Returned if the new configuration or*       new alternate interface can be supported (ALWAYS)*   USBHST_INVALID_PARAMETER - Returned if the parameters are*       not valid.*   USBHST_INSUFFICIENT_BANDWIDTH - Returned if bandwidth is*       not available.** ERRNO:*   None.** \NOMANUAL*/USBHST_STATUS usbEhcdIsBandwidthAvailable    (    UINT8   uBusIndex,            /* Host controller bus index */    UINT8   uDeviceAddress,       /* Handle to the device addr */    UINT8   uDeviceSpeed,         /* Speed of the device in default state */    UCHAR * pCurrentDescriptor,   /* Ptr to current configuration */    UCHAR * pNewDescriptor        /* Ptr to new configuration */    )    {    /* To hold the pointer to the descriptor header */    pUSBHST_DESCRIPTOR_HEADER   pDescHeader = NULL;    /* To hold the status of the request */    USBHST_STATUS   Status = USBHST_FAILURE;    /* To hold the bandwidth availability status */    BOOLEAN bIsBwAvailable = FALSE;    /* Pointer to the HCD specific data structure */    pUSB_EHCD_DATA  pHCDData = NULL;    /* Array to hold the total bandwidth for each Frame */    PUINT32 FrameBW;    OS_LOG_MESSAGE_LOW(EHCD,"usbEhcdIsBandwidthAvailable - Entry\n",0,0,0,0);	/* WindView Instrumentation */    USB_HCD_LOG_EVENT(		USB_EHCI_WV_TRANSFER,		"usbEhcdIsBandwidthAvailable() starts",		USB_EHCD_WV_FILTER);    /* Check the validity of the parameters */    if (g_EHCDControllerCount <= uBusIndex ||        0 == uDeviceAddress ||        NULL == pNewDescriptor)        {        OS_LOG_MESSAGE_HIGH(EHCD,"Parameters are not valid\n",0,0,0,0);        return USBHST_INVALID_PARAMETER;        }    /* Extract the global data structure */    pHCDData = g_pEHCDData[uBusIndex];    /* Assert if the global pointer is not valid */    OS_ASSERT(NULL != pHCDData);    /* If this request is for the Root hub, return success */    if (uDeviceAddress == pHCDData->RHData.uDeviceAddress)        {        return USBHST_SUCCESS;        }    FrameBW = OS_MALLOC(sizeof(UINT32) * USB_EHCD_MAX_FRAMELIST_SIZE);    if(NULL == FrameBW)    {        OS_LOG_MESSAGE_HIGH(EHCD,"usbEhcdIsBandwidthAvailable - Memory not allocated for the bandwidth\n",0,0,0,0);        return USBHST_MEMORY_NOT_ALLOCATED;    }    /* Initialize the element of array to zero */    OS_MEMSET(FrameBW, 0, sizeof(UINT32) * USB_EHCD_MAX_FRAMELIST_SIZE);    /* Extract the descriptor header of the new descriptor */    pDescHeader = (pUSBHST_DESCRIPTOR_HEADER)pNewDescriptor;    /* Check if it is an interface descriptor */    if (USBHST_INTERFACE_DESC == pDescHeader->uDescriptorType)        {        /* To hold the pointer to the current interface descriptor */        pUSBHST_INTERFACE_DESCRIPTOR pCurrentInterfaceDesc = NULL;        /* To hold the pointer to the new interface descriptor */        pUSBHST_INTERFACE_DESCRIPTOR pNewInterfaceDesc = NULL;        /* Get the current interface descriptor */        pCurrentInterfaceDesc =        (pUSBHST_INTERFACE_DESCRIPTOR)pCurrentDescriptor;        /* Get the new interface descriptor */        pNewInterfaceDesc =        (pUSBHST_INTERFACE_DESCRIPTOR)pNewDescriptor;        /* Call the function to subtract the bandwidth used         * by current interface */        Status = usbEhcdSubBandwidth(pHCDData, uDeviceAddress, uDeviceSpeed, pCurrentInterfaceDesc, FrameBW);        if(USBHST_INSUFFICIENT_MEMORY == Status)        {            OS_LOG_MESSAGE_HIGH(EHCD,"Memory is not available\n",0,0,0,0);                        OS_FREE(FrameBW);            return USBHST_INSUFFICIENT_MEMORY;        }        /* Check the bandwidth for new interface */        bIsBwAvailable =  usbEhcdAddBandwidth(uDeviceSpeed, pNewInterfaceDesc, FrameBW);        if (FALSE == bIsBwAvailable)        {            OS_LOG_MESSAGE_HIGH(EHCD,"Bandwidth is not available\n",0,0,0,0);                        OS_FREE(FrameBW);            return USBHST_INSUFFICIENT_BANDWIDTH;        }    }  /* End of interface descriptor */    /* Check if it is a configuration descriptor */    else if (USBHST_CONFIG_DESC == pDescHeader->uDescriptorType)        {        /* To hold the pointer to the current configuration descriptor */        pUSBHST_CONFIG_DESCRIPTOR pCurrentConfigDesc = NULL;        /* To hold the pointer to the new configuration descriptor */        pUSBHST_CONFIG_DESCRIPTOR pNewConfigDesc = NULL;        /* To hold the pointer to the interface descriptor */        pUSBHST_INTERFACE_DESCRIPTOR pInterfaceDesc = NULL;        /* To hold the total no of interface present in the configuration */        UINT8 uInterfaceCount = 0, uCount;        /* Get the current configuration descriptor */        pCurrentConfigDesc =        (pUSBHST_CONFIG_DESCRIPTOR)pCurrentDescriptor;        /* Get the new configuration descriptor */        pNewConfigDesc =        (pUSBHST_CONFIG_DESCRIPTOR)pNewDescriptor;        /* Subtract bandwidth used by this device */        Status = usbEhcdSubDeviceBandwidth(pHCDData, uDeviceAddress, FrameBW);        if(USBHST_INSUFFICIENT_MEMORY == Status)        {            OS_LOG_MESSAGE_HIGH(EHCD,"Memory is not available\n",0,0,0,0);            OS_FREE(FrameBW);            return USBHST_INSUFFICIENT_MEMORY;        }        /* Get the total no of endpoint for this interface */        uInterfaceCount = pNewConfigDesc->bNumInterfaces;        pInterfaceDesc = (pUSBHST_INTERFACE_DESCRIPTOR)((UINT8 *)(pNewConfigDesc) +                                                    pNewConfigDesc->bLength);        for (uCount=0; uCount < uInterfaceCount; uCount++)        {            while(USBHST_INTERFACE_DESC!=pInterfaceDesc->bDescriptorType)            {                pInterfaceDesc                = (pUSBHST_INTERFACE_DESCRIPTOR)((UINT8 *)(pInterfaceDesc)                                                  + pInterfaceDesc->bLength);        }            if (0 == pInterfaceDesc->bAlternateSetting)            {                /* Check the bandwidth for this interface */                bIsBwAvailable =  usbEhcdAddBandwidth(uDeviceSpeed, pInterfaceDesc, FrameBW);                if (FALSE == bIsBwAvailable)                {                 OS_LOG_MESSAGE_HIGH(EHCD,"Bandwidth is not available\n",0,0,0,0);                 OS_FREE(FrameBW);                 return USBHST_INSUFFICIENT_BANDWIDTH;                }            }            pInterfaceDesc            = (pUSBHST_INTERFACE_DESCRIPTOR)((UINT8 *)(pInterfaceDesc)                                              + pInterfaceDesc->bLength);        } /* End of for () */    }  /* End of configuration descriptor */    /*     * If it is not an interface or configuration descriptor,     * then it is an error     */    else        {        OS_LOG_MESSAGE_HIGH(EHCD,"Descriptor type is not valid\n",0,0,0,0);        OS_FREE(FrameBW);        return USBHST_INVALID_PARAMETER;        }    OS_LOG_MESSAGE_LOW(EHCD,"usbEhcdIsBandwidthAvailable - Exit\n",0,0,0,0);    OS_FREE(FrameBW);    /* Return success */    return USBHST_SUCCESS;    }/* End of usbEhcdIsBandwidthAvailable() *//***************************************************************************** usbEhcdSubmitURB - submits a request to a pipe.** This function is used to submit a request to the pipe. <uBusIndex> specifies* the host controller bus index. <uPipeHandle> holds the pipe handle. <pURB>* is the pointer to the URB holding the request details.** RETURNS: *   USBHST_SUCCESS - Returned if the URB is submitted successfully.*   USBHST_INVALID_PARAMETER - Returned if the parameters are not valid.*   USBHST_INSUFFICIENT_BANDWIDTH - Returned if memory is insufficient for the*       request.** ERRNO:*   None.** \NOMANUAL*/USBHST_STATUS usbEhcdSubmitURB    (    UINT8  uBusIndex,        /* Index of the host controller */    UINT32   uPipeHandle,    /* Pipe handle */    pUSBHST_URB  pURB        /* Pointer to the URB */    )                        {    /* To hold the pointer to the data structure */    pUSB_EHCD_DATA pHCDData = NULL;    /* To hold the PID value */    UINT32 pId;    /* Pointer to the HCD maintained pipe */    pUSB_EHCD_PIPE pHCDPipe = NULL;    /* To hold the request information */    pUSB_EHCD_REQUEST_INFO  pRequestInfo = NULL;    /* To hold the status of the request */    USBHST_STATUS Status = USBHST_FAILURE;    /* To hold the status of the func

⌨️ 快捷键说明

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