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

📄 usbtcdnet2280endpoint.c

📁 This the compressed USB driver source code for vxworks5.6. It has device controller driver and other
💻 C
📖 第 1 页 / 共 5 页
字号:
                sizeToCopy = pEndpointInfo->dmaTransferLength -                                 (NET2280_CFG_READ (pTarget,                                         NET2280_DMACOUNT_OFFSET(endpointIndex))                                        & NET2280_DMACOUNT_BC);                /* Invalidate DMA buffer */                USB_PCI_MEM_INVALIDATE ((char *) pEndpointInfo->dmaBuffer,                                            sizeToCopy);                /* Read the EP_AVAIL register contents */                data32 = NET2280_CFG_READ (pTarget,                                   NET2280_EP_AVAIL_OFFSET (endpointIndex));                /*                 * Check if there is a short packet and there is some more                 * data in the FIFO which is yet to be copied.                 * This condition can happen when the data received is not a                 * multiple of 4.                 */                if ((pEndpointInfo->dmaTransferLength != sizeToCopy) &&                    (data32 > 0) && (data32 < 4))                    {                    /* Update pBuf pointer */                    pBuf =  pTrb->pBuffer + sizeToCopy;                    /* Update the size to copy */                    sizeToCopy += data32;                    /* Copy the size of data available */                      i = data32;                    /* Read EP_DATA register for the corresponding endpoint */                    data32 = NET2280_CFG_READ (pTarget,                             NET2280_EP_DATA_OFFSET (endpointIndex));                    /* Update TRB::pBuffer */                    for (; i > 0; i--)                        {                        *pBuf = (char) (data32 & 0xFF);                                  data32 >>= 8;                        pBuf++;                              }                    }                                 /*                 * Clear the NAK OUT mode bit which enables further                  * reception of packets.                 */                 NET2280_CFG_WRITE (pTarget,                                    NET2280_EP_STAT_OFFSET(endpointIndex),                                    NET2280_EP_STAT_NAKOUT);                /*                 * If the size of data requested is more than the                  * dma transfer length, initiate the dma again                 */                if ((sizeToCopy == pEndpointInfo->dmaTransferLength) &&                    (pTrb->uActLength > pEndpointInfo->dmaTransferLength))                    {                    /* Store the return value temporarily, need not use it */                    data32 = initializeDma(pTarget, pEndpointInfo);                    }                 else /* Request is completed */                    {                    USB_TCD_LOG_EVENT (USB_TCD_NET2280_ENDPOINT,                    "usbTcdNET2280FncCopyDataFromEpBuf...DMA \                    Transfer Completed Successfully... Disabling DMA ",                    USB_TCD_NET2280_WV_FILTER);                    /* Disable the DMA */                    disableDma (pTarget, pEndpointInfo);                    }                /* update uActLength with the size copied */                  pTrb->uActLength = sizeToCopy;                return OK;                }             else                 {                pTrb->uActLength = 0;                /* DMA is in USE */                  return OK;                  }                               }        else            {            /*             * Determine the size of data which can be transmitted             * in one dma transfer             */            pEndpointInfo->dmaTransferLength = (pTrb->uActLength <             NET2280_DMA_TRANS_SIZE) ? pTrb->uActLength :                                       NET2280_DMA_TRANS_SIZE;            /* Copy the buffer pointer */            pEndpointInfo->dmaBuffer = pTrb->pBuffer;             /* WindView Instrumentation */            USB_TCD_LOG_EVENT (USB_TCD_NET2280_ENDPOINT,            "usbTcdNET2280FncCopyDataFromEpBuf: Intiating DMA Activity... ",            USB_TCD_NET2280_WV_FILTER);            /* Initiate DMA activity on that endpoint */            pTrb->uActLength = initializeDma (pTarget, pEndpointInfo);            }          }         else        {#endif        /* Determine if transfer type is CONTROL */        if (transferType == USB_ATTR_CONTROL)            {            if (pTarget->statusOUTPending &&               (pTrb->uActLength == 0))                {                pTarget->statusOUTPending = FALSE;                /*                 * Status Stage. The zero length packet will be sent when                  * Control Trnafere Handshake bit is  cleared. This handled                  * in Interrupt routines                 */                return OK;                }                  if (pTarget->setupIntPending)                {                /* Reset the flags */                pTarget->statusOUTPending = FALSE;                pTarget->statusINPending = FALSE;                /* Setup Data has come from host. read the setup register */                /* Update TRB::uActLength to 8 */                pTrb->uActLength = 8;                 /* Read the first setup regsiter */                data32 = NET2280_CFG_READ (pTarget, NET2280_SETUP0123_REG);                for (i = 0; i < 4; i++)                    {                    *(pBuf + i) = (char) (data32 & 0xFF);                              data32 >>= 0x8;                    }                pBuf = pBuf + 4;                /* Read the second setup regsiter */                data32 = NET2280_CFG_READ (pTarget, NET2280_SETUP4567_REG);                for (i = 0; i < 4; i++)                    {                    *(pBuf + i) = (char) (data32 & 0xFF);                              data32 >>= 0x8;                    }                  /* If there is no data stage, update the status pending flag */                if ((pTrb->pBuffer[6] | (pTrb->pBuffer[7] << 8)) == 0)                    pTarget->statusINPending = TRUE;                return OK;                }            } #ifdef NET2280_DMA_SUPPORTED        /*          * If a short packet is detected,          * clear the NAKOUT bit so that further packets can         * be accepted.         */        if (pEndpointInfo->shortPacket)            {            /* Clear the short packet detected flag in EP_STAT register */            NET2280_CFG_WRITE (pTarget,                     NET2280_EP_STAT_OFFSET(endpointIndex),NET2280_EP_STAT_NAKOUT);            /* Reset the short packet detected flag */            pEndpointInfo->shortPacket = FALSE;            }#endif        /* Retrieve the size to be copied from the dataLength field */        sizeToCopy = pEndpointInfo->dataLength;        /* Determine the size to copy */        if (pTrb->uActLength < sizeToCopy)            {            sizeToCopy = pTrb->uActLength;            }        /*          * If it is the last packet which is being copied, set         * the statuspending flag to TRUE.         */        if ((transferType == USB_ATTR_CONTROL) &&           (sizeToCopy == pTrb->uActLength))            pTarget->statusINPending = TRUE;        /* Update TRB::uActLength to sizeToCppy */        pTrb->uActLength = sizeToCopy;        while (sizeToCopy >= 4)            {                        /* Read ET_DATA register for the corresponding endpoint */            data32 = NET2280_CFG_READ (pTarget,                      NET2280_EP_DATA_OFFSET (endpointIndex));             /* Update TRB::pBuffer */            for (i = 0; i < 4; i++)                {                *(pBuf + i) = (char) (data32 & 0xFF);                          data32 >>= 0x8;                }            pBuf = pBuf + 4;              /* decrement size to copy by 4 */            sizeToCopy -= 4;            }          if (sizeToCopy != 0)                                 {                         /*             * There is a short packet received. Read the data from the FIFO             * buffer and clear the NAK OUT Packet bit of endpoint response              * regsiter              */            data32 = NET2280_CFG_READ (pTarget,                      NET2280_EP_DATA_OFFSET (endpointIndex));                                     for (i = 0; i < sizeToCopy; i++)                {                *(pBuf)++ = (char) (data32 & 0xFF);                 data32 >>= 8;                }            }#ifdef NET2280_DMA_SUPPORTED        }#endif     USB_NET2280_DEBUG ("usbTcdNET2280FncCopyDataFromEpBuf: Exiting...\n",    0,0,0,0,0,0);    return OK;                     }                                           /********************************************************************************* usbTcdNET2280FncCopyDataToEpBuf - implements TCD_FNC_COPY_DATA_TO_EPBUF** This function copies the data into the endpoint FIFO buffer from the buffer* that is passed.** RETURNS: OK or ERROR if not able to read data from the enpoint fifo.** ERRNO:* \is* \i S_usbTcdLib_BAD_PARAM.* Bad Parameter is passed.* \ie** \NOMANUAL*/LOCAL STATUS usbTcdNET2280FncCopyDataToEpBuf     (    pTRB_COPY_DATA_TO_EPBUF pTrb		/* TRB to be executed */    )    {    pTRB_HEADER	pHeader = (pTRB_HEADER) pTrb;	/* TRB_HEADER */    pUSB_TCD_NET2280_ENDPOINT	pEndpointInfo = NULL;/*USB_TCD_NET2280_ENDPOINT*/    pUSB_TCD_NET2280_TARGET	pTarget = NULL;	/* USB_TCD_NET2280_TARGET */    UINT8	endpointIndex = 0;		/* endpoint index */    UINT8	transferType = 0;		/* transfer type */    UINT32	sizeToCopy = 0;			/* size to data to copy */    unsigned char  * pBuf = pTrb->pBuffer;	/* pointer to buffer */    UINT32	data32 = 0;			/* temporary variable */    UINT8       i = 0;    UINT16	maxPacket = 0;     /* WindView Instrumentation */    USB_TCD_LOG_EVENT(USB_TCD_NET2280_ENDPOINT,    "usbTcdNET2280FncCopyDataToEpBuf entered...", USB_TCD_NET2280_WV_FILTER);    USB_NET2280_DEBUG ("usbTcdNET2280FncCopyDataToEpBuf: Entered...\n",    0,0,0,0,0,0);    /* Validate parameters */    if ((pHeader == NULL) || (pHeader->trbLength < sizeof (TRB_HEADER)) ||        (pHeader->handle == NULL) || (pTrb->pipeHandle == 0))        {        /* WindView Instrumentation */        USB_TCD_LOG_EVENT (USB_TCD_NET2280_ENDPOINT,        "usbTcdNET2280FncCopyDataToEpBuf exiting...Bad Parameters received",        USB_TCD_NET2280_WV_FILTER);        USB_NET2280_ERROR ("usbTcdNET2280FncCopyDataToEpBuf: Bad Parameters \        ...\n",0,0,0,0,0,0);        return ossStatus(S_usbTcdLib_BAD_PARAM);        }    pEndpointInfo = (pUSB_TCD_NET2280_ENDPOINT)pTrb->pipeHandle;    pTarget = (pUSB_TCD_NET2280_TARGET)pHeader->handle;    endpointIndex = pEndpointInfo->endpointIndex;    transferType = pEndpointInfo->transferType;    /*     * If transfer type is Control and dirction is IN set endpointIndex to 0.      * Endpoint index is used to access the endpoint specific hardware and      * as there is only one control endpoint, set endpoint Index to 0     */     if (endpointIndex == NET2280_ENDPT_0_IN)                endpointIndex = 0;                          #ifdef NET2280_DMA_SUPPORTED    /*      * Check if the endpoint supports DMA and the request length is a     * multiple of maxpacket size.     */    if (pEndpointInfo->isDmaSupported &&        ((pTrb->uActLength %4) == 0))        {        /* Check if a dma transfer is already in use */        if (pEndpointInfo->dmaInUse)            {                        /* Check if dmaEot is detected for the corresponding endpoint*/             if ((pTarget->dmaEot & (1 << endpointIndex)) != 0)                {                /* Reset the corresponding bit in pTarget->dmaEot */                pTarget->dmaEot &= ~(1 << endpointIndex);                /*                  * Initiate another DMA transfer                  * if the actLength is non-zero.                 */                if (pTrb->uActLength != 0)                    {                    /* Update the dma transfer length */                    pEndpointInfo->dmaTransferLength = (pTrb->uActLength <                                 NET2280_DMA_TRANS_SIZE) ?                     pTrb->uActLength : NET2280_DMA_TRANS_SIZE;                    /* Copy the buffer pointer */                    pEndpointInfo->dmaBuffer = pTrb->pBuffer;

⌨️ 快捷键说明

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