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

📄 download_configure.c

📁 hifn ipsec固件下载工具
💻 C
📖 第 1 页 / 共 5 页
字号:
/*----------------------------------------------------------------------------*  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: @(#) download_configure.c 1.37@(#) $";/*----------------------------------------------------------------------------* * @file download_configure.c * @brief Download of a cdl file, then set the parameters and a simple policy. * * This program downloads the firmware and then does the initial * configuration of the eSC using the unit table file and the eSC * configuration file.  It waits for the system to be ready, and optionally * sets a simple policy into the system.  This program is both an * example/starting point for an application that can bring up and manage a * HIPP III system, and a download configure tool. * * Use: *    ./download_configure --help * for help in running this program. * * If persistent storage access is required, the persistent storage server * must also be started before executing this program. * * If the IKE package is not installed, the program will be linked against a * stub routine and no policy can will be set on the system. * * The steps taken in this application to download and configure the system * are as follows: * * (downloading though host0 port or on a Viper (44x0/84x0)) *    1.  Download the DPU firmware (doing a soft boot reset as needed) *    2.  Set the of day on the DPU *    3.  Download the POST code to the eSC *    4.  Download the eSC firmware *    5.  Set up the eSC/DPU configuration parameters *    6.  Set up the unit table on the eSC, *    7.  Set any DPU options (ESPUDP) *        the PPCI address of the hardware (DPU & eSC) *    8.  Wait for the code on the eSC to complete its initialization *    9.  Enable the GMACs *   10.  Optionally set up a bypass policy. * * When using the mii port on a Topcat (43x0/83x0) the steps are the same as * above, but the order is different for steps 1-3.  Steps 5-9 are the same: * * (downloading though mii port) *    1a.  Download the eSC Bank Access Workaround file (if present, does soft *         boot reset if it is needed.)  This step is not needed when loading *         through the host0 port. *    1b.  Download the POST code to the eSC (soft boot reset if needed and *         not done in step above.) *    2.   Download the DPU firmware *    3.   Set the time of day on the DPU *    4.   Download the eSC firmware *   5-10. These steps are the same as when loading through host0. * * Note that for proper operation of this code when linked against the * ft-api the source address used for the ft-api portion of the code must * not match the source address used for the download-api portion of the * code.  This is because the ft-api uses a different socket for receiving * than that used in the download portion of this code.  A read status * response to the download-api portion will also be received by the ft-api * socket.  The ft-api socket can then mistake this old read status response * as a read status response to recent read status it issued. * *----------------------------------------------------------------------------*//* @defgroup CD_API_UTIL *//*------------------------------------* * Header Include *------------------------------------*//* Standard includes */#include <stdio.h>#include <string.h>#include <stdlib.h>#include <unistd.h>       /* for close  */#include <getopt.h>/* API specific includes */#include "hftc_pub_common.h"#include "hftc_pub_types.h"#include "hftc_pub_errors.h"#include "hftc_pub_base.h"#include "hftc_pub_download.h"#include "hftc_pub_gmac.h"#include "hftc_pub_service.h"#include "hftc_pub_translate_enums.h"#include "hftc_pub_download.h"          /* For HFTC_DEVICE_ID values *//* Application specific includes */#include "defpolicy.h"#include "download.h"#include "load_config_params.h"#include "enable_gmacs.h"#include "hftc_pub_os_common.h"#include "hftc_pub_app_utils.h"/*------------------------------------* * Constants and Types *------------------------------------*/#define  DL_DEBUG   0     /* Set = 1 to get debug output, 0 for none. *//*   Build number.*/#define BUILD_NUMBER    0/*------------------------------------* * External Variables *------------------------------------*//*------------------------------------* * File-Scope Variables *------------------------------------*/static HFTC_UnitData_t UnitTable[2] ={ /*     This is the unit table, used until we have a new unit table ready to     download.     PPCI         MAC Address            Unit Type     Address    (network byte order)     Note that the unit type does not matter, and we don't yet know the unit     type.  The unit type information needs to be correct when the unit     table is sent to the eSC, however, this unit table is not sent to the     eSC. */    {DEST_PPCIADDR_DPU, DEST_MACADDR, HFTC_DEFAULT_UNIT_TYPE}, /* Unit 0 DPU */    {DEST_PPCIADDR_ESC, DEST_MACADDR, HFTC_DEFAULT_UNIT_TYPE}  /* Unit 1 eSC */};#define NUMUNITS (sizeof(UnitTable)/sizeof(HFTC_UnitData_t))/*   This is the local data information.  Our default unit table uses 0x02 as   the source PPCI address for ft/ft-min, so this table will use the same   value.*/static HFTC_UnitData_t LocalAddressData ={  0x02, SRC_MACADDR, HFTC_HOST};/*   We do an inital read hardware status, for determining if the target is a   Viper or a Topcat.  This information is needed in several places to apply   assorted workarounds.  The hardware status information is filled in from   a call in the main routine, and there is a routine used to query the   hardware target type within this module.*/HFTC_Unit_t                unit                   = 0;HFTC_hardware_status_t     hardware_status        = {0};/*------------------------------------* * Implementation *------------------------------------*//*----------------------------------------------------------------------------* * initParam *----------------------------------------------------------------------------* * @ingroup CD_API_UTIL * * Initialize parameters * * This routine is used internally only to initialize the parameters to * their default values.  It is called before printing out default values, * and called before parsing the input for the real values. * * @param param_p        WO: Pointer to download parameters (to be initialized) * * @par Externals: *    None. * * @return *    param_p (initialize parameters) * * @par Errors: *    None. * * @par Locks: *    None. * * @par Assumptions: *    param_p points to a valid download_param_t structure. * *----------------------------------------------------------------------------*/staticvoid initParam(download_param_t *param_p){   HFTC_Buffer_t        destMACAddr[] = DEST_MACADDR;   HFTC_Buffer_t        srcMACAddr[]  = SRC_MACADDR;   /* Initialize the parameters to get the defaults */   memset(param_p, 0, sizeof(download_param_t));   param_p->dfile[0]            = 0;            /* No default files. */   param_p->pfile[0]            = 0;   param_p->efile[0]            = 0;   param_p->interface[0]        = 0;            /* No default interface. */   param_p->unitTable[0]        = 0;   param_p->configparams[0]     = 0;   param_p->root[0]             = 0;   param_p->rootSpecified       = HFTC_FALSE;   /* --root not specified */   param_p->forceDownload       = HFTC_FALSE;   /* Don't force a download */   param_p->processorType       = HFTC_DPU;   param_p->destPPCIAddrDpu     = DEST_PPCIADDR_DPU;   param_p->destPPCIAddrEsc     = DEST_PPCIADDR_ESC;   param_p->srcPPCIAddr         = SRC_PPCIADDR;   param_p->codeBufferLen       = CODEBUFLEN;   param_p->noSoftBootReset     = HFTC_FALSE;   /* Reset if needed */   param_p->forceSoftBootReset  = HFTC_FALSE;   /* But, don't force reset */   param_p->noVerify            = HFTC_FALSE;   /* Use verification */   param_p->noSetTod            = HFTC_FALSE;   /* Don't set time of day */   param_p->noRun               = HFTC_FALSE;   /* Don't run code */   param_p->noConfigParams      = HFTC_FALSE;   /* Config eSC/DPU if loaded */   param_p->noGmacEnable        = HFTC_FALSE;   /* Enable GMACs */   param_p->miiDownload         = HFTC_FALSE;   /* Download through host 0 */   param_p->mii133MHzDownload   = HFTC_FALSE;   /* Don't assume 133 MHz Mii */   param_p->promiscuous         = HFTC_FALSE;   /* Use MAC filtering */   param_p->bypassPolicy        = HFTC_FALSE;   /* Load no policy by default */   param_p->longSdramTest       = HFTC_FALSE;   /* No long SDRAM test */   param_p->postMonitorMode     = HFTC_FALSE;   /* Not POST Monitor Mode */   param_p->espudpPortsSet      = HFTC_FALSE;   /* No ESPUDP port values */   param_p->espudpPortValues    = 0;   param_p->numDdlFiles         = 0;            /* No DDL files specified.  */   (void) memcpy(param_p->destMACAddr,                 destMACAddr,                 sizeof(param_p->destMACAddr));   (void) memcpy(param_p->srcMACAddr,                 srcMACAddr,                 sizeof(param_p->srcMACAddr));} /* initParam *//*----------------------------------------------------------------------------* * printParam *----------------------------------------------------------------------------* * @ingroup CD_API_UTIL * * Print parameters (used for debug) * * @param param_p        WO: Pointer to download parameters * * @par Externals: *    None. * * @return *    param_p (initialize parameters) * * @par Errors: *    None. * * @par Locks: *    None. * * @par Assumptions: *    None. * *----------------------------------------------------------------------------*/staticvoid printParam(download_param_t *param_p){   uint32_t i;   printf("Parameters param_p=%p\n", param_p);   printf("    dfile              = %s\n", param_p->dfile);   printf("    pfile              = %s\n", param_p->pfile);   printf("    efile              = %s\n", param_p->efile);   printf("    wfile              = %s\n", param_p->wfile);   printf("    interface          = %s\n", param_p->interface);   printf("    unit table file    = %s\n", param_p->unitTable);   printf("    config params file = %s\n", param_p->configparams);   printf("    rootSpecified      = %d\n", param_p->rootSpecified);   printf("    forceDownload      = %d\n", param_p->forceDownload);   printf("    processorType      = %d\n", param_p->processorType);   printf("    destPPCIAddrDpu    = 0x%04x\n", param_p->destPPCIAddrDpu);   printf("    destPPCIAddrEsc    = 0x%04x\n", param_p->destPPCIAddrEsc);   printf("    srcPPCIAddr        = 0x%04x\n", param_p->srcPPCIAddr);   printf("    codeBufferLen      = %d\n", param_p->codeBufferLen);   printf("    noSoftBootReset    = %d\n", param_p->noSoftBootReset);   printf("    forceSoftBootReset = %d\n", param_p->forceSoftBootReset);   printf("    noVerify           = %d\n", param_p->noVerify);   printf("    noSetTod           = %d\n", param_p->noSetTod);   printf("    noRun              = %d\n", param_p->noRun);   printf("    noConfigParams     = %d\n", param_p->noConfigParams);   printf("    noGmacEnable       = %d\n", param_p->noGmacEnable);   printf("    miiDownload        = %d\n", param_p->miiDownload);   printf("    mii133MHzDownload  = %d\n", param_p->mii133MHzDownload);   printf("    promiscuous        = %d\n", param_p->promiscuous);   printf("    bypassPolicy       = %d\n", param_p->bypassPolicy);   printf("    longSdramTest      = %d\n", param_p->longSdramTest);   printf("    postMonitorMode    = %d\n", param_p->postMonitorMode);   printf("    espudpPortsSet     = %d\n", param_p->espudpPortsSet);   printf("    espudpPortValues   = 0x%08x\n", param_p->espudpPortValues);   printf("    numDdlFiles        = %d\n", param_p->numDdlFiles);   for (i = 0; i < param_p->numDdlFiles; i++)   {      printf("    ddlFile[%d]         = %s (to %s)\n",             i, param_p->ddlFile[i],             (param_p->ddlDestination[i] == HFTC_DPU) ? "DPU" : "ESC");   }   return;} /* end printParam *//*----------------------------------------------------------------------------* * printUsage *----------------------------------------------------------------------------* * @ingroup CD_API_UTIL * * Prints program usage. * * @param *    None. * * @par Externals: *    None. * * @return *    None. * * @par Errors: *    None. * * @par Locks: *    None. * * @par Assumptions: *    None. * *----------------------------------------------------------------------------*/void printUsage(void){   /* Initialize the parameters to get the defaults */   download_param_t     param;   initParam(&param);   printf("\nUSAGE:\n""         download_configure [OPTIONS]\n""\n""DESCRIPTION:\n""\n""  download_configure is an SDK download/configuration tool that can be\n""  used to reset, download, and configure a HIPP III device.  It also\n""  serves as an example program for how to use the SDK for these tasks.\n""\n""OPTIONS:\n""\n""    -h, --help\n""        Display this help message.\n\n""    -r, --root  SDK_ROOT\n""        Specify root directory of SDK and use it to generate paths to \n""        default filenames.  This parameter is a shorthand for the \n""        following set of options:\n""\n""           --dpu-file      SDK_ROOT/firmware/xY00_dpu.cdl\n""           --esc-file      SDK_ROOT/firmware/xY00_esc.cdl\n""           --esc-post-file SDK_ROOT/firmware/xY00_esc_post.cdl\n""           --unit-table    SDK_ROOT/config/xY00_escunit\n""           --config-file   SDK_ROOT/config/xY00_configparams\n""\n""        where 'SDK_ROOT' is the path specified, and 'xY00' is either x400\n""        or x300 based on the chip type.  The chip type is determined by\n""        querying the chip via a 'status' command.\n""\n""        These values can be overridden by specifying the corresponding\n""        flag values explicitly AFTER the -r option (since command-line\n""        options are parsed from left to right).\n""\n""        See 'examples' section at the bottom for more.\n""\n""  Code download options:\n""\n"

⌨️ 快捷键说明

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