📄 intprismdownload.c
字号:
numDataRecords + 1)); return ERROR; } pNew->addr = addr; pNew->dataLen = dataLen; pNew->data = pData; pNew->pNext = pDataRecords; pDataRecords = pNew; numDataRecords++; return OK; } else { /* navigate the list until a position to insert after is found, or we are at the end */ while (pIndex->pNext != NULL) { if ( ((DATA_RECORD *) pIndex->pNext)->addr > addr) { break; } else { pIndex = pIndex->pNext; } } } } pNew = (DATA_RECORD *) malloc(sizeof(DATA_RECORD)); if (pNew == NULL) { WLANDL_DEBUG(DEBUG_ERROR, ("intPrismDataRecordAdd: Error could not " "malloc space for data record %i\n", numDataRecords + 1)); return ERROR; } pNew->addr = addr; pNew->dataLen = dataLen; pNew->data = pData; pNew->pNext = pIndex->pNext; pIndex->pNext = pNew; numDataRecords++; return OK; }/******************************************************************************* intPrismChecksumVerified - verify the checksum of a S record** The sum of the chars making up the S record are added as 16 bit hex values. * The 1's complement of this sum should be equal to the checksum** RETURNS: TRUE if the S record matches the checksum, else FALSE* ERRNO: N/A*/LOCAL BOOL intPrismChecksumVerified ( UINT8 expectedCheckSum, /* the (1' complement of) checksum for the record*/ char* sRecord /* ptr. to the S record data used for checksum */ ) { char nextData[3]; UINT8 sum = 0; int i = 0; /* add up the data in the S record */ while (sRecord[i] != '\0') { bcopy(sRecord + i, nextData, 2); nextData[2] = '\0'; sum += (UINT8) strtoul(nextData, NULL, 16); i = i + 2; } /* compare the 1's complement of the sum with the expected checksum */ if ( (~sum & 0xFF) == expectedCheckSum) { return TRUE; } else { WLANDL_DEBUG(DEBUG_ERROR, ("intPrismCheckSumVerified: (~sum & 0xFF) = " "0x%x, checksum = 0x%x\n", (~sum & 0xFF), expectedCheckSum)); WLANDL_DEBUG(DEBUG_ERROR, ("intPrismCheckSumVerified: data = %s\n", sRecord)); return FALSE; } }/***************************************************************************** * NOMANUAL* intPrismPdaRead - read the Production Data Area of the card* * The PDA is read from the card memory starting at a specific address, until* the PDA end record is encountered.** RETURNS: OK if the PDA was read successfully, else ERROR* ERRNO: N/A*/STATUS intPrismPdaRead ( WLAN_DEV * pWlanDev, /* wlan device ptr */ UINT32 pdaAddr /* PDA start address */ ) { UINT32 tmpLen; UINT32 tmpItemCode; UINT16 * pData; UINT32 i; /* clear old records */ if (numPdaRecords != 0) { intPrismPdaRecordsFree(); } /* Enable the AuxPort, set with the address of the PDA */ if (intPrismAuxPortSet(pWlanDev, TRUE) == ERROR) { WLANDL_DEBUG(DEBUG_ERROR, ("intPrismPdaRead: Error - could not enable" " aux port\n")); return ERROR; } intPrismAuxAddrSet(pWlanDev, pdaAddr); /* * Read the PDA (from AuxData register) until the PDA End Record is * encountered */ while (1) { tmpLen = WLAN_IN_16(WLAN_BASE_ADDR + WLAN_AUX_DATA); tmpItemCode = WLAN_IN_16(WLAN_BASE_ADDR + WLAN_AUX_DATA); WLANDL_DEBUG(DEBUG_FLOOD, ("intPrismPdaRead: read itemCode = 0x%x, len = 0x%x\n", tmpItemCode, tmpLen)); if ( (tmpItemCode == 0) && (tmpLen != 2)) /* this can't be a correct PDA address if this condition occurs */ { intPrismPdaRecordsFree(); return ERROR; } else if ((tmpItemCode == 0) && (tmpLen == 2)) { break; } pData = (UINT16 *) malloc((tmpLen - 1) * sizeof(UINT16)); if (pData == NULL) { } for (i = 0; i < tmpLen - 1; i++) { pData[i] = WLAN_IN_16(WLAN_BASE_ADDR + WLAN_AUX_DATA); } intPrismPdaRecordAdd(tmpItemCode, tmpLen, pData); } /* disable the Aux Port */ if (intPrismAuxPortSet(pWlanDev, FALSE) == ERROR) { WLANDL_DEBUG(DEBUG_ERROR, ("intPrismPdaRead: Error - could not disable" " aux port\n")); return ERROR; } return OK; }/****************************************************************************** * intPrismPdaRecordsFree - free any memory allocated for PDA records** RETURNS: N/A* ERRNO: N/A*/LOCAL void intPrismPdaRecordsFree(void) { PDA_RECORD * pIndex = pPdaRecords; PDA_RECORD * pTmp; if (numPdaRecords == 0) return; while (pIndex != NULL) { pTmp = pIndex->pNext; free(pIndex->data); free(pIndex); pIndex = pTmp; } numPdaRecords = 0; pPdaRecords = NULL; return; }/****************************************************************************** * intPrismDataRecordsFree - free any memory allocated for data records** RETURNS: N/A* ERRNO: N/A*/LOCAL void intPrismDataRecordsFree(void) { DATA_RECORD * pIndex = pDataRecords; DATA_RECORD * pTmp; if (numDataRecords == 0) return; while (pIndex != NULL) { pTmp = pIndex->pNext; free(pIndex->data); free(pIndex); pIndex = pTmp; } numDataRecords = 0; pDataRecords = NULL; return; }/****************************************************************************** * intPrismInfoRecordsFree - free any memory allocated for info records** RETURNS: N/A* ERRNO: N/A*/LOCAL void intPrismInfoRecordsFree(void) { INFO_RECORD * pIndex = pInfoRecords; INFO_RECORD * pTmp; if (numInfoRecords == 0) return; while (pIndex != NULL) { pTmp = pIndex->pNext; free(pIndex->data); free(pIndex); pIndex = pTmp; } numInfoRecords = 0; pInfoRecords = NULL; return; }/****************************************************************************** * intPrismPlugRecordsFree - free any memory allocated for plug records** RETURNS: N/A* ERRNO: N/A*/LOCAL void intPrismPlugRecordsFree(void) { PLUG_RECORD * pIndex = pPlugRecords; PLUG_RECORD * pTmp; if (numPlugRecords == 0) { return; } while (pIndex != NULL) { pTmp = pIndex->pNext; free(pIndex); pIndex = pTmp; } numPlugRecords = 0; pPlugRecords = NULL; return; }/****************************************************************************** * intPrismCrcRecordsFree - free any memory allocated for Crc records** RETURNS: N/A* ERRNO: N/A*/LOCAL void intPrismCrcRecordsFree(void) { CRC_RECORD * pTmp; CRC_RECORD * pIndex = pCrcRecords; if (numCrcRecords == 0) { return; } while (pIndex != NULL) { pTmp = pIndex->pNext; free(pIndex); pIndex = pTmp; } numCrcRecords = 0; pCrcRecords = NULL; return; }/****************************************************************************** * intPrismDataBlocksFree - free any memory allocated for the final load image** RETURNS: N/A* ERRNO: N/A*/LOCAL void intPrismDataBlocksFree(void) { DATA_BLOCK * pIndex = pDataBlocks; DATA_BLOCK * pTmp; if (numDataBlocks == 0) return; while (pIndex != NULL) { pTmp = pIndex->pNext; free(pIndex->pData); free(pIndex); pIndex = pTmp; } numDataBlocks = 0; pDataBlocks = NULL; return; } /****************************************************************************** NOMANUAL* intPrismDownloadCleanup - free memory allocated for all record types* * The memory allocated for data records, info records, plug records, * crc records, pdaRecords and the final load image is freed up** RETURNS N/A* ERRNO: N/A*/void intPrismDownloadCleanup(void) { intPrismDataRecordsFree(); intPrismPlugRecordsFree(); intPrismInfoRecordsFree(); intPrismCrcRecordsFree(); intPrismPdaRecordsFree(); intPrismDataBlocksFree(); return; }/****************************************************************************** NOMANUAL* intPrismDownloadStatsShow - display the num of each type of record read** Prints to stdio the num of
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -