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

📄 usbuhcdscheduleqsupport.c

📁 usb2 driver for vxwokrs
💻 C
📖 第 1 页 / 共 5 页
字号:
    INT32 n    )    {    /*     * The Host Controller maintains an array of 1024 pointers which     * point to the isochronous TD which are added in each list     */    return(127 + n % 128);    }/* End of usbUhcdFindQlinkToTree() *//***************************************************************************** usbUhcdFindHcdPipe - locates an HCD pipe structure** This routine locates an HCD pipe structure.** RETURNS: NULL if pipe not found** ERRNO:*   None.** \NOMANUAL*/USB_UHCD_HCD_PIPE *usbUhcdFindHcdPipe    (    UINT8 BusIndex,    UINT8 deviceNum,    UINT8 endPointNum,    UINT8 direction,    UINT8 type    )    {    /* Pointer to the host controller stucture */    PUHCD_DATA  pHCDData = NULL;           /* Temporary pointer to hold the HCD specific pipe pointer */    USB_UHCD_HCD_PIPE *scanPipe = NULL;    OS_LOG_MESSAGE_MEDIUM(UHCD,"Entering usbUhcdFindHcdPipe\n",0,0,0,0);    /* Check if the pointer is valid */    if (g_pUHCDData == NULL)        {        OS_LOG_MESSAGE_HIGH(UHCD,"HCD Data pointer is NULL\n",0,0,0,0);        return NULL;        }    /* Retrieve the pointer to hcd data structure */    pHCDData = g_pUHCDData[BusIndex];    /* Scan each HCD pipe block in the queue of pipes maintained */    for (scanPipe = pHCDData->usbUhcdPipe; scanPipe != NULL; scanPipe = scanPipe->next)        {        /*         * Check for the device number, endpoint number, direction of the pipe,         * and the type of the pipe         */        if (scanPipe->deviceNum == deviceNum &&            scanPipe->endPointNum == endPointNum  &&            scanPipe->endPointDirection == direction &&            scanPipe->endPointType == type)            /* Return the pipe block's address */            return scanPipe;        }/* End of for () */    /* If Pipe not found */    OS_LOG_MESSAGE_MEDIUM(UHCD,"Exiting usbUhcdFindHcdPipe\n",0,0,0,0);    return NULL;    }/* End of usbUhcdFindHcdPipe() *//***************************************************************************** usbUhcdEnterCritical - guards shared data structures** This function is called before accessing shared data structures to * guard them from multiple access.** RETURNS: N/A** ERRNO:*   None.** \NOMANUAL*/void usbUhcdEnterCritical     (    PUHCD_DATA   pHCDData    )    {    OS_LOG_MESSAGE_MEDIUM(UHCD,"Entering usbUhcdEnterCritical\n",0,0,0,0);    /*     * If the semaphore used for mutual exclusion is not created yet,     * create the semaphore     */    if (pHCDData->usbUhcdSemCritical == NULL)        {        OS_LOG_MESSAGE_MEDIUM(UHCD,"Semaphore not created creating\n",0,0,0,0);        /* Create the Mutex semaphore */        pHCDData->usbUhcdSemCritical = OS_CREATE_EVENT (SEM_FULL);        OS_LOG_MESSAGE_HIGH(UHCD, "SEMID [0x%x]\n",(UINT32)pHCDData->usbUhcdSemCritical,0,0,0);        /* Check if the creation is success */        if (pHCDData->usbUhcdSemCritical == NULL)            {            OS_LOG_MESSAGE_MEDIUM(UHCD,"Unable to create Mutex sem for critical section support\n",0,0,0,0);            }        }    /* Take the semaphore. Will block until semaphore is available */    OS_WAIT_FOR_EVENT (pHCDData->usbUhcdSemCritical, WAIT_FOREVER);    OS_LOG_MESSAGE_MEDIUM(UHCD,"Semaphore is Taken \n",0,0,0,0);    OS_LOG_MESSAGE_MEDIUM(UHCD,"Exiting usbUhcdEnterCritical \n",0,0,0,0);    }/* End of usbUhcdEnterCritical() *//***************************************************************************** usbUhcdLeaveCritical - makes shared data structures** This function is called when the shared data structure is no longer * accessed.** RETURNS: N/A** ERRNO:*   None.** \NOMANUAL*/void usbUhcdLeaveCritical     (    PUHCD_DATA   pHCDData    )    {    OS_LOG_MESSAGE_MEDIUM(UHCD,"usbUhcdLeaveCritical() entered\n",0,0,0,0);    /* release the semphore */    OS_RELEASE_EVENT (pHCDData->usbUhcdSemCritical);    OS_LOG_MESSAGE_MEDIUM(UHCD,"Semaphore is Released \n",0,0,0,0);    }/* End of usbUhcdLeaveCritical() *//***************************************************************************** usbUhcdFormEmptyPipe - create an empty pipe block** This function is called to allocate a new pipe structure** RETURNS: NULL if pipe creation fails** ERRNO:*   None.** \NOMANUAL*/USB_UHCD_HCD_PIPE *usbUhcdFormEmptyPipe (VOID)    {    /* Temporary pointer to the USB_UHCD_HCD_PIPE structure */    USB_UHCD_HCD_PIPE *pipe = NULL;    OS_LOG_MESSAGE_MEDIUM(UHCD,"Entering usbUhcdFormEmptyPipe\n",0,0,0,0);    /* Allocate memory for the pipe data structure */    pipe = (USB_UHCD_HCD_PIPE *) OS_MALLOC(sizeof(USB_UHCD_HCD_PIPE));    /* Check if memory allocation is successful */    if (pipe)        {        OS_LOG_MESSAGE_MEDIUM(UHCD,"Pipe allocation successful\n",0,0,0,0);        OS_MEMSET (pipe, 0, sizeof (USB_UHCD_HCD_PIPE));        }    else        {        USB_UHCD_LOG_ERROR_MESSAGE("Pipe Could not allocated Successfully\n");        return NULL;        }    OS_LOG_MESSAGE_MEDIUM(UHCD,"Exiting usbUhcdFormEmptyPipe()\n",0,0,0,0);    /* Return the address of the allocated memory */    return(pipe);    }/* End of usbUhcdFormEmptyPipe() *//***************************************************************************** usbUhcdLinkQheadBetween - links a new Queue Head** This function is used to link a new Queue Head after the* existing Queue Head.** RETURNS: N/A** ERRNO:*   None.** \NOMANUAL*/void usbUhcdLinkQheadBetween    (    UINT32 uBusIndex,    USB_UHCD_QH *newQh,    USB_UHCD_QH *presentQh    )    {    OS_LOG_MESSAGE_MEDIUM(UHCD,"Entering usbUhcdLinkQheadBetween()\n",0,0,0,0);    /* Check if the parameters are valid */    if (NULL == newQh || NULL == presentQh)        {        OS_LOG_MESSAGE_MEDIUM(UHCD,"Invalid pointers\n",0,0,0,0);        return;        }    /* Check if the new QH is to be inserted between 2 QHs */    if (presentQh->nextQh)        {        OS_LOG_MESSAGE_MEDIUM(UHCD,"New Qh is to be linked in between\n",0,0,0,0);        /* Manipulate the next link pointers */        newQh->nextQh = presentQh->nextQh;        /* Update the new QH's link pointer */        newQh->dWord0Qh = presentQh->dWord0Qh;        /* Update the previous pointers also */        if (presentQh->nextQh->prevQh)            {            OS_LOG_MESSAGE_MEDIUM(UHCD,"Updating previous pointers\n",0,0,0,0);            presentQh->nextQh->prevQh = newQh;            }        }/* End of if() */    /* If there is no QH which is already linked to presentQh */    else        {        OS_LOG_MESSAGE_MEDIUM(UHCD,"No Qh present linked to current\n",0,0,0,0);        /*         * There is no element in the queue after the element         * which is to be linked. So make the next pointer as NULL         */        newQh->nextQh = NULL;        /* Make this as the last element in the queue */        newQh->dWord0Qh = USBUHCD_END_OF_LIST( uBusIndex);        }/* End of else */    /* Manipuate the link pointers to complete insertion/addition */    /* Update the previous element pointer */    newQh->prevQh = presentQh;    /* Update the next link pointer of the already existing QH */    presentQh->nextQh = newQh;    /* Update the link pointer in DWORD0 of the already existing QH */    presentQh->dWord0Qh = USB_UHCD_SWAP_DATA(uBusIndex,     (USB_UHCD_CONVERT_TO_BUS_MEM( uBusIndex, (PVOID)newQh) | USBUHCD_LINK_QH));    DMA_FLUSH(presentQh, sizeof(USB_UHCD_QH));    OS_LOG_MESSAGE_MEDIUM(UHCD,"Exiting usbUhcdLinkQheadBetween()\n",0,0,0,0);    return;    }/* End of usbUhcdLinkQheadBetween() *//***************************************************************************** usbUhcdCalculateBusTime - calculates the BW occupied by a pipe** This function is used to calculate the bandwidth occupied by a* pipe.** RETURNS: bus time in nano seconds** ERRNO:*   None.** \NOMANUAL*/INT32 usbUhcdCalculateBusTime    (    UINT8 speed,    UINT8 direction,    UINT8 pipeType,    UINT16 data    )    {    OS_LOG_MESSAGE_MEDIUM(UHCD,"Entering usbUhcdCalculateBusTime()\n",0,0,0,0);    /* Calculate the bus time for a low speed pipe */    if (speed == LOW_SPEED)        {        OS_LOG_MESSAGE_MEDIUM(UHCD,"Speed : LOW_SPEED\n",0,0,0,0);        /* Calculate the bustime for an IN pipe */        if (direction == DIR_IN )            {            OS_LOG_MESSAGE_MEDIUM(UHCD,"Direction : DIR_IN\n",0,0,0,0);            return( INT32 )            (64060 + (2 * USB_UHCD_HUB_LS_SETUP) +             (677 *  (4 + usbUhcdBitStuffTime (data)))             + USB_UHCD_HOST_DELAY);            }        /* Calculate the bustime for an OUT pipe */        else            {            OS_LOG_MESSAGE_MEDIUM(UHCD,"Direction : DIR_OUT\n",0,0,0,0);            return(INT32)            (64107 + (2 * USB_UHCD_HUB_LS_SETUP) +             (667 *  ( 4 + usbUhcdBitStuffTime (data)))             + USB_UHCD_HOST_DELAY);            }/* End of else */        }/* End of if(Speed == LOW_SPEED) */    /* Calculate the bus time for a Full speed pipe */    else if (speed == FULL_SPEED )        {        OS_LOG_MESSAGE_MEDIUM(UHCD,"Speed : FULL_SPEED\n",0,0,0,0);        /* Calculate the bus time for a control, bulk or interrupt pipe */        if (pipeType != PIPE_ISOCHRONOUS )            {            OS_LOG_MESSAGE_MEDIUM(UHCD,"pipe : control, bulk, interrupt\n",0,0,0,0);            return(UINT32)            (9107 + (84 * (4 + usbUhcdBitStuffTime (data)))             + USB_UHCD_HOST_DELAY);            }        /* Calculate the bus time for an isochronous pipe */        else            {            OS_LOG_MESSAGE_MEDIUM(UHCD,"Pipe : isochronous\n",0,0,0,0);            /* Calculate the bus time for an IN endpoint */            if (direction == DIR_IN)                {                OS_LOG_MESSAGE_MEDIUM(UHCD,"Direction : DIR_IN\n",0,0,0,0);                return(INT32)                (7268 + (84 * (4 + usbUhcdBitStuffTime (data)))                 +USB_UHCD_HOST_DELAY);                }            /* Calculate the bus time for an OUT endpoint */            else                {                OS_LOG_MESSAGE_MEDIUM(UHCD,"Direction : DIR_OUT\n",0,0,0,0);                return( INT32 )                (6265 + (84 * (4 + usbUhcdBitStuffTime (data)))                 +USB_UHCD_HOST_DELAY);                }/* End of else */            }/* End of else */        }/* End of else if () */    OS_LOG_MESSAGE_MEDIUM(UHCD,"Exiting uhc_Calculate_bus_time()\n",0,0,0,0);    USB_UHCD_LOG_ERROR_MESSAGE("Invalid Parameters\n");    return -1;    }/* End of usbUhcdCalculateBusTime() *//***************************************************************************** usbUhcdFindTreeBw - determines the bandwidth occupied** This function is used to determine the bandwidth occupied by the* list of nodes starting from index "treeIndex".** RETURNS: bandwidth occupied** ERRNO:*   None.** \NOMANUAL*/INT32 usbUhcdFindTreeBw    (    INT32     treeIndex,    USB_UHCD_PERIODIC_TREE  * usbUhcdTree    )    {    /* Copy the index of the node into a local variable */    INT32 index = treeIndex;    /* To store the bandwidth occupied by the list */    INT32 bw = 0;    OS_LOG_MESSAGE_MEDIUM(UHCD,"Entering usbUhcdFindTreeBw()\n",0,0,0,0);    /*     * Starting from "treeIndex" till the tip of the tree,     * add up all the BandWidth     */    do        {        /* Add the bandwidth occupied in the node in the list */        bw += usbUhcdTree[index].bandWidth;        /* Find the index of the next node in the list */        index = usbUhcdFindLinkForQh (index);        }while (index >= 0);     OS_LOG_MESSAGE_MEDIUM(UHCD,"Exiting uhc_find_treeBW()\n",0,0,0,0);    /* Return the computed BW */    return(bw);    }/* End of usbUhcdFindTreeBw() *//***************************************************************************** usbUhcdMaxIsoBwLinkedTo - determines maximum bandwidth** This function is used to determine the maximum bandwidth linked to the* isochronous list which is linked to the tree node of index 'index'.** RETURNS: maximum isochronous bandwidth linked to the list** ERRNO:*   None.* * \NOMANUAL*/

⌨️ 快捷键说明

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