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

📄 usbehcdinitexit.c

📁 usb2 driver for vxwokrs
💻 C
📖 第 1 页 / 共 5 页
字号:
        OS_LOG_MESSAGE_HIGH(EHCD,"usbEhcdDataUninitialize - invalid parameter\n",0,0,0,0);        return;        }    /* Disable the periodic list */    USB_EHCD_CLR_BIT(pHCDData,                 USBCMD,                 PERIODIC_SCHEDULE_ENABLE);    /* Free memory allocated for the frame list */    if (NULL != pHCDData->pAllocatedFrameList)        {        OS_FREE(pHCDData->pAllocatedFrameList);        pHCDData->pAllocatedFrameList = NULL;        }    /* Destroy the interrupt tree */    usbEhcdDestroyInterruptTree(pHCDData);    /* Destroy the signalling event */    if (NULL != pHCDData->InterruptEvent)        {        OS_DESTROY_EVENT(pHCDData->InterruptEvent);        pHCDData->InterruptEvent = NULL;        }    /* Destroy the synchronisation event */    if (NULL != pHCDData->RequestSynchEventID)        {        OS_DESTROY_EVENT(pHCDData->RequestSynchEventID);        pHCDData->RequestSynchEventID = NULL;        }    /* Destroy the reclamation list synchronisation event */    if (NULL != pHCDData->ReclamationListSynchEventID)        {        OS_DESTROY_EVENT(pHCDData->ReclamationListSynchEventID);        pHCDData->ReclamationListSynchEventID = NULL;        }    /* Destroy the bandwidth reservation event */    if (NULL != pHCDData->BandwidthEventID)        {        OS_DESTROY_EVENT(pHCDData->BandwidthEventID);        pHCDData->BandwidthEventID = NULL;        }    /* Destroy the thread created for handling the interrupts */    if (0 != pHCDData->IntHandlerThreadID)        {        OS_DESTROY_THREAD(pHCDData->IntHandlerThreadID);        pHCDData->IntHandlerThreadID = 0;        }    /* Free memory allocated for the port status */    if (NULL != pHCDData->RHData.pPortStatus)        {        OS_FREE(pHCDData->RHData.pPortStatus);        pHCDData->RHData.pPortStatus = NULL;        }    /* Free memory allocated for the interrupt data */    if (NULL != pHCDData->RHData.pHubInterruptData)        {        OS_FREE(pHCDData->RHData.pHubInterruptData);        pHCDData->RHData.pHubInterruptData = NULL;        }    /* Free memory allocated for the default pipe */    if (NULL != pHCDData->pDefaultPipe)        {	/* Free the memory allocated for the QH */    	if (NULL != pHCDData->pDefaultPipe->pQH)       	    {            OS_ASSERT(NULL != pHCDData->pDefaultPipe->pQH->pAllocatedMem);            OS_FREE(pHCDData->pDefaultPipe->pQH->pAllocatedMem);            }    	OS_FREE(pHCDData->pDefaultPipe);    	pHCDData->pDefaultPipe = NULL;        }    OS_LOG_MESSAGE_LOW(EHCD,"usbEhcdDataUninitialize - Exit\n",0,0,0,0);    return;    }    /* End of function usbEhcdDataUninitialize() *//***************************************************************************** usbEhcdInit - initializes the EHCI Host Controller** This routine intializes the EHCI Host Controller Driver and can be called* from either the target initialization code (bootup) or during runtime. * The usbd and hub interfaces should be initialized before this routine is * called.** RETURNS: TRUE, or FALSE if there is an error during HCD initialization.** ERRNO:*   None.*/BOOLEAN usbEhcdInit(VOID)    {    /* To hold the return value of bus initialization function call */    BUS_OPERATION_STATUS BusInitStatus = FALSE;    /* To hold the status of a function call */    USBHST_STATUS Status = USBHST_FAILURE;    /* To hold the pointer to the HCD maintained data structure */    pUSB_EHCD_DATA pHCDData = NULL;    /* To hold the status of the EHCD_DATA structure initialization */    BOOLEAN bInitStatus = FALSE;    /* Temporary variable to hold the count value */    UINT32 uTempCount = 0;    OS_LOG_MESSAGE_LOW(EHCD,"usbEhcdInit - Entry\n",0,0,0,0);    /*     * Check whether the globals are initialized - This can happen if this     * function is called more than once.     */    OS_ASSERT(g_pEHCDriverInfo == NULL);    OS_ASSERT(g_EHCDHandle == 0);    if ((g_pEHCDData != NULL) || (maxEhciCount == 0))        {    	OS_LOG_MESSAGE_HIGH(EHCD,"usbEhcdInit - EHCD already initialized\n",                                 0,0,0,0);	/* WindView Instrumentation */	USB_HCD_LOG_EVENT(			USB_EHCI_WV_INIT_EXIT,			"usbEhcdInit() exits - EHCD already initialized",			USB_EHCD_WV_FILTER);    	return FALSE;        }     /* Initialize the global array */    g_pEHCDData = (pUSB_EHCD_DATA *)OS_MALLOC                            (sizeof(pUSB_EHCD_DATA) * maxEhciCount);    /* Check if memory allocation is successful */    if (g_pEHCDData == NULL)        {    	OS_LOG_MESSAGE_HIGH(EHCD,"usbEhcdInit - allocation failed" \                                 "for g_pEHCDData\n",                                 0,0,0,0);	/* WindView Instrumentation */	USB_HCD_LOG_EVENT(			USB_EHCI_WV_INIT_EXIT,			"usbEhcdInit() exits - allocation failed" \                                 "for g_pEHCDData",			USB_EHCD_WV_FILTER);    	return FALSE;        }        /* Reset the global array */    OS_MEMSET (g_pEHCDData, 0,sizeof(pUSB_EHCD_DATA) * maxEhciCount);      /* Create the event used for synchronising the free list accesses */    g_ListAccessEvent = OS_CREATE_EVENT(OS_EVENT_SIGNALED);    /* Check if the event is created successfully */     if (NULL == g_ListAccessEvent)        {    	OS_LOG_MESSAGE_HIGH(EHCD,"usbEhcdInit - Error in creating the list event\n",0,0,0,0);		/* WindView Instrumentation */		USB_HCD_LOG_EVENT(			USB_EHCI_WV_INIT_EXIT,			"usbEhcdInit() exits - Creating list access event failed",			USB_EHCD_WV_FILTER);        /* free the global array */        if (g_pEHCDData != NULL)            {            OS_FREE (g_pEHCDData);            g_pEHCDData = NULL;            }      	return FALSE;        }    /* Allocate memory for the HCD maintained data structure */    g_pEHCDriverInfo  = (pUSBHST_HC_DRIVER)OS_MALLOC(sizeof(USBHST_HC_DRIVER));    /* check if memory allocation is successful */    if (NULL == g_pEHCDriverInfo)        {        OS_LOG_MESSAGE_HIGH(EHCD,"usbEhcdInit - memory not allocated for driver data",0,0,0,0);        /* Destroy the event */        OS_DESTROY_EVENT(g_ListAccessEvent);        g_ListAccessEvent = NULL;        /* free the global array */        if (g_pEHCDData != NULL)            {            OS_FREE (g_pEHCDData);            g_pEHCDData = NULL;            }  		/* WindView Instrumentation */		USB_HCD_LOG_EVENT(			USB_EHCI_WV_INIT_EXIT,			"usbEhcdInit() exits - Memory allocation failed",			USB_EHCD_WV_FILTER);        return FALSE;        }    /* Initialize the members of the data structure */    OS_MEMSET(g_pEHCDriverInfo, 0, sizeof(USBHST_HC_DRIVER));    /* Populate the members of the HC Driver data structure - start */    /* Function to retrieve the frame number */    g_pEHCDriverInfo->getFrameNumber = usbEhcdGetFrameNumber;    /* Function to change the frame interval */    g_pEHCDriverInfo->setBitRate = usbEhcdSetBitRate;    /* Function to check whether bandwidth is available */    g_pEHCDriverInfo->isBandwidthAvailable = usbEhcdIsBandwidthAvailable;    /* Function to create a pipe */    g_pEHCDriverInfo->createPipe = usbEhcdCreatePipe;    /* Function to modify the default pipe */    g_pEHCDriverInfo->modifyDefaultPipe = usbEhcdModifyDefaultPipe;    /* Function to delete the pipe */    g_pEHCDriverInfo->deletePipe = usbEhcdDeletePipe;    /* Function to check if the request is pending */    g_pEHCDriverInfo->isRequestPending = usbEhcdIsRequestPending;    /* Function to submit an URB */    g_pEHCDriverInfo->submitURB = usbEhcdSubmitURB;    /* Function to cancel an URB */    g_pEHCDriverInfo->cancelURB = usbEhcdCancelURB;    /* Function to submit a clear tt request complete  */    g_pEHCDriverInfo->clearTTRequestComplete = usbEhcdClearTTRequestComplete;    /* Function to submit a clear tt request complete  */    g_pEHCDriverInfo->resetTTRequestComplete = usbEhcdResetTTRequestComplete;    /* Populate the members of the HC Driver data structure - End */    /* Register the HCD with the USBD */    Status = usbHstHCDRegister            (            g_pEHCDriverInfo,            &g_EHCDHandle            ,&g_USBDRequestFunctions            );    /* Check whether the registration is successful */    if (USBHST_SUCCESS != Status)        {    	OS_LOG_MESSAGE_HIGH(EHCD,"usbEhcdInit - Error in registering the HCD\n",0,0,0,0);    	/* Free memory allocated */    	OS_FREE(g_pEHCDriverInfo);        g_pEHCDriverInfo = NULL;        /* Destroy the event */        OS_DESTROY_EVENT(g_ListAccessEvent);        g_ListAccessEvent = NULL;        /* free the global array */        if (g_pEHCDData != NULL)            {            OS_FREE (g_pEHCDData);            g_pEHCDData = NULL;            }  		/* WindView Instrumentation */		USB_HCD_LOG_EVENT(			USB_EHCI_WV_INIT_EXIT,			"usbEhcdInit() exits - EHCD registration failed",			USB_EHCD_WV_FILTER);    	return FALSE;        }    /* Allocate memory for the DMA */    /*     * This loop performs the initialization of all     * the Host Controllers in the system.     */    for (g_EHCDControllerCount = 0;         g_EHCDControllerCount < maxEhciCount;)        {        /* Call the bus specific initialization function to initialize the         * host controllers in the system         */        BusInitStatus = usbEhcdHostBusInitialize(&pHCDData,                                               g_EHCDControllerCount);        /*         * If the bus is not present, release memory allocated only         * for this instance and return         */        if (USB_EHCD_HC_NOT_PRESENT == BusInitStatus)            {    	    OS_LOG_MESSAGE_HIGH(EHCD,"usbEhcdInit - No other HC is present\n",0,0,0,0);    	        	    /* If atleast one host controller is found, then it is not an error*/    	    if (0 != g_EHCDControllerCount)        	    {                /* WindView Instrumentation */                USB_HCD_LOG_EVENT(                    USB_EHCI_WV_INIT_EXIT,                    "usbEhcdInit() exits successfully - no host controller",                    USB_EHCD_WV_FILTER);                /* If the Host Controller is not present, it is not an error */   	    	    return TRUE;        	    }            else                {                /* WindView Instrumentation */                USB_HCD_LOG_EVENT(                    USB_EHCI_WV_INIT_EXIT,                    "usbEhcdInit() exits - BusInit reported no controller",                    USB_EHCD_WV_FILTER);            	return FALSE;                }            }        /* If the bus initialization is not successful, return an error */        if (USB_EHCD_HCBUS_NOT_INITIALIZED == BusInitStatus)            {    	    OS_LOG_MESSAGE_HIGH(EHCD,"usbEhcdInit - Bus initialization is \                                 unsuccessful\n",0,0,0,0);    	    return FALSE;            }        /* Initialize the array element */        g_pEHCDData[g_EHCDControllerCount] = pHCDData;        /* Update the bus index in the structure */        pHCDData->uBusIndex = g_EHCDControllerCount;        /* Read the HCCPARAMS register to identify the size of data structure */        pHCDData->addressMode64 = USB_EHCD_GET_FIELD(pHCDData,                                                     HCCPARAMS,                                                     ADDRCAP);        /* Initialize the Host Controller data structure */        bInitStatus = usbEhcdDataInitialize(pHCDData);        /* Check if the EHCD_DATA structure initialization is successful */        if (TRUE != bInitStatus)            {    	    OS_LOG_MESSAGE_HIGH(EHCD,"usbEhcdInit - EHCD_DATA initialization is \                                 unsuccessful\n",0,0,0,0);            /* Call the uninitialization function of the HC bus */            usbEhcdHostBusUninitialize(pHCDData);		    /* WindView Instrumentation */		    USB_HCD_LOG_EVENT(			    USB_EHCI_WV_INIT_EXIT,			    "usbEhcdInit() exits - Controller Data Initialisation failed",			    USB_EHCD_WV_FILTER);    	    return FALSE;            }

⌨️ 快捷键说明

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