📄 intprismdownload.c
字号:
WLANDL_DEBUG(DEBUG_ERROR, ("intPrismSecondaryDownload: char buffer" " is NULL\n")); return ERROR; } /* make sure it's an Intersil card */ if ( (pWlanDev == NULL) || ( (((WLAN_DEV *)pWlanDev)->cardType != WLAN_CARDTYPE_INTERSIL_2) && (((WLAN_DEV *)pWlanDev)->cardType != WLAN_CARDTYPE_INTERSIL_2_5) && (((WLAN_DEV *)pWlanDev)->cardType != WLAN_CARDTYPE_INTERSIL_3) )) { WLANDL_DEBUG(DEBUG_ERROR, ("intPrismSecondaryDownload: Error - card is not a valid" " Intersil/Prism based wlan interface\n")); return ERROR; } /* Disable card interrupts */ WLAN_OUT_16(WLAN_BASE_ADDR + WLAN_INT_EN, 0); /* Init the MAC */ if (intPrismCommand(pWlanDev, WLAN_CMD_INI, 0, 0, 0) == ERROR) { WLANDL_DEBUG(DEBUG_ERROR, ("intPrismSecondaryDownload; failed sending init cmd\n")); return ERROR; } /* get the Download buffer location, size, load time */ dlMaxLoadTime = intPrismRIDWordRead(pWlanDev, WLAN_RID_DNLD_MAXTIME); ltv.type = WLAN_RID_DNLD_BUF; intPrismLTVRead(pWlanDev, <v); dlBufferPage = (UINT16) ltv.data[0]; dlBufferOffset = (UINT16) ltv.data[1]; dlBufferLength = (UINT16) ltv.data[2]; dlBufferLength = 1024; /* being overcautious: i use this 'small' buffer size instead of the max */ /* Prepare the load image */ intPrismDownloadCleanup(); if (intPrismSRecordsParse(pBuffer, numBytes) == ERROR) { WLANDL_DEBUG(DEBUG_ERROR, ("intPrismSecondaryDownload: Error parsing" " secondary firmware\n")); return ERROR; } if (pWlanDev->cardType == WLAN_CARDTYPE_INTERSIL_2) { pdaAddr = WLAN_PRISM_2_PDA_ADDR; } else if (pWlanDev->cardType == WLAN_CARDTYPE_INTERSIL_2_5) { pdaAddr = WLAN_PRISM_2_5_PDA_ADDR; } else if (pWlanDev->cardType == WLAN_CARDTYPE_INTERSIL_3) { pdaAddr = WLAN_PRISM_3_PDA_ADDR; } else { WLANDL_DEBUG(DEBUG_ERROR, ("intPrismSecondaryDownload: invalid card type\n")); return ERROR; } if (intPrismPdaRead(pWlanDev, pdaAddr) == ERROR) { WLANDL_DEBUG(DEBUG_FLOOD, ("intPrismSecondaryDownload: failed reading " "PDA at 0x%x\n", pdaAddr)); /* Prism 2 cards seem to have two different valid PDA addr's, depending on how old they are. try the other address here: */ if (pWlanDev->cardType == WLAN_CARDTYPE_INTERSIL_2) { pdaAddr = WLAN_PRISM_2_PDA_ADDR_ALT; WLANDL_DEBUG(DEBUG_FLOOD, ("intPrismSecondaryDownload: trying next" " pda addr 0x%x\n", pdaAddr)); if (intPrismPdaRead(pWlanDev, pdaAddr) == ERROR) { WLANDL_DEBUG(DEBUG_ERROR, ("intPrismSecondaryDownload: failed reading " "PDA at 0x%x\n", pdaAddr)); WLANDL_DEBUG(DEBUG_ERROR, ("intPrismSecondaryDownload: " "Error reading card PDA\n")); return ERROR; } } } /* make sure the Firmware is compatible with the given card */ if (!intPrismIsFwCompatible()) { WLANDL_DEBUG(DEBUG_ERROR, ("intPrismSecondaryDownload: Secondary F/W is" " not compatible with card\n")); intPrismDownloadCleanup(); return ERROR; } /* build the load image */ if (intPrismLoadImageBuild() == ERROR) { WLANDL_DEBUG(DEBUG_ERROR, ("intPrismSecondaryDownload: Error building " "load image\n")); return ERROR; } if (intPrismCrcCalculate() == ERROR) { WLANDL_DEBUG(DEBUG_ERROR, ("intPrismSecondaryDownload: Error computing " "CRC value for load image\n")); return ERROR; } if (intPrismLoadImagePlug() == ERROR) { WLANDL_DEBUG(DEBUG_ERROR, ("intPrismSecondaryDownload: Error plugging" " load image\n")); return ERROR; } /* Enable the AUX Port */ intPrismAuxPortSet(pWlanDev, TRUE); /* create the FLASH d/l buffer dest address out of the page and offset */ destAddr = ((UINT32) (dlBufferPage << 7)) + dlBufferOffset; /* set ptr. to the first DATA_BLOCK */ pDataBlockIndex = pDataBlocks; /* is incremented as each word in the current DATA_BLOCK is written */ blockWordIndex = 0; /* write each DATA_BLOCK to the card */ while (pDataBlockIndex != NULL) { UINT16 dlAddrLow = 0; UINT16 dlAddrHigh = 0; /* determine num of bytes to write in this cycle, keeping in mind that there is a max number that can be written at time */ if ( (pDataBlockIndex->numBytes - (blockWordIndex * 2)) > dlBufferLength) { /* write the max allowable num of bytes */ numBytesToWrite = dlBufferLength; } else { /* write the remaining num of bytes in this DATA_BLOCK */ numBytesToWrite = pDataBlockIndex->numBytes - (blockWordIndex * 2); } /* Issue the download enable command */ if (doDownload) { /* PARAM 0: the low 16 bits of the data d/l address PARAM 1: the high 16 bits of the data d/l address */ dlAddrLow = (pDataBlockIndex->addr + (blockWordIndex * 2)) & 0xFFFF; dlAddrHigh = (pDataBlockIndex->addr + (blockWordIndex) * 2) >> 16; if (intPrismCommand(pWlanDev, WLAN_CMD_NV_DL_ENABLE, dlAddrLow, dlAddrHigh, numBytesToWrite) == ERROR) { WLANDL_DEBUG(DEBUG_ERROR, ("intPrismSecondaryDownload; failed" " sending WLAN_CMD_NV_DL_ENABLE cmd\n")); return ERROR; } } /* set the dest address in Flash for the d/l buffer. Presumably, data will be written to this buffer, and then copied to the d/l address specified in the enable command immediately above */ intPrismAuxAddrSet(pWlanDev, destAddr); /* write the data */ for (i = 0; i < numBytesToWrite / 2; i++) { if (doDownload) { WLAN_OUT_16(WLAN_BASE_ADDR + WLAN_AUX_DATA, pDataBlockIndex->pData[blockWordIndex]); } blockWordIndex++; } /* Issue the write complete command */ if (doDownload) { if (intPrismCommand(pWlanDev, WLAN_CMD_NV_DL_PROGRAM, dlAddrLow, dlAddrHigh, numBytesToWrite) == ERROR) { WLANDL_DEBUG(DEBUG_ERROR, ("intPrismSecondaryDownload; failed" " sending WLAN_CMD_NV_DL_PROGRAM cmd\n")); return ERROR; } } /* check if we are done with this DATA_BLOCK */ if ((blockWordIndex * 2) == pDataBlockIndex->numBytes) { pDataBlockIndex = pDataBlockIndex->pNext; blockWordIndex = 0; } } /* Finished writing all the data to Flash */ /* Issue the download complete command */ if (doDownload) { if (intPrismCommand(pWlanDev, WLAN_CMD_DL_DISABLE, 0, 0, 0) == ERROR) { WLANDL_DEBUG(DEBUG_ERROR, ("intPrismSecondaryDownload; failed" " sending WLAN_CMD_DL_DISABLE cmd\n")); return ERROR; } } /* disable aux port */ intPrismAuxPortSet(pWlanDev, FALSE); /* re-init the card */ if (intPrismCommand(pWlanDev, WLAN_CMD_INI, 0, 0, 0) == ERROR) { WLANDL_DEBUG(DEBUG_ERROR, ("intPrismSecondaryDownload; failed sending init cmd\n")); } /* don't cleanup if this was a 'fake' download, user may wish to examine the parsed firmware records */ if (doDownload) { intPrismDownloadCleanup(); } else { printf("intPrismSecondaryDownload: finished (false) download\n"); } return OK; }/******************************************************************************* intPrismTertiaryDownload - Download Tertiary AP Firmware to a wlan card* * A wrapper (intPrismTertApFileDownload and intPrismTertApFtpDownload) for * this routine exists in intPrismTertAp. ** This routine loads Tertiary AP firmware (supplied by Intersil) onto an* Prism based wlan card. The Tertiary F/W must be compatible with the* given card. The following steps are performed in the process:** \ml* \m 1. Read the card PDA* \m 2. Parse the Tertiary hex code* \m 3. Verify F/W<-->card compatibility* \m 4. Issue the download command to the card* \m 5. Enable Aux Data Port* \m 6. Build load image, Calculate CRC of image, Plug the load image* \m 7. Write load Image* \m 8. Issue download complete command* \m 9. Disable Aux Port* \me** RETURNS: OK if the firmware was loaded onto the card successfully, else ERROR* ERRNO: N/A* SEE ALSO: intPrismTertAp*/STATUS intPrismTertiaryDownload ( WLAN_DEV * pWlanDev,/* wlan device structure */ char * pTertBuffer, /* buffer of char's that constitutes the Tertiary F/W */ UINT32 numBytes /* num of bytes in the Tertiary char buffer */ ) { UINT16 destAddrLow, destAddrHigh; UINT32 pdaAddr = 0; /* Read the Production Data Area of the card */ if (pWlanDev->cardType == WLAN_CARDTYPE_INTERSIL_2) { pdaAddr = WLAN_PRISM_2_PDA_ADDR; } else if (pWlanDev->cardType == WLAN_CARDTYPE_INTERSIL_2_5) { pdaAddr = WLAN_PRISM_2_5_PDA_ADDR; } else if (pWlanDev->cardType == WLAN_CARDTYPE_INTERSIL_3) { pdaAddr = WLAN_PRISM_3_PDA_ADDR; } else { WLANDL_DEBUG(DEBUG_ERROR, ("intPrismTertiaryDownload: invalid card type\n")); return ERROR; } if (intPrismPdaRead(pWlanDev, pdaAddr) == ERROR) { WLANDL_DEBUG(DEBUG_FLOOD, ("intPrismTertiaryDownload: failed reading " "PDA at 0x%x\n", pdaAddr)); /* Prism 2 cards seem to have two different valid PDA addr's, depending on how old they are. try the other address here: */ if (pWlanDev->cardType == WLAN_CARDTYPE_INTERSIL_2) { pdaAddr = WLAN_PRISM_2_PDA_ADDR_ALT; WLANDL_DEBUG(DEBUG_FLOOD, ("intPrismTertiaryDownload: try reading " "PDA at 0x%x\n", pdaAddr)); if (intPrismPdaRead(pWlanDev, pdaAddr) == ERROR) { WLANDL_DEBUG(DEBUG_ERROR, ("intPrismTertiaryDownload: " "Error reading card PDA\n")); return ERROR; } } } /* Parse the S-records that make up the Tertiary Firmware */ if (intPrismSRecordsParse(pTertBuffer, numBytes) == ERROR) { WLANDL_DEBUG(DEBUG_ERROR, ("intPrismTertiaryDownload: failed parsing tert. hex" " file\n")); intPrismDownloadCleanup(); return ERROR; } if (ramDownloadAddr == 0) { WLANDL_DEBUG(DEBUG_ERROR, ("intPrismTertiaryDownload: unknown RAM download " "address\n")); intPrismDownloadCleanup(); return ERROR; } /* make sure the Tertiary Firmware is compatible with the given card */ if (!intPrismIsFwCompatible()) { WLANDL_DEBUG(DEBUG_ERROR, ("intPrismTertiaryDownload; Tertiary code is" " not compatible with card\n")); intPrismDownloadCleanup(); return ERROR; } /* Init the MAC */ if (intPrismCommand(pWlanDev, WLAN_CMD_INI, 0, 0, 0) == ERROR) { WLANDL_DEBUG(DEBUG_ERROR, ("intPrismTertiaryDownload: failed sending init cmd\n")); intPrismDownloadCleanup(); return ERROR; } /* * Disable the MAC Port 0 (likely already disabled by the init command * above, but let's be explicitely sure) */ if (intPrismCommand(pWlanDev, WLAN_CMD_DISABLE, 0, 0, 0) == ERROR) { WLANDL_DEBUG(DEBUG_ERROR, ("intPrismTertiaryDownload; failed disabling card cmd\n")); intPrismDownloadCleanup(); return ERROR; } /* Build the params for the download command */ WLANDL_DEBUG(DEBUG_INFO, ("intPrismTertiaryDownload: ramDownloadAddr = %x\n", ramDownloadAddr)); /* low 16 bits of RAM addr */ destAddrLow = ramDownloadAddr & 0x0000FFFF; /* high 16 bits of RAM addr */ destAddrHigh = ramDownloadAddr >> 16; /* Enable the AUX Port */ intPrismAuxPortSet(pWlanDev, TRUE); /* Issue the enable RAM download command */ if (intPrismCommand(pWlanDev, WLAN_CMD_RAM_DL_ENABLE, destAddrLow, destAddrHigh, 0) == ERROR )
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -