📄 ixnpedl.c
字号:
/** * @file IxNpeDl.c * * @author Intel Corporation * @date 08 January 2002 * * @brief This file contains the implementation of the public API for the * IXP425 NPE Downloader component * * * @par * IXP400 SW Release version 2.0 * * -- Copyright Notice -- * * @par * Copyright 2001-2005, Intel Corporation. * All rights reserved. * * @par * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the Intel Corporation nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * @par * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @par * -- End of Copyright Notice --*//* * Put the system defined include files required *//* * Put the user defined include files required */#include "IxNpeDl.h"#include "IxNpeDlImageMgr_p.h"#include "IxNpeDlNpeMgr_p.h"#include "IxNpeDlMacros_p.h"#include "IxFeatureCtrl.h"#include "IxOsal.h"/* * #defines used in this file */ #define IMAGEID_MAJOR_NUMBER_DEFAULT 0 #define IMAGEID_MINOR_NUMBER_DEFAULT 0/* * Typedefs whose scope is limited to this file. */typedef struct{ BOOL validImage; IxNpeDlImageId imageId;} IxNpeDlNpeState;/* module statistics counters */typedef struct{ UINT32 attemptedDownloads; UINT32 successfulDownloads; UINT32 criticalFailDownloads;} IxNpeDlStats;/* * Variable declarations global to this file only. Externs are followed * by static variables. */static IxNpeDlNpeState ixNpeDlNpeState[IX_NPEDL_NPEID_MAX] ={ {FALSE, {IX_NPEDL_NPEID_MAX, 0, 0, 0}}, {FALSE, {IX_NPEDL_NPEID_MAX, 0, 0, 0}}, {FALSE, {IX_NPEDL_NPEID_MAX, 0, 0, 0}}};static IxNpeDlStats ixNpeDlStats;/* * Software guard to prevent NPE from being started multiple times. */static BOOL ixNpeDlNpeStarted[IX_NPEDL_NPEID_MAX] ={FALSE, FALSE, FALSE} ;/* * static function prototypes. */PRIVATE IX_STATUSixNpeDlNpeInitAndStartInternal (UINT32 *imageLibrary, UINT32 imageId);/* * Function definition: ixNpeDlMicrocodeImageLibraryOverride */PUBLIC IX_STATUSixNpeDlMicrocodeImageLibraryOverride (UINT32 *clientImageLibrary){ IX_STATUS status = IX_SUCCESS; IX_NPEDL_TRACE0 (IX_NPEDL_FN_ENTRY_EXIT, "Entering ixNpeDlMicrocodeImageLibraryOverride\n"); if (clientImageLibrary == NULL) { status = IX_NPEDL_PARAM_ERR; IX_NPEDL_ERROR_REPORT ("ixNpeDlMicrocodeImageLibraryOverride - " "invalid parameter\n"); } else { status = ixNpeDlImageMgrMicrocodeImageLibraryOverride (clientImageLibrary); if (status != IX_SUCCESS) { status = IX_FAIL; } } /* end of if-else(clientImageLibrary) */ IX_NPEDL_TRACE1 (IX_NPEDL_FN_ENTRY_EXIT, "Exiting ixNpeDlMicrocodeImageLibraryOverride : " "status = %d\n", status); return status;}/* * Function definition: ixNpeDlImageDownload */PUBLIC IX_STATUSixNpeDlImageDownload (IxNpeDlImageId *imageIdPtr, BOOL verify){ UINT32 imageSize; UINT32 *imageCodePtr = NULL; IX_STATUS status; IxNpeDlNpeId npeId = imageIdPtr->npeId; IX_NPEDL_TRACE0 (IX_NPEDL_FN_ENTRY_EXIT, "Entering ixNpeDlImageDownload\n"); ixNpeDlStats.attemptedDownloads++; /* Check input parameters */ if ((npeId >= IX_NPEDL_NPEID_MAX) || (npeId < 0)) { status = IX_NPEDL_PARAM_ERR; IX_NPEDL_ERROR_REPORT ("ixNpeDlImageDownload - invalid parameter\n"); } else { /* Ensure initialisation has been completed */ ixNpeDlNpeMgrInit(); /* If not IXP42X A0 stepping, proceed to check for existence of npe's */ if ((IX_FEATURE_CTRL_SILICON_TYPE_A0 != (ixFeatureCtrlProductIdRead() & IX_FEATURE_CTRL_SILICON_STEPPING_MASK)) || (IX_FEATURE_CTRL_DEVICE_TYPE_IXP42X != ixFeatureCtrlDeviceRead ())) { if (npeId == IX_NPEDL_NPEID_NPEA) { if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEA) == IX_FEATURE_CTRL_COMPONENT_DISABLED) { IX_NPEDL_WARNING_REPORT("Warning: the NPE A component you specified does" " not exist\n"); return IX_SUCCESS; } } /* end of if(npeId) */ else if (npeId == IX_NPEDL_NPEID_NPEB) { if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEB)== IX_FEATURE_CTRL_COMPONENT_DISABLED) { IX_NPEDL_WARNING_REPORT("Warning: the NPE B component you specified" " does not exist\n"); return IX_SUCCESS; } } /* end of elseif(npeId) */ else if (npeId == IX_NPEDL_NPEID_NPEC) { if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEC)== IX_FEATURE_CTRL_COMPONENT_DISABLED) { IX_NPEDL_WARNING_REPORT("Warning: the NPE C component you specified" " does not exist\n"); return IX_SUCCESS; } } /* end of elseif(npeId) */ } /* end of if(IX_FEATURE_CTRL_SILICON_TYPE_B0) */ /*End of Silicon Type Check*/ /* stop and reset the NPE */ if (IX_SUCCESS != ixNpeDlNpeStopAndReset (npeId)) { IX_NPEDL_ERROR_REPORT ("Failed to stop and reset NPE\n"); return IX_FAIL; } /* Locate image */ status = ixNpeDlImageMgrImageLocate (imageIdPtr, &imageCodePtr, &imageSize); if (IX_SUCCESS == status) { /* * If download was successful, store image Id in list of * currently loaded images. If a critical error occured * during download, record that the NPE has an invalid image */ status = ixNpeDlNpeMgrImageLoad (npeId, imageCodePtr, verify); if (IX_SUCCESS == status) { ixNpeDlNpeState[npeId].imageId = *imageIdPtr; ixNpeDlNpeState[npeId].validImage = TRUE; ixNpeDlStats.successfulDownloads++; status = ixNpeDlNpeExecutionStart (npeId); } else if ((status == IX_NPEDL_CRITICAL_NPE_ERR) || (status == IX_NPEDL_CRITICAL_MICROCODE_ERR)) { ixNpeDlNpeState[npeId].imageId = *imageIdPtr; ixNpeDlNpeState[npeId].validImage = FALSE; ixNpeDlStats.criticalFailDownloads++; } } /* end of if(IX_SUCCESS) */ /* condition: image located successfully in microcode image */ } /* end of if-else(npeId) */ /* condition: parameter checks ok */ IX_NPEDL_TRACE1 (IX_NPEDL_FN_ENTRY_EXIT, "Exiting ixNpeDlImageDownload : status = %d\n", status); return status;}/* * Function definition: ixNpeDlAvailableImagesCountGet */PUBLIC IX_STATUSixNpeDlAvailableImagesCountGet (UINT32 *numImagesPtr){ IX_STATUS status; IX_NPEDL_TRACE0 (IX_NPEDL_FN_ENTRY_EXIT, "Entering ixNpeDlAvailableImagesCountGet\n"); /* Check input parameters */ if (numImagesPtr == NULL) { status = IX_NPEDL_PARAM_ERR; IX_NPEDL_ERROR_REPORT ("ixNpeDlAvailableImagesCountGet - " "invalid parameter\n"); } else { /* * Use ImageMgr module to get no. of images listed in Image Library Header. * If NULL is passed as imageListPtr parameter to following function, * it will only fill number of images into numImagesPtr */ status = ixNpeDlImageMgrImageListExtract (NULL, numImagesPtr); } /* end of if-else(numImagesPtr) */ IX_NPEDL_TRACE1 (IX_NPEDL_FN_ENTRY_EXIT, "Exiting ixNpeDlAvailableImagesCountGet : " "status = %d\n", status); return status;}/* * Function definition: ixNpeDlAvailableImagesListGet */PUBLIC IX_STATUSixNpeDlAvailableImagesListGet (IxNpeDlImageId *imageIdListPtr, UINT32 *listSizePtr){ IX_STATUS status; IX_NPEDL_TRACE0 (IX_NPEDL_FN_ENTRY_EXIT, "Entering ixNpeDlAvailableImagesListGet\n"); /* Check input parameters */ if ((imageIdListPtr == NULL) || (listSizePtr == NULL)) { status = IX_NPEDL_PARAM_ERR; IX_NPEDL_ERROR_REPORT ("ixNpeDlAvailableImagesListGet - " "invalid parameter\n"); } else { /* Call ImageMgr to get list of images listed in Image Library Header */ status = ixNpeDlImageMgrImageListExtract (imageIdListPtr, listSizePtr); } /* end of if-else(imageIdListPtr) */ IX_NPEDL_TRACE1 (IX_NPEDL_FN_ENTRY_EXIT, "Exiting ixNpeDlAvailableImagesListGet : status = %d\n", status); return status;}/* * Function definition: ixNpeDlLoadedImageGet */PUBLIC IX_STATUSixNpeDlLoadedImageGet (IxNpeDlNpeId npeId, IxNpeDlImageId *imageIdPtr){ IX_STATUS status = IX_SUCCESS; IX_NPEDL_TRACE0 (IX_NPEDL_FN_ENTRY_EXIT,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -