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

📄 syswlanendpentium.c

📁 vworks 下wlan的实现代码
💻 C
📖 第 1 页 / 共 3 页
字号:
/* sysWlanEndPcPentium.c - system configuration module for Wlan END device */ /* Copyright 2001-2003 Wind River Systems, Inc. */ /*modification history--------------------02c,23may03,ss  changed sysCfgParamGet to use hardcoded WEP key lengths02b,13may03,dxb  Changed sysPrismEndLoad to sysWlanEndPrismLoad.02a,13may03,dxb  Added comments for intConnect routines.01z,06may03,rb  Removed warnings with diab01y,28apr03,ss  added STA version info01x,20sep02,dxb  Renamed to sysWlanEndPentium.c01w,30apr02,ss  removed references to sysPcmcia.h01v,23apr02,dxb  Updated INCLUDE_WLAN_END functionality.01u,22apr02,eja  Added code to switch terminal to com1 on bootup.01t,20apr02,ss  added endian safe in/out routines01s,18apr02,ss  Added wlanIoctl routine01r,16apr02,ss  Fixed bug in sysPrismEndLoad, using pBSP variable01q,10apr02,ss  Added support or LinkSys MiniPCI wlan card, made                 sysWlanPciInit generic01p,20mar02,dxb  Removed compiler warnings01o,06mar02,rb  Fixed error in WLAN_REGION01n,27feb02,rb  Fixed bug with WLAN_WEP_ENABLE01m,20feb02,rb  Added international support01l,19feb02,cjl  Converted PRINT_MSG to WLAN_DEBUG and used current debug                 methodology.01k,13feb02,dxb  Updated list of includes.01j,07feb02,dxb  Updated to include changes to wlanEnd.h.01i,05feb02,dxb  Updated to include changes from wlanEnd.h01h,04feb02,eja  Added sysWlanParamGet () to enable wlan driver to use Bsp                 defined config parameters.01g,23nov01,eja  Added more explicit comment if card not found in bridge.01f,22nov01,eja  Added dummy routine to pull in show routines.01e,15nov01,eja  Got rid of bsp routine table.01d,04oct01,ss   Removed LUCENT_BRIDGE_VENDORID from PCI bridge table01c,04oct01,ss   Modified to support multiple instances of wlan cards detected01b,25sep01,dxb  Removed references to EJA test code.01a,07sep01,eja  Converted file to unix format.*//*DESCRIPTIONThis is the WRS-supplied configuration module for the VxWorks Wlan END driver. */#include <vxWorks.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <end.h>#include <intLib.h>#include <iv.h>#include <vmLib.h>   #include <sysLib.h>#include <drv/pci/pciIntLib.h>#include <drv/pci/pciConfigLib.h>#include <wrn/wlan/wlanEnd.h>#include "config.h"#include "configWlan.h"#include <ioLib.h>#ifdef INCLUDE_WLAN_END/*************************************************************************** * DEFINES **************************************************************************/char * wlanStaVersion = WLAN_STA_VERSION;/* COM port redirect definition */#define COM2 "/tyCo/1"/* SUPPORTED BRIDGES and PCI cards: updates or new cards should be defined here   and in sysWlanBrds [] (further down in this file)*/#define LINKSYS_BRIDGE_VENDORID   (0x16AB)#define LINKSYS_BRIDGE_DEVICEID   (0x1102)#define LINKSYS_PCI_VENDORID   (0x1260) /* LinkSys WMP11 Mini-PCI */#define LINKSYS_PCI_DEVICEID   (0x3873) /* LinkSys WMP11 Mini-PCI */#define SMC_BRIDGE_VENDORID    (0x1638)#define SMC_BRIDGE_DEVICEID    (0x1100)#define CISCO_BRIDGE_VENDORID  (0x14B9)#define CISCO_BRIDGE_DEVICEID  (0x4800)/* the two supported chipsets (unique driver for each) */#define CARD_TYPE_PRISM 0   /* Intersil Prism based cards */#define CARD_TYPE_CISCO 1   /* Cisco Aironet cards *//* max num of PCI cards */#define MAX_DEVICES            (8)#define NON_VALID (-1)#define COR_OFFSET          (0x3E0) /* for PCMCIA */#define COR_RESET_VALUE     (0x41)#define MAX_BARS             (6)     /* max number of base address regs */#define MEM_SPACE_REG        (0)     /* bit 0 BAR value for memory space */#define IO_SPACE_REG         (1)     /* bit 0 BAR value for io space */#define EXT_INTERRUPT_BASE   INT_NUM_IRQ0#define PCI_DEV_MMU_MSK      (~(VM_PAGE_SIZE - 1))  /* Mask MMU page */#define PCI_DEV_ADRS_SIZE    VM_PAGE_SIZE           /* one page *//**************************************************************************** * Local variables ***************************************************************************//* a card is uniquely identified by this struct */typedef struct     {    UINT32      vendorId;           /* Vendor ID */    UINT32      deviceId;           /* Device ID */    UINT32      phyCardType;        /* WLAN_PCMCIA_CARD or WLAN_PCI_CARD,                                        as defined in wlanEnd.h */    } WLAN_BOARD_ID;/* the PCI resource info for a device */typedef struct     {    UINT32         iobaseCsr;      /* IO Base Address */    UINT32         membaseCsr;     /* MEM Base Address */    UINT32         irqLevel;       /* Interrupt Request Level */    UINT32         irqVector;      /* Interrupt Request vector */    UINT32         pciBus;         /* PCI Bus number */    UINT32         pciDevice;      /* PCI Device number */    UINT32         pciFunc;        /* PCI Function number */        UINT32         type;    /* type of card(CARD_TYPE_CISCO or CARD_TYPE_PRISM)*/    UINT8          phyType; /* the physical type of card                                (WLAN_PCI or WLAN_PCMCIA) */    INT8           used;    /* Flag to check if resource is taken */      } WLAN_PCI_RSRC;/* All Supported bridges/cards */LOCAL WLAN_BOARD_ID sysWlanBrds [] =    {        {LINKSYS_BRIDGE_VENDORID,LINKSYS_BRIDGE_DEVICEID,WLAN_PCMCIA_CARD},        {LINKSYS_PCI_VENDORID,   LINKSYS_PCI_DEVICEID,   WLAN_PCI_CARD},        {CISCO_BRIDGE_VENDORID,  CISCO_BRIDGE_DEVICEID,  WLAN_PCI_CARD},        {SMC_BRIDGE_VENDORID,    SMC_BRIDGE_DEVICEID,    WLAN_PCMCIA_CARD}    };LOCAL WLAN_PCI_RSRC bridge[MAX_DEVICES]; LOCAL UINT16 numBridges = 0;  /* num of pci cards found *//*************************************************************************** * Function declarations **************************************************************************/LOCAL STATUS sysWlanPciBarGet (WLAN_PCI_RSRC *);STATUS sysWlanPcmciaCardEnable (UINT16);INT32  sysWlanCardRsrcGet (INT32);STATUS sysWlanPciInit (void);STATUS sysWlanCfgParamGet (UINT32, INT32);void   sysWlanIntConnect    (INT32, INT32, INT32, STATUS *);void   sysWlanIntDisconnect (INT32, INT32, INT32, STATUS *);void   sysWlanIntEnable     (INT32, STATUS *);void   sysWlanIntDisable    (INT32, STATUS *);STATUS sysWlanPcmciaCfgShow (void);END_OBJ * sysWlanEndPrismLoad (char * initString, void * pBSP);END_OBJ * sysWlanEndAironetLoad (char * initString, void * pBSP);UINT8  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);/*************************************************************************** * External Function declarations **************************************************************************/IMPORT STATUS sysMmuMapAdd (void *, UINT, UINT, UINT);#ifdef INCLUDE_PRISM_END  IMPORT END_OBJ * intPrismLoad (char *, void *);  LOCAL  void *    pWlanLoad = (void *) intPrismLoad;#endif#ifdef INCLUDE_AIRONET_END  IMPORT END_OBJ * cisAironetEndLoad (char *, void *);   LOCAL  void *    pAironetLoad = (void *) cisAironetEndLoad;#endif#ifdef INCLUDE_PRISM_END/****************************************************************************** sysWlanEndPrismLoad - load an instance of the intPrism END driver** This routine loads the wlan intPrism 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. <baseAddr>:<vecnum>:<intLvl>** .IP <baseAddr>* Device register base address* .IP <vecNum>* Interrupt vector number* .IP <intLvl>* Interrupt level** RETURNS: pointer to END object or ERROR.* SEE ALSO: intPrismEndLoad()*/END_OBJ * sysWlanEndPrismLoad    (    char * initString,   /* Initial parameters to initialize device with */    void * pBSP              )    {    /*     * The End driver END_LOAD_STRING should be:     * "<baseAddr>:<intVec>:<intLevel>:<attachmentType>:<nRxFrames>"     *  Note that the unit number is prepended by mux.     */    char       paramStr [END_INIT_STR_MAX];   /* from end.h */    UINT32     baseAddr  = 0;             /* base addr for access to board reg */    UINT32     iVec     = 0;                  /* interrupt vector */    UINT32     iLevel   = 0;                  /* interrupt level */    END_OBJ *  pEnd     = NULL;    char *     cp       = NULL; 	    char *     token    = NULL;    UINT16     unitNum  = 0;     INT32      cardRsrc = -1;            if (pWlanLoad == NULL)        {        return (NULL);        }        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 = (END_OBJ *)((FUNCPTR) pWlanLoad) (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.         */            /* get the unit num from init string */        cp = strcpy (paramStr, initString);                 token = strtok(cp, ":");        if (token == NULL)             {            printf("sysWlanEndPrismLoad: Error determining unit num\n");            return NULL;            }                unitNum = atoi(token);        /* Get a resource for the card */        if ( (cardRsrc = sysWlanCardRsrcGet(CARD_TYPE_PRISM)) == -1)            {            printf ("sysWlanEndPrismLoad: Error getting card resource\n");            return (NULL);            }                        /* set the pBSP variable to hold the card type and type of            access memory access */        if (bridge[cardRsrc].phyType == WLAN_PCMCIA_CARD)             {            /* enable the pccard I/O space */            if (sysWlanPcmciaCardEnable(cardRsrc) == ERROR)                {                printf ("sysWlanEndPrismLoad: Error enabling card I/O space\n");                return (NULL);                }                        baseAddr = bridge[cardRsrc].iobaseCsr;                    pBSP = (void *) (WLAN_IO_ACCESS | WLAN_PCMCIA_CARD);                        }        else             {            baseAddr = bridge[cardRsrc].membaseCsr;                    pBSP = (void *) (WLAN_MEM_ACCESS | WLAN_PCI_CARD);            }                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 */                iVec = bridge[cardRsrc].irqVector;        iLevel = bridge[cardRsrc].irqLevel;                sprintf (cp, "%#x:%#x:%#x:%d:%d",                  baseAddr,                  iVec,                 iLevel,                  0,                  0);                if ( (pEnd = (END_OBJ *)((FUNCPTR) pWlanLoad) (paramStr, pBSP))              == (END_OBJ *) ERROR )            {            printf ("sysWlanEndPrismLoad: Error - device load routine failed.\n");            }        }    return (pEnd);    }#endif#ifdef INCLUDE_AIRONET_END/****************************************************************************** sysWlanEndAironetLoad - load an instance of the cisAir END driver** This routine loads the wlan cisAir 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.* <baseAddr>:<vecnum>:<intLvl>** .IP <baseAddr>* Device register base 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 cisAir device, this routine* should be changed.** RETURNS: pointer to END object or ERROR.** SEE ALSO: anetEndLoad()*/END_OBJ * sysWlanEndAironetLoad    (    char * initString,   /* Initial parameters to initialize device with */    void * pBSP          /* index into load routine table                */    )    {    /*     * The End driver END_LOAD_STRING should be:     * "<baseAddr>:<intVec>:<intLevel>:<attachmentType>:<nRxFrames>"     *  Note that the unit number is prepended by mux.     */    char       paramStr [END_INIT_STR_MAX]; /* from end.h */    UINT32     baseAddr    = 0;    /* base addr for access to board registers */    UINT32     iVec      = 0;                  /* interrupt vector */    UINT32     iLevel    = 0;                  /* interrupt level */    END_OBJ *  pEnd      = NULL;    char *     cp        = NULL; 	    char *     token     = NULL;    UINT16     unitNum   = 0;                     /* unit num from init string */    INT32      cardRsrc  = -1;    if (pAironetLoad == NULL)        {        return (NULL);        }        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 = (END_OBJ *)((FUNCPTR) pAironetLoad) (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.         */            /* get the unit num from init string */        cp = strcpy (paramStr, initString);                 token = strtok(cp, ":");        if (token == NULL)             {            printf("sysWlanEndAironetLoad: Error determining unit num\n");            return NULL;            }                unitNum = atoi(token);        /* Get a resource for the card */        if ( (cardRsrc = sysWlanCardRsrcGet(CARD_TYPE_CISCO)) == -1)            {            printf ("sysWlanEndAironetLoad: Error getting card resource\n");            return (NULL);            }                if (bridge[cardRsrc].phyType == WLAN_PCMCIA_CARD)            {            /* enable the pccard I/O space */            if (sysWlanPcmciaCardEnable(cardRsrc) == ERROR)                {                printf ("sysWlanEndAironetLoad: Error enabling card I/O space\n");                return (NULL);                }            }                /* save the base address and set the pBSP variable to hold the            card type and type of memory access */        baseAddr = bridge[cardRsrc].iobaseCsr;                pBSP = (void *) (WLAN_IO_ACCESS | WLAN_PCMCIA_CARD);                                        cp = strcpy (paramStr, initString); /* cp points to paramStr */        /* Now, we advance cp, by finding the end the string */        cp += strlen (paramStr);        

⌨️ 快捷键说明

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