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

📄 download_configure.c

📁 hifn ipsec固件下载工具
💻 C
📖 第 1 页 / 共 5 页
字号:
      if (param_p->processorType == HFTC_DPU)      {         parameter = HFTC_PP_READ_HARDWARE_STATUS;         unit = 0;      }      else if (param_p->processorType == HFTC_ESC)      {         parameter = HFTC_AP_READ_HARDWARE_STATUS;         unit = 1;      }      else      {         status = HFTC_INVALID_VALUE;         break;      }      /*         Get the current time.  We are only going to retry for a limited         amount of clock time, so we need to know how much time has passed.      */      tstatus = HFTC_get_time(&current_seconds, &current_milliseconds);      if (tstatus != HFTC_STATUS_OK)      {         status = tstatus;         printf("** Error: HFTC_get_time problem, status = %s (%d)\n",                HFTC_Status_t_text(status), status);         break;      }      end_seconds = current_seconds + timeoutSeconds;      end_milliseconds = current_milliseconds;      /*         Keep trying if we get a resend; it syncs up sequence numbers.         With ft-api the API handles the transmit and receive for the user.      */      do      {         status = HFTC_GetSystemParameter(unit, cbp, reqid,                                          parameter, hardware_status_p);         if (status == HFTC_RESEND)         {            ++numRetransmits;            if (numRetransmits == NUM_RETRANSMITS)            {               printf("Read status: resend -- retry.\n");            }         }         else if (status == HFTC_TIMEOUT)         {            ++numRetransmits;            if (numRetransmits == NUM_RETRANSMITS)            {               printf("Read status: timeout -- retry.\n");            }         }         /*            If timeoutSeconds have passed, exit with a timeout.         */         tstatus = HFTC_get_time(&current_seconds, &current_milliseconds);         if (tstatus != HFTC_STATUS_OK)         {            status = tstatus;            printf("** Error: HFTC_get_time problem, status = %s (%d)\n",                  HFTC_Status_t_text(status), status);            break;         }         if (current_seconds > end_seconds ||               (current_seconds == end_seconds &&                current_milliseconds >= end_milliseconds))         {            /* Status is already set. */            break;         }      } while ((status == HFTC_RESEND) || (status == HFTC_TIMEOUT));      if (status != HFTC_STATUS_OK)      {         printf("** Error: Read hardware status failed.\n");         printf(" Error from HFTC_GetSystemParameter, status = %s (%d)\n",                  HFTC_Status_t_text(status), status);      }   } while (HFTC_FALSE);   if (DL_DEBUG)   {      printf("<--%s status = %d\n", __func__, status);   }   return status;} /* end read_status *//*----------------------------------------------------------------------------* *   is_viper *----------------------------------------------------------------------------* * @ingroup CD_API_UTIL * @brief Figures out if this is a viper or topcat.  Stores results * * This uses the saved status of a processor to determine if this is a viper * or topcat. * * @param param_p           RO: Parameters pointer * * @par Externals: *    HFTC_hardware_status_t     hardware_status        Hardware status * * @return *    HFTC_TRUE             Target is a Viper *    HFTC_FALSE            Target is a Topcat * * @par Errors: *    None. * * @par Assumptions: *    Assumes that the external hardware status value has been filled in. * *----------------------------------------------------------------------------*/HFTC_Boolean_t is_viper(){   HFTC_Boolean_t viper = HFTC_FALSE;   if ((hardware_status.deviceIdBRC == HFTC_DEVICE_ID_X400) ||         (hardware_status.deviceIdBRC == HFTC_DEVICE_ID_X450))   {      viper = HFTC_TRUE;   }   return viper;} /* end is_viper *//*----------------------------------------------------------------------------* *   need_viper_workarounds *----------------------------------------------------------------------------* * @ingroup CD_API_UTIL * @brief Figures out if the viper workarounds are needed * * This reads a ROM location to see if the workarounds are needed. * They are only needed on vipers with a hardwareVersion of 1. * * @param param_p           RO: Parameters pointer * * @par Externals: *    HFTC_hardware_status_t     hardware_status        Hardware status * * @return *    HFTC_TRUE             workarounds are needed. *    HFTC_FALSE            no workarounds are needed. * * @par Errors: *    None. * * @par Assumptions: *    Assumes that the external hardware status value has been filled in. * *----------------------------------------------------------------------------*/staticHFTC_Boolean_t need_viper_workarounds(){   HFTC_Boolean_t need_workarounds = HFTC_FALSE;   HFTC_Status_t  status;   uint32_t       startWordAddress  = VIPER_HWVER_ADDR;   uint32_t       wordLength = 1;   uint32_t       buffer[1];        /* For one word. */   uint32_t       version;   uint32_t       retries = 0;   if (is_viper() == HFTC_TRUE)   {      do      {         /*            Read a special ROM location to determine if this is rev 1.            viper hardware, which requires some special workarounds.         */         status = HFTC_ReadMemory(0, NULL, 0, HFTC_MEM_PP_NORMAL,                                  startWordAddress, &wordLength, buffer);         RESEND_TIMEOUTS(status, retries);      } while (status == HFTC_RESEND);      if ((status != HFTC_STATUS_OK) || (wordLength != 1))      {         printf("** ERROR: Cannot determine Viper hardware version.  "                "Memory read failed.  Aborting.  status = %s (%d)\n",                 HFTC_Status_t_text(status), status);         exit(status);      }      version = HFTC_BE_to_uint32(&buffer[0]);      version >>= VIPER_HWVER_SHIFT;      if (version == VIPER_HWVER_1)      {         need_workarounds = HFTC_TRUE;      }   }   return need_workarounds;} /* end need_viper_workarounds *//*----------------------------------------------------------------------------* *   viper_reset_patch *----------------------------------------------------------------------------* * @ingroup CD_API_UTIL * @brief Temporary workaround for Viper, applies needed patch after reset. * * @param param_p       RO: Parameters pointer * * @par Externals: *    None. * * @return *    None. * * @par Errors: *    Errors returned from ft/ft-min. * * @par Assumptions: *    None. * * NOTE: According to ER-1 which this is working around, we may get failures *       on the initial writes.  Ignore the failures. * *----------------------------------------------------------------------------*/HFTC_Status_t viper_reset_patch(download_param_t   *param_p){   HFTC_Status_t             status                  = HFTC_STATUS_OK;   uint32_t                  wordLength;   uint32_t                  address;   uint32_t                  word;   uint32_t                  data[1]                 = {0};   if (DL_DEBUG)   {      printf("-->%s\n", __func__);   }   do   {      if (need_viper_workarounds() == HFTC_FALSE)      {         break;      }      if (DL_DEBUG)      {         printf("Applying Viper reset patch.\n");      }      /*         We may have just done a reset, so we need to register units once         more before we can continue using ft/ft-min.  They use a unit         table, and the values needed for that unit table may have changed         due to a reset.      */      status = register_units_from_param(param_p);      if (status != HFTC_STATUS_OK)      {         /* Printing done in register_units_from_param */         break;      }      /* write 800072a0 c9107ba5 */      do      {         wordLength = 1;         address = 0x800072A0;         word = 0xc9107ba5;         HFTC_uint32_to_BE(word, &data[0]);         status = HFTC_WriteMemory(0, NULL, 0,                                 HFTC_MEM_PP_NORMAL,                                 address,                                 &wordLength,                                 data);      }      while ((status == HFTC_RESULT_UNKNOWN) || (status == HFTC_RESEND));      if ((status != HFTC_STATUS_OK) && DL_DEBUG)      {         printf("\nUnable to write %08x to %08x; status = %s (%d)\n",                word, address, HFTC_Status_t_text(status), status);      }      /* write 800072a4 800004fa */      do      {         wordLength = 1;         address = 0x800072A4;         word = 0x800004fa;         HFTC_uint32_to_BE(word, &data[0]);         status = HFTC_WriteMemory(0, NULL, 0,                                 HFTC_MEM_PP_NORMAL,                                 address,                                 &wordLength,                                 data);      }      while ((status == HFTC_RESULT_UNKNOWN) || (status == HFTC_RESEND));      if ((status != HFTC_STATUS_OK) && DL_DEBUG)      {         printf("\nUnable to write %08x to %08x; status = %s (%d).\n",                word, address, HFTC_Status_t_text(status), status);      }      /* write -x 10 1 */      do      {         wordLength = 1;         address = 0x00000010;         word = 0x00000001;         HFTC_uint32_to_BE(word, &data[0]);         status = HFTC_WriteMemory(0, NULL, 0,                                 HFTC_MEM_PP_AUX,                                 address,                                 &wordLength,                                 data);      }      while ((status == HFTC_RESULT_UNKNOWN) || (status == HFTC_RESEND));      if ((status != HFTC_STATUS_OK) && DL_DEBUG)      {         printf("\nUnable to write %08x to %08x; status = %s (%d).\n",                word, address, HFTC_Status_t_text(status), status);      }   } while (HFTC_FALSE);   if (status == HFTC_STATUS_OK)   {      /* printf("  Viper reset patch applied.\n"); */   }   if (DL_DEBUG)   {      printf("<--%s status=%s (%d)\n", __func__,             HFTC_Status_t_text(status), status);   }   return status;} /* End viper_reset_patch *//*----------------------------------------------------------------------------* *   set_tod *----------------------------------------------------------------------------* * @ingroup CD_API_UTIL * @brief Set the time of day. * * This uses the Utility API to set the time of day. * * @param unit          RO: Unit number of target being downloaded. * @param param_p       RO: Parameters pointer * * @par Externals: *    None. * * @return *    HFTC_STATUS_OK    Status Read * * @par Errors: *    None. * * @par Assumptions: *    Assumes the ppci driver has been set up for ut-api usage. * *----------------------------------------------------------------------------*/staticHFTC_Status_t set_tod(HFTC_Unit_t         unit,                      download_param_t   *param_p){   HFTC_Status_t              status       = HFTC_STATUS_OK;   uint32_t                   timeOfDay;   HFTC_Reqid_t               reqid = 0x1234; /* Arbitrary value */   HFTC_Cbp_t                 cbp   = NULL;   uint32_t                   retries = 0;   if (DL_DEBUG)   {      printf("-->%s\n", __func__);   }   do   {      /*

⌨️ 快捷键说明

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