📄 intprismdownload.c
字号:
{ WLANDL_DEBUG(DEBUG_ERROR, ("intPrismTertiaryDownload: Error - " "RAM download enable command failed\n")); intPrismDownloadCleanup(); return ERROR; } /* build the load image */ if (intPrismLoadImageBuild() == ERROR) { WLANDL_DEBUG(DEBUG_ERROR, ("intPrismTertiaryDownload: Error - " "could not build load image\n")); return ERROR; } if (intPrismCrcCalculate() == ERROR) { WLANDL_DEBUG(DEBUG_ERROR, ("intPrismTertiaryDownload: Error - " "could not compute crc for image\n")); return ERROR; } if (intPrismLoadImagePlug() == ERROR) { WLANDL_DEBUG(DEBUG_ERROR, ("intPrismTertiaryDownload: Error - " "could not plug load image\n")); return ERROR; } /* Write the download image to RAM */ if (intPrismLoadImageWrite(pWlanDev) == ERROR) { WLANDL_DEBUG(DEBUG_ERROR, ("intPrismTertiaryDownload: Error - " "load image write failed\n")); return ERROR; } if ( (wlanDlDebug != DEBUG_INFO) && (wlanDlDebug != DEBUG_FLOOD) ) { /* free memory used by parsed records */ intPrismDownloadCleanup(); } else { /* leave the parsed records available for examining */ WLANDL_DEBUG(DEBUG_INFO, ("intPrismTertiaryDownload: DEBUG_INFO or DEBUG_FLOOD set" " - parsed data not cleaned up\n")); } /* Issue the download disable (ie. complete) command */ if (intPrismCommand(pWlanDev, WLAN_CMD_DL_DISABLE, destAddrLow, destAddrHigh, 0) == ERROR ) { WLANDL_DEBUG(DEBUG_ERROR, ("intPrismTertiaryDownload: Error - " "download complete command failed\n")); return ERROR; } /* Disable the AUX Port */ intPrismAuxPortSet(pWlanDev, FALSE); return OK; }/******************************************************************************* intPrismIsFwCompatible - Determine if the Firmware is compatible with the* card it is being used on* * The card Component ID (found in PDA record 0x0008) is compared with the * Component ID's identified by the Firmware File (by Info Record 0x0004). If a* match is found, the card should be compatible with the given Firmware file* being used. The routines intPrismSRecordsParse and intPrismPdaRead should* have been called prior to this routine.** RETURNS: TRUE if the Component ID of the card matches the list of ID's the * Firmware file supports, else FALSE* ERRNO: N/A*/LOCAL BOOL intPrismIsFwCompatible(void) { UINT16 cardCompId = 0; UINT16 cardVarient = 0; UINT16 cardMajorVersion = 0; UINT16 cardMinorVersion = 0; PDA_RECORD * pTmpPdaRecord = pPdaRecords; INFO_RECORD * pTmpInfoRecord = pInfoRecords; if (pTmpPdaRecord == NULL) { WLANDL_DEBUG(DEBUG_ERROR, ("intPrismIsFwCompatible: no pda records found\n")); return FALSE; } if (pTmpInfoRecord == NULL) { WLANDL_DEBUG(DEBUG_ERROR, ("intPrismIsFwCompatible: no info records found\n")); return FALSE; } /* get the Component ID, Varient, Major Version, Minor Version of the card, this info can be found in the PDA of the card */ while (pTmpPdaRecord != NULL) { if (pTmpPdaRecord->itemCode == PDA_CODE_COMP_ID) { cardCompId = pTmpPdaRecord->data[0]; cardVarient = pTmpPdaRecord->data[1]; cardMajorVersion = pTmpPdaRecord->data[2]; cardMinorVersion = pTmpPdaRecord->data[3]; WLANDL_DEBUG(DEBUG_INFO, ("intPrismIsFwCompatible: card has comp id = 0x%x" " varient = %i, major = %i, minor = %i\n", cardCompId, cardVarient, cardMajorVersion, cardMinorVersion)); pTmpPdaRecord = NULL; break; } else { pTmpPdaRecord = pTmpPdaRecord->pNext; } } if (cardCompId == 0) { WLANDL_DEBUG(DEBUG_ERROR, ("intPrismIsFwCompatible: card comp. id not found " "in pda\n")); return FALSE; } /* find a match in the Info Records parsed from the F/W file */ while (pTmpInfoRecord != NULL) { if (pTmpInfoRecord->type == INFO_RECORD_CODE_COMP_ID) { WLANDL_DEBUG(DEBUG_INFO, ("intPrismIsFwCompatible: F/W is compatible with " "comp. id = 0x%x, varient = %i, major = %i, " "minor = %i\n", pTmpInfoRecord->data[0], pTmpInfoRecord->data[1], pTmpInfoRecord->data[2], pTmpInfoRecord->data[3])); if ( (pTmpInfoRecord->data[0] == cardCompId) && (pTmpInfoRecord->data[1] == cardVarient) && (pTmpInfoRecord->data[2] == cardMajorVersion) && (pTmpInfoRecord->data[3] == cardMinorVersion) ) { WLANDL_DEBUG(DEBUG_INFO, ("intPrismIsFwCompatible: Comp. Id match " "found\n")); return TRUE; } } pTmpInfoRecord = pTmpInfoRecord->pNext; } WLANDL_DEBUG(DEBUG_ERROR, ("intPrismIsFwCompatible: Comp.Id's did not match\n")); return FALSE; }/****************************************************************************** * intPrismSRecordsParse - parse a buffer containing Firmware in S Record format** Before this routine can be called, pBuffer must be set to point to the * characters making up the Firmware file. The buffer of S records is then* parsed and broken up into Data records, Info records, CRC records and* Plug Records. Also, the address in RAM (if one exists) where the download * should begin is parsed from the buffer. ** RETURNS: OK if the parsing was successful, else ERROR* ERRNO: N/A*/LOCAL STATUS intPrismSRecordsParse ( char * pBuffer, /* buffer of chars the make up the F/W in S Record's */ UINT32 buffSize /* num of bytes in buffer */ ) { UINT32 lineCounter = 0; UINT32 bufferPosition = 0; UINT32 index = 0; char lineBuffer[MAX_SRECORD_LEN]; char tmpBuffer[80]; char tmpAddr[S3_ADDR_LEN + 1]; char tmpNumBytes[S3_NUMBYTES_LEN + 1]; char tmpCheckSum[S3_CHECKSUM_LEN + 1]; UINT32 recAddr; UINT32 recLen; UINT8 recCheckSum; /* make sure we have a buffer to read from */ if (pBuffer == NULL) { WLANDL_DEBUG(DEBUG_ERROR, ("intPrismSRecordsParse: Error - pointer to " "firmware buffer is NULL\n")); return ERROR; } /* while we are not done reading the buffer... */ while (bufferPosition < buffSize) { /* store one S record at a time into lineBuffer */ /* while the end of S record (line) not reached */ while ((char) pBuffer[bufferPosition] != '\n') { lineBuffer[index] = pBuffer[bufferPosition]; bufferPosition++; index++; } bufferPosition++; /* increment past '\n' */ lineBuffer[index] = '\0'; index = 0; /* reset index for next line */ lineCounter++; WLANDL_DEBUG(DEBUG_FLOOD, ("intPrismSRecordsParse: Line Number: " "%i = %s\n", lineCounter, lineBuffer)); if ( (lineBuffer[0] != 'S') && (lineBuffer[0] != 's') ) { WLANDL_DEBUG(DEBUG_ERROR, ("intPrismSRecordsParse: unrecognized file" " format, Returning ERROR\n")); return ERROR; } if (lineBuffer[1] == '7') { /* Parse S7 Record */ WLANDL_DEBUG(DEBUG_FLOOD,("intPrismSRecordsParse: S7 record " "found\n")); bcopy((const char *) lineBuffer + S7_ADDR_OFFSET, (char *) tmpAddr, S7_ADDR_LEN); tmpAddr[S7_ADDR_LEN] = '\0'; ramDownloadAddr = strtoul(tmpAddr, NULL, 16); WLANDL_DEBUG(DEBUG_FLOOD, ("intPrismSRecordsParse: Ram Download " "Address = %x\n", ramDownloadAddr)); } else if (lineBuffer[1] == '3') { /* Parse S3 Record */ /* Get the S3 Address */ bcopy((const char *) lineBuffer + S3_ADDR_OFFSET, (char *) tmpAddr, S3_ADDR_LEN); tmpAddr[S3_ADDR_LEN] = '\0'; recAddr = strtoul(tmpAddr, NULL, 16); /* Get the num of bytes in record */ bcopy((const char *) lineBuffer + S3_NUMBYTES_OFFSET, (char *) tmpNumBytes, S3_NUMBYTES_LEN); tmpNumBytes[S3_NUMBYTES_LEN] = '\0'; recLen = strtoul(tmpNumBytes, NULL, 16); /* Get the checksum */ bcopy((const char *) lineBuffer + RECORD_TYPE_LEN + S3_NUMBYTES_LEN + (recLen * 2) - S3_CHECKSUM_LEN, (char* )tmpCheckSum, S3_CHECKSUM_LEN); tmpCheckSum[S3_CHECKSUM_LEN] = '\0'; recCheckSum = strtoul(tmpCheckSum, NULL, 16); /* verify the checksum */ bcopy((const char *) lineBuffer + S3_NUMBYTES_OFFSET, (char *) tmpBuffer, (recLen * 2) - S3_CHECKSUM_LEN + S3_NUMBYTES_LEN); tmpBuffer[(recLen * 2) - S3_CHECKSUM_LEN + S3_NUMBYTES_LEN] = '\0'; if (!intPrismChecksumVerified(recCheckSum, tmpBuffer)) { WLANDL_DEBUG(DEBUG_ERROR, ("intPrismSRecordsParse: ERROR - " "checksum verification failed for " "line %d\n", lineCounter)); return ERROR; } /* handle each type of record */ switch (recAddr) { case S3_PLUG_RECORD_ADDR: { UINT32 itemCode; UINT32 addr; UINT32 dataLen; /* parse a Plug Record */ WLANDL_DEBUG(DEBUG_FLOOD, ("intPrismSRecordsParse: Plug Record\n")); /* get the item code */ bcopy(lineBuffer + S3_PLUG_ITEM_NUM_OFFSET, tmpBuffer, S3_PLUG_ITEM_NUM_LEN); tmpBuffer[S3_PLUG_ITEM_NUM_LEN] = '\0'; itemCode = strtoul(tmpBuffer, NULL, 16); itemCode = L_TO_B_ENDIAN_32(itemCode); /* get the dest addr to plug at */ bcopy(lineBuffer + S3_PLUG_DEST_ADDR_OFFSET, tmpBuffer, S3_PLUG_DEST_ADDR_LEN); tmpBuffer[S3_PLUG_DEST_ADDR_LEN] = '\0'; addr = strtoul(tmpBuffer,NULL, 16); addr = L_TO_B_ENDIAN_32(addr); /* get the length of data to plug */ bcopy(lineBuffer + S3_PLUG_DATA_LEN_OFFSET, tmpBuffer, S3_PLUG_DATA_LEN_LEN); tmpBuffer[S3_PLUG_DATA_LEN_LEN] = '\0'; dataLen = strtoul(tmpBuffer,NULL, 16); dataLen = L_TO_B_ENDIAN_32(dataLen); intPrismPlugRecordAdd(itemCode, addr, dataLen); break; } case S3_CRC_RECORD_ADDR: { UINT32 addr; UINT32 len; UINT32 program; /* parse a CRC-16 generation record */ WLANDL_DEBUG(DEBUG_FLOOD, ("intPrismSRecordsParse: CRC Record\n")); /* get the addr to start crc calc from */ bcopy(lineBuffer + S3_CRC_ADDR_OFFSET, tmpBuffer, S3_CRC_ADDR_LEN); tmpBuffer[S3_CRC_ADDR_LEN] = '\0'; addr = strtoul(tmpBuffer, NULL, 16); addr = L_TO_B_ENDIAN_32(addr); /* get the size of the crc calc segment */ bcopy(lineBuffer + S3_CRC_LEN_OFFSET, tmpBuffer, S3_CRC_LEN_LEN); tmpBuffer[S3_CRC_LEN_LEN] = '\0'; len = strtoul(tmpBuffer, NULL, 16); len = L_TO_B_ENDIAN_32(len); /* get the program crc flag */ bcopy(lineBuffer + S3_CRC_PROGRAM_OFFSET, tmpBuffer, S3_CRC_PROGRAM_LEN); tmpBuffer[S3_CRC_PROGRAM_LEN] = '\0'; program = strtoul(tmpBuffer, NULL, 16); intPrismCrcRecordAdd(addr, len, program); break; } case S3_INFO_RECORD_ADDR: { UINT16 len; UINT16 type; UINT16 * pData; UINT16 i; /* parse an Info record */ WLANDL_DEBUG(DEBUG_FLOOD, ("intPrismSRecordsParse: Info Record\n")); /* length (in words) of info record */ bcopy(lineBuffer + S3_INFO_LEN_OFFSET, tmpBuffer, S3_INFO_LEN_LEN); tmpBuffer[S3_INFO_LEN_LEN] = '\0';
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -