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

📄 usbehcdtransfermanagement.c

📁 usb2 driver for vxwokrs
💻 C
📖 第 1 页 / 共 5 页
字号:
/* usbEhcdTransferManagement.c - transfer management functions of the EHCD *//* Copyright 2004-2005 Wind River Systems, Inc.    This software includes software licensed to Wind River Systems, Inc.   by Wipro, Ltd. Wind River licensees may use this software according     to the terms of their Wind River license agreement(s) applicable to    this software.*//*modification history--------------------01l,28mar05,pdg  non-PCI changes01k,22mar05,mta  64-bit support added (SPR #104950)01j,02mar05,ami  SPR #106383 (Max EHCI Host Controller Issue)01i,02feb05,pdg  Fix for multiple device connection/disconnection01h,19jan05,pdg  Fix for SPR #104949(USB STACK 2.1 PID 2.1 ISN'T CORRECTLY                 SUPPORTING ON BOARD VIA VT8237 EHCI HOST)01g,10dec04,pdg  corrected IP code error - short packet detection01f,03dec04,ami  Merged IP Changes01e,26oct04,ami  Severity Changes for Debug Messages01d,15oct04,ami  Apigen Changes01c,16aug04,pdg  Fix for print-stop-reprint01b,03aug04,pdg  Fixed coverity errors01a,03aug04,ami  Warning Messages Removed01g,05jul04,???  TD is accessed even after cancelling. Fix for this is                 provided here.01f,08Sep03,nrv Changed g_HostControllerCount to g_EHCDControllerCount01e,28Jul03,gpd Incorporated the changes after integration testing.01d,23Jul03,gpd Incorporated the changes after testing on MIPS.01c,03Jul03,gpd changed the search algorithm on a delete pipe                cancelling URBs should use the asynch on advance and frame                                            list rollover interrupts.01b,26jun03,gpd changing the code to WRS standards.01a,25apr02,ram written.*//*DESCRIPTIONThis module defines the interfaces which are registered with the USBD duringEHCI Host Controller Driver initialization.INCLUDE FILES: usbhst.h, usbEhcdDataStructures.h, usbEhcdInterfaces.h,usbEhcdUtil.h, usbEhcdConfig.h, usbEhcdHal.h, usbEhcdRHEmulation.h, usbEhcdDebug.hSEE ALSO:None*//*INTERNAL ******************************************************************************* * Filename         : EHCD_TransferManagement.c * * Copyright        : * * THE COPYRIGHT IN THE CONTENTS OF THIS SOFTWARE VEST WITH WIPRO * LIMITED A COMPANY INCORPORATED UNDER THE LAWS OF INDIA AND HAVING * ITS REGISTERED OFFICE AT DODDAKANNELLI SARJAPUR ROAD  BANGALORE * 560 035. DISTRIBUTION OR COPYING OF THIS SOFTWARE BY * ANY INDIVIDUAL OR ENTITY OTHER THAN THE ADDRESSEE IS STRICTLY * PROHIBITED AND MAY INCUR LEGAL LIABILITY. IF YOU ARE NOT THE * ADDRESSEE PLEASE NOTIFY US IMMEDIATELY BY PHONE OR BY RETURN EMAIL. * THE ADDRESSEE IS ADVISED TO MAINTAIN THE PROPRIETARY INTERESTS OF * THIS COPYRIGHT AS PER APPLICABLE LAWS. * * Description      :  This contains the functions which handle the transfer *                     management requests from the USBD. * * ******************************************************************************//* includes */#include "usb2/usbOsal.h"#include "usb2/BusAbstractionLayer.h"#include "usb2/usbHst.h"#include "usb2/usbEhcdDataStructures.h"#include "usb2/usbEhcdInterfaces.h"#include "usb2/usbEhcdUtil.h"#include "usb2/usbEhcdConfig.h"#include "usb2/usbEhcdHal.h"#include "usb2/usbEhcdRhEmulation.h"#include "usb2/usbHcdInstr.h"/* globals *//* To hold the array of pointers to the HCD maintained data structures */extern pUSB_EHCD_DATA *g_pEHCDData;/* Number of host controllers present in the system */extern UINT32  g_EHCDControllerCount;/***************************************************************************** usbEhcdCreatePipe - creates a pipe specific to an endpoint.** This function creates the host controller driver specific data structure,* creates the queue head if it is a non-isochronous pipe and populates the* <puPipeHandle> parameter with the pointer to the data structure created for* the pipe. <uBusIndex> is the index of the host controller. <uDeviceAddress>* is the address of the device holding the endpoint. <uDeviceSpeed> is the * speed of the device holding the endpoint. <pEndpointDescriptor> is the * pointer to the endpoint descriptor. <uHighSpeedHubInfo> is the high speed* hub information. <puPipeHandle> is the pointer to the handle to the pipe.** RETURNS: *   USBHST_SUCCESS - Returned if the pipe was created successfully.*   USBHST_INVALID_PARAMETER - Returned if the parameters are not valid.*   USBHST_INSUFFICIENT_MEMORY - Returned if the memory allocation *                                for the pipe failed.** ERRNO:*   None.** \NOMANUAL*/USBHST_STATUS usbEhcdCreatePipe    (    UINT8   uBusIndex,          /* Host controller index      */    UINT8   uDeviceAddress,     /* USB device address         */    UINT8   uDeviceSpeed,       /* USB device speed           */    UCHAR  *pEndpointDescriptor,/* Endpoint descriptor        */    UINT16  uHighSpeedHubInfo,  /* High speed hub information */    UINT32 *puPipeHandle        /* Pointer to the pipe handle */    )    {    /* To hold the status of the request */    USBHST_STATUS Status = USBHST_FAILURE;    /* Pointer to the Endpoint Descriptor */    pUSBHST_ENDPOINT_DESCRIPTOR pEndpointDesc = NULL;    /* To hold the pointer to the EHCD maintained pipe data structure */    pUSB_EHCD_PIPE pHCDPipe = NULL;    /* Bandwidth required for this pipe */    UINT32 uBandwidth = 0;    /* Pointer to the HCD specific data structure */    pUSB_EHCD_DATA  pHCDData = NULL;    /* Microframe mask */    UINT32 uUFrameMask = 0;    /* To hold the index of the list */    UINT32 uListIndex = 0;    /* To hold the index into the microframes */    UINT32 uUFrameIndex = 0;    /* To hold the control end point */    UINT32 controlEndFlag;    /* To hold the pointer to the Queue Head */    pUSB_EHCD_QH pQH = NULL;	/* WindView Instrumentation */	USB_HCD_LOG_EVENT(		USB_EHCI_WV_TRANSFER,		"usbEhcdCreatePipe() starts",		USB_EHCD_WV_FILTER);    OS_LOG_MESSAGE_LOW(EHCD,"usbEhcdCreatePipe - Entry\n",0,0,0,0);    /* Check the validity of the parameters */    if ((g_EHCDControllerCount <= uBusIndex) ||        (USB_EHCD_MAX_DEVICE_ADDRESS < uDeviceAddress) ||        (NULL == pEndpointDescriptor) ||        (NULL == puPipeHandle))        {        OS_LOG_MESSAGE_HIGH(EHCD,"EHCD_CreatePipe - 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);    /* Check if the request is for the Root hub and route it */    if (uDeviceAddress == pHCDData->RHData.uDeviceAddress)        {        Status = usbEhcdRhCreatePipe(pHCDData,                                     uDeviceAddress,                                     uDeviceSpeed,                                     pEndpointDescriptor,                                     puPipeHandle);        return Status;        }    /* Retrieve the endpoint descriptor */    pEndpointDesc = (pUSBHST_ENDPOINT_DESCRIPTOR)pEndpointDescriptor;    /* Swap the maximum packet size to get it in CPU endian format */    pEndpointDesc->wMaxPacketSize =                        OS_UINT16_LE_TO_CPU(pEndpointDesc->wMaxPacketSize);    /* Check the validity of the endpoint type */    if ((USBHST_ISOCHRONOUS_TRANSFER !=         (pEndpointDesc->bmAttributes & USB_EHCD_ENDPOINT_TYPE_MASK)) &&        (USBHST_INTERRUPT_TRANSFER !=         (pEndpointDesc->bmAttributes & USB_EHCD_ENDPOINT_TYPE_MASK)) &&        (USBHST_CONTROL_TRANSFER !=         (pEndpointDesc->bmAttributes & USB_EHCD_ENDPOINT_TYPE_MASK)) &&        (USBHST_BULK_TRANSFER !=         (pEndpointDesc->bmAttributes & USB_EHCD_ENDPOINT_TYPE_MASK)))        {        OS_LOG_MESSAGE_HIGH(EHCD,"usbEhcdCreatePipe - endpoint types is not valid\n",0,0,0,0);        return USBHST_INVALID_PARAMETER;        }    /* Check if the endpoint type is isochronous or interrupt */    if ((USBHST_ISOCHRONOUS_TRANSFER ==         (pEndpointDesc->bmAttributes & USB_EHCD_ENDPOINT_TYPE_MASK)) ||        (USBHST_INTERRUPT_TRANSFER ==         (pEndpointDesc->bmAttributes & USB_EHCD_ENDPOINT_TYPE_MASK)))        {        /* To hold the maximum packet size for the endpoint */        UINT32 uMaxPacketSize = 0;        /* To hold the status of the bandwidth availability */        BOOLEAN bIsBwAvailable = FALSE;        /* If the device speed is high speed, the payload is         * equal the maxpacketsize * number of packets that can         * be sent in a microframe.         * The bits 0 to 10 give the maximum packet size. The bits 11 and 12         * give the (number of packets in a microframe - 1).         */        if (USBHST_HIGH_SPEED == uDeviceSpeed)            {            uMaxPacketSize =            ((pEndpointDesc->wMaxPacketSize) &             USB_EHCD_ENDPOINT_MAX_PACKET_SIZE_MASK) *            ((((pEndpointDesc->wMaxPacketSize) &               USB_EHCD_ENDPOINT_NUMBER_OF_TRANSACTIONS_MASK) >> 11) + 1);            }        /* If it is low or full speed, the maximum packet size is the same         * as that retrieved from the endpoint descriptor         */        else            {            uMaxPacketSize = pEndpointDesc->wMaxPacketSize;            }        /* Calculate the bandwidth which is required for this pipe          *  Pass speed as high speed always EHCD is always high speed          */        uBandwidth = usbEhcdCalculateBusTime(                                            USBHST_HIGH_SPEED,                                            (pEndpointDesc->bEndpointAddress) & USB_EHCD_DIR_IN,                                            (pEndpointDesc->bmAttributes) & USB_EHCD_ENDPOINT_TYPE_MASK,                                            uMaxPacketSize);        /* Check if this bandwidth can be accomodated */        bIsBwAvailable = usbEhcdCheckBandwidth(pHCDData,                                               uBandwidth,                                               uDeviceSpeed,                                               pEndpointDesc,                                               &uListIndex,                                               &uUFrameMask);        /* If bandwidth is not available, return an error */        if (FALSE == bIsBwAvailable)            {            OS_LOG_MESSAGE_HIGH(EHCD,"usbEhcdCreatePipe - bandwidth is not available\n",0,0,0,0);            return USBHST_INSUFFICIENT_BANDWIDTH;            }        }    /* Allocate memory for the USB_EHCD_PIPE data structure */    pHCDPipe = (pUSB_EHCD_PIPE)OS_MALLOC(sizeof(USB_EHCD_PIPE));    /* Check if memory allocation is successful */    if (NULL == pHCDPipe)        {        OS_LOG_MESSAGE_HIGH(EHCD,"usbEhcdCreatePipe - Memory not allocated for EHCD pipe\n",0,0,0,0);        return USBHST_MEMORY_NOT_ALLOCATED;        }    /* Update the pointer to the pipe handle */    *puPipeHandle = (UINT32)pHCDPipe;    /* Initialize the pipe data structure */    USB_EHCD_PIPE_INITIALIZE(pHCDPipe);    /* Update the endpoint speed */    pHCDPipe->uSpeed = uDeviceSpeed;    /* Update the device address which holds the endpoint */    pHCDPipe->uAddress = uDeviceAddress;    /* Update the high speed hub information */    pHCDPipe->uHubInfo = uHighSpeedHubInfo;    /* Update the type of endpoint to be created */    pHCDPipe->uEndpointType =    (pEndpointDesc->bmAttributes) & USB_EHCD_ENDPOINT_TYPE_MASK;    /* Update the direction of the endpoint */    pHCDPipe->uEndpointDir =    ((pEndpointDesc->bEndpointAddress & USB_EHCD_DIR_IN) >> USB_EHCD_DIR_BIT_POSITION) & 0x1;    /* Update Endpoint address */    pHCDPipe->uEndpointAddress = pEndpointDesc->bEndpointAddress;    /* Store the maximum packet size - for high speed includes the number     * of transactions in a microframe also     */    pHCDPipe->uMaximumPacketSize = pEndpointDesc->wMaxPacketSize;    /* If it is an interrupt or isochronous endpoint, update the bandwidth */    if ((USBHST_ISOCHRONOUS_TRANSFER == pHCDPipe->uEndpointType) ||        (USBHST_INTERRUPT_TRANSFER == pHCDPipe->uEndpointType))        {        /* To hold the status of the bandwidth reservation */        BOOLEAN bStatus = FALSE;        /* Update the bandwidth occupied by the endpoint */        pHCDPipe->uBandwidth = uBandwidth;        /* Initialize the last index */        pHCDPipe->uLastIndex = USB_EHCD_NO_LIST;        /* Copy the list index */        pHCDPipe->uListIndex = uListIndex;        /* Copy the mask value */        pHCDPipe->uUFrameMaskValue = uUFrameMask;        /* Update the tree node bandwidth if it is an interrupt endpoint */        if (USBHST_INTERRUPT_TRANSFER == pHCDPipe->uEndpointType)            {            /* Copy the list index */            pHCDPipe->uListIndex = uListIndex;            /* Exclusively access the bandwidth resource */            OS_WAIT_FOR_EVENT(pHCDData->BandwidthEventID,OS_WAIT_INFINITE);            /* This loop will update the tree bandwidth for every microframe */

⌨️ 快捷键说明

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