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

📄 usbklsitest.c

📁 T2.0 USB driver.rar T2.0 USB driver.rar
💻 C
字号:
/* usbKlsiTest.c - Test routines for the USB Klsi Ethernet Driver *//* Copyright 1999-2001 Wind River Systems, Inc. *//*Modification history--------------------01b,01jun01,wef	removed component parameter names01a,01may01,wef	Created*//*DESCRIPTIONThis file contains test routines for use in testing the KLSI USB Ethernetdriver.  This code allows a KLSI USB Network adapter to be used in a vxWorks system. For more information refer to the .I "vxWorks Network Programmer's Guide",.I "Writing and Enhanced Network Driver" and.I "USB Developer's Kit User's Guide"*//* includes */#include "drv/usb/usbKlsiEnd.h"#undef	ETHER_MAP_IP_MULTICAST#include "etherMultiLib.h"		/* multicast stuff. *//* defines */#define PRODUCT_ID		NETGEAR_PRODUCT_ID#define VENDOR_ID		NETGEAR_VENDOR_ID#define KLSI_NO_IN_BFRS         40              /* No of Input Buffers */#define KLSI_NO_OUT_IRPS	20		/* No of IRPs submitted */#undef	ETHER_MAP_IP_MULTICAST#ifdef INCLUDE_NT_ULIPextern int ntResolv ();#endif /* INCLUDE_NT_ULIP *//* locals */LOCAL END_OBJ*   	pKlsiEndDev;/******************************************************************************** sysUsbKlsiEndLoad - load (create) USB END device** This routine loads the usb end device with initial parameters specified by* values given in the BSP configuration files (config.h).** RETURNS: pointer to END object or ERROR.** SEE ALSO: usbEndLoad()*/    /*     * The usbEnd driver END_LOAD_STRING should be:     * "<vendorId>:<productId>:<noofRxbuffers>:<noofIRPs>"     * Note that unit string is prepended by the mux, so we      * don't put it here.      * <noofRxbuffers> are the no of input buffers should get allocated     * <noofIRPs> are the no of IRP s should be created     */END_OBJ * sysUsbKlsiEndLoad    (    char * pParamStr,   /* ptr to initialization parameter string */    void * unused       /* unused optional argument */    )    {    char paramStr [END_INIT_STR_MAX];   /* from end.h */	    static char usbEndParam[] = "%d:%d:%d:%d:";			    if (strlen (pParamStr) == 0)        {        /*          * muxDevLoad() calls us twice.  If the string is         * zero length, then this is the first time through         * this routine, so we just return the device name.         */	pKlsiEndDev = klsiEndLoad(pParamStr);        }    else	{        /*         * On the second pass though here, we actually create          * the initialization parameter string on the fly.            * Note that we will be handed our unit number on the          * second pass through and we need to preserve that information.         * So we use the unit number handed from the input string.         */		sprintf (paramStr,"%c:", * pParamStr);	 	sprintf (usbEndParam,		"%d:%d:%d:%d", 		VENDOR_ID,		PRODUCT_ID,		KLSI_NO_IN_BFRS,		KLSI_NO_OUT_IRPS);        strcat(paramStr,usbEndParam);        if ((pKlsiEndDev = klsiEndLoad (paramStr )) == (END_OBJ *)NULL)	    {            logMsg("Error: usb network device failed klsiEndLoad routine.\n",		 0, 0, 0, 0, 0, 0);	    }	}    return (pKlsiEndDev);    }void usbKlsiEndStart	(     int       unitNum,	         	/* unit number */    char *    pAddrString,         	/* enet address */    int       netmask		        /* netmask */    )    {    char *    pDevName ="usb";	        	/* Device name */    char *    pTgtName= "host";        	/* Host Name */    char *    pNetRoute  = "90.0.0.3";	/* netroute   */    M2_INTERFACETBL endM2Tbl;    pKlsiEndDev = endFindByName (pDevName, unitNum);    if (pKlsiEndDev == NULL)	{	printf ("SD..Could not find %s%d\n", pDevName, unitNum);	return;        }    if (muxIoctl(pKlsiEndDev, EIOCGMIB2, (caddr_t) &endM2Tbl) == ERROR)	{	printf ("SD..Cannot perform EIOCMIB2 ioctl.\n");	return;        }    if (ipAttach(unitNum, pDevName) != OK)	{	printf ("SD..Failed to attach to device %s", pDevName);	return;	}    if (usrNetIfConfig (pDevName, 			unitNum, 			pAddrString, 			pTgtName, 			netmask) != OK)        {        printf ("SD..Failed to configure %s%d for IP.\n", pDevName, unitNum);        return;        }        printf ("Attached TCP/IP interface to %s unit %d\n", pDevName, unitNum);    }/* * This function is taken from usrEndLibInit() and modified suitably to load  * the end driver when USB Ethernet device is dynamically attached or detached.  * Its basically a sample fuction in the way which user should follow the to  * load Klsi device dynamically. *  */STATUS loadKlsi (int unitNum, USB_KLSI_DEV * pDev)    {        END_OBJ*      pCookie = NULL;    	    /* Add our default address resolution functions. */#ifdef INCLUDE_NT_ULIP    muxAddrResFuncAdd (M2_ifType_ethernet_csmacd, 0x800, ntResolv);#else    muxAddrResFuncAdd (M2_ifType_ethernet_csmacd, 0x800, arpresolve);#endif    pCookie = (END_OBJ *) muxDevLoad(unitNum, 			  sysUsbKlsiEndLoad, 			  NULL,			  1,			  NULL);    if (pCookie == NULL)        {        printf("muxDevLoad failed for KLSI device \n");        return(ERROR);	         }    else        {        if (muxDevStart(pCookie) == ERROR)       	    {            printf("muxDevStart failed for KLSI device \n");	    return(ERROR);	            }        }    return (OK);    }

⌨️ 快捷键说明

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