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: ixNpeDlImageDownload
115 ixNpeDlImageDownload (IxNpeDlImageId
*imageIdPtr
,
119 UINT32
*imageCodePtr
= NULL
;
121 IxNpeDlNpeId npeId
= imageIdPtr
->npeId
;
123 IX_NPEDL_TRACE0 (IX_NPEDL_FN_ENTRY_EXIT
,
124 "Entering ixNpeDlImageDownload\n");
126 ixNpeDlStats
.attemptedDownloads
++;
128 /* Check input parameters */
129 if ((npeId
>= IX_NPEDL_NPEID_MAX
) || (npeId
< 0))
131 status
= IX_NPEDL_PARAM_ERR
;
132 IX_NPEDL_ERROR_REPORT ("ixNpeDlImageDownload - invalid parameter\n");
136 /* Ensure initialisation has been completed */
139 /* If not IXP42X A0 stepping, proceed to check for existence of npe's */
140 if ((IX_FEATURE_CTRL_SILICON_TYPE_A0
!=
141 (ixFeatureCtrlProductIdRead() & IX_FEATURE_CTRL_SILICON_STEPPING_MASK
))
142 || (IX_FEATURE_CTRL_DEVICE_TYPE_IXP42X
!= ixFeatureCtrlDeviceRead ()))
144 if (npeId
== IX_NPEDL_NPEID_NPEA
)
146 if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEA
) ==
147 IX_FEATURE_CTRL_COMPONENT_DISABLED
)
149 IX_NPEDL_WARNING_REPORT("Warning: the NPE A component you specified does"
153 } /* end of if(npeId) */
154 else if (npeId
== IX_NPEDL_NPEID_NPEB
)
156 if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEB
)==
157 IX_FEATURE_CTRL_COMPONENT_DISABLED
)
159 IX_NPEDL_WARNING_REPORT("Warning: the NPE B component you specified"
160 " does not exist\n");
163 } /* end of elseif(npeId) */
164 else if (npeId
== IX_NPEDL_NPEID_NPEC
)
166 if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEC
)==
167 IX_FEATURE_CTRL_COMPONENT_DISABLED
)
169 IX_NPEDL_WARNING_REPORT("Warning: the NPE C component you specified"
170 " does not exist\n");
173 } /* end of elseif(npeId) */
174 } /* end of if(IX_FEATURE_CTRL_SILICON_TYPE_B0) */ /*End of Silicon Type Check*/
176 /* stop and reset the NPE */
177 if (IX_SUCCESS
!= ixNpeDlNpeStopAndReset (npeId
))
179 IX_NPEDL_ERROR_REPORT ("Failed to stop and reset NPE\n");
184 status
= ixNpeDlImageMgrImageLocate (imageIdPtr
, &imageCodePtr
,
186 if (IX_SUCCESS
== status
)
189 * If download was successful, store image Id in list of
190 * currently loaded images. If a critical error occured
191 * during download, record that the NPE has an invalid image
193 status
= ixNpeDlNpeMgrImageLoad (npeId
, imageCodePtr
,
195 if (IX_SUCCESS
== status
)
197 ixNpeDlNpeState
[npeId
].imageId
= *imageIdPtr
;
198 ixNpeDlNpeState
[npeId
].validImage
= true;
199 ixNpeDlStats
.successfulDownloads
++;
201 status
= ixNpeDlNpeExecutionStart (npeId
);
203 else if ((status
== IX_NPEDL_CRITICAL_NPE_ERR
) ||
204 (status
== IX_NPEDL_CRITICAL_MICROCODE_ERR
))
206 ixNpeDlNpeState
[npeId
].imageId
= *imageIdPtr
;
207 ixNpeDlNpeState
[npeId
].validImage
= false;
208 ixNpeDlStats
.criticalFailDownloads
++;
210 } /* end of if(IX_SUCCESS) */ /* condition: image located successfully in microcode image */
211 } /* end of if-else(npeId) */ /* condition: parameter checks ok */
213 IX_NPEDL_TRACE1 (IX_NPEDL_FN_ENTRY_EXIT
,
214 "Exiting ixNpeDlImageDownload : status = %d\n", status
);
219 * Function definition: ixNpeDlAvailableImagesCountGet
222 ixNpeDlAvailableImagesCountGet (UINT32
*numImagesPtr
)
226 IX_NPEDL_TRACE0 (IX_NPEDL_FN_ENTRY_EXIT
,
227 "Entering ixNpeDlAvailableImagesCountGet\n");
229 /* Check input parameters */
230 if (numImagesPtr
== NULL
)
232 status
= IX_NPEDL_PARAM_ERR
;
233 IX_NPEDL_ERROR_REPORT ("ixNpeDlAvailableImagesCountGet - "
234 "invalid parameter\n");
239 * Use ImageMgr module to get no. of images listed in Image Library Header.
240 * If NULL is passed as imageListPtr parameter to following function,
241 * it will only fill number of images into numImagesPtr
243 status
= ixNpeDlImageMgrImageListExtract (NULL
, numImagesPtr
);
244 } /* end of if-else(numImagesPtr) */
246 IX_NPEDL_TRACE1 (IX_NPEDL_FN_ENTRY_EXIT
,
247 "Exiting ixNpeDlAvailableImagesCountGet : "
248 "status = %d\n", status
);
253 * Function definition: ixNpeDlAvailableImagesListGet
256 ixNpeDlAvailableImagesListGet (IxNpeDlImageId
*imageIdListPtr
,
261 IX_NPEDL_TRACE0 (IX_NPEDL_FN_ENTRY_EXIT
,
262 "Entering ixNpeDlAvailableImagesListGet\n");
264 /* Check input parameters */
265 if ((imageIdListPtr
== NULL
) || (listSizePtr
== NULL
))
267 status
= IX_NPEDL_PARAM_ERR
;
268 IX_NPEDL_ERROR_REPORT ("ixNpeDlAvailableImagesListGet - "
269 "invalid parameter\n");
273 /* Call ImageMgr to get list of images listed in Image Library Header */
274 status
= ixNpeDlImageMgrImageListExtract (imageIdListPtr
,
276 } /* end of if-else(imageIdListPtr) */
278 IX_NPEDL_TRACE1 (IX_NPEDL_FN_ENTRY_EXIT
,
279 "Exiting ixNpeDlAvailableImagesListGet : status = %d\n",
285 * Function definition: ixNpeDlLoadedImageGet
288 ixNpeDlLoadedImageGet (IxNpeDlNpeId npeId
,
289 IxNpeDlImageId
*imageIdPtr
)
291 IX_STATUS status
= IX_SUCCESS
;
293 IX_NPEDL_TRACE0 (IX_NPEDL_FN_ENTRY_EXIT
,
294 "Entering ixNpeDlLoadedImageGet\n");
296 /* Check input parameters */
297 if ((npeId
>= IX_NPEDL_NPEID_MAX
) || (npeId
< 0) || (imageIdPtr
== NULL
))
299 status
= IX_NPEDL_PARAM_ERR
;
300 IX_NPEDL_ERROR_REPORT ("ixNpeDlLoadedImageGet - invalid parameter\n");
305 /* If not IXP42X A0 stepping, proceed to check for existence of npe's */
306 if ((IX_FEATURE_CTRL_SILICON_TYPE_A0
!=
307 (ixFeatureCtrlProductIdRead() & IX_FEATURE_CTRL_SILICON_STEPPING_MASK
))
308 || (IX_FEATURE_CTRL_DEVICE_TYPE_IXP42X
!= ixFeatureCtrlDeviceRead ()))
310 if (npeId
== IX_NPEDL_NPEID_NPEA
&&
311 (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEA
) ==
312 IX_FEATURE_CTRL_COMPONENT_DISABLED
))
314 IX_NPEDL_WARNING_REPORT("Warning: the NPE A component you specified does"
317 } /* end of if(npeId) */
319 if (npeId
== IX_NPEDL_NPEID_NPEB
&&
320 (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEB
) ==
321 IX_FEATURE_CTRL_COMPONENT_DISABLED
))
323 IX_NPEDL_WARNING_REPORT("Warning: the NPE B component you specified does"
326 } /* end of if(npeId) */
328 if (npeId
== IX_NPEDL_NPEID_NPEC
&&
329 (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEC
) ==
330 IX_FEATURE_CTRL_COMPONENT_DISABLED
))
332 IX_NPEDL_WARNING_REPORT("Warning: the NPE C component you specified does"
335 } /* end of if(npeId) */
336 } /* end of if not IXP42x-A0 silicon */
338 if (ixNpeDlNpeState
[npeId
].validImage
)
340 /* use npeId to get imageId from list of currently loaded
342 *imageIdPtr
= ixNpeDlNpeState
[npeId
].imageId
;
347 } /* end of if-else(ixNpeDlNpeState) */
348 } /* end of if-else(npeId) */
350 IX_NPEDL_TRACE1 (IX_NPEDL_FN_ENTRY_EXIT
,
351 "Exiting ixNpeDlLoadedImageGet : status = %d\n",
357 * Function definition: ixNpeDlLatestImageGet
360 ixNpeDlLatestImageGet (
362 IxNpeDlFunctionalityId functionalityId
,
363 IxNpeDlImageId
*imageIdPtr
)
367 IX_NPEDL_TRACE0 (IX_NPEDL_FN_ENTRY_EXIT
,
368 "Entering ixNpeDlLatestImageGet\n");
370 /* Check input parameters */
371 if ((npeId
>= IX_NPEDL_NPEID_MAX
) ||
373 (imageIdPtr
== NULL
))
375 status
= IX_NPEDL_PARAM_ERR
;
376 IX_NPEDL_ERROR_REPORT ("ixNpeDlLatestImageGet - "
377 "invalid parameter\n");
378 } /* end of if(npeId) */
382 /* If not IXP42X A0 stepping, proceed to check for existence of npe's */
383 if ((IX_FEATURE_CTRL_SILICON_TYPE_A0
!=
384 (ixFeatureCtrlProductIdRead() & IX_FEATURE_CTRL_SILICON_STEPPING_MASK
))
385 || (IX_FEATURE_CTRL_DEVICE_TYPE_IXP42X
!= ixFeatureCtrlDeviceRead ()))
387 if (npeId
== IX_NPEDL_NPEID_NPEA
&&
388 (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEA
) ==
389 IX_FEATURE_CTRL_COMPONENT_DISABLED
))
391 IX_NPEDL_WARNING_REPORT("Warning: the NPE A component you specified does"
394 } /* end of if(npeId) */
396 if (npeId
== IX_NPEDL_NPEID_NPEB
&&
397 (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEB
) ==
398 IX_FEATURE_CTRL_COMPONENT_DISABLED
))
400 IX_NPEDL_WARNING_REPORT("Warning: the NPE B component you specified does"
403 } /* end of if(npeId) */
405 if (npeId
== IX_NPEDL_NPEID_NPEC
&&
406 (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEC
) ==
407 IX_FEATURE_CTRL_COMPONENT_DISABLED
))
409 IX_NPEDL_WARNING_REPORT("Warning: the NPE C component you specified does"
412 } /* end of if(npeId) */
413 } /* end of if not IXP42x-A0 silicon */
415 imageIdPtr
->npeId
= npeId
;
416 imageIdPtr
->functionalityId
= functionalityId
;
417 imageIdPtr
->major
= IMAGEID_MAJOR_NUMBER_DEFAULT
;
418 imageIdPtr
->minor
= IMAGEID_MINOR_NUMBER_DEFAULT
;
419 /* Call ImageMgr to get list of images listed in Image Library Header */
420 status
= ixNpeDlImageMgrLatestImageExtract(imageIdPtr
);
421 } /* end of if-else(npeId) */
423 IX_NPEDL_TRACE1 (IX_NPEDL_FN_ENTRY_EXIT
,
424 "Exiting ixNpeDlLatestImageGet : status = %d\n",
431 * Function definition: ixNpeDlNpeStopAndReset
434 ixNpeDlNpeStopAndReset (IxNpeDlNpeId npeId
)
436 IX_STATUS status
= IX_SUCCESS
;
438 IX_NPEDL_TRACE0 (IX_NPEDL_FN_ENTRY_EXIT
,
439 "Entering ixNpeDlNpeStopAndReset\n");
441 /* Ensure initialisation has been completed */
444 /* If not IXP42X A0 stepping, proceed to check for existence of npe's */
445 if ((IX_FEATURE_CTRL_SILICON_TYPE_A0
!=
446 (ixFeatureCtrlProductIdRead() & IX_FEATURE_CTRL_SILICON_STEPPING_MASK
))
447 || (IX_FEATURE_CTRL_DEVICE_TYPE_IXP42X
!= ixFeatureCtrlDeviceRead ()))
450 * Check whether NPE is present
452 if (IX_NPEDL_NPEID_NPEA
== npeId
)
454 /* Check whether NPE A is present */
455 if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEA
)==
456 IX_FEATURE_CTRL_COMPONENT_DISABLED
)
458 /* NPE A does not present */
459 IX_NPEDL_WARNING_REPORT ("ixNpeDlNpeStopAndReset - Warning:NPEA does not present.\n");
462 } /* end of if(IX_NPEDL_NPEID_NPEA) */
463 else if (IX_NPEDL_NPEID_NPEB
== npeId
)
465 /* Check whether NPE B is present */
466 if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEB
)==
467 IX_FEATURE_CTRL_COMPONENT_DISABLED
)
469 /* NPE B does not present */
470 IX_NPEDL_WARNING_REPORT ("ixNpeDlNpeStopAndReset - Warning:NPEB does not present.\n");
473 } /* end of elseif(IX_NPEDL_NPEID_NPEB) */
474 else if (IX_NPEDL_NPEID_NPEC
== npeId
)
476 /* Check whether NPE C is present */
477 if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEC
)==
478 IX_FEATURE_CTRL_COMPONENT_DISABLED
)
480 /* NPE C does not present */
481 IX_NPEDL_WARNING_REPORT ("ixNpeDlNpeStopAndReset - Warning:NPEC does not present.\n");
484 } /* end of elseif(IX_NPEDL_NPEID_NPEC) */
488 IX_NPEDL_ERROR_REPORT ("ixNpeDlNpeStopAndReset - invalid Npe ID\n");
489 status
= IX_NPEDL_PARAM_ERR
;
490 } /* end of if-else(IX_NPEDL_NPEID_NPEC) */
491 } /* end of if not IXP42x-A0 Silicon */
493 if (status
== IX_SUCCESS
)
495 /* call NpeMgr function to stop the NPE */
496 status
= ixNpeDlNpeMgrNpeStop (npeId
);
497 if (status
== IX_SUCCESS
)
499 /* call NpeMgr function to reset the NPE */
500 status
= ixNpeDlNpeMgrNpeReset (npeId
);
502 } /* end of if(status) */
504 IX_NPEDL_TRACE1 (IX_NPEDL_FN_ENTRY_EXIT
,
505 "Exiting ixNpeDlNpeStopAndReset : status = %d\n", status
);
507 if (IX_SUCCESS
== status
)
509 /* Indicate NPE has been stopped */
510 ixNpeDlNpeStarted
[npeId
] = false ;
517 * Function definition: ixNpeDlNpeExecutionStart
520 ixNpeDlNpeExecutionStart (IxNpeDlNpeId npeId
)
522 IX_STATUS status
= IX_SUCCESS
;
524 IX_NPEDL_TRACE0 (IX_NPEDL_FN_ENTRY_EXIT
,
525 "Entering ixNpeDlNpeExecutionStart\n");
527 /* If not IXP42X A0 stepping, proceed to check for existence of npe's */
528 if ((IX_FEATURE_CTRL_SILICON_TYPE_A0
!=
529 (ixFeatureCtrlProductIdRead() & IX_FEATURE_CTRL_SILICON_STEPPING_MASK
))
530 || (IX_FEATURE_CTRL_DEVICE_TYPE_IXP42X
!= ixFeatureCtrlDeviceRead ()))
533 * Check whether NPE is present
535 if (IX_NPEDL_NPEID_NPEA
== npeId
)
537 /* Check whether NPE A is present */
538 if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEA
)==
539 IX_FEATURE_CTRL_COMPONENT_DISABLED
)
541 /* NPE A does not present */
542 IX_NPEDL_WARNING_REPORT ("ixNpeDlNpeExecutionStart - Warning:NPEA does not present.\n");
545 } /* end of if(IX_NPEDL_NPEID_NPEA) */
546 else if (IX_NPEDL_NPEID_NPEB
== npeId
)
548 /* Check whether NPE B is present */
549 if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEB
)==
550 IX_FEATURE_CTRL_COMPONENT_DISABLED
)
552 /* NPE B does not present */
553 IX_NPEDL_WARNING_REPORT ("ixNpeDlNpeExecutionStart - Warning:NPEB does not present.\n");
556 } /* end of elseif(IX_NPEDL_NPEID_NPEB) */
557 else if (IX_NPEDL_NPEID_NPEC
== npeId
)
559 /* Check whether NPE C is present */
560 if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEC
)==
561 IX_FEATURE_CTRL_COMPONENT_DISABLED
)
563 /* NPE C does not present */
564 IX_NPEDL_WARNING_REPORT ("ixNpeDlNpeExecutionStart - Warning:NPEC does not present.\n");
567 } /* end of elseif(IX_NPEDL_NPEID_NPEC) */
571 IX_NPEDL_ERROR_REPORT ("ixNpeDlNpeExecutionStart - invalid Npe ID\n");
572 return IX_NPEDL_PARAM_ERR
;
573 } /* end of if-else(IX_NPEDL_NPEID_NPEC) */
574 } /* end of if not IXP42x-A0 Silicon */
576 if (true == ixNpeDlNpeStarted
[npeId
])
578 /* NPE has been started. */
582 /* Ensure initialisation has been completed */
585 /* call NpeMgr function to start the NPE */
586 status
= ixNpeDlNpeMgrNpeStart (npeId
);
588 if (IX_SUCCESS
== status
)
590 /* Indicate NPE has started */
591 ixNpeDlNpeStarted
[npeId
] = true ;
594 IX_NPEDL_TRACE1 (IX_NPEDL_FN_ENTRY_EXIT
,
595 "Exiting ixNpeDlNpeExecutionStart : status = %d\n",
602 * Function definition: ixNpeDlNpeExecutionStop
605 ixNpeDlNpeExecutionStop (IxNpeDlNpeId npeId
)
607 IX_STATUS status
= IX_SUCCESS
;
609 IX_NPEDL_TRACE0 (IX_NPEDL_FN_ENTRY_EXIT
,
610 "Entering ixNpeDlNpeExecutionStop\n");
612 /* Ensure initialisation has been completed */
615 /* If not IXP42X A0 stepping, proceed to check for existence of npe's */
616 if ((IX_FEATURE_CTRL_SILICON_TYPE_A0
!=
617 (ixFeatureCtrlProductIdRead() & IX_FEATURE_CTRL_SILICON_STEPPING_MASK
))
618 || (IX_FEATURE_CTRL_DEVICE_TYPE_IXP42X
!= ixFeatureCtrlDeviceRead ()))
621 * Check whether NPE is present
623 if (IX_NPEDL_NPEID_NPEA
== npeId
)
625 /* Check whether NPE A is present */
626 if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEA
)==
627 IX_FEATURE_CTRL_COMPONENT_DISABLED
)
629 /* NPE A does not present */
630 IX_NPEDL_WARNING_REPORT ("ixNpeDlNpeExecutionStop - Warning:NPEA does not present.\n");
633 } /* end of if(IX_NPEDL_NPEID_NPEA) */
634 else if (IX_NPEDL_NPEID_NPEB
== npeId
)
636 /* Check whether NPE B is present */
637 if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEB
)==
638 IX_FEATURE_CTRL_COMPONENT_DISABLED
)
640 /* NPE B does not present */
641 IX_NPEDL_WARNING_REPORT ("ixNpeDlNpeExecutionStop - Warning:NPEB does not present.\n");
644 } /* end of elseif(IX_NPEDL_NPEID_NPEB) */
645 else if (IX_NPEDL_NPEID_NPEC
== npeId
)
647 /* Check whether NPE C is present */
648 if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEC
)==
649 IX_FEATURE_CTRL_COMPONENT_DISABLED
)
651 /* NPE C does not present */
652 IX_NPEDL_WARNING_REPORT ("ixNpeDlNpeExecutionStop - Warning:NPEC does not present.\n");
655 } /* end of elseif(IX_NPEDL_NPEID_NPEC) */
659 IX_NPEDL_ERROR_REPORT ("ixNpeDlNpeExecutionStop - invalid Npe ID\n");
660 status
= IX_NPEDL_PARAM_ERR
;
661 } /* end of if-else(IX_NPEDL_NPEID_NPEC) */
662 } /* end of if not IXP42X-AO Silicon */
664 if (status
== IX_SUCCESS
)
666 /* call NpeMgr function to stop the NPE */
667 status
= ixNpeDlNpeMgrNpeStop (npeId
);
670 IX_NPEDL_TRACE1 (IX_NPEDL_FN_ENTRY_EXIT
,
671 "Exiting ixNpeDlNpeExecutionStop : status = %d\n",
674 if (IX_SUCCESS
== status
)
676 /* Indicate NPE has been stopped */
677 ixNpeDlNpeStarted
[npeId
] = false ;
684 * Function definition: ixNpeDlUnload
691 IX_NPEDL_TRACE0 (IX_NPEDL_FN_ENTRY_EXIT
,
692 "Entering ixNpeDlUnload\n");
694 status
= ixNpeDlNpeMgrUninit();
696 IX_NPEDL_TRACE1 (IX_NPEDL_FN_ENTRY_EXIT
,
697 "Exiting ixNpeDlUnload : status = %d\n",
703 * Function definition: ixNpeDlStatsShow
706 ixNpeDlStatsShow (void)
708 ixOsalLog (IX_OSAL_LOG_LVL_USER
,
709 IX_OSAL_LOG_DEV_STDOUT
,
710 "\nixNpeDlStatsShow:\n"
711 "\tDownloads Attempted by user: %u\n"
712 "\tSuccessful Downloads: %u\n"
713 "\tFailed Downloads (due to Critical Error): %u\n\n",
714 ixNpeDlStats
.attemptedDownloads
,
715 ixNpeDlStats
.successfulDownloads
,
716 ixNpeDlStats
.criticalFailDownloads
,
719 ixNpeDlImageMgrStatsShow ();
720 ixNpeDlNpeMgrStatsShow ();
724 * Function definition: ixNpeDlStatsReset
727 ixNpeDlStatsReset (void)
729 ixNpeDlStats
.attemptedDownloads
= 0;
730 ixNpeDlStats
.successfulDownloads
= 0;
731 ixNpeDlStats
.criticalFailDownloads
= 0;
733 ixNpeDlImageMgrStatsReset ();
734 ixNpeDlNpeMgrStatsReset ();
738 * Function definition: ixNpeDlNpeInitAndStartInternal
741 ixNpeDlNpeInitAndStartInternal (UINT32
*imageLibrary
,
745 UINT32
*imageCodePtr
= NULL
;
747 IxNpeDlNpeId npeId
= IX_NPEDL_NPEID_FROM_IMAGEID_GET(imageId
);
748 IxFeatureCtrlDeviceId deviceId
= IX_NPEDL_DEVICEID_FROM_IMAGEID_GET(imageId
);
750 IX_NPEDL_TRACE0 (IX_NPEDL_FN_ENTRY_EXIT
,
751 "Entering ixNpeDlNpeInitAndStartInternal\n");
753 ixNpeDlStats
.attemptedDownloads
++;
755 /* Check input parameter device correctness */
756 if ((deviceId
>= IX_FEATURE_CTRL_DEVICE_TYPE_MAX
) ||
757 (deviceId
< IX_FEATURE_CTRL_DEVICE_TYPE_IXP42X
))
759 status
= IX_NPEDL_PARAM_ERR
;
760 IX_NPEDL_ERROR_REPORT ("ixNpeDlNpeInitAndStartInternal - "
761 "invalid parameter\n");
762 } /* End valid device id checking */
764 /* Check input parameters */
765 else if ((npeId
>= IX_NPEDL_NPEID_MAX
) || (npeId
< 0))
767 status
= IX_NPEDL_PARAM_ERR
;
768 IX_NPEDL_ERROR_REPORT ("ixNpeDlNpeInitAndStartInternal - "
769 "invalid parameter\n");
774 /* Ensure initialisation has been completed */
777 /* Checking if image being loaded is meant for device that is running.
778 * Image is forward compatible. i.e Image built for IXP42X should run
779 * on IXP46X but not vice versa.*/
780 if (deviceId
> (ixFeatureCtrlDeviceRead() & IX_FEATURE_CTRL_DEVICE_TYPE_MASK
))
782 IX_NPEDL_ERROR_REPORT ("ixNpeDlNpeInitAndStartInternal - "
783 "Device type mismatch. NPE Image not "
784 "meant for device in use \n");
785 return IX_NPEDL_DEVICE_ERR
;
786 }/* if statement - matching image device and current device */
788 /* If not IXP42X A0 stepping, proceed to check for existence of npe's */
789 if ((IX_FEATURE_CTRL_SILICON_TYPE_A0
!=
790 (ixFeatureCtrlProductIdRead() & IX_FEATURE_CTRL_SILICON_STEPPING_MASK
))
791 || (IX_FEATURE_CTRL_DEVICE_TYPE_IXP42X
!= ixFeatureCtrlDeviceRead ()))
793 if (npeId
== IX_NPEDL_NPEID_NPEA
)
795 if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEA
) ==
796 IX_FEATURE_CTRL_COMPONENT_DISABLED
)
798 IX_NPEDL_WARNING_REPORT("Warning: the NPE A component you specified does"
802 } /* end of if(npeId) */
803 else if (npeId
== IX_NPEDL_NPEID_NPEB
)
805 if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEB
)==
806 IX_FEATURE_CTRL_COMPONENT_DISABLED
)
808 IX_NPEDL_WARNING_REPORT("Warning: the NPE B component you specified"
809 " does not exist\n");
812 } /* end of elseif(npeId) */
813 else if (npeId
== IX_NPEDL_NPEID_NPEC
)
815 if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEC
)==
816 IX_FEATURE_CTRL_COMPONENT_DISABLED
)
818 IX_NPEDL_WARNING_REPORT("Warning: the NPE C component you specified"
819 " does not exist\n");
822 } /* end of elseif(npeId) */
823 } /* end of if not IXP42X-A0 Silicon */
825 /* stop and reset the NPE */
826 status
= ixNpeDlNpeStopAndReset (npeId
);
827 if (IX_SUCCESS
!= status
)
829 IX_NPEDL_ERROR_REPORT ("Failed to stop and reset NPE\n");
834 status
= ixNpeDlImageMgrImageFind (imageLibrary
, imageId
,
835 &imageCodePtr
, &imageSize
);
836 if (IX_SUCCESS
== status
)
839 * If download was successful, store image Id in list of
840 * currently loaded images. If a critical error occured
841 * during download, record that the NPE has an invalid image
843 status
= ixNpeDlNpeMgrImageLoad (npeId
, imageCodePtr
, true);
844 if (IX_SUCCESS
== status
)
846 ixNpeDlNpeState
[npeId
].validImage
= true;
847 ixNpeDlStats
.successfulDownloads
++;
849 status
= ixNpeDlNpeExecutionStart (npeId
);
851 else if ((status
== IX_NPEDL_CRITICAL_NPE_ERR
) ||
852 (status
== IX_NPEDL_CRITICAL_MICROCODE_ERR
))
854 ixNpeDlNpeState
[npeId
].validImage
= false;
855 ixNpeDlStats
.criticalFailDownloads
++;
858 /* NOTE - The following section of code is here to support
859 * a deprecated function ixNpeDlLoadedImageGet(). When that
860 * function is removed from the API, this code should be revised.
862 ixNpeDlNpeState
[npeId
].imageId
.npeId
= npeId
;
863 ixNpeDlNpeState
[npeId
].imageId
.functionalityId
=
864 IX_NPEDL_FUNCTIONID_FROM_IMAGEID_GET(imageId
);
865 ixNpeDlNpeState
[npeId
].imageId
.major
=
866 IX_NPEDL_MAJOR_FROM_IMAGEID_GET(imageId
);
867 ixNpeDlNpeState
[npeId
].imageId
.minor
=
868 IX_NPEDL_MINOR_FROM_IMAGEID_GET(imageId
);
869 } /* end of if(IX_SUCCESS) */ /* condition: image located successfully in microcode image */
870 } /* end of if-else(npeId-deviceId) */ /* condition: parameter checks ok */
872 IX_NPEDL_TRACE1 (IX_NPEDL_FN_ENTRY_EXIT
,
873 "Exiting ixNpeDlNpeInitAndStartInternal : "
874 "status = %d\n", status
);
879 * Function definition: ixNpeDlCustomImageNpeInitAndStart
882 ixNpeDlCustomImageNpeInitAndStart (UINT32
*imageLibrary
,
887 if (imageLibrary
== NULL
)
889 status
= IX_NPEDL_PARAM_ERR
;
890 IX_NPEDL_ERROR_REPORT ("ixNpeDlCustomImageNpeInitAndStart "
891 "- invalid parameter\n");
895 status
= ixNpeDlNpeInitAndStartInternal (imageLibrary
, imageId
);
896 } /* end of if-else(imageLibrary) */
902 * Function definition: ixNpeDlNpeInitAndStart
905 ixNpeDlNpeInitAndStart (UINT32 imageId
)
907 return ixNpeDlNpeInitAndStartInternal (NULL
, imageId
);
911 * Function definition: ixNpeDlLoadedImageFunctionalityGet
914 ixNpeDlLoadedImageFunctionalityGet (IxNpeDlNpeId npeId
,
915 UINT8
*functionalityId
)
917 /* Check input parameters */
918 if ((npeId
>= IX_NPEDL_NPEID_MAX
) || (npeId
< 0))
920 IX_NPEDL_ERROR_REPORT ("ixNpeDlLoadedImageFunctionalityGet "
921 "- invalid parameter\n");
922 return IX_NPEDL_PARAM_ERR
;
924 if (functionalityId
== NULL
)
926 IX_NPEDL_ERROR_REPORT ("ixNpeDlLoadedImageFunctionalityGet "
927 "- invalid parameter\n");
928 return IX_NPEDL_PARAM_ERR
;
931 if (ixNpeDlNpeState
[npeId
].validImage
)
933 *functionalityId
= ixNpeDlNpeState
[npeId
].imageId
.functionalityId
;