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

📄 usbohcitransfermanagement.c

📁 风河的vxworks-6.3 FOR amcc440epx BSP!
💻 C
📖 第 1 页 / 共 5 页
字号:
/* Function to delete a pipe from the list of periodic pipes */LOCAL USBHST_STATUS usbOhciDeletePeriodicPipe				(UINT8                       	uHostControllerIndex,                 PUSB_OHCI_ENDPOINT_DESCRIPTOR  pEndpointDescriptor);/* Function to check whether the URB is pending for the endpoint */LOCAL BOOLEAN usbOhciIsUrbPending				(UINT8                         	uHostControllerIndex,                  PUSB_OHCI_ENDPOINT_DESCRIPTOR  pEndpointDescriptor,                 pUSBHST_URB                   	pUrb);/* Function to cancel an URB pending for the endpoint */LOCAL USBHST_STATUS usbOhciCancelUrbForEndpoint				(UINT8                         	uHostControllerIndex,                 PUSB_OHCI_ENDPOINT_DESCRIPTOR  pEndpointDescriptor,                 pUSBHST_URB                   	pUrb);/*  * Function to modify the general transfer descriptor list. If an URB is to be  * deleted, the transfer descriptor list should modified in order to remove  * the transfer descriptors associated with the URB to be deleted. */LOCAL VOID usbOhciModifyGeneralTransferDescriptorList(                UINT32                      	uHostControllerIndex,                PUSB_OHCI_ENDPOINT_DESCRIPTOR   pEndpointDescriptor,        	PUSB_OHCI_URB_LIST              pPreviousUrbListNode,        	PUSB_OHCI_URB_LIST              pUrbToBeCancelled);/*  * Function to modify the isochronous transfer descriptor list. If an URB is  * to be deleted, the transfer descriptor list should modified in order to  * remove the transfer descriptors associated with the URB to be deleted. */LOCAL VOID usbOhciModifyIsochronousTransferDescriptorList(                         UINT32                      	 uHostControllerIndex,                         PUSB_OHCI_ENDPOINT_DESCRIPTOR   pEndpointDescriptor,    			 PUSB_OHCI_URB_LIST              pPreviousUrbListNode,    			 PUSB_OHCI_URB_LIST              pUrbToBeCancelled);/* functions *//*********************** GLOBAL FUNCTIONS DEFINITION **************************//* NONE *//******************* MODULE SPECIFIC FUNCTIONS DEFINITION *********************//*************** THESE FUNCTIONS WILL BE REGISTERED WITH USBD *****************//***************************************************************************** usbOhciCreatePipe - creates the pipes** This function is used to create the pipes for the endpoint. The function * takes the endpoint descriptor as parameter.** PARAMETERS: <uHostControllerIndex (IN)> - Host controller index corresponding * to the OHCI controller.** <uDeviceAddress (IN)> - USB address for the device.** <uSpeed (IN)> - Speed of the device.** <pEndpointDescriptor (IN)> - Pointer to the endpoint descriptor.** <uHighSpeedHubInfo (IN)> - 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.** Note: This parameter is not used in OHCI driver.** <puPipeHandle (OUT)> - Pointer to the pipe handle corresponding to endpoint.** RETURNS: USBHST_SUCCESS on success,* USBHST_INVALID_PARAMETER if the parameters are not valid* USBHST_INSUFFICIENT_MEMORY if the memory allocation fails** ERRNO:*   None.*/LOCAL USBHST_STATUS usbOhciCreatePipe    (    UINT8      uHostControllerIndex,    UINT8      uDeviceAddress,    UINT8      uSpeed,    PUCHAR     pEndpointDescriptor,    UINT16     uHighSpeedHubInfo,    PUINT32    puPipeHandle    )    {    /* To hold the pointer to the OHCI endpoint descriptor */    PUSB_OHCI_ENDPOINT_DESCRIPTOR   pOhciEndpointDescriptor = NULL;    /* To hold the temporary pointer to the OHCI endpoint descriptor */    PUSB_OHCI_ENDPOINT_DESCRIPTOR   pTempEndpointDescriptor = NULL;    /* To hold the pointer to the empty general transfer descriptor */    PUSB_OHCI_GENERAL_TRANSFER_DESCRIPTOR   									pEmptyGeneralTransferDescriptor = NULL;    /* To hold the pointer to the empty isochronous transfer descriptor */    PUSB_OHCI_ISOCHRONOUS_TRANSFER_DESCRIPTOR 									pEmptyIsochronousTransferDescriptor = 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 status of adding an interrupt or isochronous endpoint      * descriptor to the periodic endpoint descriptor list.     */    USBHST_STATUS   nStatus = USBHST_SUCCESS;    /*      * Variable to hold the information to be populated in the OHCI      * endpoint descriptor (BEGIN).     */    /* To hold the pointer to the USB Endpoint Descriptor */    PUSB_ENDPOINT_DESCRIPTOR   pUsbEndpointDescriptor = 0;    /* To hold the endpoint number */    UINT8   						uEndpointNumber = 0;    /* To hold the endpoint direction */    UINT8   						uEndpointDirection = 0;    /* To hold the endpoint transfer type */    UINT8   						uEndpointTransferType = 0;    /* To hold the maximum packet size for the endpoint */    UINT16   						uEndpointMaximumPacketSize = 0;    /* To hold the format of the transfer descriptor (TD) */    UINT8   						uTransferDescriptorFormat = 0;    /*      * Variable to hold the information to be populated in the OHCI      * endpoint descriptor (END).     */    /* To hold the temporary data */    UINT32  						uTemp = 0;        /* Debug print */    OS_LOG_MESSAGE_LOW(        OHCD,        "Entering the function: usbOhciCreatePipe().\n",         0,         0,         0,         0);	/* WindView Instrumentation */	USB_HCD_LOG_EVENT(		USB_OHCI_WV_TRANSFER, 		"usbOhciCreatePipe() 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: usbOhciCreatePipe().\n",             0,             0,             0,             0);    		        return USBHST_INVALID_PARAMETER;    	}    /* Check whether the device address is valid */    if (uDeviceAddress > 127)    	{    	/* Debug print */        OS_LOG_MESSAGE_LOW(            OHCD,            "Exiting the function: usbOhciCreatePipe().\n",             0,             0,             0,             0);    			        return USBHST_INVALID_PARAMETER;    	}    /* Check whether the device speed is valid */    if ((uSpeed != USBHST_FULL_SPEED) && (uSpeed != USBHST_LOW_SPEED))    	{    	/* Debug print */        OS_LOG_MESSAGE_LOW(            OHCD,            "Exiting the function: usbOhciCreatePipe().\n",             0,             0,             0,             0);    				        return USBHST_INVALID_PARAMETER;    	}    /* Check whether the pointer to the pipe handle is valid */    if (puPipeHandle == NULL)    	{    	/* Debug print */        OS_LOG_MESSAGE_LOW(            OHCD,            "Exiting the function: usbOhciCreatePipe().\n",             0,             0,             0,             0);    				        return USBHST_INVALID_PARAMETER;    	}    /* Obtain the pointer to the host controller information */    pOhciControllerInfo = &usbOhciControllerInfo[uHostControllerIndex];    /*     * Check whether the request is addressed to the root hub.     *     * NOTE: Two levels of check are required.     *     *       a) Check whether the pipe is created when the root hub     *          is in default state. This condition will arise when the      *          default control pipe (address 0, endpoint 0) is created      *          as part of the OHCI controller initialization.     *       b) Check whether the device address corresponds to the      *          the root hub address.     */    if ((pOhciControllerInfo->uRootHubState != USB_OHCI_DEVICE_DEFAULT_STATE) &&        (pOhciControllerInfo->uRootHubAddress == uDeviceAddress))    	{        /*          * Update the pipe handle parameter.         *         * NOTE: This is a dummy pipe handle created for the endpoints         *       on the root hub.         */        *puPipeHandle = (UINT32) USB_OHCI_ROOT_HUB_PIPE_HANDLE;        /* Return success. No pipes are created for the root hub. */        /* Debug print */        OS_LOG_MESSAGE_LOW(            OHCD,            "Exiting the function: usbOhciCreatePipe().\n",             0,             0,             0,             0);    			        return USBHST_SUCCESS;    	}    /*      * Check whether the USB endpoint desriptor pointer is valid.     *     * NOTE: No pipes are created for the root hub. Hence, validate the     *       pEndpointDescriptor parameter after confirming the request     *       is not for the root hub.     */    if (pEndpointDescriptor == NULL)   		{   		/* Debug print */        OS_LOG_MESSAGE_LOW(            OHCD,            "Exiting the function: usbOhciCreatePipe().\n",             0,             0,             0,             0);    				        return USBHST_INVALID_PARAMETER;    	}    /* Initialize the pointer to the USB endpoint descritpor */    pUsbEndpointDescriptor = (PUSB_ENDPOINT_DESCRIPTOR) pEndpointDescriptor;    /* Check whether the USB endpoint descriptor is valid */    if (pUsbEndpointDescriptor->bDescriptorType != 		USB_OHCI_ENDPOINT_DESCRIPTOR_TYPE)    	{    	/* Debug print */        OS_LOG_MESSAGE_LOW(            OHCD,            "Exiting the function: usbOhciCreatePipe().\n",             0,             0,             0,             0);    				        return USBHST_INVALID_PARAMETER;    	}    /*      * Check whether an attempt is made to create a pipe for the default      * control endpoint. Duplication of default pipe is not allowed.     */    if ((uDeviceAddress == 0) &&         (pOhciControllerInfo->pDefaultEndpointDescriptor != NULL))    	{    	/* Debug print */        OS_LOG_MESSAGE_LOW(            OHCD,            "Exiting the function: usbOhciCreatePipe().\n",             0,             0,             0,             0);    				        return USBHST_INVALID_PARAMETER;    	}    /* Obtain the base address */    uBaseAddress = pOhciControllerInfo->uBaseAddress;    /* Allocate memory for the OHCI endpoint descriptor */    pOhciEndpointDescriptor =        (PUSB_OHCI_ENDPOINT_DESCRIPTOR)        OS_MALLOC(sizeof(USB_OHCI_ENDPOINT_DESCRIPTOR) +                  USB_OHCI_ENDPOINT_DESCRIPTOR_ALIGNMENT);    /* Check whether the memory allocation was successful */    if (pOhciEndpointDescriptor == NULL)    	{    	/* Debug print */        OS_LOG_MESSAGE_LOW(            OHCD,            "Exiting the function: usbOhciCreatePipe().\n",             0,             0,             0,             0);    				        return USBHST_INSUFFICIENT_MEMORY;    	}    /* Clear the endpoint descriptor memory */    OS_MEMSET(pOhciEndpointDescriptor,               0,               sizeof(USB_OHCI_ENDPOINT_DESCRIPTOR) +               USB_OHCI_ENDPOINT_DESCRIPTOR_ALIGNMENT);    /*     * Check whether the OHCI endpoint descriptor is aligned to 16 bytes     * boundary.     */    uTemp = (UINT32) pOhciEndpointDescriptor;    if ((uTemp & USB_OHCI_ENDPOINT_DESCRIPTOR_ALIGNMENT_MASK) != 0)    	{        /* Align the OHCI endpoint descriptor to 16 bytes boundary */        pOhciEndpointDescriptor =            (PUSB_OHCI_ENDPOINT_DESCRIPTOR)            ((uTemp & (~USB_OHCI_ENDPOINT_DESCRIPTOR_ALIGNMENT_MASK)) +              USB_OHCI_ENDPOINT_DESCRIPTOR_ALIGNMENT);    	}    /*     * Store the pointer to the non aligned endpoint descriptor. This      * pointer will be used to release the memory allocated for the     * endpoint descriptor.     */    pOhciEndpointDescriptor->pNonAlignedEndpointDescriptor =        (PUSB_OHCI_ENDPOINT_DESCRIPTOR) uTemp;    /* Store the aligned ED in the data structure. This is required     * to retrieve this pointer from the PCI pointer     */    pOhciEndpointDescriptor->pAlignedED = pOhciEndpointDescriptor;    /* Obtain the endpoint number */    uEndpointNumber =        USB_GET_ENDPOINT_NUMBER(pUsbEndpointDescriptor->bEndpointAddress);    /* Obtain the endpoint direction */    uEndpointDirection =        USB_GET_ENDPOINT_DIRECTION(pUsbEndpointDescriptor->bEndpointAddress);

⌨️ 快捷键说明

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