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

📄 usbd.c

📁 usb2 driver for vxwokrs
💻 C
📖 第 1 页 / 共 5 页
字号:
/* usbd.c - USBD Routines *//* 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--------------------01c,08aug05,ami  Added USBD_NOTIFY_ALL support in subclass field01a,03aug04,ami  Warning Messages Removed01b,05may04,???  Fix for registering a driver specifying USBD_NOTIFY_ALL after                 connecting a device01a,23jun03,cfc Changing the code to WRS standards*/                             /*DESCRIPTIONThis file initializes the various global variables forUSBD module to come up and provides registrationinterfaces to the class driver and Host Controller Driver.module.This file includes the urb.c and device.c source filesINCLUDE FILES: usb2/usbd.h*//*INTERNAL ******************************************************************************* * Filename         : usbd.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 initializes the various global variables for *                    USBD module to come up and provides registration *                    interfaces to the class driver and Host Controller Driver. *                    module. * * ******************************************************************************//* Include Files */#include "usb2/usbd.h"/******************************  Global Variables  ****************************//* * This global variable is used to maintain the list of information about * all the Host Controller Drivers registered with USBD */LOCAL USBHST_HC_DRIVER             gHCDriverList[USBD_MAX_HCD_NUM];/* * This global variable is used to maintain the list of information about all * the USB buses registered with USBD. */LOCAL USBD_BUS_INFO                gUSBBusInfoList[USBD_MAX_BUS_NUM];/* * This global variable is used to maintain the list of information about all * the USB device drivers registered with USBD. */LOCAL pUSBD_DEVICE_DRIVER_LIST     gpDeviceDriverList = NULL;/* * This global lock is used to protect the race conditions while accessing * global device driver list. */LOCAL OS_EVENT_ID                  gDeviceDriverListLock = OS_INVALID_EVENT_ID;/* * This global lock is used to protect the race conditions while accessing * global HC driver list. */LOCAL OS_EVENT_ID                  gHCDriverListLock = OS_INVALID_EVENT_ID;;/* This global variable contains the hub class driver function pointers */LOCAL USBHST_HUB_FUNCTION_LIST    *gpHubFunctionList = NULL;/* This global variable states wheather USBD is inited or not */LOCAL UINT8                        guUSBDInited = 0;/* * This global variable used to store the pointers to USBD entry points that * are visible to only Hub Class Driver */LOCAL USBHST_USBD_TO_HUB_FUNCTION_LIST      gUsbdFunctionList=                                                      {usbHstDeviceNew,                                                       usbHstDeviceConfigure,                                                       usbHstDeviceRemove,                                                       usbHstDeviceSuspend,                                                       usbHstDeviceResume,                                                        usbHstClearTTComplete,                                                       usbHstResetTTComplete};/* Initialize the OSAL debugging flag mechanism */UINT32 usbdOsalDbg = DEBUG_OFF;/**************************** SUB MODULE INCLUDES *****************************//* * Device manager provides for handling Plug & Play and Power * Management. The Device Manager provides the interfaces for * the following functionality: * *  1.  Handle device connection and disconnection. *  2.  Configure a newly attached device. *  3.  Handle device suspend and resume. *  4.  Interfaces for the client software to selectively *      suspend or resume a device. */#include "device.c"/* * This module provides interfaces to communicate with the * USB Device. The class drivers can use these interfaces to * 1.   Issue USB Standard Requests to the device. * 2.   Issue Class Specific or Vendor Specific using data *      transfers on the Default Control Endpoint. * 3.   Perform all data transfers to the device. * 4.   Cancel data transfers. */#include "urb.c"/* usbdMisc.c has interfaces needed for usrUsbTool */#include "usbdMisc.c"#define USBD_NOTIFY_ALL 0xFFFF/***************************************************************************** usbdInit - initializes USBD2.0** This routine initializes the global variables for the USBD2.0 layer. It * should be called before any hub, hcd, or class driver initialization* code.** RETURNS: USBHST_SUCCESS, USBHST_FAILURE if event's could not be created** ERRNO: None*/USBHST_STATUS usbdInit(void)    {    /* Local variable for loop count */    UINT8   uIndex = 0;    OS_LOG_MESSAGE_LOW(USBD, "Entering usbdInit() Function.\n",0,0,0,0);    /* Check if USBD is alreadey inited */    if ( 0 != guUSBDInited)        {		/* WindView Instrumentation */		USB_USBD_LOG_EVENT(			USB_USBD_WV_INIT_EXIT,			"usbdInit() exits : Error - already called once",			USB_USBD_WV_FILTER);        OS_LOG_MESSAGE_HIGH(USBD, "USBD has already been inited.\n",0,0,0,0);                 return USBHST_FAILURE;        } /* END if USBD is alreadey inited */        /* Capture the lock  variable */    OS_LOCKED_INCREMENT(guUSBDInited);    /* Initialize the memory allocation model */    OS_MEMPOOL_INIT();    /* set the memory to zero for all elements in gHCDriverList */    for (uIndex = 0; uIndex < USBD_MAX_HCD_NUM; uIndex++)        {        OS_MEMSET(&gHCDriverList[uIndex], 0, sizeof(USBHST_HC_DRIVER));        }    /* set the memory to zero for elements in gUSBBusInfoList */    for (uIndex = 0; uIndex < USBD_MAX_BUS_NUM; uIndex++)        {        OS_MEMSET(&gUSBBusInfoList[uIndex], 0, sizeof(USBD_BUS_INFO));        }    /* Initialize the g_DeviceDriverList to NULL */    gpDeviceDriverList = NULL;    /*     * Create lock to avoid race conditions while accessing     * global device driver list     */    gDeviceDriverListLock = OS_CREATE_EVENT(OS_EVENT_SIGNALED);    /* Check if the device driver list lock is valid */    if (OS_INVALID_EVENT_ID == gDeviceDriverListLock)        {		/* WindView Instrumentation */		USB_USBD_LOG_EVENT(			USB_USBD_WV_INIT_EXIT,			"usbdInit() Failed: Cannot create gDeviceDriverListLock.\n",			USB_USBD_WV_FILTER);        OS_LOG_MESSAGE_HIGH(            USBD,            "usbdInit() Failed: Cannot create gDeviceDriverListLock.\n",            0,            0,            0,            0);        /* Capture the lock  variable */        OS_LOCKED_DECREMENT(guUSBDInited);        return USBHST_FAILURE;        }    /*     * Create lock to avoid race conditions while accessing     * global HC driver list     */    gHCDriverListLock = OS_CREATE_EVENT(OS_EVENT_SIGNALED);    /* Check if the HC driver list lock is valid */    if (OS_INVALID_EVENT_ID == gHCDriverListLock)        {		/* WindView Instrumentation */		USB_USBD_LOG_EVENT(			USB_USBD_WV_INIT_EXIT,			"usbdInit() Failed: Cannot create gHCDriverListLock.\n",			USB_USBD_WV_FILTER);        OS_LOG_MESSAGE_HIGH(            USBD,            "usbdInit() Failed: Cannot create gHCDriverListLock.\n",            0,            0,            0,            0);        /* Destroy the created lock */        OS_DESTROY_EVENT (gDeviceDriverListLock);        /* Capture the lock  variable */        OS_LOCKED_DECREMENT(guUSBDInited);                return USBHST_FAILURE;        }    /* Initialize the hub operations to NULL */    gpHubFunctionList = NULL;		/* WindView Instrumentation */		USB_USBD_LOG_EVENT(			USB_USBD_WV_INIT_EXIT,			"usbdInit() exits successfully.\n",			USB_USBD_WV_FILTER);    OS_LOG_MESSAGE_LOW(USBD, "Exiting USBD_Init() Function.\n",0,0,0,0);    return USBHST_SUCCESS;    } /* End of function usbdInit() *//***************************************************************************** usbdExit - exits USBD2.0** This routine frees up memory allocated for the USBD2.0 layer and should * only be called when bringing the USB2.0 stack down.** RETURNS: USBHST_SUCCESS, USBHST_FAILURE if bus count is not zero** ERRNO: None*/USBHST_STATUS usbdExit(void)    {    /* Local variable for loop count */    UINT8   uIndex = 0;    OS_LOG_MESSAGE_LOW(USBD, "Entering usbdExit() Function.\n",0,0,0,0);        /* Check if USBD is alreadey inited */    if ( 1 != guUSBDInited)        {		/* WindView Instrumentation */		USB_USBD_LOG_EVENT(			USB_USBD_WV_INIT_EXIT,			"usbdExit() Error : USBD  has not been initialized.\n",			USB_USBD_WV_FILTER);        OS_LOG_MESSAGE_HIGH(USBD, "USBD  has not been initialized.\n",0,0,0,0);                 return USBHST_FAILURE;        } /* END if USBD is alreadey inited */        /*      * Increment the g_uUSBDInited to make it 2      * to block both USBD_Init() and USBD_Exit()      */    OS_LOCKED_INCREMENT(guUSBDInited);    /*     * If uFunctionalCount for any entry in gUSBBusInfoList is Non-Zero return     * USBHST_FAILURE     */    for (uIndex = 0; uIndex < USBD_MAX_HCD_NUM; uIndex++)        {        if (0 != gHCDriverList[uIndex].uNumberOfBus)            {		/* WindView Instrumentation */		USB_USBD_LOG_EVENT(			USB_USBD_WV_INIT_EXIT,			"usbdExit():Failed Bus count is not zero.\n",			USB_USBD_WV_FILTER);            OS_LOG_MESSAGE_HIGH(USBD,                                "usbdExit():Failed Bus count is not zero.\n",                                0,                                0,                                0,                                0);            return USBHST_FAILURE;            }        }    /*     * If gDeviceDriverList is not NULL then release the memory     * allocated for each entry in gDeviceDriverList.     */    while (NULL != gpDeviceDriverList)        {        /* To store the driver list node information */        pUSBD_DEVICE_DRIVER_LIST     pDeviceDriverNode;        /* Store the current driver list node in pDeviceDriverNode */        pDeviceDriverNode = gpDeviceDriverList;        /* Get the next driver in the list */        gpDeviceDriverList = gpDeviceDriverList->pNextDriver;        /* Free the memory allocated for single driver */        OS_FREE(pDeviceDriverNode);        }    /* Destroy the device driver list lock */    OS_DESTROY_EVENT(gDeviceDriverListLock);    /* Destroy the HC driver list lock */    OS_DESTROY_EVENT(gHCDriverListLock);

⌨️ 快捷键说明

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