usbpegasustest.c
来自「T2.0 USB driver.rar T2.0 USB driver.rar」· C语言 代码 · 共 220 行
C
220 行
/* usbPegasusTest.c - Test routines for the USB Pegasus Ethernet Driver *//* Copyright 1999-2001 Wind River Systems, Inc. *//*Modification history--------------------01b,10jun01,wef cleaned up01a,01may01,wef Created*//*DESCRIPTION This file contains test routines for use in testing the Pegasus USB Ethernetdriver. This code allows a Pegasus USB Network adapter to be used in a vxWorkssystem.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/usbPegasusEnd.h"#undef ETHER_MAP_IP_MULTICAST#include "etherMultiLib.h" /* multicast stuff. *//* defines */#ifdef INCLUDE_NT_ULIPextern int ntResolv ();#endif /* INCLUDE_NT_ULIP *//* locals */LOCAL END_OBJ* pEnd;/******************************************************************************** sysUsbEndPegasusLoad - 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.**/ END_OBJ * sysUsbPegasusEndLoad ( char * pParamStr, /* ptr to initialization parameter string */ void * unused /* unused optional argument */ ) { /* * The usbEnd driver END_LOAD_STRING should be: * "<vendorId>:<productId>:<noofRxbuffers>:<noofIRPs>" */ char paramStr [END_INIT_STR_MAX]; /* from end.h */ static char usbEndParam[] = "%d:%d:%d:%d"; END_OBJ * pEnd; 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. */ pEnd = usbPegasusEndLoad(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:\n", * pParamStr); sprintf (usbEndParam, "%d:%d:%d:%d\n", SOHOWARE_VENDOR_ID, SOHOWARE_PRODUCT_ID, PEGASUS_NO_IN_BFRS, PEGASUS_NO_OUT_IRPS); strcat(paramStr,usbEndParam); if ((pEnd = usbPegasusEndLoad (paramStr)) == (END_OBJ *)NULL) { logMsg ("Error: usb network device failed usbEndLoad routine.\n"); } } return (pEnd); }/* * 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 loadPegasus(int unitNum, USB_PEGASUS_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, sysUsbPegasusEndLoad, NULL, 1, NULL); if (pCookie == NULL) { logMsg ("muxDevLoad failed for PEGASUS device \n", 0, 0, 0, 0, 0, 0); return(ERROR); } else { if (muxDevStart(pCookie) == ERROR) { logMsg ("muxDevStart failed for Pegasus device \n", 0, 0, 0, 0, 0, 0); return(ERROR); } } return (OK);}/******************************************************************************** usbPegasusEndStart- TODO*** RETURNS: Nothing**/void usbPegasusEndStart ( int unitNum, /* unit number */ char * pAddrString, /* enet address */ int netmask /* netmask */ ) { char * pDevName ="usb"; /* Device name */ char * pTgtName= "kakisa"; /* Host Name */ M2_INTERFACETBL endM2Tbl; pEnd = endFindByName (pDevName, unitNum); if (pEnd == NULL) { logMsg ("SD..Could not find %s%d\n", pDevName, unitNum, 0, 0, 0, 0); return; } if (muxIoctl(pEnd, EIOCGMIB2, (caddr_t) &endM2Tbl) == ERROR) { logMsg ("SD..Cannot perform EIOCMIB2 ioctl.\n", 0, 0, 0, 0, 0, 0); return; } if (ipAttach(unitNum, pDevName) != OK) { logMsg ("SD..Failed to attach to device %s", pDevName, 0, 0, 0, 0, 0); return; } if (usrNetIfConfig (pDevName, unitNum, pAddrString, pTgtName, netmask) != OK) { logMsg ("SD..Failed to configure %s%d for IP.\n", pDevName, unitNum, 0, 0, 0, 0); return; } logMsg ("Attached TCP/IP interface to %s unit %d\n", pDevName, unitNum, 0, 0, 0, 0); }
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?