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

📄 mconfig.c

📁 Atheros AP Test with Agilent N4010A source code
💻 C
📖 第 1 页 / 共 5 页
字号:
    gLibInfo.pLibDevArray[devNum]->mem.pIndexBlocks = NULL;
    gLibInfo.pLibDevArray[devNum]->mem.pAllocMap = NULL;

    // Assign to the MDK Memory Map
    pLibDev->mem.pAllocMap = pExtAllocMap;
    pLibDev->mem.pIndexBlocks = pExtIndexBlocks;
    pLibDev->mem.usingExternalMemory = TRUE;
}

MANLIB_API A_UINT16 getDevIndex
(
    A_UINT32 devNum
)
{
    if (gLibInfo.pLibDevArray[devNum] == NULL) {
        mError(devNum, EINVAL, "Device Number %d:getDevIndex \n", devNum);
        return (A_UINT16)-1;
    }

    return gLibInfo.pLibDevArray[devNum]->devMap.devIndex;
}
/**************************************************************************
* closeDevice - Free all structures associated with this device
*
*/
MANLIB_API void closeDevice
(
    A_UINT32 devNum
) 
{
//      FIELD_VALUES *pFieldValues;

    if(gLibInfo.pLibDevArray[devNum] == NULL) {
        mError(devNum, EINVAL, "Device Number %d:closeDevice\n", devNum);
        return;
    }
    if(gLibInfo.pLibDevArray[devNum]->mem.usingExternalMemory == FALSE) {
        if(gLibInfo.pLibDevArray[devNum]->mem.pIndexBlocks) {
            free(gLibInfo.pLibDevArray[devNum]->mem.pIndexBlocks);
            gLibInfo.pLibDevArray[devNum]->mem.pIndexBlocks = NULL;
        }
        if (gLibInfo.pLibDevArray[devNum]->mem.pAllocMap) {
            free(gLibInfo.pLibDevArray[devNum]->mem.pAllocMap);
            gLibInfo.pLibDevArray[devNum]->mem.pAllocMap = NULL;
        }
    }

    if(gLibInfo.pLibDevArray[devNum]->eepData.infoValid) {
        freeEepStructs(devNum);
        gLibInfo.pLibDevArray[devNum]->eepData.infoValid = FALSE;
    }

    
    if (gLibInfo.pLibDevArray[devNum]->regArray) {
        free(gLibInfo.pLibDevArray[devNum]->regArray);
        gLibInfo.pLibDevArray[devNum]->regArray = NULL;
    }
    if (gLibInfo.pLibDevArray[devNum]->pModeArray) {
        free(gLibInfo.pLibDevArray[devNum]->pModeArray);
        gLibInfo.pLibDevArray[devNum]->pModeArray  = NULL;
    }

    if (gLibInfo.pLibDevArray[devNum]->pciValuesArray) {
        free(gLibInfo.pLibDevArray[devNum]->pciValuesArray);
        gLibInfo.pLibDevArray[devNum]->pciValuesArray = NULL;
    }
  
    if(gLibInfo.pLibDevArray[devNum]->pEarHead) {
        ar5212EarFree(gLibInfo.pLibDevArray[devNum]->pEarHead);
    }

    free(gLibInfo.pLibDevArray[devNum]);
    gLibInfo.pLibDevArray[devNum] = NULL;
    gLibInfo.devCount--;
}

/**************************************************************************
* specifySubSystemID - Tell library what subsystemID to try if can't find
*                      a match 
*
* 
*
*/
MANLIB_API void specifySubSystemID
(
 A_UINT32 devNum,
 A_UINT32   subsystemID
)
{
    mError(devNum, EIO, "Device Number %d:specifySubSystemID is an obsolete library command\n", devNum);
    
    devNum = 0;         //quiet compiler warning.
    subsystemID = 0; 
    return;
}

