📄 ixnpedl.c
字号:
{ /* * Check whether NPE is present */ if (IX_NPEDL_NPEID_NPEA == npeId) { /* Check whether NPE A is present */ if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEA)== IX_FEATURE_CTRL_COMPONENT_DISABLED) { /* NPE A does not present */ IX_NPEDL_WARNING_REPORT ("ixNpeDlNpeExecutionStop - Warning:NPEA does not present.\n"); return IX_SUCCESS; } } /* end of if(IX_NPEDL_NPEID_NPEA) */ else if (IX_NPEDL_NPEID_NPEB == npeId) { /* Check whether NPE B is present */ if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEB)== IX_FEATURE_CTRL_COMPONENT_DISABLED) { /* NPE B does not present */ IX_NPEDL_WARNING_REPORT ("ixNpeDlNpeExecutionStop - Warning:NPEB does not present.\n"); return IX_SUCCESS; } } /* end of elseif(IX_NPEDL_NPEID_NPEB) */ else if (IX_NPEDL_NPEID_NPEC == npeId) { /* Check whether NPE C is present */ if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEC)== IX_FEATURE_CTRL_COMPONENT_DISABLED) { /* NPE C does not present */ IX_NPEDL_WARNING_REPORT ("ixNpeDlNpeExecutionStop - Warning:NPEC does not present.\n"); return IX_SUCCESS; } } /* end of elseif(IX_NPEDL_NPEID_NPEC) */ else { /* Invalid NPE ID */ IX_NPEDL_ERROR_REPORT ("ixNpeDlNpeExecutionStop - invalid Npe ID\n"); status = IX_NPEDL_PARAM_ERR; } /* end of if-else(IX_NPEDL_NPEID_NPEC) */ } /* end of if not IXP42X-AO Silicon */ if (status == IX_SUCCESS) { /* call NpeMgr function to stop the NPE */ status = ixNpeDlNpeMgrNpeStop (npeId); } IX_NPEDL_TRACE1 (IX_NPEDL_FN_ENTRY_EXIT, "Exiting ixNpeDlNpeExecutionStop : status = %d\n", status); if (IX_SUCCESS == status) { /* Indicate NPE has been stopped */ ixNpeDlNpeStarted[npeId] = FALSE ; } return status;}/* * Function definition: ixNpeDlUnload */PUBLIC IX_STATUSixNpeDlUnload (void){ IX_STATUS status; IX_NPEDL_TRACE0 (IX_NPEDL_FN_ENTRY_EXIT, "Entering ixNpeDlUnload\n"); status = ixNpeDlNpeMgrUninit(); IX_NPEDL_TRACE1 (IX_NPEDL_FN_ENTRY_EXIT, "Exiting ixNpeDlUnload : status = %d\n", status); return status;}/* * Function definition: ixNpeDlStatsShow */PUBLIC voidixNpeDlStatsShow (void){ ixOsalLog (IX_OSAL_LOG_LVL_USER, IX_OSAL_LOG_DEV_STDOUT, "\nixNpeDlStatsShow:\n" "\tDownloads Attempted by user: %u\n" "\tSuccessful Downloads: %u\n" "\tFailed Downloads (due to Critical Error): %u\n\n", ixNpeDlStats.attemptedDownloads, ixNpeDlStats.successfulDownloads, ixNpeDlStats.criticalFailDownloads, 0,0,0); ixNpeDlImageMgrStatsShow (); ixNpeDlNpeMgrStatsShow ();}/* * Function definition: ixNpeDlStatsReset */PUBLIC voidixNpeDlStatsReset (void){ ixNpeDlStats.attemptedDownloads = 0; ixNpeDlStats.successfulDownloads = 0; ixNpeDlStats.criticalFailDownloads = 0; ixNpeDlImageMgrStatsReset (); ixNpeDlNpeMgrStatsReset ();}/* * Function definition: ixNpeDlNpeInitAndStartInternal */PRIVATE IX_STATUSixNpeDlNpeInitAndStartInternal (UINT32 *imageLibrary, UINT32 imageId){ UINT32 imageSize; UINT32 *imageCodePtr = NULL; IX_STATUS status; IxNpeDlNpeId npeId = IX_NPEDL_NPEID_FROM_IMAGEID_GET(imageId); IxFeatureCtrlDeviceId deviceId = IX_NPEDL_DEVICEID_FROM_IMAGEID_GET(imageId); IX_NPEDL_TRACE0 (IX_NPEDL_FN_ENTRY_EXIT, "Entering ixNpeDlNpeInitAndStartInternal\n"); ixNpeDlStats.attemptedDownloads++; /* Check input parameter device correctness */ if ((deviceId >= IX_FEATURE_CTRL_DEVICE_TYPE_MAX) || (deviceId < IX_FEATURE_CTRL_DEVICE_TYPE_IXP42X)) { status = IX_NPEDL_PARAM_ERR; IX_NPEDL_ERROR_REPORT ("ixNpeDlNpeInitAndStartInternal - " "invalid parameter\n"); } /* End valid device id checking */ /* Check input parameters */ else if ((npeId >= IX_NPEDL_NPEID_MAX) || (npeId < 0)) { status = IX_NPEDL_PARAM_ERR; IX_NPEDL_ERROR_REPORT ("ixNpeDlNpeInitAndStartInternal - " "invalid parameter\n"); } else { /* Ensure initialisation has been completed */ ixNpeDlNpeMgrInit(); /* Checking if image being loaded is meant for device that is running. * Image is forward compatible. i.e Image built for IXP42X should run * on IXP46X but not vice versa.*/ if (deviceId > (ixFeatureCtrlDeviceRead() & IX_FEATURE_CTRL_DEVICE_TYPE_MASK)) { IX_NPEDL_ERROR_REPORT ("ixNpeDlNpeInitAndStartInternal - " "Device type mismatch. NPE Image not " "meant for device in use \n"); return IX_NPEDL_DEVICE_ERR; }/* if statement - matching image device and current device */ /* 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 not IXP42X-A0 Silicon */ /* stop and reset the NPE */ status = ixNpeDlNpeStopAndReset (npeId); if (IX_SUCCESS != status) { IX_NPEDL_ERROR_REPORT ("Failed to stop and reset NPE\n"); return status; } /* Locate image */ status = ixNpeDlImageMgrImageFind (imageLibrary, imageId, &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, TRUE); if (IX_SUCCESS == status) { 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].validImage = FALSE; ixNpeDlStats.criticalFailDownloads++; } /* NOTE - The following section of code is here to support * a deprecated function ixNpeDlLoadedImageGet(). When that * function is removed from the API, this code should be revised. */ ixNpeDlNpeState[npeId].imageId.npeId = npeId; ixNpeDlNpeState[npeId].imageId.functionalityId = IX_NPEDL_FUNCTIONID_FROM_IMAGEID_GET(imageId); ixNpeDlNpeState[npeId].imageId.major = IX_NPEDL_MAJOR_FROM_IMAGEID_GET(imageId); ixNpeDlNpeState[npeId].imageId.minor = IX_NPEDL_MINOR_FROM_IMAGEID_GET(imageId); } /* end of if(IX_SUCCESS) */ /* condition: image located successfully in microcode image */ } /* end of if-else(npeId-deviceId) */ /* condition: parameter checks ok */ IX_NPEDL_TRACE1 (IX_NPEDL_FN_ENTRY_EXIT, "Exiting ixNpeDlNpeInitAndStartInternal : " "status = %d\n", status); return status;}/* * Function definition: ixNpeDlCustomImageNpeInitAndStart */PUBLIC IX_STATUSixNpeDlCustomImageNpeInitAndStart (UINT32 *imageLibrary, UINT32 imageId){ IX_STATUS status; if (imageLibrary == NULL) { status = IX_NPEDL_PARAM_ERR; IX_NPEDL_ERROR_REPORT ("ixNpeDlCustomImageNpeInitAndStart " "- invalid parameter\n"); } else { status = ixNpeDlNpeInitAndStartInternal (imageLibrary, imageId); } /* end of if-else(imageLibrary) */ return status;}/* * Function definition: ixNpeDlNpeInitAndStart */PUBLIC IX_STATUSixNpeDlNpeInitAndStart (UINT32 imageId){ return ixNpeDlNpeInitAndStartInternal (NULL, imageId);}/* * Function definition: ixNpeDlLoadedImageFunctionalityGet */PUBLIC IX_STATUSixNpeDlLoadedImageFunctionalityGet (IxNpeDlNpeId npeId, UINT8 *functionalityId){ /* Check input parameters */ if ((npeId >= IX_NPEDL_NPEID_MAX) || (npeId < 0)) { IX_NPEDL_ERROR_REPORT ("ixNpeDlLoadedImageFunctionalityGet " "- invalid parameter\n"); return IX_NPEDL_PARAM_ERR; } if (functionalityId == NULL) { IX_NPEDL_ERROR_REPORT ("ixNpeDlLoadedImageFunctionalityGet " "- invalid parameter\n"); return IX_NPEDL_PARAM_ERR; } if (ixNpeDlNpeState[npeId].validImage) { *functionalityId = ixNpeDlNpeState[npeId].imageId.functionalityId; return IX_SUCCESS; } else { return IX_FAIL; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -