📄 usbuhcdmanageport.c
字号:
/* usbUhcdManagePort.c - USB UHCI HCD port status handler *//* Copyright 2004 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--------------------01e,15oct04,ami Refgen Changes01d,11oct04,ami Apigen Changes01c,28jul03,mat Endian Related Changes01b,26jun03,mat changing the code to WRS standards.01a,25apr03,ram written.*//*DESCRIPTIONThis file contains the handlers which regularly scan the UHCI's port for status changeINCLUDE FILES: usb2/usbOsal.h, usb2/usbHst.h, usb2/usbUhci.h, usb2/usbUhcdCommon.h, usb2/usbUhcdScheduleQueue.h,usb2/usbUhcdSupport.h, usb2/BusAbstractionLayer.h*//*INTERNAL ******************************************************************************* * Filename : usbUhcdManagePort.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 which regularly scan the * UHCI's port for status change * * ******************************************************************************//* includes */#include "usb2/usbOsal.h"#include "usb2/usbHst.h"#include "usb2/usbUhci.h"#include "usb2/usbUhcdCommon.h"#include "usb2/usbUhcdScheduleQueue.h"#include "usb2/usbUhcdSupport.h"#include "usb2/BusAbstractionLayer.h"/* defines */#define USB_UHCD_REQUEST_FAILURE ERROR/* * Macro Name : USB_UHCD_READ_BIT_IN_REG * Description : This macro is used to check whether a bit is set * of the given value. * Parameters : regValue IN any Value * whichBit IN Bit number which is to be checked * readBit INOUT Place holder to hold the read bit * Return Type : NULL * Calls : None * Called by : None * To Do : None */#define USB_UHCD_READ_BIT_IN_REG(regValue, whichBit, readBit) \ (*(readBit) = ((regValue >> whichBit) & 0x01)) extern void usbUhcdIsr (INT32 pHCDData);/***************************************************************************** usbUhcdManagePort - checks the port status** This thread monitors at periodic intervals for a change in the UHCI's* root port registersinvoked periodically to check the port status** RETURNS: N/A** ERRNO:* None.** \NOMANUAL*/void usbUhcdManagePort ( INT32 pHCDData ) { /* Pointer to the host controller stucture */ PUHCD_DATA ptrHCDData = (PUHCD_DATA)pHCDData; /* To hold the offset of the register */ UINT8 offset = 0; /* To hold the Port status and control register value */ UINT16 portStatus = 0; /* To hold the previous value for the Port State changed.... */ UINT16 prevPortStatus[2] = {0,0}; /* To hold the index into the number of ports supported */ UINT8 i = 0; UINT8 readBit_1 = 0x0; UINT8 readBit_3 = 0x0; UINT8 readBit_6 = 0x0; /* Flag to hold, whether there is any change in Port State or not.. */ BOOLEAN portStatusFlag = FALSE; OS_LOG_MESSAGE_HIGH(UHCD,"Entering manage port\n",0,0,0,0); /* * This is an infinite loop which * 1. Checks for any change in the Root hub ports * 2. If there are any changes, signals the task handling the * Root hub emulation module's interrupt transfer request. * 3. Wait for some time, to repeat the operation again * 4. All the above steps are repeated. */ while (1) { /* Reset the Status Flag */ portStatusFlag = FALSE; /* * This loop checks whether any of the Root hub ports have * undergone a change */ for (i = 0; i < 2; ++i) { /* Offset 0 is for PORT 1 and Offset 1 is for PORT 2 */ offset = (i == 0) ? (USB_UHCD_PORT1) : (USB_UHCD_PORT2); /* * Check if the port at index i has undergone any change * Bit 6 indicates that a Resume signal is detected * Bit 3 indicates that there is a port enable/disable change * Bit 1 indicates that there is a connect status change. */ portStatus = usbUhcdReadReg(ptrHCDData, offset); /* To check whether a reset change has happened */ if((portStatus != prevPortStatus[i]) && \ (( (portStatus & 0x2) !=0 )||(prevPortStatus[i] != 0) )) { /* Check exact value to retrieve interrupt */ USB_UHCD_READ_BIT_IN_REG(portStatus,1,&readBit_1); USB_UHCD_READ_BIT_IN_REG(portStatus,3,&readBit_3); USB_UHCD_READ_BIT_IN_REG(portStatus,6,&readBit_6); if( readBit_1 || \ readBit_3 || \ readBit_6 \ ) { /* * The following peice of code is the workarround for the scenario, when * the bit 3 of the Port status and control register is get set. * This bit indicates the Port enabled/disabled status has changed. * For the root hub, this gets set only when a port is disabled due to disconnect * on the that port due to the appropriate conditions existing at the EOF2 points. * * The workarround for this is that the softwars clears this bit by writing a 1 to it. */ if (portStatus & 0x08) { usbUhcdPortSetBit( ptrHCDData ,offset, 3); } /* Update the Flag... */ portStatusFlag = TRUE; OS_LOG_MESSAGE_HIGH(UHCD,"DETECT Change in Port Status [%d] [0x%x]->[0x%x] \n",i,prevPortStatus[i],portStatus,0); }/* End of if () */ } /* end-if */ if ((ptrHCDData->usbUhcdResetChange[i] == 1)) { /* Update the Flag... */ portStatusFlag = TRUE; } /* Update the previous value for the Port status */ prevPortStatus[i] = portStatus; }/* End of for () */ /* If found change in status..*/ if(portStatusFlag) { /* * Release the semaphore to the uhc_ProcessRH_InterruptTransfer * task. This enables the task to handle an interrupt * transfer request for the Root hub. */ OS_RELEASE_EVENT (ptrHCDData->usbUhcdSemPortInterruptTransfer); } /* * It is to be done for periodic checking of the Ports. * Issue delay, so that it could preempt itself, and goes into * pending state, to let the other thread run. */ /* Polling mode support */ usbUhcdIsr(pHCDData); OS_DELAY_MS(50); }/* End of while () */ }/* End of uhc_manage_port() */ /**************** End of File usbUhcdManagePort.c ********************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -