📄 usbhubinitialization.c
字号:
/* usbHubInitialization.c - Initialization and cleanup of HUB class driver *//* Copyright 2003 Wind River Systems, Inc. *//*Modification history--------------------01a,27jun03,nrv Changing the code to WRS standards*//*DESCRIPTIONThis module provides the initialization and the clean up functions for the USB Hub Class Driver.INCLUDE FILES: usb2/usbOsal.h usb2/usbHubCommon.h usb2/usbHubGlobalVariables.h usb2/usbHubInitialization.h usb2/usbHubClassInterface.h usb2/usbHst.h usb2/usbHcdInstr.h*//*INTERNAL ******************************************************************************* * Filename : HUB_Initialization.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 module provides the initialization and the clean up * functions for the USB Hub Class Driver. * * ******************************************************************************//************************** INCLUDE FILES *************************************/#include "usb2/usbOsal.h"#include "usb2/usbHubCommon.h"#include "usb2/usbHubGlobalVariables.h"#include "usb2/usbHubInitialization.h"#include "usb2/usbHubClassInterface.h"#include "usb2/usbHst.h"#include "usb2/usbHcdInstr.h"/**************************** SUB MODULE INCLUDES *****************************/#include "usbHubGlobalVariables.c"#include "usbHubUtility.c"#include "usbHubPortEventHandler.c"#include "usbHubEventHandler.c"#include "usbHubBusManager.c"#include "usbHubClassInterface.c"/* usbHubMisc.c has interfaces needed for usrUsbTool */#include "usbHubMisc.c"/******************* MODULE SPECIFIC VARIABLES DEFINITION *********************//* This stores the information about the Hub Driver. */LOCAL USBHST_DEVICE_DRIVER HubDriverInfo;/************************ GLOBAL FUNCTIONS DEFINITION *************************//***************************************************************************** usbHubInit - registers USB Hub Class Driver function pointers.** This function initializes the global variables and registers USB* Hub Class Driver function pointers with the USB Host Software Stack. This also* retrieves the USB Host Software Stack functions for future access.** RETURNS: 0 , -1 on fail.** ERRNO: None*/INT8 usbHubInit(void) { /* Variable to store the result */ USBHST_STATUS Result = USBHST_FAILURE; /* Void pointer to handle the data interchange with the USB Host software */ void * pContext = NULL; /* WindView Instrumentation */ USB_HUB_LOG_EVENT( USB_HUB_WV_INIT_EXIT, "Entering usbHubInit() Function", USB_HUB_WV_FILTER); /* Debug message */ OS_LOG_MESSAGE_HIGH( HUB, "USB HUB DRIVER IS BEING LOADED:Version=%s, CreateDate=%s\n", (UINT32)USB_HUB_VERSION_NUMBER, (UINT32)USB_HUB_VERSION_DATE, 0, 0); /* Initialize the global bus list by setting gpGlobalBus to NULL.*/ gpGlobalBus = NULL; /* * Initialize HubDriverInfo with the function pointers to the HUB_AddHub, * HUB_RemoveHub, HUB_SuspendHub, HUB_ResumeHub and the hub class code. */ /* Clear the HubDriverInfo structure */ OS_MEMSET(&HubDriverInfo,0,sizeof(USBHST_DEVICE_DRIVER)); /* State that we are using class specific matching */ HubDriverInfo.bFlagVendorSpecific = FALSE; /* The Class code for Hub class devices is 0x09H */ HubDriverInfo.uVendorIDorClass = 0x09; /* The Sub Class code for Hub class devices is 0x00H */ HubDriverInfo.uProductIDorSubClass = 0x00; /* The device protocol for Hub class devices is 0x00H */ HubDriverInfo.uBCDUSBorProtocol = 0x00; /* Call HUB_AddHub to add a normal Hub */ HubDriverInfo.addDevice = usbHubAdd; /* Call HUB_RemoveHub to remove a normal Hub */ HubDriverInfo.removeDevice = usbHubRemove; /* Call HUB_SuspendHub to suspend a Hub */ HubDriverInfo.suspendDevice = usbHubSuspend; /* Call HUB_ResumeHub to resume a Hub */ HubDriverInfo.resumeDevice = usbHubResume; /* * Initialize HUB_FUNCTION_LIST structure with the function pointers to the * HUB_AddRootHub, HUB_RemoveRootHub, HUB_SelectiveSuspendDevice, * HUB_SelectiveResumeDevice, HUB_CheckPower and HUB_ResetDevice. */ /* Clear the USBHST_FUNCTION_LIST structure */ OS_MEMSET(&g_usbHstFunctionList,0,sizeof(USBHST_FUNCTION_LIST)); /* Call HUB_SelectiveSuspendDevice to selectively suspend a device */ g_usbHstFunctionList.HubFunctionList.selectiveSuspendDevice = usbHubSelectiveSuspendDevice; /* Call HUB_SelectiveResumeDevice to selectively resume a device */ g_usbHstFunctionList.HubFunctionList.selectiveResumeDevice = usbHubSelectiveResumeDevice; /* Call HUB_AddRootHub to add a root hub device */ g_usbHstFunctionList.HubFunctionList.addRootHub = usbHubAddRoot; /* Call HUB_RemoveRootHub to remove a root hub device */ g_usbHstFunctionList.HubFunctionList.removeRootHub = usbHubRemoveRoot; /* Call HUB_CheckPower to check the power compatibility of a device */ g_usbHstFunctionList.HubFunctionList.checkForPower = usbHubCheckPower; /* Call HUB_ResetDevice to selectively reset a device */ g_usbHstFunctionList.HubFunctionList.resetDevice = usbHubResetDevice; /* Call HUB_ClearTT to submit ClearTT Request */ g_usbHstFunctionList.HubFunctionList.clearTT = usbHubClearTT; /* Call Hub_ResetTT to submit a ResetTT Request*/ g_usbHstFunctionList.HubFunctionList.resetTT = usbHubResetTT; /* Cast the hub function list pointer to (PVOID) */ pContext = (PVOID)(&g_usbHstFunctionList); /* * Register with the USB Host software * we pass the pointer to the Hub Function list to the USB Host Software * stack. * In return we get the pointer to the USBHST Function list. */ Result = usbHstDriverRegister(&HubDriverInfo, &pContext); /* If USBHST_RegisterDriver does not return USBHST_SUCCESS then return -1.*/ if (USBHST_SUCCESS != Result) { /* Debug Message */ OS_LOG_MESSAGE_HIGH( HUB, "usbHubInit:Unable to register with USBHST Return=0x%x\n", Result, 0, 0, 0); return -1; } /* Debug Message */ OS_LOG_MESSAGE_MEDIUM( HUB,"usbHubInit: Registered with USBHST\n",0,0,0,0); /* Verify the pContext */ OS_ASSERT(NULL != pContext); /* Verify the new device interface */ OS_ASSERT(NULL != g_usbHstFunctionList.UsbdToHubFunctionList.newDevice); /* Verify the configure device interface */ OS_ASSERT(NULL != g_usbHstFunctionList.UsbdToHubFunctionList.configureDevice); /* Verify the remove device interface */ OS_ASSERT(NULL != g_usbHstFunctionList.UsbdToHubFunctionList.removeDevice); /* Verify the suspend interface */ OS_ASSERT(NULL != g_usbHstFunctionList.UsbdToHubFunctionList.suspendDevice); /* Verify the Resume interface */ OS_ASSERT(NULL != g_usbHstFunctionList.UsbdToHubFunctionList.resumeDevice); /* Verify the ResetTTComplete interface */ OS_ASSERT(NULL != g_usbHstFunctionList.UsbdToHubFunctionList.resetTTComplete); /* Verify the ClearTTComplete interface */ OS_ASSERT(NULL != g_usbHstFunctionList.UsbdToHubFunctionList.clearTTComplete); /* WindView Instrumentation */ USB_HUB_LOG_EVENT( USB_HUB_WV_INIT_EXIT, "Exiting usbHubInit() Function", USB_HUB_WV_FILTER); /* Debug Message */ OS_LOG_MESSAGE_HIGH( HUB, "USB HUB DRIVER SUCCESSFULLY LOADED:Version=%s, CreateDate=%s\n", (UINT32)USB_HUB_VERSION_NUMBER, (UINT32)USB_HUB_VERSION_DATE, 0, 0); /* Return 0. */ return 0; } /* End of HUB_Init() function *//***************************************************************************** usbHubExit - de-registers and cleans up the USB Hub Class Driver. ** de-registers and cleans up the USB Hub Class Driver from the USB Host Software* Stack.** RETURNS: None** ERRNO: None*/INT8 usbHubExit (void) { /* Store the value of the de-registration */ USBHST_STATUS Result; /* If gpGlobalBus is not NULL, then return -1. */ if (NULL != gpGlobalBus) { /* Debug Message */ OS_LOG_MESSAGE_MEDIUM( HUB, "usbHubExit: g_GlobalBus Not Null :0x%x\n", gpGlobalBus->uBusHandle, 0, 0, 0); return -1; } /* Call the USBHST_DeregisterDriver with HubDriverInfo.*/ Result = usbHstDriverDeregister(&HubDriverInfo); /* If the USBHST_DeregisterDriver call fails then return -1. */ if (USBHST_SUCCESS != Result) { /* Debug Message */ OS_LOG_MESSAGE_MEDIUM( HUB, "usbHubExit: failed to deregister with USBHST:0x%x\n", Result, 0, 0, 0); return -1; } /* WindView Instrumentation */ USB_HUB_LOG_EVENT( USB_HUB_WV_INIT_EXIT, "Exiting usbHubInit() Function", USB_HUB_WV_FILTER); /* Debug Message */ OS_LOG_MESSAGE_HIGH( HUB, "USB HUB DRIVER IS EXITING:Version=%s, CreateDate=%s\n", (UINT32)USB_HUB_VERSION_NUMBER, (UINT32)USB_HUB_VERSION_DATE, 0, 0); /* Return 0.*/ return 0; } /* End of HUB_Exit() function *//**************************** End of File HUB_Initialization.c ****************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -