?? download.c
字號:
HFTC_Status_t status = HFTC_STATUS_OK; uint32_t sendFrameLen; /* Do code verify, and verify that the code was downloaded properly. */ if (DL_DEBUG) { printf("-->%s\n", __func__); } do { status = HFTC_CD_VerifyCodeImage(unit, &sendFrameLen, sframe); /* We've got a frame to transmit */ if (status != HFTC_STATUS_OK) { /* We have an error and thus want to exit. */ break; } /* Exchange frames */ status = exchangeFrames(unit, frameLen, sendFrameLen, CodeDownLoad, sframe, rframe); } while ((status == HFTC_CALL_AGAIN) || (status == HFTC_RESULT_UNKNOWN)); if (DL_DEBUG) { printf("<--%s status = %s (%d)\n", __func__, HFTC_Status_t_text(status), status); } return status;} /* End doCodeVerify *//*----------------------------------------------------------------------------* * setLongSdramTest *----------------------------------------------------------------------------* * @ingroup CD_API_UTIL * @brief Set POST parameter to run long SDRAM test as part of POST. * * Again, the logic in this routine is similar to that in doCodeDownload. * * @param unit RO: Unit number of target being downloaded. * @param frameLen RO: The maximum length of a frame, the size of the * sframe buffer and rframe buffer. * @param sframe WO: Pointer to buffer for frame to send. * @param rframe WO: Pointer to buffer where frame is received. * * @par Externals: * None. * * @return * * @par Errors: * None. * * @par Assumptions: * *----------------------------------------------------------------------------*/staticHFTC_Status_t setLongSdramTest(HFTC_Unit_t unit, uint32_t frameLen, HFTC_Buffer_t *sframe, HFTC_Buffer_t *rframe){ HFTC_Status_t status = HFTC_STATUS_OK; uint32_t sendFrameLen; /* Issue the set post parameter. */ if (DL_DEBUG) { printf("-->%s\n", __func__); } do { status = HFTC_CD_SetPOSTParameter(unit, HFTC_CD_RUN_LONG_SDRAM_TEST, HFTC_CD_LST_ON, &sendFrameLen, sframe); /* We've got a frame to transmit */ if (status != HFTC_STATUS_OK) { /* We have an error and thus want to exit. */ break; } /* Exchange frames */ status = exchangeFrames(unit, frameLen, sendFrameLen, CodeDownLoad, sframe, rframe); } while ((status == HFTC_CALL_AGAIN) || (status == HFTC_RESEND)); if (DL_DEBUG) { printf("<--%s status = %d\n", __func__, status); } return status;} /* End setLongSdramTest *//*----------------------------------------------------------------------------* * setPostMonitorMode *----------------------------------------------------------------------------* * @ingroup CD_API_UTIL * @brief Set POST parameter to run in POST Monitor Mode. * * Again, the logic in this routine is similar to that in doCodeDownload. * (These should probably be combined.) * * @param unit RO: Unit number of target being downloaded. * @param frameLen RO: The maximum length of a frame, the size of the * sframe buffer and rframe buffer. * @param sframe WO: Pointer to buffer for frame to send. * @param rframe WO: Pointer to buffer where frame is received. * * @par Externals: * None. * * @return * * @par Errors: * None. * * @par Assumptions: * *----------------------------------------------------------------------------*/staticHFTC_Status_t setPostMonitorMode(HFTC_Unit_t unit, uint32_t frameLen, HFTC_Buffer_t *sframe, HFTC_Buffer_t *rframe){ HFTC_Status_t status = HFTC_STATUS_OK; uint32_t sendFrameLen; /* Issue the set post parameter. */ if (DL_DEBUG) { printf("-->%s\n", __func__); } do { status = HFTC_CD_SetPOSTParameter(unit, HFTC_CD_POST_MONITOR_MODE, HFTC_CD_PM_MODE_ON, &sendFrameLen, sframe); /* We've got a frame to transmit */ if (status != HFTC_STATUS_OK) { /* We have an error and thus want to exit. */ break; } /* Exchange frames */ status = exchangeFrames(unit, frameLen, sendFrameLen, CodeDownLoad, sframe, rframe); } while ((status == HFTC_CALL_AGAIN) || (status == HFTC_RESEND)); if (DL_DEBUG) { printf("<--%s status = %d\n", __func__, status); } return status;} /* End setPostMonitorMode *//*----------------------------------------------------------------------------* * doRunCode *----------------------------------------------------------------------------* * @ingroup CD_API_UTIL * @brief Do the run code in the non error path. * * Again, the logic in this routine is similar to that in doCodeDownload. * * @param unit RO: Unit number of target being downloaded. * @param frameLen RO: The maximum length of a frame, the size of the * sframe buffer and rframe buffer. * @param sframe WO: Pointer to buffer for frame to send. * @param rframe WO: Pointer to buffer where frame is received. * * @par Externals: * None. * * @return * * @par Errors: * None. * * @par Assumptions: * *----------------------------------------------------------------------------*/staticHFTC_Status_t doRunCode(HFTC_Unit_t unit, uint32_t frameLen, HFTC_Buffer_t *sframe, HFTC_Buffer_t *rframe){ HFTC_Status_t status = HFTC_STATUS_OK; uint32_t sendFrameLen; /* Issue the run code. */ if (DL_DEBUG) { printf("-->%s\n", __func__); } do { status = HFTC_CD_RunCode(unit, &sendFrameLen, sframe); /* We've got a frame to transmit */ if (status != HFTC_STATUS_OK) { /* We have an error and thus want to exit. */ break; } /* Exchange frames */ status = exchangeFrames(unit, frameLen, sendFrameLen, CodeDownLoad, sframe, rframe); } while ((status == HFTC_CALL_AGAIN) || (status == HFTC_RESULT_UNKNOWN)); if (DL_DEBUG) { printf("<--%s status = %s (%d)\n", __func__, HFTC_Status_t_text(status), status); } return status;} /* End doRunCode *//*----------------------------------------------------------------------------* * doCodeDownload *----------------------------------------------------------------------------* * @ingroup CD_API_UTIL * @brief Do the actual data download * * Pass blocks of data to HFTC_DD_GenerateCfgDataFrame until it returns * an Ethernet frame. Send the Ethernet frame to the target processor, * handling any timeouts or retransmissions. Receive a response from the * target processor in the form of an Ethernet frame. Process that * response with HFTC_DD_CheckCfgDataResonse. * Repeat above until we are done. * * Pseudo code for the function below is as follows: * * save file pos * * do * * do * read next config block * generate a frame to transmit * while call again * * exchange frames * * if result unknown * rewind * else * save new file pos * end * * while call again * * @param f RO: File handle of .ddl file * @param processorType RO: DPU or eSC * @param maxFrameLen RO: * @param dataBlockLen RO: * * @par Externals: * None. * * @return * * @par Errors: * None. * * @par Assumptions: * None. * *----------------------------------------------------------------------------*/staticHFTC_Status_t doDownloadConfig(FILE *f, HFTC_Unit_t unit, uint32_t maxFrameLen, uint32_t dataBlockLen){ HFTC_Status_t status = HFTC_STATUS_OK; int fpos; int freadResult; HFTC_Buffer_t *dataBlock_p; HFTC_Buffer_t *sframe_p; HFTC_Buffer_t *rframe_p; uint32_t blockNumber; uint32_t savedBlock; uint32_t dataRecord; uint32_t sendFrameLen; /* Allocate buffers for datablocks and frames. */ do { dataBlock_p = HFTC_malloc(dataBlockLen); if (dataBlock_p == NULL) { printf("Malloc of dataBlock failed.\n"); break; } sframe_p = HFTC_malloc(maxFrameLen); if (sframe_p == NULL) { printf("Malloc of transmit frame failed.\n"); break; } rframe_p = HFTC_malloc(maxFrameLen); if (rframe_p == NULL) { printf("Malloc of receive frame failed.\n"); break; } blockNumber = 0; dataRecord = 0; /* Save off our file position in case we need to retransmit */ fpos = ftell(f); savedBlock = 0; do { do { /* Read some (more) data */ if (DL_DEBUG) { printf("debug, reading block %d.\n",blockNumber); } freadResult = fread(dataBlock_p, dataBlockLen, 1, f); if (freadResult != 1) { printf("read of file failed.\n"); status = HFTC_UNEXPECTED_ERROR; break; } blockNumber++; status = HFTC_DD_GenerateCfgDataFrame(unit, dataBlock_p, &sendFrameLen, sframe_p); } while (status == HFTC_CALL_AGAIN); if (status != HFTC_STATUS_OK) { /* If the status is not OK, then something went wrong. Abort the download. */ printf("Problem in generating Data Frame, status = %s (%d)\n", HFTC_Status_t_text(status), status); break; } if (DL_DEBUG) { printf("debug, transmit data record %d.\n",dataRecord); } status = exchangeFrames(unit, maxFrameLen, sendFrameLen, DataDownLoad,
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -