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

📄 usbehcdutil.c

📁 vxWorks下USB2.0中的EHCI的HCD源码,极具有参考价值
💻 C
📖 第 1 页 / 共 5 页
字号:
    /* Pointer to the allocated memory location */    VOID * pAllocatedMem = NULL;    OS_LOG_MESSAGE_LOW(EHCD,"usbEhcdAddToFreeSITDList - Entry\n",0,0,0,0);    /* Check the validity of the parameter */    if (NULL == pSITD)        {    	OS_LOG_MESSAGE_HIGH(EHCD,"usbEhcdAddToFreeSITDList - \                                    Parameter not valid\n",0,0,0,0);        return FALSE;        }    /* Assert if the Allocated memory for the ITD is not valid */    OS_ASSERT(NULL != pSITD->pAllocatedMem);    /* Store the allocated memory in a temporary pointer */    pAllocatedMem = pSITD->pAllocatedMem;    /* Reinitialize the memory */    OS_MEMSET(pSITD, 0, sizeof(USB_EHCD_SITD));    /* Copy the allocated memory pointer back */    pSITD->pAllocatedMem = pAllocatedMem;    /* Wait on the signalling of the event */    OS_WAIT_FOR_EVENT(g_ListAccessEvent,OS_WAIT_INFINITE);    /* Update the next element of the SITD */    pSITD->pNext = pHeadFreeSITD;    /* Make this ITD as the head of the free list */    pHeadFreeSITD = pSITD;    /* If tail pointer is NULL, this SITD becomes the tail pointer */    if (NULL == pTailFreeSITD)        {        pTailFreeSITD = pSITD;        }    /* Release the event */    OS_RELEASE_EVENT(g_ListAccessEvent);    OS_LOG_MESSAGE_LOW(EHCD,"usbEhcdAddToFreeSITDList - Exit\n",0,0,0,0);    return TRUE;    }    /* End of usbEhcdAddToFreeSITDList() *//***************************************************************************** usbEhcdGetFreeQTD - gets a QTD from the free list** This function is used to retrieve a QTD from the free QTD list** RETURNS: Pointer to the USB_EHCD_QTD data structure if the list is non-empty*          NULL if the list is empty.** ERRNO:*   None.** \NOMANUAL*/pUSB_EHCD_QTD usbEhcdGetFreeQTD    (    VOID    )    {    /* Pointer to the QTD */    pUSB_EHCD_QTD pQTD = NULL;    VOID * pTempAllocatedMemory = NULL;    OS_LOG_MESSAGE_LOW(EHCD,"usbEhcdGetFreeQTD - Entry\n",0,0,0,0);    /* Assert if the list access event is not valid */    OS_ASSERT(NULL != g_ListAccessEvent);    /* Check if there is any element in the free list and extract the element.     * Update the free list. This is done acquiring and releasing an event.     */    /* Wait on the signalling of the event */    OS_WAIT_FOR_EVENT(g_ListAccessEvent,OS_WAIT_INFINITE);    /* There are elements in the free list */    if (NULL != pHeadFreeQTD)        {        pQTD = pHeadFreeQTD;        pHeadFreeQTD = pHeadFreeQTD->pNext;        /*         * If this is the only element in the free list,         * the list becomes empty.         */        if (pQTD == pTailFreeQTD)            {            pTailFreeQTD = NULL;            }        /* remember the allocated memory pointer */        pTempAllocatedMemory = pQTD->pAllocatedMem;        /* Initialize all the elements of the Queue Head */        OS_MEMSET(pQTD, 0, sizeof(USB_EHCD_QTD));        /* written back the remembered allocated memory */        pQTD->pAllocatedMem = pTempAllocatedMemory;        }    /* Release the event */    OS_RELEASE_EVENT(g_ListAccessEvent);    OS_LOG_MESSAGE_LOW(EHCD,"usbEhcdGetFreeQTD - Exit\n",0,0,0,0);    /* Return the pointer to QTD */    return pQTD;    }    /* End of usbEhcdGetFreeQTD() *//***************************************************************************** usbEhcdGetFreeQH - gets a QH from the free list** This function is used to retrieve a QH from the free QH list** RETURNS: Pointer to the USB_EHCD_QH data structure if the list is non-empty*          NULL if the list is empty.** ERRNO:*   None.** \NOMANUAL*/pUSB_EHCD_QH usbEhcdGetFreeQH( void )    {    /* Pointer to the QH */    pUSB_EHCD_QH pQH = NULL;    VOID   *pTempAllocatedMemory = NULL;    /* Assert if the list access event is not valid */    OS_ASSERT(NULL != g_ListAccessEvent);    /* Check if there is any element in the free list and extract the element.     * Update the free list. This is done acquiring and releasing an event.     */    /* Wait on the signalling of the event */    OS_WAIT_FOR_EVENT(g_ListAccessEvent,OS_WAIT_INFINITE);    /* There are elements in the free list */    if (NULL != pHeadFreeQH)        {        pQH = pHeadFreeQH;        pHeadFreeQH = pHeadFreeQH->pNext;        /*         * If this is the only element in the free list,         * the list becomes empty.         */        if (pQH == pTailFreeQH)            {            pTailFreeQH = NULL;            }        /* remember the allocated memory pointer */        pTempAllocatedMemory = pQH->pAllocatedMem;        /* Initialize all the elements of the Queue Head */        OS_MEMSET(pQH, 0, sizeof(USB_EHCD_QH));        /* written back the remembered allocated memory */        pQH->pAllocatedMem = pTempAllocatedMemory;        }    /* Release the event */    OS_RELEASE_EVENT(g_ListAccessEvent);    /* Return the QH pointer */    return pQH;    }    /* End of usbEhcdGetFreeQH() *//***************************************************************************** usbEhcdGetFreeITD - gets a ITD from the free list** This function is used to retrieve a ITD from the free ITD list** RETURNS: Pointer to the USB_EHCD_ITD data structure if the list is non-empty*          NULL if the list is empty.** ERRNO:*   None.** \NOMANUAL*/pUSB_EHCD_ITD usbEhcdGetFreeITD(void)    {    /* Pointer to the ITD */    pUSB_EHCD_ITD pITD = NULL;    VOID  *pTempAllocatedMemory = NULL;    /* Assert if the list access event is not valid */    OS_ASSERT(NULL != g_ListAccessEvent);    /* Check if there is any element in the free list and extract the element.     * Update the free list. This is done acquiring and releasing an event.     */    /* Wait on the signalling of the event */    OS_WAIT_FOR_EVENT(g_ListAccessEvent,OS_WAIT_INFINITE);    /* There are elements in the free list */    if (NULL != pHeadFreeITD)        {        pITD = pHeadFreeITD;        pHeadFreeITD = pHeadFreeITD->pNext;        /*         * If this is the only element in the free list,         * the list becomes empty.         */        if (pITD == pTailFreeITD)            {            pTailFreeITD = NULL;            }        /* remember the allocated memory pointer */        pTempAllocatedMemory = pITD->pAllocatedMem;        /* Initialize all the elements of the Queue Head */        OS_MEMSET(pITD, 0, sizeof(USB_EHCD_ITD));        /* written back the remembered allocated memory */        pITD->pAllocatedMem = pTempAllocatedMemory;        }    /* Release the event */    OS_RELEASE_EVENT(g_ListAccessEvent);    /* Return the ITD pointer */    return pITD;    }    /* End of usbEhcdGetFreeITD() *//***************************************************************************** usbEhcdGetFreeSITD - gets a SITD from the free list** This function is used to retrieve a SITD from the free ITD list** RETURNS: Pointer to the USB_EHCD_SITD data structure if the list is non-empty*          NULL if the list is empty.** ERRNO:*   None.** \NOMANUAL*/pUSB_EHCD_SITD usbEhcdGetFreeSITD( void )    {    /* Pointer to the SITD */    pUSB_EHCD_SITD pSITD = NULL;    VOID *pTempAllocatedMemory = NULL;    /* Assert if the list access event is not valid */    OS_ASSERT(NULL != g_ListAccessEvent);    /*     * Check if there is any element in the free list and extract the element.     * Update the free list. This is done acquiring and releasing an event.     */    /* Wait on the signalling of the event */    OS_WAIT_FOR_EVENT(g_ListAccessEvent,OS_WAIT_INFINITE);    /* There are elements in the free list */    if (NULL != pHeadFreeSITD)        {        pSITD = pHeadFreeSITD;        pHeadFreeSITD = pHeadFreeSITD->pNext;        /*         * If this is the only element in the free list,         * the list becomes empty.         */        if (pSITD == pTailFreeSITD)            {            pTailFreeSITD = NULL;            }        /* remember the allocated memory pointer */        pTempAllocatedMemory = pSITD->pAllocatedMem;        /* Initialize all the elements of the Queue Head */        OS_MEMSET(pSITD, 0, sizeof(USB_EHCD_SITD));        /* written back the remembered allocated memory */        pSITD->pAllocatedMem = pTempAllocatedMemory;        }    /* Release the event */    OS_RELEASE_EVENT(g_ListAccessEvent);    /* Return the pointer to SITD */    return pSITD;    }    /* End of usbEhcdGetFreeSITD() *//***************************************************************************** usbEhcdFreeAllLists - releases all the free lists.** This function frees up all the elements in the free list during the HCD* uninitialization.** RETURNS: None.** ERRNO:*   None.** \NOMANUAL*/VOID usbEhcdFreeAllLists(VOID)    {    /* Pointer to the USB_EHCD_QH data structure */    pUSB_EHCD_QH pQH = NULL;    /* Pointer to the USB_EHCD_QTD data structure */    pUSB_EHCD_QTD pQTD = NULL;    /* Pointer to the USB_EHCD_ITD data structure */    pUSB_EHCD_ITD pITD = NULL;    /* Pointer to the USB_EHCD_SITD data structure */    pUSB_EHCD_SITD pSITD = NULL;    OS_LOG_MESSAGE_LOW(EHCD,"usbEhcdFreeAllLists - Entry\n",0,0,0,0);    /* Assert if the list access event is not valid */    OS_ASSERT(NULL != g_ListAccessEvent);    /* Wait on the signalling of the event */    OS_WAIT_FOR_EVENT(g_ListAccessEvent,OS_WAIT_INFINITE);    /* Free the elements in the QH list */    for (; pHeadFreeQH != NULL; pHeadFreeQH = pQH)        {    	/* Store the next pointer temporarily */    	pQH = pHeadFreeQH->pNext;        /* Assert if the allocated memory pointer is invalid */        OS_ASSERT(NULL != pHeadFreeQH->pAllocatedMem);    	/* Free the Queue head data structure */    	memPartFree(ehcdmemPartID, pHeadFreeQH->pAllocatedMem);        }    /* Update the head and tail pointers to NULL */    pHeadFreeQH = NULL;    pTailFreeQH = NULL;    /* Free the elements in the QTD list */    for (; pHeadFreeQTD != NULL; pHeadFreeQTD = pQTD)        {    	/* Store the next pointer temporarily */    	pQTD = pHeadFreeQTD->pNext;        /* Assert if the allocated memory pointer is invalid */        OS_ASSERT(NULL != pHeadFreeQTD->pAllocatedMem);    	/* Free the Queue element data structure */    	memPartFree(ehcdmemPartID, pHeadFreeQTD->pAllocatedMem);        }    /* Update the head and tail pointers to NULL */    pHeadFreeQTD = NULL;    pTailFreeQTD = NULL;    /* Free the elements in the ITD list */    for (; pHeadFreeITD != NULL; pHeadFreeITD = pITD)        {    	/* Store the next pointer temporarily */    	pITD = pHeadFreeITD->pNext;        /* Assert if the allocated memory pointer is invalid */        OS_ASSERT(NULL != pHeadFreeITD->pAllocatedMem);    	/* Free the iTD data structure */    	memPartFree(ehcdmemPartID, pHeadFreeITD->pAllocatedMem);        }    /* Update the head and tail pointers to NULL */    pHeadFreeITD = NULL;    pTailFreeITD = NULL;    /* Free the elements in the SITD list */    for (; pHeadFreeSITD != NULL; pHeadFreeSITD = pSITD)        {    	/* Store the next pointer temporarily */    	pSITD = pHeadFreeSITD->pNext;        /* Assert if the allocated memory pointer is invalid */        OS_ASSERT(NULL != pHeadFreeSITD->pAllocatedMem);

⌨️ 快捷键说明

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