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

📄 usbehcdtransfermanagement.c

📁 vxWorks下USB2.0中的EHCI的HCD源码,极具有参考价值
💻 C
📖 第 1 页 / 共 5 页
字号:
                 }                        /* Release the exclusive access */            OS_RELEASE_EVENT(pHCDData->RequestSynchEventID);            /* Exclusively access the bandwidth resource */            OS_WAIT_FOR_EVENT(pHCDData->BandwidthEventID,OS_WAIT_INFINITE);            /* This loop will remove the bandwidth             * allocated in each of the frames             */            for (uFrameIndex = pHCDPipe->uListIndex;                USB_EHCD_MAX_FRAMELIST_SIZE > uFrameIndex;                uFrameIndex += pHCDPipe->uStepValue)                {                /* This loop will update the frame list bandwidth                 * for every microframe                 */                for (uUFrameIndex = 0;                    USB_EHCD_MAX_MICROFRAME_NUMBER > uUFrameIndex;                    uUFrameIndex++)                    {                    /* Check if bandwidth is to be updated for this                     * microframe and update the bandwidth                     */                    if (0 !=                        ((pHCDPipe->uUFrameMaskValue >> uUFrameIndex) & 0x01))                        {                        pHCDData->FrameListData[uFrameIndex].                        uBandwidth[uUFrameIndex] -= pHCDPipe->uBandwidth;                        pHCDData->FrameBandwidth[uFrameIndex][uUFrameIndex] -=                        pHCDPipe->uBandwidth;                        }                    }                }            /* Release the bandwidth exclusive access */            OS_RELEASE_EVENT(pHCDData->BandwidthEventID);            /* Update the bandwidth */            bStatus = usbEhcdUpdateBandwidth(pHCDData);            /* Check if bandwidth updation is successful */            if (FALSE == bStatus)                {                OS_ASSERT(FALSE);                }            }/* End of isochronous endpoint removal request handling */        /* Create a synchronisation  event*/        if (NULL == (pHCDPipe->DeleteSynchEventID = OS_CREATE_EVENT(OS_EVENT_NON_SIGNALED)))            {            OS_ASSERT(FALSE);            }        /* Add to the reclamation list */        USB_EHCD_ADD_TO_PERIODIC_RECLAMATION_LIST(pHCDData,                                                  pHCDPipe);        /* Enable the interrupt to be generated on a frame list rollover */        USB_EHCD_SET_BIT_USBINTR_INT_ON_FRAME_LIST_ROLLOVER(pHCDData);        /* Wait for event handler task to free the resources */        OS_WAIT_FOR_EVENT(pHCDPipe->DeleteSynchEventID, OS_WAIT_INFINITE);        /* Delete the event created */        OS_DESTROY_EVENT(pHCDPipe->DeleteSynchEventID);        /* Free the PIPE */        OS_FREE(pHCDPipe);        }/* End of else */    OS_LOG_MESSAGE_LOW(EHCD,"usbEhcdDeletePipe - Exit\n",0,0,0,0);    /* Return the success status */    return USBHST_SUCCESS;    }/* End of function usbEhcdDeletePipe() *//***************************************************************************** usbEhcdModifyDefaultPipe - modifies the default pipe characteristics.** This function is used to modify the properties (device speed and maximum * packet size) of the default pipe (address 0, endpoint 0). <uBusIndex> * specifies the host controller bus index. <uDefaultPipeHandle> holds the* pipe handle of the default pipe. <uDeviceSpeed> is the speed of the * device which needs to be modified. <uMaxPacketSize> is the maximum packet* size of the default pipe which needs to be modified. <uHighSpeedHubInfo>* specifies the nearest high speed hub and the port number information. This* information will be used to handle a split transfer to the full / low speed* device. The high byte will hold the high speed hub address. The low byte* will hold the port number to which the USB 1.1 device is connected.*** RETURNS: *   USBHST_SUCCESS - Returned if the deafult pipe properties were modified*       successfully.*   USBHST_INVALID_PARAMETER - Returned if the parameters are not valid.** ERRNO:*   None.** \NOMANUAL*/USBHST_STATUS usbEhcdModifyDefaultPipe    (    UINT8   uBusIndex,          /* Host controller bus index               */    UINT32  uDefaultPipeHandle, /* Handle to the default pipe              */    UINT8   uDeviceSpeed,       /* Speed of the device in default state    */    UINT8   uMaxPacketSize,     /* Maximum packet size of the default pipe */    UINT16   uHighSpeedHubInfo  /* High speed hub info for USB 1.1 device  */    )    {    /* To hold the pointer to the EHCD maintained pipe data structure */    pUSB_EHCD_PIPE pHCDPipe = NULL;    /* Pointer to the HCD specific data structure */    pUSB_EHCD_DATA  pHCDData = NULL;	/* WindView Instrumentation */	USB_HCD_LOG_EVENT(		USB_EHCI_WV_TRANSFER,		"usbEhcdModifyDefaultPipe() starts",		USB_EHCD_WV_FILTER);    OS_LOG_MESSAGE_LOW(EHCD,"usbEhcdModifyDefaultPipe - Entry\n",0,0,0,0);    /* Check the validity of the parameters */    if ((g_EHCDControllerCount <= uBusIndex) ||        (0 == uDefaultPipeHandle) ||        (USBHST_HIGH_SPEED != uDeviceSpeed &&         USBHST_FULL_SPEED != uDeviceSpeed &&         USBHST_LOW_SPEED != uDeviceSpeed))        {        OS_LOG_MESSAGE_HIGH(EHCD,"usbEhcdModifyDefaultPipe - parameters 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);    /* Check if this request is for the Root hub */    if (0 == pHCDData->RHData.uDeviceAddress)        {        return USBHST_SUCCESS;        }    /* WARNING : This function will change on split support */    /* Extract the default pipe handle */    pHCDPipe = (pUSB_EHCD_PIPE)uDefaultPipeHandle;    /* Flush the contents of the QH to RAM */    CACHE_DMA_INVALIDATE (pHCDPipe->pQH, sizeof(USB_EHCD_QH));    /* Modify the default pipe contents */    USB_EHCD_SET_BITFIELD(QH,                          pHCDPipe->pQH->uEndPointCharacteristics,                          uDeviceSpeed,                          ENDPOINT_CHARACTERISTICS_ENDPT_SPEED );                             /*pHCDPipe->pQH->dword2.mult = 1;*/   USB_EHCD_SET_BITFIELD(QH,                         pHCDPipe->pQH->uEndPointCapabilities,                         1,                         ENDPOINT_CAPABILITIES_MULT  );    /* Update the hub address and port number for the USB 1.1 device */    if (uDeviceSpeed != USBHST_HIGH_SPEED)        {        USB_EHCD_SET_BITFIELD(QH,                              pHCDPipe->pQH->uEndPointCapabilities,                              ((uHighSpeedHubInfo &                                    USB_EHCD_PARENT_HUB_ADDRESS_MASK)>> 8),                              ENDPOINT_CAPABILITIES_HUB_ADDR );        USB_EHCD_SET_BITFIELD(QH,                              pHCDPipe->pQH->uEndPointCapabilities,                              (uHighSpeedHubInfo &                                        USB_EHCD_HUB_PORT_NUMBER_MASK),                               ENDPOINT_CAPABILITIES_PORT_NUMBER);        }    else        {        USB_EHCD_SET_BITFIELD(QH,                              pHCDPipe->pQH->uEndPointCapabilities,                              0,                              ENDPOINT_CAPABILITIES_HUB_ADDR );        USB_EHCD_SET_BITFIELD(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(QH,                              pHCDPipe->pQH->uEndPointCharacteristics,                              1 ,                              ENDPOINT_CHARACTERISTICS_CONTROL_ENDPOINT_FLAG);        USB_EHCD_SET_BITFIELD(QH,                              pHCDPipe->pQH->uEndPointCharacteristics,                              0,                              ENDPOINT_CHARACTERISTICS_RL);        }    else        {        USB_EHCD_SET_BITFIELD(QH,                              pHCDPipe->pQH->uEndPointCharacteristics,                              USB_EHCD_MAX_NAK_RATE,                              ENDPOINT_CHARACTERISTICS_RL);        }    /* Modify the maximum packet size */    USB_EHCD_SET_BITFIELD(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 */    )    {	/* WindView Instrumentation */    USB_HCD_LOG_EVENT(		USB_EHCI_WV_TRANSFER,		"usbEhcdIsBandwidthAvailable() starts",		USB_EHCD_WV_FILTER);#if 0    /* 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 */    pEHCD_DATA  pHCDData = NULL;    OS_LOG_MESSAGE_LOW(EHCD,"usbEhcdIsBandwidthAvailable - Entry\n",0,0,0,0);    /* 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;        }    /* 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 check whether the bandwidth can         * be accomodated.         */        bIsBwAvailable = USB_EHCD_CheckBandwidthInterface(pHCDData,                                                          uDeviceAddress);        }    /* 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;        /* Check if the current descriptor is NULL */        if (NULL != pCurrentDescriptor)

⌨️ 快捷键说明

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