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

📄 syswlanendppc.c

📁 vworks 下wlan的实现代码
💻 C
📖 第 1 页 / 共 2 页
字号:
/* sysWlanEndPpc.c - system configuration module for Wlan END device */ /* Copyright 2001-2003 Wind River Systems, Inc. */ /*modification history--------------------01x,23may03,ss  modified sysCfgParamGet to not use strlen for WEP key sizes01w,13may03,dxb  Cleaned up comments.01v,13may03,dxb  Added comments for intConnect routines.01u,06may03,rb  Removed warnings under diab01t,28apr03,ss  added STA version info01s,26apr02,dxb  Added wlanIoctl() routine.01r,23apr02,dxb  Added #ifdef INCLUDE_SYM_CFCARD to symbol import routine.01q,17apr02,dxb  Updated with new byte macros.01p,20mar02,dxb  Removed sysWlanBcopy().01o,27feb02,rb  Fixed bug with WLAN_WEP_ENABLE01n,20feb02,rb  Added international support01m,15feb02,rb  Corrected endianness in sysWlanCfgParamerGet()01l,14feb02,ss  Added required extern for reference to Symbol CF Card init                 routine01k,13feb02,dxb  Removed reference to sysPcmcia.h.01j,11feb02,dxb  Updated for version 1.01.01i,04feb02,eja  Added sysWlanCfgParamGet () to enable driver to use Bsp level                 config parameters.01h,17jan02,ss  Include Symbol card support01g,26nov01,rb  Used proper prototype for cardPresent()01f,26nov01,rb  Check card presence before accessing01e,23nov01,rb  Now attempts to bring up both drivers, even though at most one                 will succeed01d,23nov01,rb   Added soft reset to sysWlanPccardEnable()01d,22nov01,eja  Added dummy routine include aironet show routines in image.01c,21nov01,cjl  Fix static/local merge error...01b,20nov01,rb   Added support for cisco example driver01b,15nov01,eja  Got rid of global bsp routine table.01a,13nov01,cjl  Changed wlanLoad to intPrismLoad*//*DESCRIPTIONThis is the WRS-supplied configuration module for the VxWorks Wlan (wln) END driver. *//* SYSTEM INCLUDES */#include <vxWorks.h>#include <vxLib.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <end.h>#include <intLib.h>#include <iv.h>#include <sysLib.h>#include <wrn/wlan/wlanEnd.h>#include "wrn/wlan/intPrismHw.h"/* END - SYSTEM INCLUDES */ char * wlanStaVersion = WLAN_STA_VERSION;/* LOCAL INCLUDES */#include "config.h"#include "configWlan.h"/* END - LOCAL INCLUDES */#ifdef INCLUDE_WLAN_END /* END INCLUDES *//* DATA TYPES  *//* END - DATA TYPES *//* DEFINES *//* Driver debug */#define SYS_WLAN_DEBUG/* This macro executes a printf if the debug level is   less than or equal to the given level */#ifdef SYS_WLAN_DEBUG#  define DBG_NONE   (5)#  define DBG_FATAL  (4)         #  define DBG_ERROR  (3)#  define DBG_INFO   (2)#  define DBG_FLOOD  (1)   INT32 sysWlanDebug = DBG_INFO;#  define PRINT_MSG(level, x) if (sysWlanDebug <= level) printf x#else#  define PRINT_MSG(level, x)#endif#define COR_OFFSET          (0x3E0)/* We'll use hardcoded values for the COR registers so that we don't need toparse the tuples. If a new driver is added, the value will need to be determined by parsing the tuples by hand.  The PC-Card Standard 7.0 by JEIDA is very helpful for this task */#define PRISM_COR_SETTING         (0x41)#define AIRONET_COR_SETTING         (0x45)#define EXT_INTERRUPT_BASE  0/* END - DEFINES *//* Global variable to determine if a card has already been brought up.  If so, we don't want to try another one, since the soft reset would kill theprevious driver.  Note that this scheme will need to be modified if a MBXboard with more than one PCMCIA socket is used (no known boards like this, but you never know) */BOOL cardInitialized = FALSE;/* EXTERNAL METHODS */#ifdef INCLUDE_PRISM_ENDIMPORT END_OBJ *intPrismLoad    (    char * initString,   /* Initial parameters to initialize device with */    void * pBSP          /* BSP specific pointer - unused in this driver */    );#endif#ifdef INCLUDE_AIRONET_ENDIMPORT END_OBJ *cisAironetEndLoad    (    char * initString,   /* Initial parameters to initialize device with */    void * pBSP          /* BSP specific pointer - unused in this driver */    );#endif#ifdef INCLUDE_SYM_CFCARD/* Symbol CF Card init routines */IMPORT STATUS intPrismSymDownload(WLAN_DEV *);IMPORT UINT16 * intPrismSymMacAddrGet(void);/* function ptr's to Symbol CF card routines that are required by intPrismHw.c   in order to initialize a Symbol CF Card.  These function ptr's are set in    this manner to allow the intPrism driver to build without any unnecessary   dependencies on Symbol only modules*/IMPORT STATUS   (* pIntPrismSymDownload)   (WLAN_DEV *);IMPORT UINT16 * (* pIntPrismSymMacAddrGet) (void);#endif /* INCLUDE_SYM_CFCARD *//* Used to get microsecond resolution delays */IMPORT void		sysMsDelay ( UINT );IMPORT BOOL        cardPresent(int);/* END - EXTERNAL METHODS *//* LOCAL METHODS */LOCAL STATUS sysWlanPccardEnable    (INT32, UINT8 *,                                     UINT16,UINT32 *,                                     UINT32 *,UINT32 *, UINT16);/* END - LOCAL METHODS *//* PUBLIC METHODS */#ifdef INCLUDE_PRISM_ENDEND_OBJ * sysWlanEndPrismLoad    (char *, void *);#endif#ifdef INCLUDE_AIRONET_ENDEND_OBJ * sysWlanEndAironetLoad    (char *, void *);#endifUINT8  sysWlanIOInByte        (UINT32);void   sysWlanIOOutByte       (UINT32, UINT8);UINT16 sysWlanIOInWord        (UINT32);void   sysWlanIOOutWord       (UINT32, UINT16);UINT32 sysWlanIOInLong        (UINT32);void   sysWlanIOOutLong       (UINT32, UINT32);UINT8  sysWlanMemInByte        (UINT32);void   sysWlanMemOutByte       (UINT32, UINT8);UINT16 sysWlanMemInWord        (UINT32);void   sysWlanMemOutWord       (UINT32, UINT16);UINT32 sysWlanMemInLong        (UINT32);void   sysWlanMemOutLong       (UINT32, UINT32);UINT16 sysWlanMemEndianInWord  (UINT32);void   sysWlanMemEndianOutWord (UINT32, UINT16);UINT16 sysWlanIOEndianInWord   (UINT32);void   sysWlanIOEndianOutWord  (UINT32, UINT16);void   sysWlanIntConnect    (INT32, INT32,                              INT32, STATUS *);void   sysWlanIntDisconnect (INT32, INT32,                              INT32, STATUS *);void   sysWlanIntEnable     (INT32, STATUS *);void   sysWlanIntDisable    (INT32, STATUS *);STATUS sysWlanCfgParamGet   (UINT32, INT32);/* END - PUBLIC METHODS */#ifdef INCLUDE_PRISM_END/****************************************************************************** sysWlanEndPrismLoad - load an instance of the wlan END driver for Intersil *                       Prism based cards** This routine loads the driver with the parameters specified * by the resource table for the device, and some default values.** The END device load string formed by this routine is in the following* following format.* <devIoAddr>:<vecnum>:<intLvl>** .IP <devIoAddr>* Device register base IO address* .IP <vecNum>* Interrupt vector number.* .IP <intLvl>* Interrupt level.** This routine only loads and initializes instance zero of the device.* If the user wishes to use more than one wlan devices, this routine* should be changed.** RETURNS: pointer to END object or ERROR.** SEE ALSO: wlanEndLoad()*/END_OBJ * sysWlanEndPrismLoad    (    char * initString,   /* Initial parameters to initialize device with */    void * pBSP          /* BSP specific pointer - unused in this driver */    )    {    /*     * The End driver END_LOAD_STRING should be:     * "<ioBase>:<intVec>:<intLevel>"     *  Note that the unit number is prepended by mux.     */    char       paramStr [END_INIT_STR_MAX]; /* from end.h */    UINT32     ioBase = 0;                  /* base I/O port of this board */    UINT32     iVec   = 0;                  /* interrupt vector */    UINT32     iLevel = 0;                  /* interrupt level */    END_OBJ *  pEnd   = NULL;    char *     cp     = NULL; 	    LOCAL char wlanParamTemplate [] = "%#x:%#x:%#x:%d:%d";    /* set access type to memory-mapped PCMCIA card - the only       option available for the mbx860 */    pBSP = (void *) (WLAN_MEM_ACCESS | WLAN_PCMCIA_CARD);    if (strlen (initString) == 0)        {#ifdef INCLUDE_SYM_CFCARD        /* set the function ptr for the Symbol init routines */        pIntPrismSymDownload = intPrismSymDownload;        pIntPrismSymMacAddrGet = intPrismSymMacAddrGet;#endif /* INCLUDE_SYM_CFCARD */        /*          * muxDevLoad() calls us twice.  If the string is         * zero length, then this is the first time through         * this routine, so we just return.         */        pEnd = intPrismLoad (initString, pBSP);        }    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.         */        /* Check to see if a card has already been initialized.  If so, we        don't want to knock it out, so return NULL*/        if (cardInitialized)            {            printf("Card already initialized!\n");            return NULL;            }        /* We don't want to access the card if it's not there */        if (!cardPresent(0))            {            return NULL;            }        /* enable the pccard I/O space */        if (sysWlanPccardEnable (0,NULL,0,&ioBase,&iVec,&iLevel,                                  PRISM_COR_SETTING)            == ERROR)            {            printf (" sysWlanEndLoad: Error enabling pcmcia space\n");            return (NULL);            }                    cp = strcpy (paramStr, initString); /* cp points to paramStr */        /* Now, we advance cp, by finding the end the string */        cp += strlen (paramStr);                /* finish off the initialization parameter string */        sprintf (cp, wlanParamTemplate,                  ioBase,                  iVec,                 iLevel,                  0,                  0);        if ((pEnd = intPrismLoad (paramStr, pBSP)) == (END_OBJ *)NULL)            {            printf("sysWlanEndPrismLoad: Error initializing device or device"                   " not present\n");            }        else            {            cardInitialized = TRUE;            }        }    return (pEnd);    }#endif /* INCLUDE_PRISM_END */#ifdef INCLUDE_AIRONET_END/****************************************************************************** sysWlanEndAironetLoad - load an instance of the wlan END driver for Cisco*                       Aironet based cards** This routine loads the driver with the parameters specified * by the resource table for the device, and some default values.** The END device load string formed by this routine is in the following* following format.* <devIoAddr>:<vecnum>:<intLvl>** .IP <devIoAddr>* Device register base IO address* .IP <vecNum>* Interrupt vector number.* .IP <intLvl>* Interrupt level.** This routine only loads and initializes instance zero of the device.* If the user wishes to use more than one wlan devices, this routine* should be changed.** RETURNS: pointer to END object or ERROR.** SEE ALSO: wlanEndLoad()*/END_OBJ * sysWlanEndAironetLoad    (    char * initString,   /* Initial parameters to initialize device with */    void * pBSP          /* BSP specific pointer - unused in this driver */    )    {    /*     * The End driver END_LOAD_STRING should be:     * "<ioBase>:<intVec>:<intLevel>"     *  Note that the unit number is prepended by mux.     */    char       paramStr [END_INIT_STR_MAX]; /* from end.h */    UINT32     ioBase = 0;                  /* base I/O port of this board */    UINT32     iVec   = 0;                  /* interrupt vector */    UINT32     iLevel = 0;                  /* interrupt level */    END_OBJ *  pEnd   = NULL;    char *     cp     = NULL; 	    char wlanParamTemplate [] = "%#x:%#x:%#x:%d:%d";    /* set access type to memory-mapped PCMCIA card - the only       option available for the mbx860 */    pBSP = (void *) (WLAN_MEM_ACCESS | WLAN_PCMCIA_CARD);    if (strlen (initString) == 0)        {        /*          * muxDevLoad() calls us twice.  If the string is         * zero length, then this is the first time through         * this routine, so we just return.         */        pEnd = cisAironetEndLoad (initString, pBSP);        }    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.         */        /* Check to see if a card has already been initialized.  If so, we        don't want to knock it out, so return NULL*/        if (cardInitialized)            {            return NULL;            }        /* We don't want to access the card if it's not there */        if (!cardPresent(0))            {            return NULL;            }                /* enable the pccard I/O space */        if (sysWlanPccardEnable (0,NULL,0,&ioBase,&iVec,&iLevel,                                  AIRONET_COR_SETTING)            == ERROR)            {            printf (" sysWlanEndLoad: Error enabling pcmcia space\n");            return (NULL);            }                    cp = strcpy (paramStr, initString); /* cp points to paramStr */        /* Now, we advance cp, by finding the end the string */        cp += strlen (paramStr);                /* finish off the initialization parameter string */        sprintf (cp, wlanParamTemplate,                  ioBase,                  iVec,                 iLevel,                  0,                  0);        if ((pEnd = cisAironetEndLoad (paramStr, pBSP)) == (END_OBJ *)NULL)            {            printf("sysWlanEndAironetLoad: Error initializing device or "                   "device not present\n");            }        else            {            cardInitialized = TRUE;            }        }    return (pEnd);    }#endif /*INCLUDE_AIRONET_END*//****************************************************************************** sysWlanMemInByte - read an 8 bit value from specified device address ** RETURNS: 8 bit value form the specified device address** NOMANUAL*/UINT8 sysWlanMemInByte    (    UINT32 addr    )    {    return (* (volatile UINT8 *) addr);    }/****************************************************************************** sysWlanMemOutByte - write an 8 bit value to specified device address** RETURNS: N/A** NOMANUAL*/void sysWlanMemOutByte    (    UINT32 addr,    UINT8  data    )    {    * (volatile UINT8 *) addr = data;    }/****************************************************************************** sysWlanMemInWord - read a 16 bit value from the specified device address ** RETURNS: 16 bit value from the specified device address.** NOMANUAL*/UINT16 sysWlanMemInWord    (    UINT32 addr    )    {    UINT16 localData = 0;    UINT16 data = 0;        data = * (volatile UINT16 *) addr;    localData = WLAN_SWAP_ENDIAN_16 (data);    return (localData);    }/****************************************************************************** sysWlanMemOutWord - write a 16 bit value to specified device address** RETURNS: N/A** NOMANUAL*/void sysWlanMemOutWord    (    UINT32 addr,    UINT16 data    )    {    UINT16 localData = 0;         localData = WLAN_SWAP_ENDIAN_16 (data);    * (volatile UINT16 *) addr = localData;    }/****************************************************************************** sysWlanMemInLong - read a 32 bit value form the specified device address  ** RETURNS: 32 bit value from the specified device address.** NOMANUAL*/

⌨️ 快捷键说明

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