📄 usbhubeventhandler.c
字号:
/* usbHubEventHandler.c - Functions for handling HUB events *//* Copyright 2003 Wind River Systems, Inc. *//*Modification history--------------------01a,27jun03,nrv Changing the code to WRS standards*//*DESCRIPTIONThis provides the functions for handling the hub events. This is used in conjunction with the Port Event Handling Module and Bus Manager Module.INCLUDE FILES: usb2/usbOsal.h usb2/usbHst.h usb2/usbHubCommon.h usb2/usbHubUtility.h usb2/usbHubEventHandler.h*//*INTERNAL ******************************************************************************* * Filename : HUB_HubEventHandler.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 provides the functions for handling the hub events. * This is used in conjunction with the Port Event Handling * Module and Bus Manager Module. * * ******************************************************************************//************************** INCLUDE FILES *************************************/#include "usb2/usbOsal.h"#include "usb2/usbHst.h"#include "usb2/usbHubCommon.h"#include "usb2/usbHubUtility.h"#include "usb2/usbHubEventHandler.h"/************************ GLOBAL FUNCTIONS DEFINITION *************************//***************************************************************************** usbHubEventHandler - Handle the hub event.** This is the function to handle the hub event. This has the maximum priority * over any other event. Each Bus structure maintains a variable whose count is* incremented every time a hub event is detected and decremented every time a* hub event is handled. Only when this counter is 0 are other events handled.** RETURNS: N/A** ERRNO: None** \NOMANUAL*/LOCAL USBHST_STATUS usbHubEventHandler ( pUSB_HUB_INFO pHub ) { /* To store the Hub Status */ USB_HUB_STATUS HubStatus; /* To store the length of the buffer */ UINT8 uLength = sizeof(USB_HUB_STATUS); /* To store the result */ USBHST_STATUS Result; /* Counter for the port numbers */ UINT8 uPortCount = 0; /* WindView Instrumentation */ USB_HUB_LOG_EVENT( USB_HUB_WV_EVENT_HANDLER, "Entering usbHubEventHandler() Function", USB_HUB_WV_FILTER); /* Debug Message */ OS_LOG_MESSAGE_LOW( HUB, "usbHubEventHandler: Called pHub=0x%x\n", (UINT32)pHub, 0, 0, 0); /* If the pHub is NULL then return USBHST_INVALID_PARAMETER */ if (NULL == pHub) { /* Debug Message */ OS_LOG_MESSAGE_MEDIUM( HUB,"usbHubEventHandler: Done pHub=NULL\n",0,0,0,0); return USBHST_INVALID_PARAMETER; }/* End of if (NULL == pHub) */ /* Call HUB_GET_HUB_STATUS for getting the HUB_STATUS structure. * i. If the call fails then set the pHub::StateOfHub * as MARKED_FOR_DELETION. * ii.Return the result. */ Result = USB_HUB_GET_STATUS(pHub,(UINT8 *)(&HubStatus),&uLength); /* Check if the call failed. */ if (( USBHST_SUCCESS != Result)|| (sizeof(USB_HUB_STATUS) != uLength)) { /* Debug Message */ OS_LOG_MESSAGE_HIGH( HUB,"usbHubEventHandler: GetHubStatus Failed\n",0,0,0,0); /* Mark the hub for deletion */ pHub->StateOfHub = USB_MARKED_FOR_DELETION; return Result; }/* End of if (USBHST_SUCCESS != Result) */ /* for all ports that are enabled, * i. Call HUB_PowerOnPort() with pHub and port count to re enable the * port. If the call fails, then return USBHST_FAILURE. */ for (uPortCount = 0; uPortCount < pHub->HubDescriptor.bNbrPorts; uPortCount++) { Result=usbHubPowerOnPort(pHub,uPortCount); if (USBHST_SUCCESS !=Result) { /* Debug Message */ OS_LOG_MESSAGE_HIGH( HUB, "usbHubEventHandler:power on port %d failed\n", uPortCount, 0, 0, 0); return Result; }/* End of if (USBHST_SUCCESS !=Result) */ } /* End of for (uPortCount.... */ /* * Call OS_LOCKED_DECREMENT() to decrement pHub::pBus::uNumberOfHubEvents. */ OS_LOCKED_DECREMENT(pHub->pBus->uNumberOfHubEvents); /* Clean up the bit of hub status */ pHub->pStatus[0] = (pHub->pStatus[0] & (0xFE)); /* WindView Instrumentation */ USB_HUB_LOG_EVENT( USB_HUB_WV_EVENT_HANDLER, "Exiting usbHubEventHandler() Function", USB_HUB_WV_FILTER); /* Debug Message */ OS_LOG_MESSAGE_LOW( HUB, "usbHubEventHandler: Done pHub=0x%x\n", (UINT32)pHub, 0, 0, 0); /* Return USBHST_SUCCESS*/ return USBHST_SUCCESS; }/* End of HUB_HubEventHandler ()*//**************************** End of File HUB_HubEventHandler.c ***************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -