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

📄 usbohcitransfermanagement.c

📁 风河的vxworks-6.3 FOR amcc440epx BSP!
💻 C
📖 第 1 页 / 共 5 页
字号:
                                (USB_OHCD_CONVERT_TO_BUS_MEM (                                uHostControllerIndex,                                 pOhciEndpointDescriptor)));        		}        	/*        	 * Update the pointer to the tail of the bulk endpoint descriptor        	 * list        	 */       		pOhciControllerInfo->pBulkEndpointDescriptorListTail =            	pOhciEndpointDescriptor;        	break;    	case USB_OHCI_INTERRUPT_TRANSFER:        	/* Compute the bandwidth required for the endpoint */        	uEndpointMaximumPacketSize =            	USB_OHCI_COMPUTE_BANDWIDTH_FOR_INTERRUPT_ENDPOINT(                    uSpeed,                    uEndpointDirection,                	uEndpointMaximumPacketSize);        	/*        	 * Call the function to add the new endpoint descriptor to the        	 * interrupt endpoint descriptor list.        	 */        	nStatus = usbOhciAddNodeToEndpointDescriptorList(                      	uHostControllerIndex,                      	pOhciEndpointDescriptor,                      	pUsbEndpointDescriptor->bInterval,                      	uEndpointMaximumPacketSize);        	/*        	 * Check whether the new endpoint descriptor was successfully added        	 * to the interrupt endpoint descriptor list.        	 */        	if (nStatus != USBHST_SUCCESS)        		{            	/* Delete the transfer descriptor list */            	usbOhciDestroyGeneralTransferDescriptorList(                	pEmptyGeneralTransferDescriptor);            	/* Release the memory allocated for the endpoint descritpor */                OHCI_FREE(pOhciEndpointDescriptor->pNonAlignedEndpointDescriptor);                /* Reset the handle to the pipe */                pOhciEndpointDescriptor = NULL;                /* Update the status of the operation */                nStatus = USBHST_INSUFFICIENT_BANDWIDTH;        		}        	break;    	case USB_OHCI_ISOCHRONOUS_TRANSFER:        	/* Compute the bandwidth required for the endpoint */        	uEndpointMaximumPacketSize =            	USB_OHCI_COMPUTE_BANDWIDTH_FOR_ISOCHRONOUS_ENDPOINT(                    uSpeed,                    uEndpointDirection,                	uEndpointMaximumPacketSize);        	/*        	 * Call the function to add the new endpoint descriptor to the        	 * interrupt endpoint descriptor list.        	 */        	nStatus = usbOhciAddNodeToEndpointDescriptorList(                      	uHostControllerIndex,                      	pOhciEndpointDescriptor,                      	USB_OHCI_ISOCHRONOUS_ENDPOINT_POLLING_INTERVAL,                      	uEndpointMaximumPacketSize);        	/*        	 * Check whether the new endpoint descriptor was successfully added        	 * to the interrupt endpoint descriptor list.        	 */        	if (nStatus != USBHST_SUCCESS)        		{            	/* Delete the transfer descriptor list */            	usbOhciDestroyIsochronousTransferDescriptorList(                	pEmptyIsochronousTransferDescriptor);            	/* Release the memory allocated for the endpoint descritpor */                OHCI_FREE(pOhciEndpointDescriptor->pNonAlignedEndpointDescriptor);                /* Reset the handle to the pipe */                pOhciEndpointDescriptor = NULL;                /* Update the status of the operation */                nStatus = USBHST_INSUFFICIENT_BANDWIDTH;        		}        	break;    	default:        	/* Check whether the general transfer descriptor list is valid */        	if (pEmptyGeneralTransferDescriptor != NULL)        		{            	/* Delete the transfer descriptor list */            	usbOhciDestroyGeneralTransferDescriptorList(                	pEmptyGeneralTransferDescriptor);        		}        	/* Check whether the isochronous transfer descriptor list is valid */        	if (pEmptyIsochronousTransferDescriptor != NULL)        		{            	/* Delete the transfer descriptor list */            	usbOhciDestroyIsochronousTransferDescriptorList(                	pEmptyIsochronousTransferDescriptor);        		}        	/* Release the memory allocated for the endpoint descriptor */                OHCI_FREE(pOhciEndpointDescriptor->pNonAlignedEndpointDescriptor);                     /* Reset the handle to the pipe */            pOhciEndpointDescriptor = NULL;            /* Update the status of the operation */            nStatus = USBHST_INSUFFICIENT_BANDWIDTH;            break;    	};    /*     * Release the 'endpoint list access event' before updating the     * list. This event is important to prevent simultaneous updation of     * the endpoint descriptor list.     */    OS_RELEASE_EVENT(pOhciControllerInfo->endpointListAccessEvent);    /* If the status is not success, release the memory allocated earlier     * and return the status     */     if (nStatus != USBHST_SUCCESS)        {        /* Release the memory allocated for the endpoint descritpor */        OHCI_FREE(pOhciEndpointDescriptor->pNonAlignedEndpointDescriptor);        OS_LOG_MESSAGE_HIGH(            OHCD,            "Exiting the function with an error: usbOhciCreatePipe().\n",             0,             0,             0,             0);    			        return nStatus;        }    /* Populate the endpoint descriptor (END) */    /* Update the pipe parameter */    *puPipeHandle = (UINT32) pOhciEndpointDescriptor;    /* Return the status of the create pipe operation */        /* Debug print */        OS_LOG_MESSAGE_LOW(            OHCD,            "Exiting the function: usbOhciCreatePipe().\n",             0,             0,             0,             0);    			    return nStatus;    } /* End of function usbOhciCreatePipe () *//***************************************************************************** usbOhciDeletePipe - deletes a pipe** This function is used to delete a pipe corresponding to an endpoint.** PARAMETERS: <uHostControllerIndex (IN)> - Host controller index corresponding* to the OHCI controller.** <uPipeHandle (IN)> - Handle to the pipe to be deleted.** RETURNS: USBHST_SUCCESS on success,* USBHST_INVALID_PARAMETER if the parameters are not valid** ERRNO:*   None.*/LOCAL USBHST_STATUS usbOhciDeletePipe    (    UINT8  uHostControllerIndex,    UINT32 uPipeHandle    )    {    /* To hold the pointer to the endpoint descriptor */    PUSB_OHCI_ENDPOINT_DESCRIPTOR pEndpointDescriptor = NULL;    /* To hold the pointer to the temporary endpoint descriptor */    PUSB_OHCI_ENDPOINT_DESCRIPTOR pTempEndpointDescriptor = NULL;    /* To hold the pointer to the head of the periodic list */    PUINT32  puPeriodicListHead = NULL;    /* To hold the pointer to the host controller information */    PUSB_OHCI_INFORMATION   pOhciControllerInfo = NULL;    /* To hold the base address of the OHCI Controller */    UINT32  uBaseAddress = 0;    /* To hold the polling interval for the periodic endpoints */    UINT8   uPollingInterval = 0;    /* To hold the loop index */    UINT32  uIndex = 0;    /* To hold the status of the delete operation */    USBHST_STATUS   nStatus = USBHST_SUCCESS;        /* Debug print */    OS_LOG_MESSAGE_LOW(        OHCD,        "Entering the function: usbOhciDeletePipe().\n",         0,         0,         0,         0);    				/* WindView Instrumentation */	USB_HCD_LOG_EVENT(		USB_OHCI_WV_TRANSFER,		"usbOhciDeletePipe() starts",		USB_OHCD_WV_FILTER);    /* Check whether the OHCI host controller index is valid */    if (uHostControllerIndex >= maxOhciCount)    	{    	/* Debug print */        OS_LOG_MESSAGE_LOW(            OHCD,            "Exiting the function: usbOhciDeletePipe().\n",             0,             0,             0,             0);    				        return USBHST_INVALID_PARAMETER;    	}    /* Check whether the pipe parameter is valid */    if (uPipeHandle == USB_OHCI_INVALID_PIPE_HANDLE)    	{    	/* Debug print */        OS_LOG_MESSAGE_LOW(            OHCD,            "Exiting the function: usbOhciDeletePipe().\n",             0,             0,             0,             0);    					        return USBHST_INVALID_PARAMETER;    	}    /* Obtain the pointer to the host controller information */    pOhciControllerInfo = &usbOhciControllerInfo[uHostControllerIndex];    /*     * Check whether the pipe handle to corresponds to the pipes on     * the root hub.     *     * NOTE: A dummy pipe handle created for the endpoints on the     *       root hub.     */    if (uPipeHandle == USB_OHCI_ROOT_HUB_PIPE_HANDLE)    	{        /*          * Check whether the status change URB is pending for the          * root hub          */        if (NULL != pOhciControllerInfo->pRootHubInterruptRequest)            {            /* To hold the temporary pointer to the URB */            pUSBHST_URB pUrb = pOhciControllerInfo->pRootHubInterruptRequest;            /*              * Reset the status change URB information in the OHCI              * information             */            pOhciControllerInfo->pRootHubInterruptRequest = NULL;            /* Call the call back function for the URB */            (*(pUrb->pfCallback))(pUrb);            }        /* Debug print */        OS_LOG_MESSAGE_LOW(            OHCD,            "Exiting the function: usbOhciDeletePipe().\n",             0,             0,             0,             0);    				        return USBHST_SUCCESS;    	}    /*     * NOTE: It is assumed that the USBD will provide a valid pipe handle.     *       If this handle is invalid, the HCD driver might crash.     *     *       Since the pipe handle is visible only to HCD and USBD, the     *       check has been intensionaly removed to reduce the code size.     *     *       However, if needed, the pipe handle can be compared against     *       the list of endpoint descriptors for every transfer.     */    /* Initialize the endpoint descriptor */    pEndpointDescriptor = (PUSB_OHCI_ENDPOINT_DESCRIPTOR) uPipeHandle;    /* Obtain the base address */    uBaseAddress = pOhciControllerInfo->uBaseAddress;    /*     * Check whether the pipe is present in the list of control pipes.     * If present, delete the pipe and return the status. (BEGIN)     */    /* Read the contents of the HcControlHeadED */    pTempEndpointDescriptor = (PUSB_OHCI_ENDPOINT_DESCRIPTOR)				  (USB_OHCD_CONVERT_FROM_BUS_MEM (                                   uHostControllerIndex,                                    (USB_OHCI_REG_READ(uHostControllerIndex,                                   uBaseAddress +			           USB_OHCI_CONTROL_HEAD_ED_REGISTER_OFFSET))));    if (pTempEndpointDescriptor != NULL)    {        /* Retieve the actual allocated ED from the stored pointer */            pTempEndpointDescriptor = pTempEndpointDescriptor->pAlignedED;    }        /* Check whether the control list is valid */    if (pTempEndpointDescriptor != NULL)    	{        /*         * Check whether the pipe corresponds to the pipe at the head         * of list of control pipes.         */        if (pTempEndpointDescriptor == pEndpointDescriptor)        	{            /*             * Call the function to delete the pipe from the list of             * control pipes.             */            nStatus = usbOhciDeleteControlPipe (uHostControllerIndex,                                             	pTempEndpointDescriptor);            /* Debug print */            OS_LOG_MESSAGE_LOW(                OHCD,                "Exiting the function: usbOhciDeletePipe().\n",                 0,                 0,                 0,                 0);    				            /* Return from the function */            return nStatus;        	}        /*         * Traverse the control list to check whether pipe is present in         * the list of control pipes         */        while ((pTempEndpointDescriptor != NULL) &&               (pTempEndpointDescriptor != pEndpointDescriptor))        	{            /* Traverse to the next element in the list */            /* Copy the value in the HCD maintained next pointer */

⌨️ 快捷键说明

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