/**************************************************************************
* setResetParams - Setup params prior to calling resetDevice 
*
* These are new params added for second generation products
*
*/
MANLIB_API void setResetParams
(
 A_UINT32 devNum,
 A_CHAR     *pFilename,
 A_BOOL     eePromLoad,
 A_BOOL     forceCfgLoad,  
 A_UCHAR    mode,
 A_UINT16     initCodeFlag
)
{
    LIB_DEV_INFO *pLibDev = gLibInfo.pLibDevArray[devNum];
    A_UINT16      i;


//  printf("\n In SetResetParams pfilename = %s \n",pFilename);
    if (checkDevNum(devNum) == FALSE) {
        mError(devNum, EINVAL, "Device Number %d:setResetParams\n", devNum);
        return;
    }
    
    pLibDev->eePromLoad = eePromLoad;
//  pLibDev->eePromHeaderLoad = eePromHeaderLoad;
    pLibDev->mode = mode;
    pLibDev->use_init = initCodeFlag;

    if(eePromLoad == 0) {
        //force the eeprom header to re-apply, next time we load eeprom
        for (i = 0; i < 4; i++) {
            pLibDev->eepromHeaderApplied[i] = FALSE;
        }
    }
    if(forceCfgLoad) {
        //force the pci values to be regenerated
        pLibDev->regFileRead = 0;       
        //printf("SNOOP::: regFileRead to zero\n");

        //force the eeprom header to re-apply
        for (i = 0; i < 4; i++) {
            pLibDev->eepromHeaderApplied[i] = FALSE;
        }
    }

    if(( pFilename == '\0' ) || ( pFilename == NULL ) || (pFilename[0] == (A_CHAR)NULL)) {
        return;
   }


#ifndef MDK_AP    
    //do a check for file exist and is readable
    if(_access(pFilename, 04) != 0) {
        mError(devNum, EINVAL, "Device Number %d:setRegFilename: either file [%s] does not exist or is not readable\n", devNum, pFilename);
        return;
    }

    //if there is a config file change then reset the config file reading
    if(strcmp(pLibDev->regFilename, pFilename) != 0) {
        pLibDev->regFileRead = 0;
        //printf("SNOOP::: regFileRead to zero\n");
    }

    strcpy(pLibDev->regFilename, pFilename);
#endif
}

/**************************************************************************
* configureLibParams - Allow certain library params to be configured.
*                      Similar to setResetParmams.  This function will
*                      use a strcuture to pass params as this will be device
*                      specific params that will grow through time.
*
*/
MANLIB_API void configureLibParams
(
 A_UINT32 devNum,
 LIB_PARAMS *pLibParamsInfo
)
{
    LIB_DEV_INFO *pLibDev = gLibInfo.pLibDevArray[devNum];
    if (pLibDev->libCfgParams.loadEar != pLibParamsInfo->loadEar) {
        pLibDev->regFileRead = 0;
    } 
#ifndef __ATH_DJGPPDOS__
if (!isFalcon(devNum)) {
    if (pLibDev->artAniSetup.Enabled != pLibParamsInfo->artAniEnable) {
        if (pLibParamsInfo->artAniEnable == ART_ANI_ENABLED) {
            enableArtAniSetup(devNum);
        } else {
            disableArtAniSetup(devNum);
        }
    }
}
    pLibDev->artAniSetup.Reuse = pLibParamsInfo->artAniReuse;
    pLibDev->artAniSetup.currNILevel = pLibParamsInfo->artAniNILevel;
    pLibDev->artAniSetup.currBILevel = pLibParamsInfo->artAniBILevel;
    pLibDev->artAniSetup.currSILevel = pLibParamsInfo->artAniSILevel;
#else
    pLibParamsInfo->artAniEnable = ART_ANI_DISABLED;
#endif
    // chainmask from eeprom gets precedence
    if (pLibDev->libCfgParams.chain_mask_updated_from_eeprom) {
        pLibParamsInfo->tx_chain_mask = pLibDev->libCfgParams.tx_chain_mask;
        pLibParamsInfo->rx_chain_mask = pLibDev->libCfgParams.rx_chain_mask;
    }
    if (pLibDev->libCfgParams.useEepromNotFlash > 0) {
        pLibParamsInfo->useEepromNotFlash = pLibDev->libCfgParams.useEepromNotFlash;
    }
    memcpy(&(pLibDev->libCfgParams), pLibParamsInfo, sizeof(LIB_PARAMS));
    return;
}

/**************************************************************************
* getDeviceInfo - get a subset of the device info for display
    *
*/
MANLIB_API void getDeviceInfo
(
 A_UINT32 devNum, 
 SUB_DEV_INFO *pInfoStruct      //pointer to caller assigned struct
)
{
    LIB_DEV_INFO *pLibDev = gLibInfo.pLibDevArray[devNum];
    A_UINT32    strLength;

    if(pLibDev->ar5kInitIndex == UNKNOWN_INIT_INDEX) {
        mError(devNum, EIO, "Device Number %d:getDeviceInfo fail, run resetDevice first\n", devNum);
        return;
    }
    pInfoStruct->aRevID = pLibDev->aRevID;
    pInfoStruct->hwDevID = pLibDev->hwDevID;
    pInfoStruct->swDevID = ar5kInitData[pLibDev->ar5kInitIndex].swDeviceID;
    pInfoStruct->bbRevID = pLibDev->bbRevID;
    pInfoStruct->macRev = pLibDev->macRev;
    pInfoStruct->subSystemID = pLibDev->subSystemID;
    strLength = strlen(pLibDev->regFilename);
    if (strLength) {
        strcpy(pInfoStruct->regFilename, pLibDev->regFilename);
        pInfoStruct->defaultConfig = 0;
    }
    else {
        //copy in the default
        if (ar5kInitData[pLibDev->ar5kInitIndex].pCfgFileVersion) {
            strcpy(pInfoStruct->regFilename, ar5kInitData[pLibDev->ar5kInitIndex].pCfgFileVersion);
        } else {
            pInfoStruct->regFilename[0]='\0';
        }
        pInfoStruct->defaultConfig = 1;
    }
    sprintf(pInfoStruct->libRevStr, DEVLIB_VER1); 

}

