4 * @author Intel Corporation
5 * @date 08 January 2002
7 * @brief This file contains the implementation of the public API for the
8 * IXP425 NPE Downloader component
12 * IXP400 SW Release version 2.0
14 * -- Copyright Notice --
17 * Copyright 2001-2005, Intel Corporation.
18 * All rights reserved.
21 * Redistribution and use in source and binary forms, with or without
22 * modification, are permitted provided that the following conditions
24 * 1. Redistributions of source code must retain the above copyright
25 * notice, this list of conditions and the following disclaimer.
26 * 2. Redistributions in binary form must reproduce the above copyright
27 * notice, this list of conditions and the following disclaimer in the
28 * documentation and/or other materials provided with the distribution.
29 * 3. Neither the name of the Intel Corporation nor the names of its contributors
30 * may be used to endorse or promote products derived from this software
31 * without specific prior written permission.
34 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
35 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
36 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
37 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
38 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
39 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
40 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
41 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
42 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
43 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47 * -- End of Copyright Notice --
51 * Put the system defined include files required
55 * Put the user defined include files required
58 #include "IxNpeDlImageMgr_p.h"
59 #include "IxNpeDlNpeMgr_p.h"
60 #include "IxNpeDlMacros_p.h"
61 #include "IxFeatureCtrl.h"
64 * #defines used in this file
66 #define IMAGEID_MAJOR_NUMBER_DEFAULT 0
67 #define IMAGEID_MINOR_NUMBER_DEFAULT 0
70 * Typedefs whose scope is limited to this file.
75 IxNpeDlImageId imageId;
78 /* module statistics counters */
81 UINT32 attemptedDownloads;
82 UINT32 successfulDownloads;
83 UINT32 criticalFailDownloads;
87 * Variable declarations global to this file only. Externs are followed
88 * by static variables.
90 static IxNpeDlNpeState ixNpeDlNpeState[IX_NPEDL_NPEID_MAX] =
92 {FALSE, {IX_NPEDL_NPEID_MAX, 0, 0, 0}},
93 {FALSE, {IX_NPEDL_NPEID_MAX, 0, 0, 0}},
94 {FALSE, {IX_NPEDL_NPEID_MAX, 0, 0, 0}}
97 static IxNpeDlStats ixNpeDlStats;
100 * Software guard to prevent NPE from being started multiple times.
102 static BOOL ixNpeDlNpeStarted[IX_NPEDL_NPEID_MAX] ={FALSE, FALSE, FALSE} ;
106 * static function prototypes.
109 ixNpeDlNpeInitAndStartInternal (UINT32 *imageLibrary, UINT32 imageId);
112 * Function definition: ixNpeDlMicrocodeImageLibraryOverride
115 ixNpeDlMicrocodeImageLibraryOverride (UINT32 *clientImageLibrary)
117 IX_STATUS status = IX_SUCCESS;
119 IX_NPEDL_TRACE0 (IX_NPEDL_FN_ENTRY_EXIT,
120 "Entering ixNpeDlMicrocodeImageLibraryOverride\n");
122 if (clientImageLibrary == NULL)
124 status = IX_NPEDL_PARAM_ERR;
125 IX_NPEDL_ERROR_REPORT ("ixNpeDlMicrocodeImageLibraryOverride - "
126 "invalid parameter\n");
130 status = ixNpeDlImageMgrMicrocodeImageLibraryOverride (clientImageLibrary);
131 if (status != IX_SUCCESS)
135 } /* end of if-else(clientImageLibrary) */
137 IX_NPEDL_TRACE1 (IX_NPEDL_FN_ENTRY_EXIT,
138 "Exiting ixNpeDlMicrocodeImageLibraryOverride : "
139 "status = %d\n", status);
144 * Function definition: ixNpeDlImageDownload
147 ixNpeDlImageDownload (IxNpeDlImageId *imageIdPtr,
151 UINT32 *imageCodePtr = NULL;
153 IxNpeDlNpeId npeId = imageIdPtr->npeId;
155 IX_NPEDL_TRACE0 (IX_NPEDL_FN_ENTRY_EXIT,
156 "Entering ixNpeDlImageDownload\n");
158 ixNpeDlStats.attemptedDownloads++;
160 /* Check input parameters */
161 if ((npeId >= IX_NPEDL_NPEID_MAX) || (npeId < 0))
163 status = IX_NPEDL_PARAM_ERR;
164 IX_NPEDL_ERROR_REPORT ("ixNpeDlImageDownload - invalid parameter\n");
168 /* Ensure initialisation has been completed */
171 /* If not IXP42X A0 stepping, proceed to check for existence of npe's */
172 if ((IX_FEATURE_CTRL_SILICON_TYPE_A0 !=
173 (ixFeatureCtrlProductIdRead() & IX_FEATURE_CTRL_SILICON_STEPPING_MASK))
174 || (IX_FEATURE_CTRL_DEVICE_TYPE_IXP42X != ixFeatureCtrlDeviceRead ()))
176 if (npeId == IX_NPEDL_NPEID_NPEA)
178 if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEA) ==
179 IX_FEATURE_CTRL_COMPONENT_DISABLED)
181 IX_NPEDL_WARNING_REPORT("Warning: the NPE A component you specified does"
185 } /* end of if(npeId) */
186 else if (npeId == IX_NPEDL_NPEID_NPEB)
188 if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEB)==
189 IX_FEATURE_CTRL_COMPONENT_DISABLED)
191 IX_NPEDL_WARNING_REPORT("Warning: the NPE B component you specified"
192 " does not exist\n");
195 } /* end of elseif(npeId) */
196 else if (npeId == IX_NPEDL_NPEID_NPEC)
198 if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEC)==
199 IX_FEATURE_CTRL_COMPONENT_DISABLED)
201 IX_NPEDL_WARNING_REPORT("Warning: the NPE C component you specified"
202 " does not exist\n");
205 } /* end of elseif(npeId) */
206 } /* end of if(IX_FEATURE_CTRL_SILICON_TYPE_B0) */ /*End of Silicon Type Check*/
208 /* stop and reset the NPE */
209 if (IX_SUCCESS != ixNpeDlNpeStopAndReset (npeId))
211 IX_NPEDL_ERROR_REPORT ("Failed to stop and reset NPE\n");
216 status = ixNpeDlImageMgrImageLocate (imageIdPtr, &imageCodePtr,
218 if (IX_SUCCESS == status)
221 * If download was successful, store image Id in list of
222 * currently loaded images. If a critical error occured
223 * during download, record that the NPE has an invalid image
225 status = ixNpeDlNpeMgrImageLoad (npeId, imageCodePtr,
227 if (IX_SUCCESS == status)
229 ixNpeDlNpeState[npeId].imageId = *imageIdPtr;
230 ixNpeDlNpeState[npeId].validImage = TRUE;
231 ixNpeDlStats.successfulDownloads++;
233 status = ixNpeDlNpeExecutionStart (npeId);
235 else if ((status == IX_NPEDL_CRITICAL_NPE_ERR) ||
236 (status == IX_NPEDL_CRITICAL_MICROCODE_ERR))
238 ixNpeDlNpeState[npeId].imageId = *imageIdPtr;
239 ixNpeDlNpeState[npeId].validImage = FALSE;
240 ixNpeDlStats.criticalFailDownloads++;
242 } /* end of if(IX_SUCCESS) */ /* condition: image located successfully in microcode image */
243 } /* end of if-else(npeId) */ /* condition: parameter checks ok */
245 IX_NPEDL_TRACE1 (IX_NPEDL_FN_ENTRY_EXIT,
246 "Exiting ixNpeDlImageDownload : status = %d\n", status);
251 * Function definition: ixNpeDlAvailableImagesCountGet
254 ixNpeDlAvailableImagesCountGet (UINT32 *numImagesPtr)
258 IX_NPEDL_TRACE0 (IX_NPEDL_FN_ENTRY_EXIT,
259 "Entering ixNpeDlAvailableImagesCountGet\n");
261 /* Check input parameters */
262 if (numImagesPtr == NULL)
264 status = IX_NPEDL_PARAM_ERR;
265 IX_NPEDL_ERROR_REPORT ("ixNpeDlAvailableImagesCountGet - "
266 "invalid parameter\n");
271 * Use ImageMgr module to get no. of images listed in Image Library Header.
272 * If NULL is passed as imageListPtr parameter to following function,
273 * it will only fill number of images into numImagesPtr
275 status = ixNpeDlImageMgrImageListExtract (NULL, numImagesPtr);
276 } /* end of if-else(numImagesPtr) */
278 IX_NPEDL_TRACE1 (IX_NPEDL_FN_ENTRY_EXIT,
279 "Exiting ixNpeDlAvailableImagesCountGet : "
280 "status = %d\n", status);
285 * Function definition: ixNpeDlAvailableImagesListGet
288 ixNpeDlAvailableImagesListGet (IxNpeDlImageId *imageIdListPtr,
293 IX_NPEDL_TRACE0 (IX_NPEDL_FN_ENTRY_EXIT,
294 "Entering ixNpeDlAvailableImagesListGet\n");
296 /* Check input parameters */
297 if ((imageIdListPtr == NULL) || (listSizePtr == NULL))
299 status = IX_NPEDL_PARAM_ERR;
300 IX_NPEDL_ERROR_REPORT ("ixNpeDlAvailableImagesListGet - "
301 "invalid parameter\n");
305 /* Call ImageMgr to get list of images listed in Image Library Header */
306 status = ixNpeDlImageMgrImageListExtract (imageIdListPtr,
308 } /* end of if-else(imageIdListPtr) */
310 IX_NPEDL_TRACE1 (IX_NPEDL_FN_ENTRY_EXIT,
311 "Exiting ixNpeDlAvailableImagesListGet : status = %d\n",
317 * Function definition: ixNpeDlLoadedImageGet
320 ixNpeDlLoadedImageGet (IxNpeDlNpeId npeId,
321 IxNpeDlImageId *imageIdPtr)
323 IX_STATUS status = IX_SUCCESS;
325 IX_NPEDL_TRACE0 (IX_NPEDL_FN_ENTRY_EXIT,
326 "Entering ixNpeDlLoadedImageGet\n");
328 /* Check input parameters */
329 if ((npeId >= IX_NPEDL_NPEID_MAX) || (npeId < 0) || (imageIdPtr == NULL))
331 status = IX_NPEDL_PARAM_ERR;
332 IX_NPEDL_ERROR_REPORT ("ixNpeDlLoadedImageGet - invalid parameter\n");
337 /* If not IXP42X A0 stepping, proceed to check for existence of npe's */
338 if ((IX_FEATURE_CTRL_SILICON_TYPE_A0 !=
339 (ixFeatureCtrlProductIdRead() & IX_FEATURE_CTRL_SILICON_STEPPING_MASK))
340 || (IX_FEATURE_CTRL_DEVICE_TYPE_IXP42X != ixFeatureCtrlDeviceRead ()))
342 if (npeId == IX_NPEDL_NPEID_NPEA &&
343 (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEA) ==
344 IX_FEATURE_CTRL_COMPONENT_DISABLED))
346 IX_NPEDL_WARNING_REPORT("Warning: the NPE A component you specified does"
349 } /* end of if(npeId) */
351 if (npeId == IX_NPEDL_NPEID_NPEB &&
352 (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEB) ==
353 IX_FEATURE_CTRL_COMPONENT_DISABLED))
355 IX_NPEDL_WARNING_REPORT("Warning: the NPE B component you specified does"
358 } /* end of if(npeId) */
360 if (npeId == IX_NPEDL_NPEID_NPEC &&
361 (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEC) ==
362 IX_FEATURE_CTRL_COMPONENT_DISABLED))
364 IX_NPEDL_WARNING_REPORT("Warning: the NPE C component you specified does"
367 } /* end of if(npeId) */
368 } /* end of if not IXP42x-A0 silicon */
370 if (ixNpeDlNpeState[npeId].validImage)
372 /* use npeId to get imageId from list of currently loaded
374 *imageIdPtr = ixNpeDlNpeState[npeId].imageId;
379 } /* end of if-else(ixNpeDlNpeState) */
380 } /* end of if-else(npeId) */
382 IX_NPEDL_TRACE1 (IX_NPEDL_FN_ENTRY_EXIT,
383 "Exiting ixNpeDlLoadedImageGet : status = %d\n",
389 * Function definition: ixNpeDlLatestImageGet
392 ixNpeDlLatestImageGet (
394 IxNpeDlFunctionalityId functionalityId,
395 IxNpeDlImageId *imageIdPtr)
399 IX_NPEDL_TRACE0 (IX_NPEDL_FN_ENTRY_EXIT,
400 "Entering ixNpeDlLatestImageGet\n");
402 /* Check input parameters */
403 if ((npeId >= IX_NPEDL_NPEID_MAX) ||
405 (imageIdPtr == NULL))
407 status = IX_NPEDL_PARAM_ERR;
408 IX_NPEDL_ERROR_REPORT ("ixNpeDlLatestImageGet - "
409 "invalid parameter\n");
410 } /* end of if(npeId) */
414 /* If not IXP42X A0 stepping, proceed to check for existence of npe's */
415 if ((IX_FEATURE_CTRL_SILICON_TYPE_A0 !=
416 (ixFeatureCtrlProductIdRead() & IX_FEATURE_CTRL_SILICON_STEPPING_MASK))
417 || (IX_FEATURE_CTRL_DEVICE_TYPE_IXP42X != ixFeatureCtrlDeviceRead ()))
419 if (npeId == IX_NPEDL_NPEID_NPEA &&
420 (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEA) ==
421 IX_FEATURE_CTRL_COMPONENT_DISABLED))
423 IX_NPEDL_WARNING_REPORT("Warning: the NPE A component you specified does"
426 } /* end of if(npeId) */
428 if (npeId == IX_NPEDL_NPEID_NPEB &&
429 (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEB) ==
430 IX_FEATURE_CTRL_COMPONENT_DISABLED))
432 IX_NPEDL_WARNING_REPORT("Warning: the NPE B component you specified does"
435 } /* end of if(npeId) */
437 if (npeId == IX_NPEDL_NPEID_NPEC &&
438 (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEC) ==
439 IX_FEATURE_CTRL_COMPONENT_DISABLED))
441 IX_NPEDL_WARNING_REPORT("Warning: the NPE C component you specified does"
444 } /* end of if(npeId) */
445 } /* end of if not IXP42x-A0 silicon */
447 imageIdPtr->npeId = npeId;
448 imageIdPtr->functionalityId = functionalityId;
449 imageIdPtr->major = IMAGEID_MAJOR_NUMBER_DEFAULT;
450 imageIdPtr->minor = IMAGEID_MINOR_NUMBER_DEFAULT;
451 /* Call ImageMgr to get list of images listed in Image Library Header */
452 status = ixNpeDlImageMgrLatestImageExtract(imageIdPtr);
453 } /* end of if-else(npeId) */
455 IX_NPEDL_TRACE1 (IX_NPEDL_FN_ENTRY_EXIT,
456 "Exiting ixNpeDlLatestImageGet : status = %d\n",
463 * Function definition: ixNpeDlNpeStopAndReset
466 ixNpeDlNpeStopAndReset (IxNpeDlNpeId npeId)
468 IX_STATUS status = IX_SUCCESS;
470 IX_NPEDL_TRACE0 (IX_NPEDL_FN_ENTRY_EXIT,
471 "Entering ixNpeDlNpeStopAndReset\n");
473 /* Ensure initialisation has been completed */
476 /* If not IXP42X A0 stepping, proceed to check for existence of npe's */
477 if ((IX_FEATURE_CTRL_SILICON_TYPE_A0 !=
478 (ixFeatureCtrlProductIdRead() & IX_FEATURE_CTRL_SILICON_STEPPING_MASK))
479 || (IX_FEATURE_CTRL_DEVICE_TYPE_IXP42X != ixFeatureCtrlDeviceRead ()))
482 * Check whether NPE is present
484 if (IX_NPEDL_NPEID_NPEA == npeId)
486 /* Check whether NPE A is present */
487 if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEA)==
488 IX_FEATURE_CTRL_COMPONENT_DISABLED)
490 /* NPE A does not present */
491 IX_NPEDL_WARNING_REPORT ("ixNpeDlNpeStopAndReset - Warning:NPEA does not present.\n");
494 } /* end of if(IX_NPEDL_NPEID_NPEA) */
495 else if (IX_NPEDL_NPEID_NPEB == npeId)
497 /* Check whether NPE B is present */
498 if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEB)==
499 IX_FEATURE_CTRL_COMPONENT_DISABLED)
501 /* NPE B does not present */
502 IX_NPEDL_WARNING_REPORT ("ixNpeDlNpeStopAndReset - Warning:NPEB does not present.\n");
505 } /* end of elseif(IX_NPEDL_NPEID_NPEB) */
506 else if (IX_NPEDL_NPEID_NPEC == npeId)
508 /* Check whether NPE C is present */
509 if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEC)==
510 IX_FEATURE_CTRL_COMPONENT_DISABLED)
512 /* NPE C does not present */
513 IX_NPEDL_WARNING_REPORT ("ixNpeDlNpeStopAndReset - Warning:NPEC does not present.\n");
516 } /* end of elseif(IX_NPEDL_NPEID_NPEC) */
520 IX_NPEDL_ERROR_REPORT ("ixNpeDlNpeStopAndReset - invalid Npe ID\n");
521 status = IX_NPEDL_PARAM_ERR;
522 } /* end of if-else(IX_NPEDL_NPEID_NPEC) */
523 } /* end of if not IXP42x-A0 Silicon */
525 if (status == IX_SUCCESS)
527 /* call NpeMgr function to stop the NPE */
528 status = ixNpeDlNpeMgrNpeStop (npeId);
529 if (status == IX_SUCCESS)
531 /* call NpeMgr function to reset the NPE */
532 status = ixNpeDlNpeMgrNpeReset (npeId);
534 } /* end of if(status) */
536 IX_NPEDL_TRACE1 (IX_NPEDL_FN_ENTRY_EXIT,
537 "Exiting ixNpeDlNpeStopAndReset : status = %d\n", status);
539 if (IX_SUCCESS == status)
541 /* Indicate NPE has been stopped */
542 ixNpeDlNpeStarted[npeId] = FALSE ;
549 * Function definition: ixNpeDlNpeExecutionStart
552 ixNpeDlNpeExecutionStart (IxNpeDlNpeId npeId)
554 IX_STATUS status = IX_SUCCESS;
556 IX_NPEDL_TRACE0 (IX_NPEDL_FN_ENTRY_EXIT,
557 "Entering ixNpeDlNpeExecutionStart\n");
559 /* If not IXP42X A0 stepping, proceed to check for existence of npe's */
560 if ((IX_FEATURE_CTRL_SILICON_TYPE_A0 !=
561 (ixFeatureCtrlProductIdRead() & IX_FEATURE_CTRL_SILICON_STEPPING_MASK))
562 || (IX_FEATURE_CTRL_DEVICE_TYPE_IXP42X != ixFeatureCtrlDeviceRead ()))
565 * Check whether NPE is present
567 if (IX_NPEDL_NPEID_NPEA == npeId)
569 /* Check whether NPE A is present */
570 if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEA)==
571 IX_FEATURE_CTRL_COMPONENT_DISABLED)
573 /* NPE A does not present */
574 IX_NPEDL_WARNING_REPORT ("ixNpeDlNpeExecutionStart - Warning:NPEA does not present.\n");
577 } /* end of if(IX_NPEDL_NPEID_NPEA) */
578 else if (IX_NPEDL_NPEID_NPEB == npeId)
580 /* Check whether NPE B is present */
581 if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEB)==
582 IX_FEATURE_CTRL_COMPONENT_DISABLED)
584 /* NPE B does not present */
585 IX_NPEDL_WARNING_REPORT ("ixNpeDlNpeExecutionStart - Warning:NPEB does not present.\n");
588 } /* end of elseif(IX_NPEDL_NPEID_NPEB) */
589 else if (IX_NPEDL_NPEID_NPEC == npeId)
591 /* Check whether NPE C is present */
592 if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEC)==
593 IX_FEATURE_CTRL_COMPONENT_DISABLED)
595 /* NPE C does not present */
596 IX_NPEDL_WARNING_REPORT ("ixNpeDlNpeExecutionStart - Warning:NPEC does not present.\n");
599 } /* end of elseif(IX_NPEDL_NPEID_NPEC) */
603 IX_NPEDL_ERROR_REPORT ("ixNpeDlNpeExecutionStart - invalid Npe ID\n");
604 return IX_NPEDL_PARAM_ERR;
605 } /* end of if-else(IX_NPEDL_NPEID_NPEC) */
606 } /* end of if not IXP42x-A0 Silicon */
608 if (TRUE == ixNpeDlNpeStarted[npeId])
610 /* NPE has been started. */
614 /* Ensure initialisation has been completed */
617 /* call NpeMgr function to start the NPE */
618 status = ixNpeDlNpeMgrNpeStart (npeId);
620 if (IX_SUCCESS == status)
622 /* Indicate NPE has started */
623 ixNpeDlNpeStarted[npeId] = TRUE ;
626 IX_NPEDL_TRACE1 (IX_NPEDL_FN_ENTRY_EXIT,
627 "Exiting ixNpeDlNpeExecutionStart : status = %d\n",
634 * Function definition: ixNpeDlNpeExecutionStop
637 ixNpeDlNpeExecutionStop (IxNpeDlNpeId npeId)
639 IX_STATUS status = IX_SUCCESS;
641 IX_NPEDL_TRACE0 (IX_NPEDL_FN_ENTRY_EXIT,
642 "Entering ixNpeDlNpeExecutionStop\n");
644 /* Ensure initialisation has been completed */
647 /* If not IXP42X A0 stepping, proceed to check for existence of npe's */
648 if ((IX_FEATURE_CTRL_SILICON_TYPE_A0 !=
649 (ixFeatureCtrlProductIdRead() & IX_FEATURE_CTRL_SILICON_STEPPING_MASK))
650 || (IX_FEATURE_CTRL_DEVICE_TYPE_IXP42X != ixFeatureCtrlDeviceRead ()))
653 * Check whether NPE is present
655 if (IX_NPEDL_NPEID_NPEA == npeId)
657 /* Check whether NPE A is present */
658 if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEA)==
659 IX_FEATURE_CTRL_COMPONENT_DISABLED)
661 /* NPE A does not present */
662 IX_NPEDL_WARNING_REPORT ("ixNpeDlNpeExecutionStop - Warning:NPEA does not present.\n");
665 } /* end of if(IX_NPEDL_NPEID_NPEA) */
666 else if (IX_NPEDL_NPEID_NPEB == npeId)
668 /* Check whether NPE B is present */
669 if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEB)==
670 IX_FEATURE_CTRL_COMPONENT_DISABLED)
672 /* NPE B does not present */
673 IX_NPEDL_WARNING_REPORT ("ixNpeDlNpeExecutionStop - Warning:NPEB does not present.\n");
676 } /* end of elseif(IX_NPEDL_NPEID_NPEB) */
677 else if (IX_NPEDL_NPEID_NPEC == npeId)
679 /* Check whether NPE C is present */
680 if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEC)==
681 IX_FEATURE_CTRL_COMPONENT_DISABLED)
683 /* NPE C does not present */
684 IX_NPEDL_WARNING_REPORT ("ixNpeDlNpeExecutionStop - Warning:NPEC does not present.\n");
687 } /* end of elseif(IX_NPEDL_NPEID_NPEC) */
691 IX_NPEDL_ERROR_REPORT ("ixNpeDlNpeExecutionStop - invalid Npe ID\n");
692 status = IX_NPEDL_PARAM_ERR;
693 } /* end of if-else(IX_NPEDL_NPEID_NPEC) */
694 } /* end of if not IXP42X-AO Silicon */
696 if (status == IX_SUCCESS)
698 /* call NpeMgr function to stop the NPE */
699 status = ixNpeDlNpeMgrNpeStop (npeId);
702 IX_NPEDL_TRACE1 (IX_NPEDL_FN_ENTRY_EXIT,
703 "Exiting ixNpeDlNpeExecutionStop : status = %d\n",
706 if (IX_SUCCESS == status)
708 /* Indicate NPE has been stopped */
709 ixNpeDlNpeStarted[npeId] = FALSE ;
716 * Function definition: ixNpeDlUnload
723 IX_NPEDL_TRACE0 (IX_NPEDL_FN_ENTRY_EXIT,
724 "Entering ixNpeDlUnload\n");
726 status = ixNpeDlNpeMgrUninit();
728 IX_NPEDL_TRACE1 (IX_NPEDL_FN_ENTRY_EXIT,
729 "Exiting ixNpeDlUnload : status = %d\n",
735 * Function definition: ixNpeDlStatsShow
738 ixNpeDlStatsShow (void)
740 ixOsalLog (IX_OSAL_LOG_LVL_USER,
741 IX_OSAL_LOG_DEV_STDOUT,
742 "\nixNpeDlStatsShow:\n"
743 "\tDownloads Attempted by user: %u\n"
744 "\tSuccessful Downloads: %u\n"
745 "\tFailed Downloads (due to Critical Error): %u\n\n",
746 ixNpeDlStats.attemptedDownloads,
747 ixNpeDlStats.successfulDownloads,
748 ixNpeDlStats.criticalFailDownloads,
751 ixNpeDlImageMgrStatsShow ();
752 ixNpeDlNpeMgrStatsShow ();
756 * Function definition: ixNpeDlStatsReset
759 ixNpeDlStatsReset (void)
761 ixNpeDlStats.attemptedDownloads = 0;
762 ixNpeDlStats.successfulDownloads = 0;
763 ixNpeDlStats.criticalFailDownloads = 0;
765 ixNpeDlImageMgrStatsReset ();
766 ixNpeDlNpeMgrStatsReset ();
770 * Function definition: ixNpeDlNpeInitAndStartInternal
773 ixNpeDlNpeInitAndStartInternal (UINT32 *imageLibrary,
777 UINT32 *imageCodePtr = NULL;
779 IxNpeDlNpeId npeId = IX_NPEDL_NPEID_FROM_IMAGEID_GET(imageId);
780 IxFeatureCtrlDeviceId deviceId = IX_NPEDL_DEVICEID_FROM_IMAGEID_GET(imageId);
782 IX_NPEDL_TRACE0 (IX_NPEDL_FN_ENTRY_EXIT,
783 "Entering ixNpeDlNpeInitAndStartInternal\n");
785 ixNpeDlStats.attemptedDownloads++;
787 /* Check input parameter device correctness */
788 if ((deviceId >= IX_FEATURE_CTRL_DEVICE_TYPE_MAX) ||
789 (deviceId < IX_FEATURE_CTRL_DEVICE_TYPE_IXP42X))
791 status = IX_NPEDL_PARAM_ERR;
792 IX_NPEDL_ERROR_REPORT ("ixNpeDlNpeInitAndStartInternal - "
793 "invalid parameter\n");
794 } /* End valid device id checking */
796 /* Check input parameters */
797 else if ((npeId >= IX_NPEDL_NPEID_MAX) || (npeId < 0))
799 status = IX_NPEDL_PARAM_ERR;
800 IX_NPEDL_ERROR_REPORT ("ixNpeDlNpeInitAndStartInternal - "
801 "invalid parameter\n");
806 /* Ensure initialisation has been completed */
809 /* Checking if image being loaded is meant for device that is running.
810 * Image is forward compatible. i.e Image built for IXP42X should run
811 * on IXP46X but not vice versa.*/
812 if (deviceId > (ixFeatureCtrlDeviceRead() & IX_FEATURE_CTRL_DEVICE_TYPE_MASK))
814 IX_NPEDL_ERROR_REPORT ("ixNpeDlNpeInitAndStartInternal - "
815 "Device type mismatch. NPE Image not "
816 "meant for device in use \n");
817 return IX_NPEDL_DEVICE_ERR;
818 }/* if statement - matching image device and current device */
820 /* If not IXP42X A0 stepping, proceed to check for existence of npe's */
821 if ((IX_FEATURE_CTRL_SILICON_TYPE_A0 !=
822 (ixFeatureCtrlProductIdRead() & IX_FEATURE_CTRL_SILICON_STEPPING_MASK))
823 || (IX_FEATURE_CTRL_DEVICE_TYPE_IXP42X != ixFeatureCtrlDeviceRead ()))
825 if (npeId == IX_NPEDL_NPEID_NPEA)
827 if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEA) ==
828 IX_FEATURE_CTRL_COMPONENT_DISABLED)
830 IX_NPEDL_WARNING_REPORT("Warning: the NPE A component you specified does"
834 } /* end of if(npeId) */
835 else if (npeId == IX_NPEDL_NPEID_NPEB)
837 if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEB)==
838 IX_FEATURE_CTRL_COMPONENT_DISABLED)
840 IX_NPEDL_WARNING_REPORT("Warning: the NPE B component you specified"
841 " does not exist\n");
844 } /* end of elseif(npeId) */
845 else if (npeId == IX_NPEDL_NPEID_NPEC)
847 if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEC)==
848 IX_FEATURE_CTRL_COMPONENT_DISABLED)
850 IX_NPEDL_WARNING_REPORT("Warning: the NPE C component you specified"
851 " does not exist\n");
854 } /* end of elseif(npeId) */
855 } /* end of if not IXP42X-A0 Silicon */
857 /* stop and reset the NPE */
858 status = ixNpeDlNpeStopAndReset (npeId);
859 if (IX_SUCCESS != status)
861 IX_NPEDL_ERROR_REPORT ("Failed to stop and reset NPE\n");
866 status = ixNpeDlImageMgrImageFind (imageLibrary, imageId,
867 &imageCodePtr, &imageSize);
868 if (IX_SUCCESS == status)
871 * If download was successful, store image Id in list of
872 * currently loaded images. If a critical error occured
873 * during download, record that the NPE has an invalid image
875 status = ixNpeDlNpeMgrImageLoad (npeId, imageCodePtr, TRUE);
876 if (IX_SUCCESS == status)
878 ixNpeDlNpeState[npeId].validImage = TRUE;
879 ixNpeDlStats.successfulDownloads++;
881 status = ixNpeDlNpeExecutionStart (npeId);
883 else if ((status == IX_NPEDL_CRITICAL_NPE_ERR) ||
884 (status == IX_NPEDL_CRITICAL_MICROCODE_ERR))
886 ixNpeDlNpeState[npeId].validImage = FALSE;
887 ixNpeDlStats.criticalFailDownloads++;
890 /* NOTE - The following section of code is here to support
891 * a deprecated function ixNpeDlLoadedImageGet(). When that
892 * function is removed from the API, this code should be revised.
894 ixNpeDlNpeState[npeId].imageId.npeId = npeId;
895 ixNpeDlNpeState[npeId].imageId.functionalityId =
896 IX_NPEDL_FUNCTIONID_FROM_IMAGEID_GET(imageId);
897 ixNpeDlNpeState[npeId].imageId.major =
898 IX_NPEDL_MAJOR_FROM_IMAGEID_GET(imageId);
899 ixNpeDlNpeState[npeId].imageId.minor =
900 IX_NPEDL_MINOR_FROM_IMAGEID_GET(imageId);
901 } /* end of if(IX_SUCCESS) */ /* condition: image located successfully in microcode image */
902 } /* end of if-else(npeId-deviceId) */ /* condition: parameter checks ok */
904 IX_NPEDL_TRACE1 (IX_NPEDL_FN_ENTRY_EXIT,
905 "Exiting ixNpeDlNpeInitAndStartInternal : "
906 "status = %d\n", status);
911 * Function definition: ixNpeDlCustomImageNpeInitAndStart
914 ixNpeDlCustomImageNpeInitAndStart (UINT32 *imageLibrary,
919 if (imageLibrary == NULL)
921 status = IX_NPEDL_PARAM_ERR;
922 IX_NPEDL_ERROR_REPORT ("ixNpeDlCustomImageNpeInitAndStart "
923 "- invalid parameter\n");
927 status = ixNpeDlNpeInitAndStartInternal (imageLibrary, imageId);
928 } /* end of if-else(imageLibrary) */
934 * Function definition: ixNpeDlNpeInitAndStart
937 ixNpeDlNpeInitAndStart (UINT32 imageId)
939 return ixNpeDlNpeInitAndStartInternal (NULL, imageId);
943 * Function definition: ixNpeDlLoadedImageFunctionalityGet
946 ixNpeDlLoadedImageFunctionalityGet (IxNpeDlNpeId npeId,
947 UINT8 *functionalityId)
949 /* Check input parameters */
950 if ((npeId >= IX_NPEDL_NPEID_MAX) || (npeId < 0))
952 IX_NPEDL_ERROR_REPORT ("ixNpeDlLoadedImageFunctionalityGet "
953 "- invalid parameter\n");
954 return IX_NPEDL_PARAM_ERR;
956 if (functionalityId == NULL)
958 IX_NPEDL_ERROR_REPORT ("ixNpeDlLoadedImageFunctionalityGet "
959 "- invalid parameter\n");
960 return IX_NPEDL_PARAM_ERR;
963 if (ixNpeDlNpeState[npeId].validImage)
965 *functionalityId = ixNpeDlNpeState[npeId].imageId.functionalityId;