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

📄 syswlanendmips.c

📁 vworks 下wlan的实现代码
💻 C
📖 第 1 页 / 共 3 页
字号:
                /* 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) pAironetLoad) (paramStr, pBSP))              == (END_OBJ *) ERROR )            {            printf ("Error:  device failed sysWlanEndAironetLoad routine.\n");            }        }    return (pEnd);    }#endif/****************************************************************************** sysWlanPciInit - prepare PCI adapter for WLAN initialization** This routine finds all PCI devices, maps and enables the Memory and IO* address space.** RETURNS: OK or ERROR on fail** NOMANUAL*/STATUS sysWlanPciInit(void)    {    INT32       pciBus;             /* pci bus number */    INT32       pciDevice;          /* pci device number */    INT32       pciFunc;            /* pci function number */    UINT16      unit;               /* card from resource table */    UINT16      instance;           /* instance of card type */    UINT32      i = 0;              /* num of cards found */        /* try to find the occurrence of the network card (from resource table) */        for (unit = 0; unit < NELEMENTS(sysWlanBrds); unit++)         {                for (instance = 0; instance < MAX_DEVICES; instance++)             {            if (pciFindDevice(sysWlanBrds[unit].vendorId,                              sysWlanBrds[unit].deviceId,                              instance,                               &pciBus,                               &pciDevice,                               &pciFunc) == OK)                {                /* Save the device's PCI bus, device, and function numbers */                bridge[i].pciBus    = pciBus;                bridge[i].pciDevice = pciDevice;                bridge[i].pciFunc   = pciFunc;                                /* Save the card type */                bridge[i].phyType = sysWlanBrds[unit].phyCardType;                                if (sysWlanBrds[unit].vendorId == CISCO_BRIDGE_VENDORID)                    {                    /* This is a Cisco card */                    bridge[i].type = CARD_TYPE_CISCO;                    }                else                    {                    /* This is an Intersil Prism compatible card */                    bridge[i].type = CARD_TYPE_PRISM;                    }                                /* Mark the resource as not used */                bridge[i].used = FALSE;                                if (sysWlanPciBarGet((void *) &bridge[i]) == ERROR)                     {                    /* Mark the resource as non-valid */                    bridge[i].used = NON_VALID;                    return (ERROR);                    }                                                 /* Save the IRQ number */                pciConfigInByte (bridge[i].pciBus,                                  bridge[i].pciDevice,                                  bridge[i].pciFunc,                                 PCI_CFG_DEV_INT_LINE,                                  (UINT8 *) &bridge[i].irqLevel);                bridge[i].irqLevel = SWAP_ENDIAN_32(bridge[i].irqLevel);                                bridge[i].irqVector  = (bridge[i].irqLevel + EXT_INTERRUPT_BASE);                                /* Mask off the BARs to obtain the true base address */                  bridge[i].iobaseCsr &= PCI_IOBASE_MASK;                bridge[i].membaseCsr &= PCI_MEMBASE_MASK;                                /* enable pci access */                bridge[i].iobaseCsr |= 0xA0000000;                bridge[i].membaseCsr |= 0xA0000000;                                                /* enable mapped memory and IO addresses */                pciConfigOutWord (bridge[i].pciBus,                                   bridge[i].pciDevice,                                   bridge[i].pciFunc,                                  PCI_CFG_COMMAND,                                   PCI_CMD_IO_ENABLE |                                  PCI_CMD_MEM_ENABLE |                                   PCI_CMD_MASTER_ENABLE);                                /* disable sleep mode */                                pciConfigOutWord (bridge[i].pciBus,                                   bridge[i].pciDevice,                                   bridge[i].pciFunc,                                   PCI_CFG_MODE,                                   SLEEP_MODE_DIS);                                i++;                }            else                 {                break;                }            }        }        numBridges = i;    return (OK);     }/****************************************************************************** sysWlanPciBarGet - Reads/Saves the implemented BAR's for a given device** For a given device (as represented by it's Bus/Device/Function values), all * BAR's are read and the determination made as to whether they are implemented* or not.  Any implemented BAR is saved in the device struct in the appropriate* position (for an IO address or Memory Mapped address).  ** NOTE: If multiple BAR's of the same type are implemented, only the last BAR * value is stored.** RETURNS: OK or ERROR on failure** NOMANUAL*/LOCAL STATUS sysWlanPciBarGet    (    WLAN_PCI_RSRC * pDevice    )    {    UINT16 tmpCmdReg = 0;    UINT32 tmpBarReg = 0;    UINT32 origBarReg = 0;    UINT16 currentBarOffset = 0;    UINT32 i = 0;        /* Disable memory mode accesses while setting up Bar */    pciConfigInWord (pDevice->pciBus, pDevice->pciDevice, pDevice->pciFunc,                     PCI_CFG_COMMAND, &tmpCmdReg);        pciConfigOutWord (pDevice->pciBus, pDevice->pciDevice, pDevice->pciFunc,                      PCI_CFG_COMMAND, (tmpCmdReg & (~PCI_CMD_MEM_ENABLE)));        /* Examine each BAR...*/    for (i = 0; i < MAX_BARS; i++)         {        currentBarOffset = PCI_CFG_BASE_ADDRESS_0 + (i * sizeof(UINT32));        origBarReg = 0;        tmpBarReg = 0;                /* save the current BAR value */        pciConfigInLong(pDevice->pciBus, pDevice->pciDevice,                         pDevice->pciFunc,currentBarOffset, &origBarReg);                        /* check to see if current BAR is implemented by writing all          1's and reading back */                pciConfigOutLong (pDevice->pciBus,                           pDevice->pciDevice,                           pDevice->pciFunc,                          currentBarOffset,                          0xFFFFFFFF);                pciConfigInLong (pDevice->pciBus,                          pDevice->pciDevice,                          pDevice->pciFunc,                         currentBarOffset,                         &tmpBarReg);        if (tmpBarReg != 0)            {            /* re-write the original BAR value */            pciConfigOutLong (pDevice->pciBus, pDevice->pciDevice,                               pDevice->pciFunc, currentBarOffset,                              origBarReg);             /* save the BAR value in the appropriate field */            if ( (origBarReg & 0x1) == MEM_SPACE_REG)                 {                pDevice->membaseCsr = origBarReg;                }            else if ( (origBarReg & 0x1) == IO_SPACE_REG)                 {                pDevice->iobaseCsr = origBarReg;                }            }        }            /* re-enable PCI memory decode by the device */    pciConfigOutWord (pDevice->pciBus,                       pDevice->pciDevice,                       pDevice->pciFunc,                      PCI_CFG_COMMAND,                       tmpCmdReg);       return OK;    }/****************************************************************************** sysWlanPcmciaCardEnable - enable I/O access mode on the pccard ** RETURNS: OK or ERROR if pccaard I/O space not enabled** NOMANUAL*/STATUS sysWlanPcmciaCardEnable    (    UINT16 index     /* index of device in device array */    )    {    UINT32 tmp = 0;    WLAN_PCI_RSRC * pDev;    pDev = (WLAN_PCI_RSRC *) &bridge[index];        /* Enable IO space on card */        * (UINT8 *) ((int) pDev->membaseCsr + COR_OFFSET) = COR_RESET_VALUE;    tmp = * (UINT8 *) ((int) pDev->membaseCsr + COR_OFFSET);            if (tmp != COR_RESET_VALUE)         {        printf("sywWlanPcmciaCardEnable: Error enabling I/O space, "               "possibly no card present\n");        bridge[index].used = NON_VALID;        return (ERROR);        }      return (OK);    }    /****************************************************************************** sysWlanCardRsrcGet - Gets an already configured card resource ** RETURNS: index into resource table  or -1 if no resource available.  ** NOMANUAL*/INT32 sysWlanCardRsrcGet     (    INT32 cardType    /* Card type on the bus */    )    {    UINT32 i = 0;    /* Check for a valid card type */    if (cardType < 0)        {        printf ("sysWlanCardRsrcGet: Non-valid bridge requested\n");        return (-1);        }    /* Find a free resource from the list */    for (i = 0; i < numBridges; i++)        {        if ( (bridge[i].type == cardType) &&              (bridge[i].used != NON_VALID))            {            /* Is the resource available */            if (bridge[i].used == FALSE)                {                /* Mark as used and return */                bridge[i].used = TRUE;                /* Return the index into the resource table */                return (i);                }            }        }        /* resource not found so return -1 */    return (-1);    }/****************************************************************************** sysWlanCfgParamGet - Routine used to get default card config parameters.** RETURNS: ERROR on invalid command** NOMANUAL*/ STATUS sysWlanCfgParamGet    (    UINT32 cmd,    INT32  data    )    {    /* Sanity check */    if (data == (INT32) NULL)        {        return (ERROR);        }    /* Get the config parameter */    switch (cmd)        {        case WLAN_SSID:            (void) bcopy (WLAN_DEFAULT_SSID,                                 (char *) data,                                 strlen (WLAN_DEFAULT_SSID));            break;        case WLAN_STATION_NAME:            (void) bcopy (WLAN_DEFAULT_STATION_NAME,                                 (char *) data,                                 strlen (WLAN_DEFAULT_STATION_NAME));            break;        case WLAN_STATION_MODE:            * (UINT16 *) data = (UINT16) WLAN_DEFAULT_STATION_MODE;            break;        case WLAN_CHANNEL:            * (UINT16 *) data = (UINT16) WLAN_DEFAULT_CHANNEL;            break;        case WLAN_TX_RATE:            * (UINT16 *) data = (UINT16) WLAN_DEFAULT_TX_RATE;            break;        case WLAN_BRATES_ENABLE:            * (UINT16 *) data = (UINT16) WLAN_DEFAULT_BRATES_ENABLE;            break;        case WLAN_BRATES:            * (UINT16 *) data = (UINT16) WLAN_DEFAULT_BRATES;            break;        case WLAN_PMANAGE_ENABLE:            * (UINT16 *) data = (UINT16) WLAN_DEFAULT_PMANAGE_ENABLE;            break;        case WLAN_AUTH_TYPE:            * (UINT16 *) data = (UINT16) WLAN_DEFAULT_AUTH_TYPE;            break;        case WLAN_WEP_ENABLE:            * (UINT16 *) data = (UINT16) WLAN_DEFAULT_WEP_ENABLE;            break;        case WLAN_WEP_TYPE:            * (UINT16 *) data = (UINT16) WLAN_DEFAULT_WEP_TYPE;            break;        case WLAN_WEP_KEY0_64:            (void) bcopy (WLAN_DEFAULT_WEP_KEY0_64,                          (char *) data,                          DOT11_40_BIT_KEY_SIZE);                        break;        case WLAN_WEP_KEY1_64:            (void) bcopy (WLAN_DEFAULT_WEP_KEY1_64,                          (char *) data,                          DOT11_40_BIT_KEY_SIZE);            break;        case WLAN_WEP_KEY2_64:            (void) bcopy (WLAN_DEFAULT_WEP_KEY2_64,                          (char *) data,                          DOT11_40_BIT_KEY_SIZE);            break;        case WLAN_WEP_KEY3_64:            (void) bcopy (WLAN_DEFAULT_WEP_KEY3_64,                          (char *) data,                          DOT11_40_BIT_KEY_SIZE);            break;        case WLAN_WEP_KEY0_128:            (void) bcopy (WLAN_DEFAULT_WEP_KEY0_128,                          (char *) data,                          DOT11_128_BIT_KEY_SIZE);            break;        case WLAN_WEP_KEY_NUMBER:            * (UINT16 *) data = (UINT16) WLAN_DEFAULT_WEP_KEY_NUMBER;            break;        case WLAN_BYTE_ORDER:            * (UINT16 *) data = (UINT16) WLAN_DEFAULT_BYTE_ORDER;            break;        case WLAN_REGION:            * (UINT16 *) data = (UINT16) WLAN_DEFAULT_REGION;            break;        default:            return (ERROR);        }    return (OK);    }/****************************************************************************** sysWlanIOInByte - read an 8 bit value from specified device address ** RETURNS: 8 bit value from the specified device address** NOMANUAL

⌨️ 快捷键说明

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