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

📄 usbuhcdrhemulate.c

📁 usb2 driver for vxwokrs
💻 C
📖 第 1 页 / 共 5 页
字号:
        {        OS_LOG_MESSAGE_MEDIUM(UHCD,"Invalid Conditions\n",0,0,0,0);        return USB_UHCD_FAIL;        }    /* Check for invalid conditions. i.e NULL Buffer condition */    if (pUrb->pTransferBuffer == NULL)        {        OS_LOG_MESSAGE_MEDIUM(UHCD,"Invalid buffer condition\n",0,0,0,0);        return USB_UHCD_FAIL;        }    /* Copy the configuration to URB's buffer */    usbUhcdCopy (pUrb->pTransferBuffer, &(pHCDData->rootHub.uConfigValue), NULL, 1);    OS_LOG_MESSAGE_MEDIUM(UHCD,"Exiting GetConfiguration\n",0,0,0,0);    /* Return success */    return USB_UHCD_PASS;    }/* End of usbUhcdGetConfiguration() *//***************************************************************************** usbUhcdGetStatus - handles the hub specific request for Root hub** This function handles the GET_STATUS standard device request issued * to the Root hub, called by usbUhcdProcessRhControlTransfer.** RETURNS: USB_UHCD_FAIL if there is an error in retrieving status** ERRNO:*   None.** \NOMANUAL*/INT32 usbUhcdGetStatus    (    USBHST_URB *pUrb    )    {    /* To hold the 2 byte status information */        /* The status is made 1 cause the Root Hub is self powered and does not support     * suppot*/    UINT16 status = 0x01;    UINT16 wValue = 0;    UINT16 wIndex = 0;    UINT16 wLength = 0;    pUSBHST_SETUP_PACKET pSetupPacket =     (pUSBHST_SETUP_PACKET )pUrb->pTransferSpecificData;    OS_LOG_MESSAGE_MEDIUM(UHCD,"Entering GetStatus\n",0,0,0,0);    /* Check if the URB and DevRequest pointers are valid */    if (NULL == pUrb || NULL == pUrb->pTransferSpecificData)        {        OS_LOG_MESSAGE_MEDIUM(UHCD,"Pointers are not valid \n",0,0,0,0);        return USB_UHCD_FAIL;        }    wValue = OS_UINT16_CPU_TO_LE(pSetupPacket->wValue);    wIndex = OS_UINT16_CPU_TO_LE(pSetupPacket->wIndex);    wLength = OS_UINT16_CPU_TO_LE(pSetupPacket->wLength);    OS_LOG_MESSAGE_MEDIUM(UHCD,"Checking parameters\n",0,0,0,0);    /*     * Check whether there are any invalid conditions     * ie invalid DevRequest parameters     */    if (wLength != 0 &&        wLength != 2)        {        OS_LOG_MESSAGE_MEDIUM(UHCD,"Invalid condition\n",0,0,0,0);        return USB_UHCD_FAIL;        }    /* Check whether the buffer pointer is valid */    if (pUrb->pTransferBuffer == NULL)        {        OS_LOG_MESSAGE_MEDIUM(UHCD,"Invalid buffer pointer\n",0,0,0,0);        return USB_UHCD_FAIL;        }    /* There is no specific status information which need to be updated */    /* Copy the status to URB's buffer */        status = OS_UINT16_CPU_TO_LE(status);    usbUhcdCopy (pUrb->pTransferBuffer, (UCHAR *) &status, NULL, 2);    OS_LOG_MESSAGE_MEDIUM(UHCD,"Exiting GetStatus\n",0,0,0,0);    /* Return success */    return USB_UHCD_PASS;    }/* End of usbUhcdGetStatus() *//***************************************************************************** usbUhcdProcessRhControlTransfer - handles control transfer** This function handles all the control transfers issued to the Root hub.** RETURNS: INT32** ERRNO:*   None.** \NOMANUAL*/void usbUhcdProcessRhControlTransfer    (    PHCD_DATA_URB pHCDDataURB    )    {    /* Pointer to the URB */    USBHST_URB *pUrb  = pHCDDataURB->purb;    /* Pointer to the Host controller stucture */    PUHCD_DATA pHCDData = pHCDDataURB->pHCDData;    pUSBHST_SETUP_PACKET pSetupPacket =    (pUSBHST_SETUP_PACKET )pUrb->pTransferSpecificData;    /* To hold the status of the function call */    INT32 ok;    /* To hold the task name of the callback function */    char cbName[20];    /*     * To hold the number of callback tasks created.     * This is for having a different task name everytime     */    static UINT rcbNum=0;    UINT16 wValue =OS_UINT16_CPU_TO_LE(pSetupPacket->wValue);    /* Free pHCDDataURB structure */      OS_FREE(pHCDDataURB);    /* Check if the URB and DevRequest pointers are valid */    if (NULL == pUrb || NULL == pUrb->pTransferSpecificData)        {        OS_LOG_MESSAGE_MEDIUM(UHCD,"Pointers are not valid\n",0,0,0,0);        return;        }    OS_LOG_MESSAGE_MEDIUM(UHCD,"Checking HUB requests\n",0,0,0,0);    /* HUB requests - (start) */    /* ClearPortFeature request */    if (pSetupPacket->bmRequestType == 0x23 &&        pSetupPacket->bRequest == 1)        {        OS_LOG_MESSAGE_MEDIUM(UHCD,"clear port feature request\n",0,0,0,0);        /* Call the function to handle the ClearPortFeature request */        ok = usbUhcdClearPortFeature (pHCDData, pUrb);        }    /* GetHubDescriptor request */    else if (pSetupPacket->bmRequestType == 0xA0 &&             pSetupPacket->bRequest == 6)        {        OS_LOG_MESSAGE_MEDIUM(UHCD,"get hub descriptor request\n",0,0,0,0);        /* Call the function to handle the GetHubDescriptor request */        ok = usbUhcdGetHubDescriptor (pUrb);        }    /* GetHubStatus request */    else if (pSetupPacket->bmRequestType == 0xA0 &&             pSetupPacket->bRequest == 0)        {        OS_LOG_MESSAGE_MEDIUM(UHCD,"get hub status request\n",0,0,0,0);        /* Call the function to handle the GetHubStatus request */        ok = usbUhcdGetHubStatus ( pUrb);        }    /* GetPortStatus request */    else if (pSetupPacket->bmRequestType == 0xA3 &&             pSetupPacket->bRequest == 0)        {        OS_LOG_MESSAGE_MEDIUM(UHCD,"get port status request\n",0,0,0,0);        /* Call the function to handle the GetPortStatus request */        ok = usbUhcdGetPortStatus (pHCDData, pUrb);        }    /* SetPortFeature request */    else if (pSetupPacket->bmRequestType == 0x23 &&             pSetupPacket->bRequest == 3)        {        OS_LOG_MESSAGE_MEDIUM(UHCD,"set port feature request\n",0,0,0,0);        /* Call the function to handle the SetPortFeature request */        ok = usbUhcdSetPortFeature (pHCDData, pUrb);        }    /* GetBusState request */    else if (pSetupPacket->bmRequestType == 0xA3 &&             pSetupPacket->bRequest == 2)        {        OS_LOG_MESSAGE_MEDIUM(UHCD,"get bus state request\n",0,0,0,0);        /* Call the function to handle the GetBusState request */        ok = usbUhcdGetBusState (pHCDData, pUrb);        }    /* SetHubDescriptor request */    else if (pSetupPacket->bmRequestType == 0x20 &&             pSetupPacket->bRequest == 7)        {        OS_LOG_MESSAGE_MEDIUM(UHCD,"set hub descriptor request\n",0,0,0,0);        /* This should be a STALL - this should be changed */        ok = USB_UHCD_PASS;        }    /* ClearHubFeature request */    else if (pSetupPacket->bmRequestType == 0x20 &&             pSetupPacket->bRequest == 1)        {        OS_LOG_MESSAGE_MEDIUM(UHCD,"clear hub feature request\n",0,0,0,0);        /*         * There is no functionality involved         * in clearing the hub feature         * So return a success         */        ok = USB_UHCD_PASS;        }    /* SetHubFeature request */    else if (pSetupPacket->bmRequestType == 0x20 &&             pSetupPacket->bRequest == 3)        {        OS_LOG_MESSAGE_MEDIUM(UHCD,"set hub feature request\n",0,0,0,0);        /*         * There is no functionality involved         * in setting the hub feature         * So return a success         */        ok = USB_UHCD_PASS;        }    /* HUB requests - (End) */    /* DEVICE requests (start) */    /* GetDescriptor request */    else if (pSetupPacket->bmRequestType == 0x80 &&             pSetupPacket->bRequest == 6)        {        OS_LOG_MESSAGE_MEDIUM(UHCD,"get descriptor request\n",0,0,0,0);        /* Call the function to handle the GetDescriptor request */        ok = usbUhcdGetDescriptor (pUrb);        }    /* SetConfiguration request */    else if (pSetupPacket->bmRequestType == 0 &&             pSetupPacket->bRequest == 9)        {        OS_LOG_MESSAGE_MEDIUM(UHCD,"set configuration request\n",0,0,0,0);        /* Call the function to handle the SetConfiguration request */        ok = usbUhcdSetConfiguration (pHCDData, pUrb);        }    /* SetAddress request */    else if (pSetupPacket->bmRequestType == 0 &&             pSetupPacket->bRequest == 5)        {        OS_LOG_MESSAGE_MEDIUM(UHCD,"set address request\n",0,0,0,0);        pHCDData->rootHub.uDeviceAddress = wValue;        ok = USB_UHCD_PASS;        }    /* GetConfiguration request */    else if (pSetupPacket->bmRequestType == 0x80 &&             pSetupPacket->bRequest == 8)        {        OS_LOG_MESSAGE_MEDIUM(UHCD,"get config request\n",0,0,0,0);        /* Call the function to handle the GetConfiguration request */        ok = usbUhcdGetConfiguration (pHCDData, pUrb);        }    /* SetDescriptor request */    else if (pSetupPacket->bmRequestType == 0 &&             pSetupPacket->bRequest == 7)        {        OS_LOG_MESSAGE_MEDIUM(UHCD,"set descriptor request\n",0,0,0,0);        /* This should be an error - should be changed */        ok = USB_UHCD_PASS;        }    /* GetStatus request */    else if ((pSetupPacket->bmRequestType & 0xFC) == 0x80 &&             pSetupPacket->bRequest == 0)        {        OS_LOG_MESSAGE_MEDIUM(UHCD,"get status request\n",0,0,0,0);        /* Call the function to handle the GetStatus request */        ok = usbUhcdGetStatus (pUrb);        }    /* SetFeature request */    else if ((pSetupPacket->bmRequestType & 0xFC) == 0 &&             pSetupPacket->bRequest == 3)        {        OS_LOG_MESSAGE_MEDIUM(UHCD,"set feature request\n",0,0,0,0);        /*         * There is no functionality involved in setting the feature         * So a success is returned here         */        ok = USB_UHCD_PASS;        }    /* ClearFeature request */    else if ((pSetupPacket->bmRequestType & 0xFC) == 0 &&             pSetupPacket->bRequest == 1)        {        OS_LOG_MESSAGE_MEDIUM(UHCD,"set clear feature request\n",0,0,0,0);        /*         * There is no functionality involved in clearing the feature         * So a success is returned here         */        ok = USB_UHCD_PASS;        }    /* DEVICE requests (End) */    /* If invalid request is issued, return a failure */    else        {        OS_LOG_MESSAGE_MEDIUM(UHCD,"invalid device request\n",0,0,0,0);        ok = USB_UHCD_FAIL;#ifdef DEBUG        printf("*** UNKNOWN req / Hub not configured !!!\n");#endif        }    OS_LOG_MESSAGE_MEDIUM(UHCD,"Device request ends\n",0,0,0,0);    /* If request completed sucessfully, fill URB's status as 0 */    if (ok)        {        OS_LOG_MESSAGE_MEDIUM(UHCD,"request completed successfully\n",0,0,0,0);        pUrb->nStatus = 0;        }    /* If request completed un-sucessfully, fill URB's status as 4 - STALL */    else        {        OS_LOG_MESSAGE_MEDIUM(UHCD,"request completed unsuccessfully\n",0,0,0,0);        pUrb->nStatus = USBHST_STALL_ERROR;        }    /* Create a different name for each callback function */    sprintf (cbName, "rcCB%d", rcbNum++);    OS_LOG_MESSAGE_MEDIUM(UHCD,"checking call back function\n",0,0,0,0);    /* If the callback function pointer is not NULL, call the function */    if (NULL != pUrb->pfCallback)        {        OS_LOG_MESSAGE_MEDIUM(UHCD,"call back function not NULL\n",0,0,0,0);        OS_CREATE_THREAD(cbName, 95, pUrb->pfCallback, pUrb);        }    OS_LOG_MESSAGE_MEDIUM(UHCD,"Exiting ProcessRH_ControlTransfer()\n",0,0,0,0);    return;    }/* End of usbUhcdProcessRhControlTransfer() *//***************************************************************************** usbUhcdProcessRhInterruptTransfer - handles interrupt transfer** This function handles the interrupt transfers issued to the Root hub, called * by usbUhcdQueueRhRequest.** RETURNS: INT32** ERRNO:*   None.* * \NOMANUAL*/void usbUhcdProcessRhInterruptTransfer    (    INT32 context    )    {        PHCD_DATA_URB pHCDDataURB = (PHCD_DATA_URB)context;    /* Pointer to the URB */    USBHST_URB *pUrb  = pHCDDataURB->purb;    /* Pointer to the Host controller stucture */    PUHCD_DATA pHCDData = pHCDDataURB->pHCDData;    /* To hold the index of the port */    INT32 i = 0;    /* To hold the status information */

⌨️ 快捷键说明

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