static A_BOOL analogRevMatch
(
    A_UINT32 index,
    A_UINT32 aRevID
)
{
    A_UINT16 i;
    A_UCHAR  aProduct = (A_UCHAR)(aRevID & 0xf);
    A_UCHAR  aRevision = (A_UCHAR)((aRevID >> 4) & 0xf);

    if(ar5kInitData[index].pAnalogRevs == NULL) {
        return(TRUE);
    }

    for (i = 0; i < ar5kInitData[index].numAnalogRevs; i++) {
        if((aProduct == ar5kInitData[index].pAnalogRevs[i].productID) &&
            (aRevision == ar5kInitData[index].pAnalogRevs[i].revID)) {
            return (TRUE);
        }
    }
    return(FALSE);
}

static A_BOOL macRevMatch
(
    A_UINT32 index,
    A_UINT32 macRev
)
{
    A_UINT16 i;
    
    if(ar5kInitData[index].pMacRevs == NULL) {
        return (TRUE);
    }

    for(i = 0; i < ar5kInitData[index].numMacRevs; i++) {
        if(macRev == ar5kInitData[index].pMacRevs[i]) {
            return(TRUE);
        }
    }
    return(FALSE);
}

A_INT32 findDevTableEntry
(
    A_UINT32 devNum
)
{
    A_UINT32 i;
    LIB_DEV_INFO *pLibDev;

    pLibDev = gLibInfo.pLibDevArray[devNum];

    //FJC: 07/24/03 this function can now be called from outside resetDevice
    //so it needs to read the hw info incase it has not been read.
    //have copied this from resetDevice rather than move it to minimize
    //inpact.  Should readly optimize this so don't do the same stuff twice.
    pLibDev->hwDevID = (pLibDev->devMap.OScfgRead(devNum, 0) >> 16) & 0xffff;

     /* Reset the device. */
     /* Masking the board specific part of the device id */
     switch (pLibDev->hwDevID & 0xff)   {
        case 0x0007:
#ifndef __ATH_DJGPPDOS__
            if (pLibDev->devMap.remoteLib)
            {
                pLibDev->macRev = hwReset(devNum, BUS_RESET | BB_RESET | MAC_RESET);
            }
            else
            {
                hwResetAr5210(devNum, BUS_RESET | BB_RESET | MAC_RESET);
#if defined(SPIRIT_AP) || defined(FREEDOM_AP)
#if !defined(COBRA_AP)
                pLibDev->macRev = (sysRegRead(AR531X_REV) >> REV_WMAC_MIN_S) & 0xff;
#endif
#else
                pLibDev->macRev = REGR(devNum, F2_SREV) & F2_SREV_ID_M;
#endif
            }
#endif
            break;
        case 0x0011:
        case 0x0012:
        case 0x0013:
        case 0x0014:
        case 0x0015:
        case 0x0016: 
        case 0x0017: 
        case 0x001a:
        case 0x001b:
        case 0x001c:
        case 0x001f:
        case 0x00b0: 
        case 0xa014:
        case 0xa016:
        case 0x0019:
        case (DEVICE_ID_COBRA&0xff):
            if (pLibDev->devMap.remoteLib)
                pLibDev->macRev = hwReset(devNum, BUS_RESET | BB_RESET | MAC_RESET);
            else
            {
                hwResetAr5211(devNum, BUS_RESET | BB_RESET | MAC_RESET);
#if defined(SPIRIT_AP) || defined(FREEDOM_AP)
#if defined(COBRA_AP)
            if((pLibDev->hwDevID & 0xff) == (DEVICE_ID_COBRA&0xff))
                pLibDev->macRev = (sysRegRead(AR531XPLUS_PCI+F2_SREV) & F2_SREV_ID_M);

⌨️ 快捷键说明

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