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

📄 usbehcdutil.c

📁 vxWorks下USB2.0中的EHCI的HCD源码,极具有参考价值
💻 C
📖 第 1 页 / 共 5 页
字号:
             CACHE_DMA_FLUSH(((char*)pQTD+pUSB_EHCD_QTD_NEXT_QTD_POINTER_OFFSET), sizeof(UINT32));            /* Invalidate the cache */              CACHE_DMA_INVALIDATE((char*)pQTD+pUSB_EHCD_QTD_NEXT_QTD_POINTER_OFFSET, sizeof(UINT32));            /* Update the next element as the current qTD element */            pQTD = pQTD->pNext;            /*             * There are no other elements in the queue             * after the newly created element.             */            pQTD->pNext = NULL;            }            /* End of if(uBytesTransfered < uTransferLength) */        }        /* End of while (uBytesTransfered < uTransferLength) */    /* Update the tail pointer */    *ppDataTail = pQTD;    /* Return TRUE from the function */    return TRUE;    }    /* End of function usbEhcdCreateQTDs() *//***************************************************************************** usbEhcdUpdateNonIsochBytesTransferred - updates the number of bytes.** This function is used to update the number of bytes* transferred in a non-isochronous transfer.** <pHead> - Pointer to the head of the list of QTDS.* <pTail> - Pointer to the tail of the list of QTDS.* <puTransferBufferLen> - Pointer to hold the number of bytes which are *                        transferred.* RETURNS: None.** ERRNO:*   None.** \NOMANUAL*/VOID usbEhcdUpdateNonIsochBytesTransferred    (    pUSB_EHCD_QTD pHead,   /* Pointer to the head QTD */    pUSB_EHCD_QTD pTail,   /* Pointer to the tail QTD */    UINT32 *puTransferBufferLen /* Pointer to the length of the transfer */    )    {    /* Flag indicating that it is a control transfer request */    BOOLEAN bIsControl = FALSE;    OS_LOG_MESSAGE_LOW(EHCD,"usbEhcdUpdateNonIsochBytesTransferred - Entry",0,0,0,0);    /* Check the validity of the parameters */    if(NULL == pHead ||       NULL == pTail ||       NULL == puTransferBufferLen)        {        OS_LOG_MESSAGE_HIGH(EHCD,"usbEhcdUpdateNonIsochBytesTransferred - parameters \                             are not valid\n",0,0,0,0);        return;        }        /* Invalidate the cache */        CACHE_DMA_INVALIDATE(pHead, sizeof(USB_EHCD_QTD));        /* If it is a SETUP PID, jump to next TD */       if(USB_EHCD_SETUP_PID == USB_EHCD_GET_BITFIELD(QTD,                                                      pHead->uTransferInfo,                                                      TOKEN_PID_CODE))        {		pHead = pHead->pNext;        bIsControl = TRUE;        }    /* Update the number of bytes transferred to be 0 initially */    *puTransferBufferLen = 0;    /*     * This loop traverses the queue of requests     * and updates the number of bytes transferred     */    do        {        /* Invalidate the cache */        CACHE_DMA_INVALIDATE(pHead, sizeof(USB_EHCD_QTD));        /* Check if the TD has been processed */        if(0 == (USB_EHCD_GET_BITFIELD(QTD,                                       pHead->uTransferInfo,                                       TOKEN_STATUS) &                                       USB_EHCD_QTD_STATUS_ACTIVE))            {            /* Check if it is a control transfer & we have reached tail */            if((TRUE == bIsControl) && (pHead == pTail))                {                break;                }            /* Update the number of bytes transfered */            *puTransferBufferLen +=              (pHead->uBytesToTransfer -              USB_EHCD_GET_BITFIELD(QTD,                                    pHead->uTransferInfo,                                    TOKEN_TOTAL_BYTES_TO_TRANSFER));            }            /* End of if(0 == (pHead->dword2.status & */        else            {            break;            }            /* End of else */        /* If all TDs have been processed, break */        if(pHead == pTail)            {            break;            }        /* Move on to next TD */		pHead = pHead->pNext;        }while(1);    OS_LOG_MESSAGE_LOW(EHCD,"usbEhcdUpdateNonIsochBytesTransferred - Exit",0,0,0,0);    return;    }    /* End of usb20_fill_noniso_bytes_transfered() *//***************************************************************************** usbEhcdUpdateNonIsochStatus - updates the status of a non-isochronous transfer.** This function is used to update the status of a non-isochronous transfer.** RETURNS: None.** ERRNO:*   None.** \NOMANUAL*/VOID usbEhcdUpdateNonIsochStatus    (    UINT8 uStatus,   /* Status field in QTD */    pUSBHST_URB pUrb, /* Pointer to the URB */    UINT8   *pHalted    )    {    OS_LOG_MESSAGE_LOW(EHCD,"usbEhcdUpdateNonIsochStatus - Entry",0,0,0,0);    *pHalted = 0;    /* Check the validity of the parameter */    if (NULL == pUrb)        {        OS_LOG_MESSAGE_HIGH(EHCD,"usbEhcdUpdateNonIsochStatus - \                             parameter not valid\n",0,0,0,0);        return;        }    /* set halted to 1 if HCD is halted */     if (0 != (uStatus & USB_EHCD_QTD_STATUS_HALTED))        {        *pHalted = 1;        /* Default halted error is STALL. This will be overwritten, if the           error is not STALL        */        pUrb->nStatus = USBHST_STALL_ERROR;        }    /* Update the URB status based on the status parameter  */    /* Data buffer error- can be underrun or overrun. Should be checked */    if (0 != (uStatus & USB_EHCD_QTD_STATUS_DATA_BUFFER_ERROR))        {        pUrb->nStatus = USBHST_BUFFER_UNDERRUN_ERROR;        }    /*     * babble error - this is set along with halt- so this condition     * should always fail. Mentioned here for completion     */    else if (0 != (uStatus & USB_EHCD_QTD_STATUS_BABBLE_DETECTED))        {        pUrb->nStatus = USBHST_STALL_ERROR;        }    /*     * Transaction error.     * Can be Timeout, CRC or bad PID     */    else if (0 != (uStatus & USB_EHCD_QTD_STATUS_XACTERR))        {        pUrb->nStatus = USBHST_TIMEOUT;        }    /* This is set only for a full/ low speed periodic transfer */    else if (0 != (uStatus & USB_EHCD_QTD_STATUS_MISSED_UFRAME))        {        pUrb->nStatus = USBHST_FAILURE;        }    /* If the above errors are not detected or HCD is not halted,       then status is SUCCESS     */    else if (1 != *pHalted)        {        pUrb->nStatus = USBHST_SUCCESS;        }    CACHE_USER_FLUSH(&pUrb->nStatus, sizeof(USBHST_STATUS));    OS_LOG_MESSAGE_LOW(EHCD,"usbEhcdUpdateNonIsochStatus - Exit",0,0,0,0);    return;    }    /* End of usbEhcdUpdateNonIsochStatus() */    /***************************************************************************** usbEhcdUpdateITDData - updates the number of bytes transferred.** This function is used to update the number of bytes* transferred and status in a isochronous transfer.** <pHead> - Pointer to the head of the list of ITDS.* <pTail> - Pointer to the tail of the list of ITDS.* <pPacketDes> - Pointer to the Packet descriptor*                        transferred.* <uMicroFrameMask> -* RETURNS: None.** ERRNO:*   None.** \NOMANUAL*/VOID usbEhcdUpdateITDData    (    pUSB_EHCD_ITD pHead,   /* Pointer to the head QTD */    pUSB_EHCD_ITD pTail,   /* Pointer to the tail QTD */    pUSBHST_ISO_PACKET_DESC pPacketDes, /* Pointer to the Packet descriptor */    UINT8 uMicroFrameMask    )    {    UINT32 uCount = 0;    UINT8 uStatus;    UINT8 uMicroFrameIndex;    OS_LOG_MESSAGE_LOW(EHCD,"usbEhcdUpdateITDData - Entry",0,0,0,0);    /* Check the validity of the parameters */    if(NULL == pHead ||       NULL == pTail ||       NULL == pPacketDes)        {        OS_LOG_MESSAGE_HIGH(EHCD,"usbEhcdUpdateITDData - parameters \                             are not valid\n",0,0,0,0);        return;        }    /*     * This loop traverses the queue of requests     * and updates the number of bytes transferred and status     */    do    {        /* Invalidate the cache */            CACHE_DMA_INVALIDATE(pHead, sizeof(USB_EHCD_ITD));        for (uMicroFrameIndex=0;           USB_EHCD_MAX_MICROFRAME_NUMBER > uMicroFrameIndex;           uMicroFrameIndex++)           {            if((uMicroFrameMask >> uMicroFrameIndex) & 0x01)            {            	/* Update the length of each microframe */				pPacketDes[uCount].uLength =                        USB_EHCD_GET_BITFIELD(ITD,                        pHead->uTransactionStatusControlList[uMicroFrameIndex],                        TRANSACTION_LENGTH);                /* Update the Status of each microframe */                pPacketDes[uCount].nStatus =                USB_EHCD_GET_BITFIELD(ITD,                        pHead->uTransactionStatusControlList[uMicroFrameIndex],                        TRANSACTION_STATUS);                /* get the status and update for per packet  */                uStatus = USB_EHCD_GET_BITFIELD(ITD,                        pHead->uTransactionStatusControlList[uMicroFrameIndex],                        TRANSACTION_STATUS);                if ((0 != (uStatus & USB_EHCD_ITD_STATUS_BABBLE_DETECTED))||                    (0 != (uStatus & USB_EHCD_ITD_STATUS_XACTERR)))                    {                    pPacketDes[uCount].nStatus = USBHST_FAILURE;                    }                else if (0 != (uStatus & USB_EHCD_ITD_STATUS_BUFFER_ERROR))                     {                     pPacketDes[uCount].nStatus = USBHST_BUFFER_UNDERRUN_ERROR;                     }                else /* Success */                     {                     pPacketDes[uCount].nStatus = USBHST_SUCCESS;                     }                uCount++;                } /* End of if statement .... */            } /* End of for loop */        /* Move on to next TD */        pHead = pHead->pVerticalNext;        }while(pHead == pTail);    OS_LOG_MESSAGE_LOW(EHCD,"usbEhcdUpdateITDData - Exit",0,0,0,0);    return;    }    /* End of Function usbEhcdUpdateITDData *//***************************************************************************** usbEhcdUpdateSITDData - updates the number of bytes transferred.** This function is used to update the number of bytes* transferred and status in a isochronous transfer.** <pHead> - Pointer to the head of the list of SITDS.* <pTail> - Pointer to the tail of the list of SITDS.* <pPacketDes> - Pointer to the Packet descriptor*                        transferred.* RETURNS: None.** ERRNO:*   None.** \NOMANUAL*/VOID usbEhcdUpdateSITDData    (    pUSB_EHCD_SITD pHead,   /* Pointer to the head QTD */    pUSB_EHCD_SITD pTail,   /* Pointer to the tail QTD */    pUSBHST_ISO_PACKET_DESC pPacketDes /* Pointer to the Packet descriptor */    )    {    UINT32 uCount = 0;    UINT8 uStatus;        OS_LOG_MESSAGE_LOW(EHCD,"usbEhcdUpdateITDData - Entry",0,0,0,0);    /* Check the validity of the parameters */    if(NULL == pHead ||       NULL == pTail ||       NULL == pPacketDes)        {        OS_LOG_MESSAGE_HIGH(EHCD,"usbEhcdUpdateITDData - parameters \                             are not valid\n",0,0,0,0);        return;        }    /*     * This loop traverses the queue of requests     * and updates the number of bytes transferred and status     */    do    {        /* Invalidate the cache */            CACHE_DMA_INVALIDATE(pHead, sizeof(USB_EHCD_SITD));    	/* Update the length of each microframe */        /*pPacketDes[uCount].uLength =        pHead->dword3.total_bytes_to_transfer; */        pPacketDes[uCount].uLength =                USB_EHCD_GET_BITFIELD(SITD,                        pHead->uTransferState,                        TRANSFER_STATE_TOTAL_BYTES_TO_TRANSFER);        /* get the status and update for per packet  */        uStatus = USB_EHCD_GET_BITFIELD(SITD,                        pHead->uTransferState,                        TRANSFER_STATE_TOTAL_BYTES_TO_TRANSFER);        if (0 != (uStatus & USB_EHCD_SITD_STATUS_ERROR))            {            pPacketDes[uCount].nStatus = USBHST_FAILURE;            }        else if (0 != (uStatus & USB_EHCD_SITD_STATUS_BUFFER_ERROR))            {                pPacketDes[uCount].nStatus = USBHST_BUFFER_UNDERRUN_ERROR;            }        else if (0 != (uStatus & USB_EHCD_SITD_STATUS_BABBLE_DETECTED))            {                pPacketDes[uCount].nStatus = USBHST_FAILURE;            }        else if (0 != (uStatus & USB_EHCD_SITD_STATUS_XACTERR))            {                pPacketDes[uCount].nStatus = USBHST_FAILURE;            }        else if (0 != (uStatus & USB_EHCD_SITD_STATUS_MISSED_FRAME))            {                pPacketDes[uCount].nStatus = USBHST_FAILURE;            }        else /* Success */            {                pPacketDes[uCount].nStatus = USBHST_SUCCESS;            }                uCount++;        /* Move on to next TD */        pHead = pHead->pVerticalNext;        }while(pHead == pTail);    OS_LOG_MESSAGE_LOW(EHCD,"usbEhcdUpdateSITDData - Exit",0,0,0,0);    return;    }    /* End of Function usbEhcdUpdateSITDData *//***************************************************************************** usbEhcdCalculateBusTime - calculates the bus time

⌨️ 快捷键说明

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