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

📄 intprismhw.c

📁 vworks 下wlan的实现代码
💻 C
📖 第 1 页 / 共 5 页
字号:
            {            pMacAddr = NULL;            }        else             {            pMacAddr = (*pIntPrismSymMacAddrGet)();            }                        if (pMacAddr == NULL)             {            WLAN_DEBUG(DEBUG_ERROR,                       ("intPrismInit: Error getting Symbol card MAC addr\n"));            return ERROR;            }        else             {            ltvRecord.type = WLAN_RID_OWN_MAC_ADDRESS;            ltvRecord.length = 4;            ltvRecord.data[0] = pMacAddr[0];            ltvRecord.data[1] = pMacAddr[1];            ltvRecord.data[2] = pMacAddr[2];                        if (intPrismLTVWrite(pWlanDev, &ltvRecord) == ERROR)                {                WLAN_DEBUG(DEBUG_ERROR,                           ("intPrismInit: Error setting Symbol card MAC "                            "address\n"));                return ERROR;                }                    }        }            /* Get the MAC address */    ltvRecord.type = WLAN_RID_OWN_MAC_ADDRESS;    ltvRecord.length = 4;    intPrismLTVRead(pWlanDev, &ltvRecord);    bcopyswap((UINT8 *)ltvRecord.data, pWlanDev->MACAddr, WLAN_ENET_ADDR_LEN);    status = OK;        /* Set the card into infrastructure mode */    status = intPrismRIDWordWrite(pWlanDev, WLAN_RID_PORT_TYPE, WLAN_PORT_ESS);    /* The WaveLAN has a RID that allows you to enable or disable the creation    of IBSSs when the user specifies a BSS that's not currently available.  We    will turn it on, so we can create our own IBSSs */    if ((pWlanDev->cardType == WLAN_CARDTYPE_WAVELAN) ||        (pWlanDev->cardType == WLAN_CARDTYPE_3COM) )        {        status |= intPrismRIDWordWrite(pWlanDev, WVLAN_RID_CREATE_IBSS, 1);        status |= intPrismRIDWordWrite(pWlanDev, WLAN_RID_TICK_TIME,0 );        }    (void) sysWlanCfgParamGet (WLAN_BRATES_ENABLE, (INT32) &brateEnable);        if (brateEnable == TRUE)        {        (void) sysWlanCfgParamGet (WLAN_BRATES, (INT32) &brates);        }    /* For some stupid reason the intersil cards default to 1Mb/2Mb mode only.       We need to set it to use 11MBit/5.5Mbit/2Mbit/1Mbit mode.  */    if ( (pWlanDev->cardType == WLAN_CARDTYPE_INTERSIL_2) ||         (pWlanDev->cardType == WLAN_CARDTYPE_INTERSIL_2_5) ||         (pWlanDev->cardType == WLAN_CARDTYPE_INTERSIL_3))        {        if (brateEnable == TRUE)            {            status |= intPrismRIDWordWrite(pWlanDev, INTERSIL_RID_BASIC_RATES,                                            brates);            }        status |= intPrismRIDWordWrite(pWlanDev, WLAN_RID_TICK_TIME,0 );        }    /* 3COM cards are initialized pretty much the same as intersil cards */    if (pWlanDev->cardType == WLAN_CARDTYPE_3COM)        {        status |= intPrismRIDWordWrite(pWlanDev, WLAN_RID_TICK_TIME, 0);        }    if (pWlanDev->cardType != WLAN_CARDTYPE_WAVELAN)        {        (void) sysWlanCfgParamGet (WLAN_AUTH_TYPE, (INT32) &authType);            status |= intPrismIoctl((END_OBJ *)pWlanDev, EIOCSAUTHTYPE,                                 (caddr_t)(INT32)authType);           }    (void) sysWlanCfgParamGet (WLAN_TX_RATE, (INT32) &txRate);        status |= intPrismIoctl((END_OBJ *)pWlanDev, EIOCSTXRATE,                             (caddr_t)(INT32)txRate);        /* Set the maximum data length */    status |= intPrismRIDWordWrite(pWlanDev, WLAN_RID_MAX_DATALEN,                                   WLAN_MAX_PACKET);    /* Set the SSID to the default value */    status |= intPrismRIDStringWrite(pWlanDev, WLAN_RID_DESIRED_SSID,                                  pWlanDev->networkName);    status |= intPrismRIDStringWrite(pWlanDev,WLAN_RID_OWN_SSID,                                     pWlanDev->networkName);    /* Set the StationName to the default value */    status |= intPrismRIDStringWrite(pWlanDev, WLAN_RID_STATION_NAME,                                  pWlanDev->stationName);    if (status != OK)        {        WLAN_DEBUG(DEBUG_FATAL, ("intPrismInit: Error configuring card\n"));        return ERROR;        }   (void) sysWlanCfgParamGet (WLAN_PMANAGE_ENABLE, (INT32) &pwrMan);   if (pwrMan == WLAN_PMANAGE_ENABLED)       {       status |= intPrismIoctl((END_OBJ *)pWlanDev, EIOCSPWRMAN,                                (caddr_t)(INT32)pwrMan);       }    /* Get the station mode (IBSS or BSS) */    (void) sysWlanCfgParamGet (WLAN_STATION_MODE, (INT32) &opMode);    /* Check to see if we should enable IBSS mode by default.  If so, do it */    if (opMode == WLAN_IBSS_MODE)        {        (void) sysWlanCfgParamGet (WLAN_CHANNEL, (INT32) &channel);        status |= intPrismIoctl((END_OBJ *)pWlanDev, EIOCSCHANNEL,                                 (caddr_t)(INT32)channel);                if (intPrismIoctl((END_OBJ *)pWlanDev, EIOCSIBSSMODE,                       (caddr_t)TRUE) != OK)            {            WLAN_DEBUG(DEBUG_ERROR, ("intPrismInit: EIOCSIBSSMODE not "                                     "supported\n"));            }        }        /* Get the wep type (40/64 or 104/128 bit) encryption */    (void) sysWlanCfgParamGet (WLAN_WEP_TYPE, (INT32) &wepType);    status |= intPrismIoctl((END_OBJ *)pWlanDev, EIOCSWEPTYPE,                             (caddr_t)(INT32)wepType);        /* Get the encryption mode */    (void) sysWlanCfgParamGet (WLAN_WEP_ENABLE, (INT32) &wepEnable);    /* Check to see if we need to enable security.  In some environments     this may be necessary to boot */    if (wepEnable == TRUE)        {        /* Make sure we support WEP */        if (intPrismIoctl((END_OBJ *)pWlanDev, EIOCGWEPAVAIL,                       (caddr_t)&wepAvail) != OK)            {            WLAN_DEBUG(DEBUG_ERROR, ("intPrismInit: IOCTL not supported\n"));            }                if (wepAvail == FALSE)            {            WLAN_DEBUG(DEBUG_ERROR,("intPrismInit: Security not supported\n"));            return ERROR;            }                status = OK;        /* OK.  Setup the default key and turn it on */                if (wepType == WLAN_WEP_TYPE_64)            {            for (i=0; i< WLAN_WEP_NUM_KEYS; i++)                {                sysWlanCfgParamGet(WLAN_WEP_KEY0_64 + i, (INT32)wepKey);                intPrismIoctl((END_OBJ *)pWlanDev, EIOCSWEPKEY0 + i,                               (caddr_t)wepKey);                }            }        else if (wepType == WLAN_WEP_TYPE_128)            {            sysWlanCfgParamGet(WLAN_WEP_KEY0_128, (INT32)wepKey);            intPrismIoctl((END_OBJ *)pWlanDev, EIOCSWEPKEY0, (caddr_t)wepKey);            }        else            {            WLAN_DEBUG(DEBUG_ERROR, ("intPrismInit: Bad wep type\n"));            status = ERROR;            }        /* Get the default wep key number */        (void) sysWlanCfgParamGet (WLAN_WEP_KEY_NUMBER, (INT32) &wepKeyNumber);        status |= intPrismIoctl((END_OBJ *)pWlanDev, EIOCSWEPDEFAULTKEY,                             (caddr_t)(INT32)wepKeyNumber);        status |= intPrismIoctl((END_OBJ *)pWlanDev, EIOCSWEP, (caddr_t)1);                /* Check to make sure that WEP was actually enabled */        status |= intPrismIoctl((END_OBJ *)pWlanDev, EIOCGWEPSTATUS,                             (caddr_t)&wepAvail);                if((wepAvail == FALSE) || (status != OK))            {            WLAN_DEBUG(DEBUG_ERROR, ("intPrismInit: Error - Security cannot "                                     "be enabled\n"));            return ERROR;            }        else            {            WLAN_DEBUG(DEBUG_ERROR, ("intPrismInit: Security Enabled!!!\n"));            }        if (pWlanDev->cardType == WLAN_CARDTYPE_3COM)            {            /* The 3COM card takes a little longer to come up, so we'll wait             for it. */            taskDelay(sysClkRateGet()/10); /* wait 100 msec */            }        }    /* Make sure interrupts are not enabled until we want it */    WLAN_OUT_16(WLAN_BASE_ADDR + WLAN_INT_EN, 0x0000);    /* Ask the card to allocate a buffer for us */    /* First, make sure another alloc is not is progress */    for (j=0; j<WLAN_MAX_TX_BUF; j++)        {        i = 0;        while((WLAN_IN_16(WLAN_BASE_ADDR + WLAN_EVENT_STAT) & WLAN_EV_ALLOC)!= 0)            {            if (i++ > WLAN_DEVICE_TIMEOUT)                {                WLAN_DEBUG(DEBUG_FATAL, ("Error allocating NIC Memory - stuck"                                         " ALLOC \n"));                WLAN_OUT_16(WLAN_BASE_ADDR + WLAN_EVENT_ACK, WLAN_EV_ALLOC);                return ERROR;                }            }                   if (intPrismCommand(pWlanDev, WLAN_CMD_ALLOC_MEM,                         WLAN_MAX_PACKET + sizeof(WLAN_FRAME),                         0, 0) == ERROR)            {            return ERROR;            }                i = 0;        while((WLAN_IN_16(WLAN_BASE_ADDR + WLAN_EVENT_STAT) &WLAN_EV_ALLOC) == 0)            {            if (i++ > (WLAN_DEVICE_TIMEOUT * 10) )                {                            WLAN_LOG(DEBUG_FATAL, ("Error Allocating NIC memory\n",                                       0,0,0,0,0,0));                return ERROR;                }            }        pWlanDev->txPool[j].fid = WLAN_IN_16(WLAN_BASE_ADDR + WLAN_ALLOC_FID);        WLAN_DEBUG(DEBUG_INFO, ("Allocated FID %04x\n",pWlanDev->txPool[j].fid));        /* ACK the alloc event */        WLAN_OUT_16(WLAN_BASE_ADDR + WLAN_EVENT_ACK, WLAN_EV_ALLOC);        }        WLAN_DEBUG(DEBUG_INFO,("intPrismInit: Card reset OK!\n"));        return OK;    }/****************************************************************************** intPrismReset - Resets the card** Disables interrupts, disables the card, re-enables the card , and then * re-enables interrupts.  This function should be called after modifying any* static RID to enable the new setting.  * * RETURNS : OK or ERROR if unable to correctly reset the card     ** ERRNO : N/A** SEE ALSO:*  PRISM Driver Programmer's Manual*/STATUS intPrismReset    (    WLAN_DEV *  pWlanDev             /* Pointer to device handle */    )    {    UINT16 status = OK;    if (pWlanDev == NULL)        {        WLAN_DEBUG(DEBUG_ERROR, ("intPrismReset: NULL pWlanDev\n"));         return ERROR;        }    /* Don't reset if card hasn't been initialized yet.  Return OK, since this    is not an error, just unnecessary (We might want to configure the card     before it's enabled, but just not reset it )*/    if (pWlanDev->cardStatus != WLAN_STATUS_UP)        {        WLAN_DEBUG(DEBUG_FLOOD, ("intPrismReset: Not resetting card since card"                                 " is not enabled\n"));        return OK;        }    status = intPrismCommand (pWlanDev, WLAN_CMD_DISABLE,0,0,0);       status |= intPrismCommand (pWlanDev, WLAN_CMD_ENABLE,0,0,0);        /* Check if the commands were run OK.  If not, try re-initializing the    card */    if (status != OK)        {        WLAN_DEBUG(DEBUG_INFO, ("intPrismReset: WARNING:Error resetting card,"                                 "will try re-initializing.\n"));        /* The INIT function will fail if the card is not in the disabled        state, so ensure that it is.  We don't care if this gives us an        error, since that would just mean the card was already disabled */        intPrismCommand (pWlanDev, WLAN_CMD_DISABLE,0,0,0);        if (intPrismInit(pWlanDev) == ERROR)            {            WLAN_DEBUG(DEBUG_INFO, ("intPrismReset: Error resetting card, "                                     "cannot recover\n"));            return ERROR;            }        else /* Well, there was an error but we recovered */            {            WLAN_DEBUG(DEBUG_INFO, ("intPrismReset: Error resetting card, "                                     "recovery successful!\n"));            }        }    return OK;    }/****************************************************************************** NOMANUAL* intPrismDiagnose - Runs the built in diagnostics on the card.            ** This command executes the built-in diagnostic program on the card, checking * for correct hardware functionality. Note that the card should have already * been initialized but must not be enabled for this function to succeed.** RETURNS: OK or ERROR if card failed the diagnostics** ERRNO: N/A** SEE ALSO: intPrismInit(), intPrismCommand()*/STATUS intPrismDiagnose    (    WLAN_DEV *pWlanDev   /* Pointer to the device handle for this card */    )    {    UINT16 result0;     /* Response from command */    UINT16 result1;     /* Response from command */     WLAN_DEBUG(DEBUG_INFO, ("intPrismDiagnose : Running card diagnostics\n"));        if(intPrismCommand(pWlanDev, WLAN_CMD_DIAG,                    DIAG_PAT_0, DIAG_PAT_1, 0) == ERROR)        {        WLAN_DEBUG(DEBUG_ERROR, ("intPrismDiagnose : Card diagnostics "                                 "FAILED!\n"));        return ERROR;        }    intPrismCommandResp(pWlanDev, &result0, &result1, NULL);        /*     After diagnostics, the 0 pattern should be in rep 1, and the 1 pattern    should be in resp 0     */    if ((result0 == DIAG_PAT_1) && (result1 == DIAG_PAT_0))        {        WLAN_DEBUG(DEBUG_INFO, ("intPrismDiagnose : Card diagnostics "                                "PASSED!\n"));

⌨️ 快捷键说明

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