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

📄 usbhubmisc.c

📁 usb2 driver for vxwokrs
💻 C
📖 第 1 页 / 共 2 页
字号:
/* usbHubMisc.c - debug functionality functions *//* 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--------------------01b,15oct04,ami  Refgen Changes01a,16Sep03,amn Changing the code to WRS standards*//*DESCRIPTIONThis module provides the debug functionality functions for theUSB Hub Class DriverINCLUDE FILES: usb2/usbHubCommon.h, usb2/usbHubUtility.h, usb2/usbHubMisc.h*//*INTERNAL ******************************************************************************* * Filename         : usbHubMisc.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 debug functionality functions for *                    the USB Hub Class Driver. * * ******************************************************************************//************************** INCLUDE FILES *************************************/#include "usb2/usbHubCommon.h"#include "usb2/usbHubUtility.h"#include "usb2/usbHubMisc.h"/****************** MODULE SPECIFIC  MACRO DEFINITIONS ************************//* Defines for the return types for detected devices */#define USBHUB_NODETYPE_HUB      (0x02)#define USBHUB_NODETYPE_DEVICE   (0x01)#define USBHUB_NODETYPE_NONE     (0x00)/************************ GLOBAL FUNCTIONS ************************************//***************************************************************************** usbHubPortCntGet -  returns the number of ports connected to a  hub.** This routine returns the number of ports connected to a  hub.** RETURNS: USBHST_SUCCESS, USBHST_FAILURE if error occured.** ERRNO: None** \NOMANUAL*/USBHST_STATUS usbHubPortCntGet    (    UINT32 uHubId,     PUINT16 pPortCount    )    {    /* The pointer to the parent hub */    pUSB_HUB_INFO pParentHub       = NULL;    /* The pointer to the actual hub */    pUSB_HUB_INFO pHub             = NULL;    /* port number of the device */    UINT8 uPortIndex           = 0;    /* The port Information */    pUSB_HUB_PORT_INFO pPort       = NULL;    /* Debug Message */    OS_LOG_MESSAGE_LOW(        HUB,        "usbdHubPortCountGet: Called devH=0x%x\n",        uHubId,        0,        0,        0);    /* if NULL parameter return USBHST_INVALID_PARAMETER */    if (NULL == pPortCount)    {        /* Debug Message */        OS_LOG_MESSAGE_HIGH(            HUB,            "usbdHubPortCountGet: Null PortCount pointer\n",            0,            0,            0,            0);        return USBHST_INVALID_PARAMETER;    }/* End of if (NULL == pPortCount ) */    /*     * Call usbHubFindParentHubInBuses() to find the parent hub and If this     * is not found, then return USBHST_INVALID_PARAMETER.     */    pParentHub = usbHubFindParentHubInBuses(uHubId);    /* if not found and not a root hub, return USBHST_INVALID_PARAMETER */    if (NULL == pParentHub)    {        /* The bus List pointer to be used for browsing the list */        pUSB_HUB_BUS_INFO pBusList = gpGlobalBus;        /* While the pbusList is not null */        while ( NULL != pBusList )        {            /* Check if we have a root hub info */            if ( NULL != pBusList->pRootHubInfo)            {                /* Check if the device handles match */                if (uHubId == pBusList->pRootHubInfo->uDeviceHandle)                {                    /* we got the hub */                    pHub = pBusList->pRootHubInfo;                    break;                }            } /* End of if ( NULL != pBusList->pRootHubInfo) */            /* Move the pointer to the next bus */            pBusList=pBusList->pNextBus;        }/* End of while (pBus... */        /* Check if we found the root hub if not, return error */        if (NULL == pBusList)        {            /* Debug Message */            OS_LOG_MESSAGE_HIGH(                HUB,                "usbdHubPortCountGet: parent hub not found\n",                0,                0,                0,                0);            return USBHST_INVALID_PARAMETER;        }/* End of if NULL... */    }/* End of if (NULL == pParentHub ) */    /* there is a parent hub */    else    {        /*         * HUB_FindPortNumber() to find the port number for this device handle.         * If this is not found, then return USBHST_INVALID_PARAMETER.         */        uPortIndex = usbHubFindPortNumber(pParentHub,uHubId);        /* Check  if the port is found */        if (USB_PORT_NUMBER_NOT_FOUND == uPortIndex)        {            /* Debug Message */            OS_LOG_MESSAGE_HIGH(                HUB,                "usbdHubPortCountGet: port num not found\n",                0,                0,                0,                0);            return USBHST_INVALID_PARAMETER;        } /* End of if (PORT_NUM.. */        /* Check if the port number is within limits */        if (uPortIndex >= (pParentHub->HubDescriptor.bNbrPorts))        {            /* Debug Message */            OS_LOG_MESSAGE_HIGH(                HUB,                "usbdHubPortCountGet: port=%d > %d\n",                uPortIndex,                pParentHub->HubDescriptor.bNbrPorts,                0,                0);            return USBHST_INVALID_PARAMETER;        } /* End of (uPortIndex > (pParentHub->.... */        /*         * Retrieve HUB_INFO structure from         * parentHub::pPortList[uPortIndex]::pHub.         */        pPort = pParentHub->pPortList[uPortIndex];        OS_ASSERT(pPort != NULL);                                       /* Verify */        /* retrieve the pHub */        pHub= pPort->pHub;        /*         * Check if the port is actually a hub. if not, return failure.         */        if (NULL == pHub)        {            /* Debug Message */            OS_LOG_MESSAGE_MEDIUM(                HUB,                "usbdHubPortCountGet: Hub Handle 0x%x is not a hub!\n",                uHubId,                0,                0,                0);            return USBHST_FAILURE;        } /* End of if (NULL == pPort->pHub) */    } /* End of else of if (NULL ==pParentHub) */    /* retrieve the port count information */    *pPortCount = pHub->HubDescriptor.bNbrPorts;    /* Debug Message */    OS_LOG_MESSAGE_LOW(        HUB,        "usbdHubPortCountGet: Completed success\n",        0,        0,        0,        0);    /* return USBHST_SUCCESS */    return USBHST_SUCCESS;} /* End of usbdHubPortCountget() *//***************************************************************************** usbHubNodeIDGet - Gets the node id of the node connected to hub port.** This routine gets the node id of the node connected to hub port.** RETURNS: USBHST_SUCCESS, USBHST_FAILURE if error occured.** ERRNO: None* * \NOMANUAL*/USBHST_STATUS usbHubNodeIDGet    (    UINT32 uHubId,    UINT16 uPortIndex,     PUINT16 pNodeType,     PUINT32 pNodeId    )    {    /* The pointer to the parent hub */    pUSB_HUB_INFO pParentHub       = NULL;    /* The pointer to the actual hub */    pUSB_HUB_INFO pHub             = NULL;    /* port number of the device */    UINT8 uPortCount           = 0;    /* The port Information */    pUSB_HUB_PORT_INFO pPort       = NULL;    /* Debug Message */    OS_LOG_MESSAGE_LOW(        HUB,        "usbdNodeIdGet: Called devH=0x%x\n",        uHubId,        0,        0,        0);    /* if NULL parameter return USBHST_INVALID_PARAMETER */    if ((NULL == pNodeType)||(NULL == pNodeId))    {        /* Debug Message */        OS_LOG_MESSAGE_HIGH(            HUB,            "usbdNodeIdGet: Null pointer in param pNodeType=0x%x"            " pNodeId=0x%x\n",            (UINT32)pNodeType,            (UINT32)pNodeId,            0,            0);        return USBHST_INVALID_PARAMETER;    }/* End of if ((NULL == pNodeType)||(NULL == pNodeId)) */    /*     * Call HUB_FindParentHubInBuses() to find the parent hub and If this     * is not found, then return USBHST_INVALID_PARAMETER.     */    pParentHub = usbHubFindParentHubInBuses(uHubId);    /* if not found and not a root hub, return USBHST_INVALID_PARAMETER */    if (NULL == pParentHub)

⌨️ 快捷键说明

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