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

📄 usbehcdutil.c

📁 usb2 driver for vxwokrs
💻 C
📖 第 1 页 / 共 5 页
字号:
    OS_RELEASE_EVENT(g_ListAccessEvent);    return TRUE;    }    /* End of usbEhcdAddToFreeITDList() *//***************************************************************************** usbEhcdAddToFreeSITDList - adds the SITD to the free list** This function is used to add a SITD to the free QH list.** <pSITD> Pointer to the USB_EHCD_ITD data structure.** RETURNS: TRUE if the SITD is added successfully.*          FALSE if the SITD is not added successfully.** ERRNO:*   None.** \NOMANUAL*/BOOLEAN usbEhcdAddToFreeSITDList    (    pUSB_EHCD_SITD pSITD    )    {    /* Pointer to the allocated memory location */    VOID * pAllocatedMem = NULL;    UINT32	uSize = 0;    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;    /*     * Retrieve the size of the SITD. pSITD.size consist of the total allocated     * size for the queue head.     * While adding the pSITD to the free list, we set the complete     * allocated memory with 0.     * Then we write back the size of the allocated structure and the allocated     * pointer value in the respective feilds.     */    uSize = pSITD->uSize;    /* Reinitialize the memory */    OS_MEMSET(pAllocatedMem, 0, uSize);    /* Copy the allocated memory pointer back */    pSITD->pAllocatedMem = pAllocatedMem;    /* Copy back the size of SITD */    pSITD->uSize = uSize;    /* 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);    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** <uSize> - Size of the QTD* * 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    (    UINT32	uSize    )    {    /* Pointer to the QTD */    pUSB_EHCD_QTD pQTD = NULL;    pUSB_EHCD_QTD pQTDTemp = 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;        /* Search in the list whether any QTD is of the requested size */         while ((pQTD != NULL) && (pQTD->uSize != uSize))            {            pQTDTemp = pQTD;            pQTD = pQTD->pNext;            }         /* If there is no free qTD available, return NULL */        if (pQTD == NULL)            {            /* Release the event */            OS_RELEASE_EVENT(g_ListAccessEvent);              return NULL;            }        /* If the head QTD itself is of the requested size,update head ptr */        if (pQTD == pHeadFreeQTD)            pHeadFreeQTD = pHeadFreeQTD->pNext;        /* Update the next pointers */        else            pQTDTemp->pNext = pQTD->pNext;         /*         * If this is the last element in the list,         * update the tail QTD.         */        if (pQTD == pTailFreeQTD)            {            pTailFreeQTD = pQTDTemp;            }        pQTD->pNext = NULL;        }    /* Release the event */    OS_RELEASE_EVENT(g_ListAccessEvent);    /* 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** <uSize> - Size of QH** 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    (    UINT32 uSize    )    {    /* Pointer to the QH */    pUSB_EHCD_QH pQH = NULL;    pUSB_EHCD_QH pQHTemp = 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;        /* Search in the list whether any pQH is of the requested size */         while ((pQH != NULL) && (pQH->uSize != uSize))            {            pQHTemp = pQH;            pQH = pQH->pNext;            }         /* If there is no free pQH available, return NULL */        if (pQH == NULL)            {            /* Release the event */            OS_RELEASE_EVENT(g_ListAccessEvent);              return NULL;            }        /* If the head pQH itself is of the requested size,update head ptr */        if (pQH == pHeadFreeQH)            pHeadFreeQH = pHeadFreeQH->pNext;        /* Update the next pointers */        else            pQHTemp->pNext = pQH->pNext;         /*         * If this is the last element in the list,         * update the tail pQH.         */        if (pQH == pTailFreeQH)            {            pTailFreeQH = pQHTemp;            }        pQH->pNext = NULL;        }    /* 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** <uSize> - Size of ITD** 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    (    UINT32	uSize    )    {    /* Pointer to the ITD */    pUSB_EHCD_ITD pITD = NULL;    pUSB_EHCD_ITD pITDTemp = 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;        /* Search in the list whether any ITD is of the requested size */         while ((pITD != NULL) && (pITD->uSize != uSize))            {            pITDTemp = pITD;            pITD = pITD->pNext;            }         /* If there is no free ITD available, return NULL */        if (pITD == NULL)            {            /* Release the event */            OS_RELEASE_EVENT(g_ListAccessEvent);              return NULL;            }        /* If the head ITD itself is of the requested size,update head ptr */        if (pITD == pHeadFreeITD)            pHeadFreeITD = pHeadFreeITD->pNext;        /* Update the next pointers */        else            pITDTemp->pNext = pITD->pNext;         /*         * If this is the last element in the list,         * update the tail ITD.         */        if (pITD == pTailFreeITD)            {            pTailFreeITD = pITDTemp;            }        pITD->pNext = NULL;        }    /* 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** <uSize> - size of SITD** 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    (    UINT32 uSize    )    {    /* Pointer to the SITD */    pUSB_EHCD_SITD pSITD = NULL;    pUSB_EHCD_SITD pSITDTemp = 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;        /* Search in the list whether any SITD is of the requested size */         while ((pSITD != NULL) && (pSITD->uSize != uSize))            {            pSITDTemp = pSITD;            pSITD = pSITD->pNext;            }         /* If there is no free SITD available, return NULL */        if (pSITD == NULL)            {            /* Release the event */            OS_RELEASE_EVENT(g_ListAccessEvent);              return NULL;            }        /* If the head SITD itself is of the requested size,update head ptr */        if (pSITD == pHeadFreeSITD)            pHeadFreeSITD = pHeadFreeSITD->pNext;        /* Update the next pointers */        else            pSITDTemp->pNext = pSITD->pNext;         /*         * If this is the last element in the list,         * update the tail SITD.         */        if (pSITD == pTailFreeSITD)            {            pTailFreeSITD = pSITDTemp;            }

⌨️ 快捷键说明

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