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

📄 load_config_params.c

📁 hifn ipsec固件下载工具
💻 C
📖 第 1 页 / 共 2 页
字号:
/*----------------------------------------------------------------------------*  Copyright (c) 2005 by Hifn, Inc, Los Gatos, CA, U.S.A.  All Rights Reserved.  This  software is furnished to licensee under a software license  agreement  and may be used and copied only in accordance with the terms and conditions  of such license and with the inclusion of the above Copyright Notice.  This  software  or  any  other  copies  thereof may not be provided or  otherwise  made  available  to any  other person.  No title to and  ownership  of  the  software   is   hereby   transferred   and   licensee  is  subject  to  all  confidentiality  provisions set forth in the  software  license  agreement.  The information in this software is  subject to change without notice.*-----------------------------------------------------------------------------*/static char const hftc_id[] = "$Id: @(#) load_config_params.c 1.21@(#) $";/*----------------------------------------------------------------------------* * @file load_config_params.c * @brief Configure the esc with values found in the configuration files. * * Configure the esc with values found in the unit table file and esc * config file. * * This code very similar to the code in config_esc and wait_esc found in the * tools/startup/src directory. * *----------------------------------------------------------------------------*//* @defgroup CD_API_UTIL *//*------------------------------------* * Header Include *------------------------------------*//* Standard includes */#include <stdio.h>#include <string.h>#include <stdlib.h>/* API specific includes */#include "hftc_pub_common.h"#include "hftc_pub_types.h"#include "hftc_pub_errors.h"#include "hftc_pub_service.h"#include "hftc_pub_translate_enums.h"#include "hftc_pub_port_mtu.h"/* Application specific includes */#include "download_configure.h"#include "hftc_pub_os_common.h"#include "hftc_pub_app_utils.h"#include "hftc_pub_download.h" /* For Device ID HFTC_DEVICE_ID_X* */#include "load_config_params.h"/*------------------------------------* * Constants and Types *------------------------------------*/#define DL_DEBUG   0     /* Set = 1 to get debug output, 0 for none. *//*------------------------------------* * External Variables *------------------------------------*//*------------------------------------* * File-Scope Variables *------------------------------------*//*------------------------------------* * Local Function Prototypes *------------------------------------*//*------------------------------------* * Implementation *------------------------------------*//*----------------------------------------------------------------------------* *   setAPUnitData *----------------------------------------------------------------------------* * @ingroup startup * @brief setAPUnitData * * Given unit data, sets APUnit Data * * @par Externals: *    None. * * @return *    Returns setup AP Unit Data. * * @par Errors: *    None. * * @par Assumptions: *    None. * *----------------------------------------------------------------------------*/staticvoid setAPUnitData(uint32_t numberOfUnits,                   HFTC_UnitData_t   *unitTable_p,                   HFTC_APUnitData_t *apUnitData_p){   uint32_t     i;   /*      HFTC_APUnitData_t is number of units followed by the unit data.      So this is pretty much a simple copy.   */   apUnitData_p->numberOfUnits = numberOfUnits;   for (i = 0; i < numberOfUnits; i++ )   {      apUnitData_p->unitData[i] = unitTable_p[i];   }} /* end setAPUnitData *//*----------------------------------------------------------------------------* *   load_config_params *----------------------------------------------------------------------------* * @ingroup startup * @brief Startup Esc using System Parameter interfaces. * * Currently program does assorted bringup items for starting up an eSC. * * @param param_p       RO: Parameters pointer * * @par Externals: *    None. * * @return *    The number of errors detected is returned. * * @par Errors: *    None. * * @par Assumptions: *    None. * *----------------------------------------------------------------------------*/HFTC_Status_t load_config_params(download_param_t   *param_p){   HFTC_Status_t              status            = HFTC_STATUS_OK;   HFTC_Unit_t                unit              = 0;   uint32_t                   i;   uint32_t                   configValue;   uint32_t                   numberOfUnits     = 0;   HFTC_UnitData_t           *unitTable_p  = NULL;  /* Pointer to unit table */   HFTC_UnitData_t           *localTable_p = NULL;  /* Pointer to local data */   HFTC_APUnitData_t          apUnitData;   HFTC_ConfigParameters_t     *escParameters_p   = NULL;   HFTC_Reqid_t               reqid             = 0;   HFTC_Cbp_t                 cbp               = NULL;   HFTC_hardware_status_t     hardware_status;   HFTC_UnitType_t            unitType;   uint32_t                   retries           = 0;   do   {      if (DL_DEBUG)      {         printf("unit table file is %s; config params file is %s.\n",                param_p->unitTable, param_p->configparams);      }      /*         Read the unit table file if it exists, if not then use our         defaults.      */      status = HFTC_ReadUnitFile(param_p->unitTable, &numberOfUnits,                                   &unitTable_p, &localTable_p);      if (status != HFTC_STATUS_OK)      {         printf("** ERROR: Problem reading unit file '%s'; exiting.\n",                param_p->unitTable);         break;      }      /*         Read Status.  This is to make sure both the DPU and eSC are         awake after being downloaded.      */      param_p->processorType = HFTC_ESC;      hardware_status.statusVersion = HFTC_HARDWARE_STATUS_VERSION_2;      status = read_status(unit, param_p, RETRANSMIT_RETRY_SECONDS,                           &hardware_status);      if (status == HFTC_STATUS_OK)      {         if (DL_DEBUG)         {            printf("First ReadStatus eSC success.\n");         }      }      else      {         printf("First status read on eSC failed.\n");         break;      }      param_p->processorType = HFTC_DPU;      hardware_status.statusVersion = HFTC_HARDWARE_STATUS_VERSION_2;      status = read_status(unit, param_p, RETRANSMIT_RETRY_SECONDS,                           &hardware_status);      if (status == HFTC_STATUS_OK)      {         if (DL_DEBUG)         {            printf("First ReadStatus DPU success.\n");         }      }      else      {         printf("First status read on DPU failed.\n");         break;      }      /*         Make sure the UnitType in the unit data matches the target we are         loading.  Look at the unit type for the eSC.      */      if ((hardware_status.deviceIdBRC == HFTC_DEVICE_ID_X400) ||          (hardware_status.deviceIdBRC == HFTC_DEVICE_ID_X450))      {         unitType = HFTC_X400;      }      else      {         unitType = HFTC_X300;      }      if (unitType != unitTable_p[ESCINDEX].UnitType)      {         printf("Error: The type of unit in the unit table doesn't match\n"                "       the device type being configured.\n");         status = HFTC_INCONSISTENT;         break;      }      /*         Next we set the PPCI addresses of the DPU and eSC.  The values used         for the PPCI addresses are taken out of the table we are going to         use for registration.      */      retries = 0;      do      {         /*            The AP PPCI Address value must go in the upper 16 bits.         */         configValue = unitTable_p[ESCINDEX].PPCIaddress << 16;         status = HFTC_SetSystemParameter(unit, cbp, reqid,                                          HFTC_AP_SOURCE_PPCI,                                          &configValue);         RESEND_TIMEOUTS(status, retries);      } while (status == HFTC_RESEND);      if (status != HFTC_STATUS_OK)      {         printf("HFTC_AP_SOURCE_PPCI failed.\n");         printf(" Error from HFTC_SetSystemParameter; status = %s (%d).\n",                  HFTC_Status_t_text(status), status);         break;      }      else if (DL_DEBUG)      {         printf("HFTC_AP_SOURCE_PPCI success.\n");      }      retries = 0;      do      {         configValue = unitTable_p[DPUINDEX].PPCIaddress;         status = HFTC_SetSystemParameter(unit, cbp, reqid,                                          HFTC_PP_SOURCE_PPCI,                                          &configValue);         RESEND_TIMEOUTS(status, retries);      } while (status == HFTC_RESEND);      if (status != HFTC_STATUS_OK)      {         printf("HFTC_PP_SOURCE_PPCI failed.\n");         printf(" Error from HFTC_SetSystemParameter, status = %s (%d)\n",                  HFTC_Status_t_text(status), status);         break;      }      else if (DL_DEBUG)      {         printf("HFTC_PP_SOURCE_PPCI success.\n");      }      /*         Then we do registration for the DPU and eSC.  This must be done         before any further communication with the DPU or eSC will succeed,         because their PPCI addresses have been changed.      */      status = HFTC_RegisterUnits(localTable_p,                                  numberOfUnits,                                  unitTable_p);      if (status != HFTC_STATUS_OK)      {         printf("HFTC_RegisterUnits failed.\n");         printf(" Error from HFTC_RegisterUnits, status = %s (%d)\n",                  HFTC_Status_t_text(status), status);         break;      }      else if (DL_DEBUG)      {         printf("HFTC_RegisterUnits success.\n");      }      /*         Get the AP unit table data into the right format for the set system         parameter call.  Note that we are using the same unit table here as         we used for registering with the utilities API on the host.  This         is not necessarily always correct.  However it is correct for the         purposes of this utility.  This is because this utility is only         bringing up one HIPP-3 target, and the data is stored in the proper         order for a unit table on the eSC.      */      setAPUnitData(numberOfUnits, unitTable_p, &apUnitData);      retries = 0;      do      {         status = HFTC_SetSystemParameter(unit, cbp, reqid,                                          HFTC_AP_REGISTERED_UNITS,                                          &apUnitData);         RESEND_TIMEOUTS(status, retries);      } while (status == HFTC_RESEND);      if (status != HFTC_STATUS_OK)      {         printf("HFTC_AP_REGISTERED_UNITS failed.\n");         printf(" Error from Set System Parameter, status = %s (%d)\n",                  HFTC_Status_t_text(status), status);         break;      }      else if (DL_DEBUG)      {         printf("HFTC_AP_REGISTERED_UNITS success.\n");      }      /*         Then we read status.  This really doesn't need to be done,         but it is helpful to see that communication can be         established to the DPU and eSC.      */      /* --------------------- Read Status ------------------------ */

⌨️ 快捷键说明

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