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

📄 usbuhcdscheduleqwaitforsignal.c

📁 usb2 driver for vxwokrs
💻 C
📖 第 1 页 / 共 3 页
字号:
/* usbUhcdScheduleQWaitForSignal.c - USB UHCD HCD ISR support routines *//* Copyright 2004 - 2005 Wind River Systems, Inc.    This software includes software licensed to Wind River Systems, Inc.   by Wipro, Ltd. Wind River licensees may use this software according     to the terms of their Wind River license agreement(s) applicable to    this software.*//*Modification history--------------------01m,20apr05,pdg  Fix for Iomega device not working01l,03apr05,ami  Correction of Non-Pci changes01k,29mar05,pdg  Corrected non-PCI changes mistakes01j,28mar05,pdg  non-PCI changes01i,14mar05,ami  SPR #106153 (Modification for handling data toggle on a stall                 condition)01h,02mar05,ami  SPR #106383 (Max UHCI Host Controller Issue)01g,31jan05,pdg  Modifying comment for short packet handling01f,28jan05,pdg  Short packet handling modified01e,18jan05,ami  Short Packet on Control Transfer handled (SPR #104979 Fix)01d,15oct04,ami  Refgen Changes01c,28jul03,mat Endian Related Changes.01b,26jun03,mat changing the code to WRS standards.01a,25apr03,ram written.*//*DESCRIPTIONThis file contains the handlers that would be invoked by theISR when relevent interrupts occur.INCLUDE FILES:  usb2/usbOsal.h, usb2/usbHst.h, usb2/usbUhcdCommon.h,usb2/usbUhcdScheduleQueue.h, usb2/usbUhcdSupport.h,usb2/usbUhcdScheduleQSupport.h, usb2/usbUhci.h*//* INTERNAL ****************************************************************************** * Filename         : usbUhcdScheduleQWaitForSignal.c * * Copyright        : * * THE COPYRIGHT IN THE CONTENTS OF THIS SOFTWARE VEST WITH WIPRO * LIMITED A COMPANY INCORPORATED UNDER THE LAWS OF INDIA AND HAVING * ITS REGISTERED OFFICE AT DODDAKANNELLI SARJAPUR ROAD  BANGALORE * 560 035. DISTRIBUTION OR COPYING OF THIS SOFTWARE BY * ANY INDIVIDUAL OR ENTITY OTHER THAN THE ADDRESSEE IS STRICTLY * PROHIBITED AND MAY INCUR LEGAL LIABILITY. IF YOU ARE NOT THE * ADDRESSEE PLEASE NOTIFY US IMMEDIATELY BY PHONE OR BY RETURN EMAIL. * THE ADDRESSEE IS ADVISED TO MAINTAIN THE PROPRIETARY INTERESTS OF * THIS COPYRIGHT AS PER APPLICABLE LAWS. * * * Description      :  This file contains the handlers that would be *                     invoked by the ISR when relevent interrupts occur. * * ******************************************************************************//* includes */#include "usb2/usbOsal.h"#include "usb2/usbHst.h"#include "usb2/usbUhcdCommon.h"#include "usb2/usbUhcdScheduleQueue.h"#include "usb2/usbUhcdSupport.h"#include "usb2/usbUhcdScheduleQSupport.h"#include "usb2/usbUhci.h"/* forward declaration *//* Pointer to the global array of HOst controller structures.*/extern PUHCD_DATA *g_pUHCDData;/* Forward declaration of the function to process the completed TDs */void usbUhcdProcessCompletedTds (PUHCD_DATA pHCDData);/* Function decleration of the function to clear all the resources when    fatel error has been occured.   */void usbUhcdCleartdOnSysError ( PUHCD_DATA pHCDData );/* Prototype of the the function to reset the UHCD Host Controller */extern void usbUhcdHcReset (PUHCD_DATA pHCDData);#define USB_UHCD_LOG_MESSAGE(a)/***************************************************************************** usbUhcdCompletedTdHandler - handles the completed TDs** This function is spawned as a task and is used to* handle the completed TDs** RETURNS: N/A** ERRNO:*   None.** \NOMANUAL*/void usbUhcdCompletedTdHandler     (    INT32 argPHCDData    )    {    PUHCD_DATA pHCDData = (PUHCD_DATA)argPHCDData;    OS_LOG_MESSAGE_MEDIUM(UHCD,"Entering usbUhcdCompletedTdHandler()\n",0,0,0,0);    /* WindView Instrumentation */    USB_HCD_LOG_EVENT(		USB_UHCI_WV_EVENT_HANDLER, 		"usbUhcdCompletedTdHandler() starts",		USB_UHCD_WV_FILTER);    /*     * This is an infinite loop performing the following operations     * 1. Waits on the signalling from the ISR indicating that the transfer     *    is completed.     * 2. Call the function to process the completed TDs.     * 3. Enable the interrupts     * 4. The steps 1 to 4 are repeated again.     */    while (1)        {        /* Wait infinitely for a semaphore to be signalled from ISR */        if (OS_WAIT_FOR_EVENT (pHCDData->usbUhcdSemCleanupTd, WAIT_FOREVER) == ERROR)            {            OS_LOG_MESSAGE_MEDIUM(UHCD,"Unable to take semaphore",0,0,0,0);            return;            }        /* Check if there is an error interrupt */        if(pHCDData->usbUhcdIntStatusValue & USB_UHCD_TRANSACTION_ERR_IOC)            {            /* Enter the critical section */            usbUhcdEnterCritical (pHCDData);            /* Clear the associative bit in the interrupt register for this HC */            pHCDData->usbUhcdIntStatusValue &= ~USB_UHCD_TRANSACTION_ERR_IOC;            /* Handle the transfer completion */            usbUhcdProcessCompletedTds(pHCDData);            /* Leave the critical section */            usbUhcdLeaveCritical (pHCDData);            }        if(pHCDData->usbUhcdIntStatusValue & USB_UHCD_HC_HALTED)        {            /*             * The Host Conrtoller sets this bit to 1, after it has stopped executing as             * a result of the RUN/STOP bit being set to 0, either by s/w or by the HC.             */            /* printf("**** HC HALTED ERROR *****\n"); */            pHCDData->usbUhcdIntStatusValue &= ~USB_UHCD_HC_HALTED;            if(pHCDData->usbUhcdIntStatusValue & USB_UHCD_HST_SYSTEM_ERR)            {                    /*                     * Bit 3 of USBSTS register indicates a Host System Error                     * (ie. the Host Controller has detected a serious error                     * during the host system access)                     * Check if there is a Host System error                     */                    printf("**** SYSTEM ERROR *****\n");                    pHCDData->usbUhcdIntStatusValue &= ~USB_UHCD_HST_SYSTEM_ERR;                    /* Enter the critical section */                    usbUhcdEnterCritical (pHCDData);                    /*                     * Remove all the data structures created for the associative host controller.                     * After removing all the stuff, host controller reset is applied.                     */                    usbUhcdCleartdOnSysError(pHCDData);                    /* Call the function to reset the UHCI Host Controller */                    usbUhcdHcReset (pHCDData);                    /* Leave the critical section */                    usbUhcdLeaveCritical (pHCDData);               }                if(pHCDData->usbUhcdIntStatusValue & USB_UHCD_HC_PROCESS_ERR)                {                    /*                     * Bit 4 of USBSTS register indicates a Host Controller Process Error                     * (ie. the Host Controller has detected a fatal error)                     * Check if there is a process error                     */                    printf("**** HC PROCESS ERROR *****\n");                    pHCDData->usbUhcdIntStatusValue &= ~USB_UHCD_HC_PROCESS_ERR;                    /* Enter the critical section */                    usbUhcdEnterCritical (pHCDData);                    /*                     * Remove all the data structures created for the associative host controller.                     * After removing all the stuff, make the RUN?STOP bit 1 to perform                     * scheduling again.                     */                    usbUhcdCleartdOnSysError(pHCDData);                    /* Clear the RUN/STOP bit in the command register */                    usbUhcdRegxSetBit(pHCDData, USB_UHCD_USBCMD, 1);                    /* Leave the critical section */                    usbUhcdLeaveCritical (pHCDData);               }            }        }/* End of while () */    OS_LOG_MESSAGE_MEDIUM(UHCD,"Exiting usbUhcdCompletedTdHandler()\n",0,0,0,0);    }/* End of usbUhcdCompletedTdHandler() *//***************************************************************************** usbUhcdProcessCompletedTds - handles the completed TDs** This routine handles the completed TDs.** RETURNS: N/A** ERRNO:*   None.** \NOMANUAL*/void usbUhcdProcessCompletedTds    (    PUHCD_DATA pHCDData    )    {    /* Pointer to the non-isochronous request queue */    USB_UHCD_NON_ISO_REQUEST_QUEUE *niRequest = NULL;    /*     * Pointer to the non-isochronous request queue block     * holding the previous request block     */    USB_UHCD_NON_ISO_REQUEST_QUEUE *niPrevious = NULL;    /*     * Pointer to the non-isochronous request queue block     * holding the temporary request block     */    USB_UHCD_NON_ISO_REQUEST_QUEUE *niTemporary = NULL;    /* Pointer to the isochronous request queue element */    USB_UHCD_ISO_REQUEST_QUEUE *iRequest = NULL;    /*     * Pointer to the isochronous request queue block     * holding the previous request block     */    USB_UHCD_ISO_REQUEST_QUEUE *iPrevious = NULL;    /*     * Pointer to the non-isochronous request queue block     * holding the temporary request block     */    USB_UHCD_ISO_REQUEST_QUEUE *iTemporary = NULL;    /* To hold the pointer to the TD which is presently serviced by HCD */    USB_UHCD_TD *qhsTd = NULL;    USB_UHCD_TD *temptd = NULL;    USB_UHCD_TD *lastTd = NULL;    USB_UHCD_TD *headTd = NULL;    USB_UHCD_TD *tailTd = NULL;    /* To hold the pointer to the temporary TD */    USB_UHCD_TD *td = NULL;    /* To hold the flag indicating that the request is halted */    UINT8 reqThatHalted = 0;    /* To hold the flag indicating that a short packet is received*/    UINT8 reqWithSp = 0;    /* To hold the last data toggle value received */    UINT8 lastToggle = 0;    /* To hold the task name of the callback function */    char cbName[20];    /* To hold the number of tasks created */    static UINT ncbNum=0;     UINT32 actlen    = 0;    UINT32 maxlen = 0;    UINT32 totlen =0;    /* Process the non-isochronous transfer request completion - Start */    /* Initialise the previous pointer to NULL */    niPrevious = NULL;    /* Start from the head of the non isochronous queue */        niRequest = pHCDData->usbUhcdNonIsoRequestQ;    USB_UHCD_LOG_MESSAGE ("Entering usbUhcdProcessCompletedTds()\n");    /* This loop is executed till all non-isochronous requests are serviced */       while (niRequest != NULL)        {        /*         * Initialise the flags indicating         * the request is halted and a short packet is received         */        reqThatHalted = reqWithSp = 0;        totlen =0;        /* cache related changes are yet to be tested */        DMA_INVALIDATE(niRequest->head, sizeof(USB_UHCD_TD));        DMA_INVALIDATE(niRequest->tail, sizeof(USB_UHCD_TD));        headTd = niRequest->head;        tailTd = niRequest->tail;        /*         * Check if the current request concluded with a Short packet &         * TD has been processed         */

⌨️ 快捷键说明

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