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

📄 usbuhcdschedulequeue.c

📁 usb2 driver for vxwokrs
💻 C
📖 第 1 页 / 共 5 页
字号:
    if (prev == NULL )        {        OS_LOG_MESSAGE_MEDIUM(UHCD,"First pipe\n",0,0,0,0);        /*         * Update the head of the list to the pipe         * next to the pipe being deleted         */        pHCDData->usbUhcdPipe = scanPipe->next;        }    /* If the pipe is not the very 1st pipe */    else        {        OS_LOG_MESSAGE_MEDIUM(UHCD,"Not the very 1st pipe\n",0,0,0,0);        /* Update the next pointers */        prev->next = scanPipe->next;        }    if (pipeToDel->endPointType != PIPE_ISOCHRONOUS)        {        /* Mark the QH as deleted */        scanPipe->qh->markedForDeletion = 1;        /* Cancel all TDs pending for that pipe */        usbUhcdProcessCompletedTds(pHCDData);        /* Free QH */        UHCI_FREE( (UCHAR*) scanPipe->qh - (scanPipe->qh->offsetForFreeing));        }    else        {        /* To hold the isoc request */        USB_UHCD_ISO_REQUEST_QUEUE *iReq = pHCDData->usbUhcdIsoRequestQ;        /* Identify the request queued on this pipe */        while (iReq != NULL)            {            if (iReq->pipe == scanPipe)                {                /* Mark the  isoc request for deletion */                iReq->markedForDeletion = 1;                }            /* Pointer to the next request*/            iReq = iReq->next;            }        /* Cancel all TDs pending for that pipe */        /* Location of the host controller is not taken into care */        usbUhcdProcessIsocTds(pHCDData);        }    /* If pipe type is interrupt, reclaim BW */    if (pipeToDel->endPointType == PIPE_INTERRUPT)        {        OS_LOG_MESSAGE_MEDIUM(UHCD,"Pipe type Interrupt\n",0,0,0,0);        pHCDData->usbUhcdTree[pipeToDel->listIndex].bandWidth -= pipeToDel->bw;        }    /* If pipe type is isochonous, reclaim BW */    if (pipeToDel->endPointType == PIPE_ISOCHRONOUS)        {        OS_LOG_MESSAGE_MEDIUM(UHCD,"Pipe type Isochronous Reclaim bandwidth \n",0,0,0,0);        for (i = 0; i<1024; i++)            {            pHCDData->usbUhcdTable[i].bandWidth -= pipeToDel->bw;             }        }    /* Free the HCD pipe block */    OS_FREE(scanPipe);    /* Leave critical section */    usbUhcdLeaveCritical(pHCDData);    OS_LOG_MESSAGE_MEDIUM(UHCD,"Exiting usbUhcdDeletePipe()\n",0,0,0,0);    /* Return success from the function */    return USBHST_SUCCESS;    }/* End of usbUhcdDeletePipe() *//***************************************************************************** usbUhcdCreatePipe - creates the pipe.** This function creates *  - the HCD maintained pipe*  - HC maintained QH for control, bulk and interrupt transfers*  - Updates the bandwidth utilised.** RETURNS: USBHST_STATUS** ERRNO:*   None.** \NOMANUAL*/USBHST_STATUS usbUhcdCreatePipe    (    UINT8  uBusIndex,    UINT8  uDeviceAddress,    UINT8  uDeviceSpeed,    UCHAR  *pEndpointDescriptor,    UINT16  uHighSpeedHubInfo,    UINT32 *puPipeHandle    )    {    PUHCD_DATA pHCDData = g_pUHCDData[uBusIndex];    /*To hold endpoint number */    INT32 endPointNum = 0;    /*To hold direction*/    INT32 direction = 0;    /* To hold the temporary QH pointer */    USB_UHCD_QH *qh =NULL;    /* To hold the present QH pointer */    USB_UHCD_QH *presentQh = NULL;    /* To hold the HCD maintained current pipe pointer */    USB_UHCD_HCD_PIPE *currentPipe = NULL;    /* To hold the bandwidth required */    UINT32 bwReqd =0;    /* To hold the polling rate calculated */    UINT8 reqPollRate = 0;    /* To hold the index into the list */    INT32 listIndex = 0;    /* Count for the For loop */    UINT32   i = 0;    pUSBHST_ENDPOINT_DESCRIPTOR pusbHstEndPointDesc =    (pUSBHST_ENDPOINT_DESCRIPTOR)pEndpointDescriptor;    /* WindView Instrumentation */    USB_HCD_LOG_EVENT(		USB_UHCI_WV_TRANSFER,		"usbUhcdCreatePipe() starts",		USB_UHCD_WV_FILTER);    OS_LOG_MESSAGE_MEDIUM(UHCD,"Entering usbUhcdCreatePipe()\n",0,0,0,0);    /* end point no is lower 4 bits*/    endPointNum = (pusbHstEndPointDesc->bEndpointAddress)& 0x0F;    /* direction is the MSB */    direction = (pusbHstEndPointDesc->bEndpointAddress)>>7;    /*Check if the pipe already exists */    if (usbUhcdFindHcdPipe (uBusIndex, uDeviceAddress,endPointNum,direction,                            (pusbHstEndPointDesc->bmAttributes & USB_UHCD_ATTR_EPTYPE_MASK))        != NULL)        {        OS_LOG_MESSAGE_MEDIUM(UHCD,"Pipe already exists\n",0,0,0,0);        return USBHST_SUCCESS;        }    /* Check if the request is for the Root hub and route it */    if (uDeviceAddress == pHCDData->rootHub.uDeviceAddress)        {        /* To hold the status of the request */        USBHST_STATUS status = USBHST_FAILURE;        OS_LOG_MESSAGE_MEDIUM(UHCD,"Request is for root hub\n",0,0,0,0);        status = usbUhcdRhCreatePipe (pHCDData,                                      uDeviceAddress,                                      uDeviceSpeed,                                      pEndpointDescriptor,                                      puPipeHandle);        return status;        }    /* Enter the critical section */    usbUhcdEnterCritical(pHCDData);    /* Check if this is the first pipe to be created */    if (pHCDData->usbUhcdPipe == NULL)        {        OS_LOG_MESSAGE_MEDIUM(UHCD,"First pipe to be created\n",0,0,0,0);        /* Call the function to create the HCD maintained pipe */        currentPipe = pHCDData->usbUhcdPipe = usbUhcdFormEmptyPipe();        /* Check if the pipe is created successfully */        if (pHCDData->usbUhcdPipe==NULL)            {            OS_LOG_MESSAGE_MEDIUM(UHCD,"Couldn't create pipe\n",0,0,0,0);            usbUhcdLeaveCritical(pHCDData);            return USBHST_INSUFFICIENT_MEMORY;            }        /*         * This is the only element in the list as of now. So make the next         * pointer as NULL         */        currentPipe->next=(USB_UHCD_HCD_PIPE *) NULL;        }    /* If pipes are already present in the list */    else        {        OS_LOG_MESSAGE_MEDIUM(UHCD,"Pipes are already in the list\n",0,0,0,0);        /* Call the function to create the HCD maintained Pipe */        currentPipe = usbUhcdFormEmptyPipe();        /* Check if pipe is created successfully */        if (currentPipe == NULL)            {            OS_LOG_MESSAGE_MEDIUM(UHCD,"Pipe creation unsuccessful\n",0,0,0,0);            usbUhcdLeaveCritical(pHCDData);            return USBHST_INSUFFICIENT_MEMORY;            }        /*         * Update the next pointer of the newly         * created pipe to be the head pointer         */        currentPipe->next = pHCDData->usbUhcdPipe;        /* Update the head pointer to the newly created pipe's head pointer */        pHCDData->usbUhcdPipe = currentPipe;        }/* End of else */    /* Update the fields of the Pipe - Start */    currentPipe->deviceNum = uDeviceAddress;    currentPipe->endPointNum = endPointNum;    /* Copy the pipe direction */    currentPipe->endPointDirection = direction;    /* Copy the pipe type */    currentPipe->endPointType = pusbHstEndPointDesc->bmAttributes &                                USB_UHCD_ATTR_EPTYPE_MASK;    /*     * There is no QH which is to be created for an isochronous endpoint     * Return TRUE from the function     */    if ((pusbHstEndPointDesc->bmAttributes & USB_UHCD_ATTR_EPTYPE_MASK) ==        PIPE_ISOCHRONOUS)        {        OS_LOG_MESSAGE_MEDIUM(UHCD,"Creating an Isocchronous Pipe No QH is to created\n ",0,0,0,0);        }    else        {        /* Call the function to create the QH */        qh = usbUhcdFormEmptyQh();        /* Check if the QH is created successfully */        if (qh == NULL)            {            OS_LOG_MESSAGE_MEDIUM(UHCD,"QH creation is unsuccessful\n",0,0,0,0);            usbUhcdLeaveCritical(pHCDData);            /* Free the pipe Stucture */            OS_FREE(currentPipe);            return USBHST_INSUFFICIENT_MEMORY;            }        }    /* Update the empty QH pointer in the pipe created */    currentPipe->qh = qh;    currentPipe->uDeviceSpeed = uDeviceSpeed;    currentPipe->uMaximumPacketSize  =  pusbHstEndPointDesc->wMaxPacketSize;    /* swap */    currentPipe->uMaximumPacketSize = OS_UINT16_CPU_TO_LE(currentPipe->uMaximumPacketSize);    /* Update the fields of the Pipe - End */    /* Claculate the bus time (BW) required */    bwReqd = usbUhcdCalculateBusTime(uDeviceSpeed,                                     direction,                                     pusbHstEndPointDesc->bmAttributes & USB_UHCD_ATTR_EPTYPE_MASK,                                     currentPipe->uMaximumPacketSize);    /* If pipe is control or bulk */    if ((currentPipe->endPointType == PIPE_CONTROL) ||        (currentPipe->endPointType == PIPE_BULK))        {        OS_LOG_MESSAGE_MEDIUM(UHCD,"Pipe type control or bulk\n",0,0,0,0);        /* Update the bandwidth required for the control/bulk pipe */        /*pHCDData->usbUhcdCBBw+=bwReqd;*/        /* Update the bandwidth occupied in the current pipe */        currentPipe->bw = bwReqd;        /* Check if the pipe is a control pipe */        if (currentPipe->endPointType == PIPE_CONTROL)            {            OS_LOG_MESSAGE_MEDIUM(UHCD,"Control type\n",0,0,0,0);            qh->dWord1Qh = USB_UHCD_SWAP_DATA(uBusIndex, qh->dWord1Qh);            /* Add to the Control QH */            usbUhcdLinkQheadBetween(uBusIndex, qh, pHCDData->usbUhcdCQh);            }        /* Check if the pipe is a Bulk pipe */        else            {            OS_LOG_MESSAGE_MEDIUM(UHCD,"Bulk type\n",0,0,0,0);            /* Add to the Bulk QH */            qh->dWord1Qh = USB_UHCD_SWAP_DATA(uBusIndex, qh->dWord1Qh);            usbUhcdLinkQheadBetween(uBusIndex, qh, pHCDData->usbUhcdBQh);            }/* End of else */        }/* End of if(pEndpointDescriptor->bmAttributes  == PIPE_CONTROL .... */    /* The following is for the Interrupt pipe */    else        if ((currentPipe->endPointType == PIPE_INTERRUPT))        {        OS_LOG_MESSAGE_MEDIUM(UHCD,"Interrupt pipe\n",0,0,0,0);        /*         * ch - ams Determine the poll rate which can be supported by the HCD.         * The HCD supports a poll rate of 1,2,4,8,16,32,64,128 & 256 ms only.         */        reqPollRate = 1 << usbUhciLog2(pusbHstEndPointDesc->bInterval) ;        /*         * Locate suitable position for QH - listIndex will hold the         * index of the list in which the QH should be linked         */        if (usbUhcdFindPosForIntQh (bwReqd,                                    reqPollRate,                                    &listIndex,                                    pHCDData->usbUhcdTable,                                    pHCDData->usbUhcdTree) == FALSE)            {            OS_LOG_MESSAGE_MEDIUM(UHCD,"No position for QH\n",0,0,0,0);            usbUhcdLeaveCritical(pHCDData);            UHCI_FREE((UCHAR*)qh - (qh->offsetForFreeing));            OS_FREE(currentPipe);            return(USBHST_FAILURE);            }        /* Update the bandwidth required by the pipe */        currentPipe->bw = bwReqd;        /* Update the list index of the pipe */        currentPipe->listIndex = listIndex;        /* Add the bandwidth required by the pipe to the list */        pHCDData->usbUhcdTree[listIndex].bandWidth += bwReqd;        /* Get the last created QH in the list */        presentQh = (USB_UHCD_QH *) pHCDData->usbUhcdTree[listIndex].qh;        /* Link the newly created QH to the list */

⌨️ 快捷键说明

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