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

📄 syswlanendarm.c

📁 vworks 下wlan的实现代码
💻 C
📖 第 1 页 / 共 3 页
字号:
/* sysWlanEndArm.c - system configuration module for Wlan END device */ /* Copyright 2003 Wind River Systems, Inc. */ /*modification history--------------------01c,23may03,ss  Modified sysCfgParamGet to not use strlen for WEP keys01b,13may03,dxb  Changed sysPrismEndLoad to sysWlanEndPrismLoad.01a,17apr03,rfm  Ported to Arm from ms7751se_le SH4 example*//* INCLUDES  */#include <vxWorks.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <end.h>#include <intLib.h>#include <iv.h>#include <sysLib.h>#include "config.h"#include "configWlan.h"#include <drv/pci/pciIntLib.h> #include <drv/pci/pciConfigLib.h> #include <wrn/wlan/wlanEnd.h>#ifdef INCLUDE_WLAN_ENDchar * wlanStaVersion = WLAN_STA_VERSION;/*************************************************************************** * DEFINES **************************************************************************//* 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   0 #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) */    UINT32         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;#endifIMPORT void pciAssignResources (int bus, int slot, int func);IMPORT STATUS pciIntConnect (VOIDFUNCPTR *vector, VOIDFUNCPTR routine,                              int parameter);IMPORT STATUS pciIntDisconnect (VOIDFUNCPTR *vector, VOIDFUNCPTR routine);#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;    /* check if the END load routine func ptr. is set */    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);                /* 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);        

⌨️ 快捷键说明

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