IxNpeDl.c 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972
  1. /**
  2. * @file IxNpeDl.c
  3. *
  4. * @author Intel Corporation
  5. * @date 08 January 2002
  6. *
  7. * @brief This file contains the implementation of the public API for the
  8. * IXP425 NPE Downloader component
  9. *
  10. *
  11. * @par
  12. * IXP400 SW Release version 2.0
  13. *
  14. * -- Copyright Notice --
  15. *
  16. * @par
  17. * Copyright 2001-2005, Intel Corporation.
  18. * All rights reserved.
  19. *
  20. * @par
  21. * Redistribution and use in source and binary forms, with or without
  22. * modification, are permitted provided that the following conditions
  23. * are met:
  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.
  32. *
  33. * @par
  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
  44. * SUCH DAMAGE.
  45. *
  46. * @par
  47. * -- End of Copyright Notice --
  48. */
  49. /*
  50. * Put the system defined include files required
  51. */
  52. /*
  53. * Put the user defined include files required
  54. */
  55. #include "IxNpeDl.h"
  56. #include "IxNpeDlImageMgr_p.h"
  57. #include "IxNpeDlNpeMgr_p.h"
  58. #include "IxNpeDlMacros_p.h"
  59. #include "IxFeatureCtrl.h"
  60. #include "IxOsal.h"
  61. /*
  62. * #defines used in this file
  63. */
  64. #define IMAGEID_MAJOR_NUMBER_DEFAULT 0
  65. #define IMAGEID_MINOR_NUMBER_DEFAULT 0
  66. /*
  67. * Typedefs whose scope is limited to this file.
  68. */
  69. typedef struct
  70. {
  71. BOOL validImage;
  72. IxNpeDlImageId imageId;
  73. } IxNpeDlNpeState;
  74. /* module statistics counters */
  75. typedef struct
  76. {
  77. UINT32 attemptedDownloads;
  78. UINT32 successfulDownloads;
  79. UINT32 criticalFailDownloads;
  80. } IxNpeDlStats;
  81. /*
  82. * Variable declarations global to this file only. Externs are followed
  83. * by static variables.
  84. */
  85. static IxNpeDlNpeState ixNpeDlNpeState[IX_NPEDL_NPEID_MAX] =
  86. {
  87. {FALSE, {IX_NPEDL_NPEID_MAX, 0, 0, 0}},
  88. {FALSE, {IX_NPEDL_NPEID_MAX, 0, 0, 0}},
  89. {FALSE, {IX_NPEDL_NPEID_MAX, 0, 0, 0}}
  90. };
  91. static IxNpeDlStats ixNpeDlStats;
  92. /*
  93. * Software guard to prevent NPE from being started multiple times.
  94. */
  95. static BOOL ixNpeDlNpeStarted[IX_NPEDL_NPEID_MAX] ={FALSE, FALSE, FALSE} ;
  96. /*
  97. * static function prototypes.
  98. */
  99. PRIVATE IX_STATUS
  100. ixNpeDlNpeInitAndStartInternal (UINT32 *imageLibrary, UINT32 imageId);
  101. /*
  102. * Function definition: ixNpeDlMicrocodeImageLibraryOverride
  103. */
  104. PUBLIC IX_STATUS
  105. ixNpeDlMicrocodeImageLibraryOverride (UINT32 *clientImageLibrary)
  106. {
  107. IX_STATUS status = IX_SUCCESS;
  108. IX_NPEDL_TRACE0 (IX_NPEDL_FN_ENTRY_EXIT,
  109. "Entering ixNpeDlMicrocodeImageLibraryOverride\n");
  110. if (clientImageLibrary == NULL)
  111. {
  112. status = IX_NPEDL_PARAM_ERR;
  113. IX_NPEDL_ERROR_REPORT ("ixNpeDlMicrocodeImageLibraryOverride - "
  114. "invalid parameter\n");
  115. }
  116. else
  117. {
  118. status = ixNpeDlImageMgrMicrocodeImageLibraryOverride (clientImageLibrary);
  119. if (status != IX_SUCCESS)
  120. {
  121. status = IX_FAIL;
  122. }
  123. } /* end of if-else(clientImageLibrary) */
  124. IX_NPEDL_TRACE1 (IX_NPEDL_FN_ENTRY_EXIT,
  125. "Exiting ixNpeDlMicrocodeImageLibraryOverride : "
  126. "status = %d\n", status);
  127. return status;
  128. }
  129. /*
  130. * Function definition: ixNpeDlImageDownload
  131. */
  132. PUBLIC IX_STATUS
  133. ixNpeDlImageDownload (IxNpeDlImageId *imageIdPtr,
  134. BOOL verify)
  135. {
  136. UINT32 imageSize;
  137. UINT32 *imageCodePtr = NULL;
  138. IX_STATUS status;
  139. IxNpeDlNpeId npeId = imageIdPtr->npeId;
  140. IX_NPEDL_TRACE0 (IX_NPEDL_FN_ENTRY_EXIT,
  141. "Entering ixNpeDlImageDownload\n");
  142. ixNpeDlStats.attemptedDownloads++;
  143. /* Check input parameters */
  144. if ((npeId >= IX_NPEDL_NPEID_MAX) || (npeId < 0))
  145. {
  146. status = IX_NPEDL_PARAM_ERR;
  147. IX_NPEDL_ERROR_REPORT ("ixNpeDlImageDownload - invalid parameter\n");
  148. }
  149. else
  150. {
  151. /* Ensure initialisation has been completed */
  152. ixNpeDlNpeMgrInit();
  153. /* If not IXP42X A0 stepping, proceed to check for existence of npe's */
  154. if ((IX_FEATURE_CTRL_SILICON_TYPE_A0 !=
  155. (ixFeatureCtrlProductIdRead() & IX_FEATURE_CTRL_SILICON_STEPPING_MASK))
  156. || (IX_FEATURE_CTRL_DEVICE_TYPE_IXP42X != ixFeatureCtrlDeviceRead ()))
  157. {
  158. if (npeId == IX_NPEDL_NPEID_NPEA)
  159. {
  160. if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEA) ==
  161. IX_FEATURE_CTRL_COMPONENT_DISABLED)
  162. {
  163. IX_NPEDL_WARNING_REPORT("Warning: the NPE A component you specified does"
  164. " not exist\n");
  165. return IX_SUCCESS;
  166. }
  167. } /* end of if(npeId) */
  168. else if (npeId == IX_NPEDL_NPEID_NPEB)
  169. {
  170. if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEB)==
  171. IX_FEATURE_CTRL_COMPONENT_DISABLED)
  172. {
  173. IX_NPEDL_WARNING_REPORT("Warning: the NPE B component you specified"
  174. " does not exist\n");
  175. return IX_SUCCESS;
  176. }
  177. } /* end of elseif(npeId) */
  178. else if (npeId == IX_NPEDL_NPEID_NPEC)
  179. {
  180. if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEC)==
  181. IX_FEATURE_CTRL_COMPONENT_DISABLED)
  182. {
  183. IX_NPEDL_WARNING_REPORT("Warning: the NPE C component you specified"
  184. " does not exist\n");
  185. return IX_SUCCESS;
  186. }
  187. } /* end of elseif(npeId) */
  188. } /* end of if(IX_FEATURE_CTRL_SILICON_TYPE_B0) */ /*End of Silicon Type Check*/
  189. /* stop and reset the NPE */
  190. if (IX_SUCCESS != ixNpeDlNpeStopAndReset (npeId))
  191. {
  192. IX_NPEDL_ERROR_REPORT ("Failed to stop and reset NPE\n");
  193. return IX_FAIL;
  194. }
  195. /* Locate image */
  196. status = ixNpeDlImageMgrImageLocate (imageIdPtr, &imageCodePtr,
  197. &imageSize);
  198. if (IX_SUCCESS == status)
  199. {
  200. /*
  201. * If download was successful, store image Id in list of
  202. * currently loaded images. If a critical error occured
  203. * during download, record that the NPE has an invalid image
  204. */
  205. status = ixNpeDlNpeMgrImageLoad (npeId, imageCodePtr,
  206. verify);
  207. if (IX_SUCCESS == status)
  208. {
  209. ixNpeDlNpeState[npeId].imageId = *imageIdPtr;
  210. ixNpeDlNpeState[npeId].validImage = TRUE;
  211. ixNpeDlStats.successfulDownloads++;
  212. status = ixNpeDlNpeExecutionStart (npeId);
  213. }
  214. else if ((status == IX_NPEDL_CRITICAL_NPE_ERR) ||
  215. (status == IX_NPEDL_CRITICAL_MICROCODE_ERR))
  216. {
  217. ixNpeDlNpeState[npeId].imageId = *imageIdPtr;
  218. ixNpeDlNpeState[npeId].validImage = FALSE;
  219. ixNpeDlStats.criticalFailDownloads++;
  220. }
  221. } /* end of if(IX_SUCCESS) */ /* condition: image located successfully in microcode image */
  222. } /* end of if-else(npeId) */ /* condition: parameter checks ok */
  223. IX_NPEDL_TRACE1 (IX_NPEDL_FN_ENTRY_EXIT,
  224. "Exiting ixNpeDlImageDownload : status = %d\n", status);
  225. return status;
  226. }
  227. /*
  228. * Function definition: ixNpeDlAvailableImagesCountGet
  229. */
  230. PUBLIC IX_STATUS
  231. ixNpeDlAvailableImagesCountGet (UINT32 *numImagesPtr)
  232. {
  233. IX_STATUS status;
  234. IX_NPEDL_TRACE0 (IX_NPEDL_FN_ENTRY_EXIT,
  235. "Entering ixNpeDlAvailableImagesCountGet\n");
  236. /* Check input parameters */
  237. if (numImagesPtr == NULL)
  238. {
  239. status = IX_NPEDL_PARAM_ERR;
  240. IX_NPEDL_ERROR_REPORT ("ixNpeDlAvailableImagesCountGet - "
  241. "invalid parameter\n");
  242. }
  243. else
  244. {
  245. /*
  246. * Use ImageMgr module to get no. of images listed in Image Library Header.
  247. * If NULL is passed as imageListPtr parameter to following function,
  248. * it will only fill number of images into numImagesPtr
  249. */
  250. status = ixNpeDlImageMgrImageListExtract (NULL, numImagesPtr);
  251. } /* end of if-else(numImagesPtr) */
  252. IX_NPEDL_TRACE1 (IX_NPEDL_FN_ENTRY_EXIT,
  253. "Exiting ixNpeDlAvailableImagesCountGet : "
  254. "status = %d\n", status);
  255. return status;
  256. }
  257. /*
  258. * Function definition: ixNpeDlAvailableImagesListGet
  259. */
  260. PUBLIC IX_STATUS
  261. ixNpeDlAvailableImagesListGet (IxNpeDlImageId *imageIdListPtr,
  262. UINT32 *listSizePtr)
  263. {
  264. IX_STATUS status;
  265. IX_NPEDL_TRACE0 (IX_NPEDL_FN_ENTRY_EXIT,
  266. "Entering ixNpeDlAvailableImagesListGet\n");
  267. /* Check input parameters */
  268. if ((imageIdListPtr == NULL) || (listSizePtr == NULL))
  269. {
  270. status = IX_NPEDL_PARAM_ERR;
  271. IX_NPEDL_ERROR_REPORT ("ixNpeDlAvailableImagesListGet - "
  272. "invalid parameter\n");
  273. }
  274. else
  275. {
  276. /* Call ImageMgr to get list of images listed in Image Library Header */
  277. status = ixNpeDlImageMgrImageListExtract (imageIdListPtr,
  278. listSizePtr);
  279. } /* end of if-else(imageIdListPtr) */
  280. IX_NPEDL_TRACE1 (IX_NPEDL_FN_ENTRY_EXIT,
  281. "Exiting ixNpeDlAvailableImagesListGet : status = %d\n",
  282. status);
  283. return status;
  284. }
  285. /*
  286. * Function definition: ixNpeDlLoadedImageGet
  287. */
  288. PUBLIC IX_STATUS
  289. ixNpeDlLoadedImageGet (IxNpeDlNpeId npeId,
  290. IxNpeDlImageId *imageIdPtr)
  291. {
  292. IX_STATUS status = IX_SUCCESS;
  293. IX_NPEDL_TRACE0 (IX_NPEDL_FN_ENTRY_EXIT,
  294. "Entering ixNpeDlLoadedImageGet\n");
  295. /* Check input parameters */
  296. if ((npeId >= IX_NPEDL_NPEID_MAX) || (npeId < 0) || (imageIdPtr == NULL))
  297. {
  298. status = IX_NPEDL_PARAM_ERR;
  299. IX_NPEDL_ERROR_REPORT ("ixNpeDlLoadedImageGet - invalid parameter\n");
  300. }
  301. else
  302. {
  303. /* If not IXP42X A0 stepping, proceed to check for existence of npe's */
  304. if ((IX_FEATURE_CTRL_SILICON_TYPE_A0 !=
  305. (ixFeatureCtrlProductIdRead() & IX_FEATURE_CTRL_SILICON_STEPPING_MASK))
  306. || (IX_FEATURE_CTRL_DEVICE_TYPE_IXP42X != ixFeatureCtrlDeviceRead ()))
  307. {
  308. if (npeId == IX_NPEDL_NPEID_NPEA &&
  309. (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEA) ==
  310. IX_FEATURE_CTRL_COMPONENT_DISABLED))
  311. {
  312. IX_NPEDL_WARNING_REPORT("Warning: the NPE A component you specified does"
  313. " not exist\n");
  314. return IX_SUCCESS;
  315. } /* end of if(npeId) */
  316. if (npeId == IX_NPEDL_NPEID_NPEB &&
  317. (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEB) ==
  318. IX_FEATURE_CTRL_COMPONENT_DISABLED))
  319. {
  320. IX_NPEDL_WARNING_REPORT("Warning: the NPE B component you specified does"
  321. " not exist\n");
  322. return IX_SUCCESS;
  323. } /* end of if(npeId) */
  324. if (npeId == IX_NPEDL_NPEID_NPEC &&
  325. (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEC) ==
  326. IX_FEATURE_CTRL_COMPONENT_DISABLED))
  327. {
  328. IX_NPEDL_WARNING_REPORT("Warning: the NPE C component you specified does"
  329. " not exist\n");
  330. return IX_SUCCESS;
  331. } /* end of if(npeId) */
  332. } /* end of if not IXP42x-A0 silicon */
  333. if (ixNpeDlNpeState[npeId].validImage)
  334. {
  335. /* use npeId to get imageId from list of currently loaded
  336. images */
  337. *imageIdPtr = ixNpeDlNpeState[npeId].imageId;
  338. }
  339. else
  340. {
  341. status = IX_FAIL;
  342. } /* end of if-else(ixNpeDlNpeState) */
  343. } /* end of if-else(npeId) */
  344. IX_NPEDL_TRACE1 (IX_NPEDL_FN_ENTRY_EXIT,
  345. "Exiting ixNpeDlLoadedImageGet : status = %d\n",
  346. status);
  347. return status;
  348. }
  349. /*
  350. * Function definition: ixNpeDlLatestImageGet
  351. */
  352. PUBLIC IX_STATUS
  353. ixNpeDlLatestImageGet (
  354. IxNpeDlNpeId npeId,
  355. IxNpeDlFunctionalityId functionalityId,
  356. IxNpeDlImageId *imageIdPtr)
  357. {
  358. IX_STATUS status;
  359. IX_NPEDL_TRACE0 (IX_NPEDL_FN_ENTRY_EXIT,
  360. "Entering ixNpeDlLatestImageGet\n");
  361. /* Check input parameters */
  362. if ((npeId >= IX_NPEDL_NPEID_MAX) ||
  363. (npeId < 0) ||
  364. (imageIdPtr == NULL))
  365. {
  366. status = IX_NPEDL_PARAM_ERR;
  367. IX_NPEDL_ERROR_REPORT ("ixNpeDlLatestImageGet - "
  368. "invalid parameter\n");
  369. } /* end of if(npeId) */
  370. else
  371. {
  372. /* If not IXP42X A0 stepping, proceed to check for existence of npe's */
  373. if ((IX_FEATURE_CTRL_SILICON_TYPE_A0 !=
  374. (ixFeatureCtrlProductIdRead() & IX_FEATURE_CTRL_SILICON_STEPPING_MASK))
  375. || (IX_FEATURE_CTRL_DEVICE_TYPE_IXP42X != ixFeatureCtrlDeviceRead ()))
  376. {
  377. if (npeId == IX_NPEDL_NPEID_NPEA &&
  378. (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEA) ==
  379. IX_FEATURE_CTRL_COMPONENT_DISABLED))
  380. {
  381. IX_NPEDL_WARNING_REPORT("Warning: the NPE A component you specified does"
  382. " not exist\n");
  383. return IX_SUCCESS;
  384. } /* end of if(npeId) */
  385. if (npeId == IX_NPEDL_NPEID_NPEB &&
  386. (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEB) ==
  387. IX_FEATURE_CTRL_COMPONENT_DISABLED))
  388. {
  389. IX_NPEDL_WARNING_REPORT("Warning: the NPE B component you specified does"
  390. " not exist\n");
  391. return IX_SUCCESS;
  392. } /* end of if(npeId) */
  393. if (npeId == IX_NPEDL_NPEID_NPEC &&
  394. (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEC) ==
  395. IX_FEATURE_CTRL_COMPONENT_DISABLED))
  396. {
  397. IX_NPEDL_WARNING_REPORT("Warning: the NPE C component you specified does"
  398. " not exist\n");
  399. return IX_SUCCESS;
  400. } /* end of if(npeId) */
  401. } /* end of if not IXP42x-A0 silicon */
  402. imageIdPtr->npeId = npeId;
  403. imageIdPtr->functionalityId = functionalityId;
  404. imageIdPtr->major = IMAGEID_MAJOR_NUMBER_DEFAULT;
  405. imageIdPtr->minor = IMAGEID_MINOR_NUMBER_DEFAULT;
  406. /* Call ImageMgr to get list of images listed in Image Library Header */
  407. status = ixNpeDlImageMgrLatestImageExtract(imageIdPtr);
  408. } /* end of if-else(npeId) */
  409. IX_NPEDL_TRACE1 (IX_NPEDL_FN_ENTRY_EXIT,
  410. "Exiting ixNpeDlLatestImageGet : status = %d\n",
  411. status);
  412. return status;
  413. }
  414. /*
  415. * Function definition: ixNpeDlNpeStopAndReset
  416. */
  417. PUBLIC IX_STATUS
  418. ixNpeDlNpeStopAndReset (IxNpeDlNpeId npeId)
  419. {
  420. IX_STATUS status = IX_SUCCESS;
  421. IX_NPEDL_TRACE0 (IX_NPEDL_FN_ENTRY_EXIT,
  422. "Entering ixNpeDlNpeStopAndReset\n");
  423. /* Ensure initialisation has been completed */
  424. ixNpeDlNpeMgrInit();
  425. /* If not IXP42X A0 stepping, proceed to check for existence of npe's */
  426. if ((IX_FEATURE_CTRL_SILICON_TYPE_A0 !=
  427. (ixFeatureCtrlProductIdRead() & IX_FEATURE_CTRL_SILICON_STEPPING_MASK))
  428. || (IX_FEATURE_CTRL_DEVICE_TYPE_IXP42X != ixFeatureCtrlDeviceRead ()))
  429. {
  430. /*
  431. * Check whether NPE is present
  432. */
  433. if (IX_NPEDL_NPEID_NPEA == npeId)
  434. {
  435. /* Check whether NPE A is present */
  436. if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEA)==
  437. IX_FEATURE_CTRL_COMPONENT_DISABLED)
  438. {
  439. /* NPE A does not present */
  440. IX_NPEDL_WARNING_REPORT ("ixNpeDlNpeStopAndReset - Warning:NPEA does not present.\n");
  441. return IX_SUCCESS;
  442. }
  443. } /* end of if(IX_NPEDL_NPEID_NPEA) */
  444. else if (IX_NPEDL_NPEID_NPEB == npeId)
  445. {
  446. /* Check whether NPE B is present */
  447. if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEB)==
  448. IX_FEATURE_CTRL_COMPONENT_DISABLED)
  449. {
  450. /* NPE B does not present */
  451. IX_NPEDL_WARNING_REPORT ("ixNpeDlNpeStopAndReset - Warning:NPEB does not present.\n");
  452. return IX_SUCCESS;
  453. }
  454. } /* end of elseif(IX_NPEDL_NPEID_NPEB) */
  455. else if (IX_NPEDL_NPEID_NPEC == npeId)
  456. {
  457. /* Check whether NPE C is present */
  458. if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEC)==
  459. IX_FEATURE_CTRL_COMPONENT_DISABLED)
  460. {
  461. /* NPE C does not present */
  462. IX_NPEDL_WARNING_REPORT ("ixNpeDlNpeStopAndReset - Warning:NPEC does not present.\n");
  463. return IX_SUCCESS;
  464. }
  465. } /* end of elseif(IX_NPEDL_NPEID_NPEC) */
  466. else
  467. {
  468. /* Invalid NPE ID */
  469. IX_NPEDL_ERROR_REPORT ("ixNpeDlNpeStopAndReset - invalid Npe ID\n");
  470. status = IX_NPEDL_PARAM_ERR;
  471. } /* end of if-else(IX_NPEDL_NPEID_NPEC) */
  472. } /* end of if not IXP42x-A0 Silicon */
  473. if (status == IX_SUCCESS)
  474. {
  475. /* call NpeMgr function to stop the NPE */
  476. status = ixNpeDlNpeMgrNpeStop (npeId);
  477. if (status == IX_SUCCESS)
  478. {
  479. /* call NpeMgr function to reset the NPE */
  480. status = ixNpeDlNpeMgrNpeReset (npeId);
  481. }
  482. } /* end of if(status) */
  483. IX_NPEDL_TRACE1 (IX_NPEDL_FN_ENTRY_EXIT,
  484. "Exiting ixNpeDlNpeStopAndReset : status = %d\n", status);
  485. if (IX_SUCCESS == status)
  486. {
  487. /* Indicate NPE has been stopped */
  488. ixNpeDlNpeStarted[npeId] = FALSE ;
  489. }
  490. return status;
  491. }
  492. /*
  493. * Function definition: ixNpeDlNpeExecutionStart
  494. */
  495. PUBLIC IX_STATUS
  496. ixNpeDlNpeExecutionStart (IxNpeDlNpeId npeId)
  497. {
  498. IX_STATUS status = IX_SUCCESS;
  499. IX_NPEDL_TRACE0 (IX_NPEDL_FN_ENTRY_EXIT,
  500. "Entering ixNpeDlNpeExecutionStart\n");
  501. /* If not IXP42X A0 stepping, proceed to check for existence of npe's */
  502. if ((IX_FEATURE_CTRL_SILICON_TYPE_A0 !=
  503. (ixFeatureCtrlProductIdRead() & IX_FEATURE_CTRL_SILICON_STEPPING_MASK))
  504. || (IX_FEATURE_CTRL_DEVICE_TYPE_IXP42X != ixFeatureCtrlDeviceRead ()))
  505. {
  506. /*
  507. * Check whether NPE is present
  508. */
  509. if (IX_NPEDL_NPEID_NPEA == npeId)
  510. {
  511. /* Check whether NPE A is present */
  512. if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEA)==
  513. IX_FEATURE_CTRL_COMPONENT_DISABLED)
  514. {
  515. /* NPE A does not present */
  516. IX_NPEDL_WARNING_REPORT ("ixNpeDlNpeExecutionStart - Warning:NPEA does not present.\n");
  517. return IX_SUCCESS;
  518. }
  519. } /* end of if(IX_NPEDL_NPEID_NPEA) */
  520. else if (IX_NPEDL_NPEID_NPEB == npeId)
  521. {
  522. /* Check whether NPE B is present */
  523. if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEB)==
  524. IX_FEATURE_CTRL_COMPONENT_DISABLED)
  525. {
  526. /* NPE B does not present */
  527. IX_NPEDL_WARNING_REPORT ("ixNpeDlNpeExecutionStart - Warning:NPEB does not present.\n");
  528. return IX_SUCCESS;
  529. }
  530. } /* end of elseif(IX_NPEDL_NPEID_NPEB) */
  531. else if (IX_NPEDL_NPEID_NPEC == npeId)
  532. {
  533. /* Check whether NPE C is present */
  534. if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEC)==
  535. IX_FEATURE_CTRL_COMPONENT_DISABLED)
  536. {
  537. /* NPE C does not present */
  538. IX_NPEDL_WARNING_REPORT ("ixNpeDlNpeExecutionStart - Warning:NPEC does not present.\n");
  539. return IX_SUCCESS;
  540. }
  541. } /* end of elseif(IX_NPEDL_NPEID_NPEC) */
  542. else
  543. {
  544. /* Invalid NPE ID */
  545. IX_NPEDL_ERROR_REPORT ("ixNpeDlNpeExecutionStart - invalid Npe ID\n");
  546. return IX_NPEDL_PARAM_ERR;
  547. } /* end of if-else(IX_NPEDL_NPEID_NPEC) */
  548. } /* end of if not IXP42x-A0 Silicon */
  549. if (TRUE == ixNpeDlNpeStarted[npeId])
  550. {
  551. /* NPE has been started. */
  552. return IX_SUCCESS ;
  553. }
  554. /* Ensure initialisation has been completed */
  555. ixNpeDlNpeMgrInit();
  556. /* call NpeMgr function to start the NPE */
  557. status = ixNpeDlNpeMgrNpeStart (npeId);
  558. if (IX_SUCCESS == status)
  559. {
  560. /* Indicate NPE has started */
  561. ixNpeDlNpeStarted[npeId] = TRUE ;
  562. }
  563. IX_NPEDL_TRACE1 (IX_NPEDL_FN_ENTRY_EXIT,
  564. "Exiting ixNpeDlNpeExecutionStart : status = %d\n",
  565. status);
  566. return status;
  567. }
  568. /*
  569. * Function definition: ixNpeDlNpeExecutionStop
  570. */
  571. PUBLIC IX_STATUS
  572. ixNpeDlNpeExecutionStop (IxNpeDlNpeId npeId)
  573. {
  574. IX_STATUS status = IX_SUCCESS;
  575. IX_NPEDL_TRACE0 (IX_NPEDL_FN_ENTRY_EXIT,
  576. "Entering ixNpeDlNpeExecutionStop\n");
  577. /* Ensure initialisation has been completed */
  578. ixNpeDlNpeMgrInit();
  579. /* If not IXP42X A0 stepping, proceed to check for existence of npe's */
  580. if ((IX_FEATURE_CTRL_SILICON_TYPE_A0 !=
  581. (ixFeatureCtrlProductIdRead() & IX_FEATURE_CTRL_SILICON_STEPPING_MASK))
  582. || (IX_FEATURE_CTRL_DEVICE_TYPE_IXP42X != ixFeatureCtrlDeviceRead ()))
  583. {
  584. /*
  585. * Check whether NPE is present
  586. */
  587. if (IX_NPEDL_NPEID_NPEA == npeId)
  588. {
  589. /* Check whether NPE A is present */
  590. if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEA)==
  591. IX_FEATURE_CTRL_COMPONENT_DISABLED)
  592. {
  593. /* NPE A does not present */
  594. IX_NPEDL_WARNING_REPORT ("ixNpeDlNpeExecutionStop - Warning:NPEA does not present.\n");
  595. return IX_SUCCESS;
  596. }
  597. } /* end of if(IX_NPEDL_NPEID_NPEA) */
  598. else if (IX_NPEDL_NPEID_NPEB == npeId)
  599. {
  600. /* Check whether NPE B is present */
  601. if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEB)==
  602. IX_FEATURE_CTRL_COMPONENT_DISABLED)
  603. {
  604. /* NPE B does not present */
  605. IX_NPEDL_WARNING_REPORT ("ixNpeDlNpeExecutionStop - Warning:NPEB does not present.\n");
  606. return IX_SUCCESS;
  607. }
  608. } /* end of elseif(IX_NPEDL_NPEID_NPEB) */
  609. else if (IX_NPEDL_NPEID_NPEC == npeId)
  610. {
  611. /* Check whether NPE C is present */
  612. if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEC)==
  613. IX_FEATURE_CTRL_COMPONENT_DISABLED)
  614. {
  615. /* NPE C does not present */
  616. IX_NPEDL_WARNING_REPORT ("ixNpeDlNpeExecutionStop - Warning:NPEC does not present.\n");
  617. return IX_SUCCESS;
  618. }
  619. } /* end of elseif(IX_NPEDL_NPEID_NPEC) */
  620. else
  621. {
  622. /* Invalid NPE ID */
  623. IX_NPEDL_ERROR_REPORT ("ixNpeDlNpeExecutionStop - invalid Npe ID\n");
  624. status = IX_NPEDL_PARAM_ERR;
  625. } /* end of if-else(IX_NPEDL_NPEID_NPEC) */
  626. } /* end of if not IXP42X-AO Silicon */
  627. if (status == IX_SUCCESS)
  628. {
  629. /* call NpeMgr function to stop the NPE */
  630. status = ixNpeDlNpeMgrNpeStop (npeId);
  631. }
  632. IX_NPEDL_TRACE1 (IX_NPEDL_FN_ENTRY_EXIT,
  633. "Exiting ixNpeDlNpeExecutionStop : status = %d\n",
  634. status);
  635. if (IX_SUCCESS == status)
  636. {
  637. /* Indicate NPE has been stopped */
  638. ixNpeDlNpeStarted[npeId] = FALSE ;
  639. }
  640. return status;
  641. }
  642. /*
  643. * Function definition: ixNpeDlUnload
  644. */
  645. PUBLIC IX_STATUS
  646. ixNpeDlUnload (void)
  647. {
  648. IX_STATUS status;
  649. IX_NPEDL_TRACE0 (IX_NPEDL_FN_ENTRY_EXIT,
  650. "Entering ixNpeDlUnload\n");
  651. status = ixNpeDlNpeMgrUninit();
  652. IX_NPEDL_TRACE1 (IX_NPEDL_FN_ENTRY_EXIT,
  653. "Exiting ixNpeDlUnload : status = %d\n",
  654. status);
  655. return status;
  656. }
  657. /*
  658. * Function definition: ixNpeDlStatsShow
  659. */
  660. PUBLIC void
  661. ixNpeDlStatsShow (void)
  662. {
  663. ixOsalLog (IX_OSAL_LOG_LVL_USER,
  664. IX_OSAL_LOG_DEV_STDOUT,
  665. "\nixNpeDlStatsShow:\n"
  666. "\tDownloads Attempted by user: %u\n"
  667. "\tSuccessful Downloads: %u\n"
  668. "\tFailed Downloads (due to Critical Error): %u\n\n",
  669. ixNpeDlStats.attemptedDownloads,
  670. ixNpeDlStats.successfulDownloads,
  671. ixNpeDlStats.criticalFailDownloads,
  672. 0,0,0);
  673. ixNpeDlImageMgrStatsShow ();
  674. ixNpeDlNpeMgrStatsShow ();
  675. }
  676. /*
  677. * Function definition: ixNpeDlStatsReset
  678. */
  679. PUBLIC void
  680. ixNpeDlStatsReset (void)
  681. {
  682. ixNpeDlStats.attemptedDownloads = 0;
  683. ixNpeDlStats.successfulDownloads = 0;
  684. ixNpeDlStats.criticalFailDownloads = 0;
  685. ixNpeDlImageMgrStatsReset ();
  686. ixNpeDlNpeMgrStatsReset ();
  687. }
  688. /*
  689. * Function definition: ixNpeDlNpeInitAndStartInternal
  690. */
  691. PRIVATE IX_STATUS
  692. ixNpeDlNpeInitAndStartInternal (UINT32 *imageLibrary,
  693. UINT32 imageId)
  694. {
  695. UINT32 imageSize;
  696. UINT32 *imageCodePtr = NULL;
  697. IX_STATUS status;
  698. IxNpeDlNpeId npeId = IX_NPEDL_NPEID_FROM_IMAGEID_GET(imageId);
  699. IxFeatureCtrlDeviceId deviceId = IX_NPEDL_DEVICEID_FROM_IMAGEID_GET(imageId);
  700. IX_NPEDL_TRACE0 (IX_NPEDL_FN_ENTRY_EXIT,
  701. "Entering ixNpeDlNpeInitAndStartInternal\n");
  702. ixNpeDlStats.attemptedDownloads++;
  703. /* Check input parameter device correctness */
  704. if ((deviceId >= IX_FEATURE_CTRL_DEVICE_TYPE_MAX) ||
  705. (deviceId < IX_FEATURE_CTRL_DEVICE_TYPE_IXP42X))
  706. {
  707. status = IX_NPEDL_PARAM_ERR;
  708. IX_NPEDL_ERROR_REPORT ("ixNpeDlNpeInitAndStartInternal - "
  709. "invalid parameter\n");
  710. } /* End valid device id checking */
  711. /* Check input parameters */
  712. else if ((npeId >= IX_NPEDL_NPEID_MAX) || (npeId < 0))
  713. {
  714. status = IX_NPEDL_PARAM_ERR;
  715. IX_NPEDL_ERROR_REPORT ("ixNpeDlNpeInitAndStartInternal - "
  716. "invalid parameter\n");
  717. }
  718. else
  719. {
  720. /* Ensure initialisation has been completed */
  721. ixNpeDlNpeMgrInit();
  722. /* Checking if image being loaded is meant for device that is running.
  723. * Image is forward compatible. i.e Image built for IXP42X should run
  724. * on IXP46X but not vice versa.*/
  725. if (deviceId > (ixFeatureCtrlDeviceRead() & IX_FEATURE_CTRL_DEVICE_TYPE_MASK))
  726. {
  727. IX_NPEDL_ERROR_REPORT ("ixNpeDlNpeInitAndStartInternal - "
  728. "Device type mismatch. NPE Image not "
  729. "meant for device in use \n");
  730. return IX_NPEDL_DEVICE_ERR;
  731. }/* if statement - matching image device and current device */
  732. /* If not IXP42X A0 stepping, proceed to check for existence of npe's */
  733. if ((IX_FEATURE_CTRL_SILICON_TYPE_A0 !=
  734. (ixFeatureCtrlProductIdRead() & IX_FEATURE_CTRL_SILICON_STEPPING_MASK))
  735. || (IX_FEATURE_CTRL_DEVICE_TYPE_IXP42X != ixFeatureCtrlDeviceRead ()))
  736. {
  737. if (npeId == IX_NPEDL_NPEID_NPEA)
  738. {
  739. if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEA) ==
  740. IX_FEATURE_CTRL_COMPONENT_DISABLED)
  741. {
  742. IX_NPEDL_WARNING_REPORT("Warning: the NPE A component you specified does"
  743. " not exist\n");
  744. return IX_SUCCESS;
  745. }
  746. } /* end of if(npeId) */
  747. else if (npeId == IX_NPEDL_NPEID_NPEB)
  748. {
  749. if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEB)==
  750. IX_FEATURE_CTRL_COMPONENT_DISABLED)
  751. {
  752. IX_NPEDL_WARNING_REPORT("Warning: the NPE B component you specified"
  753. " does not exist\n");
  754. return IX_SUCCESS;
  755. }
  756. } /* end of elseif(npeId) */
  757. else if (npeId == IX_NPEDL_NPEID_NPEC)
  758. {
  759. if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEC)==
  760. IX_FEATURE_CTRL_COMPONENT_DISABLED)
  761. {
  762. IX_NPEDL_WARNING_REPORT("Warning: the NPE C component you specified"
  763. " does not exist\n");
  764. return IX_SUCCESS;
  765. }
  766. } /* end of elseif(npeId) */
  767. } /* end of if not IXP42X-A0 Silicon */
  768. /* stop and reset the NPE */
  769. status = ixNpeDlNpeStopAndReset (npeId);
  770. if (IX_SUCCESS != status)
  771. {
  772. IX_NPEDL_ERROR_REPORT ("Failed to stop and reset NPE\n");
  773. return status;
  774. }
  775. /* Locate image */
  776. status = ixNpeDlImageMgrImageFind (imageLibrary, imageId,
  777. &imageCodePtr, &imageSize);
  778. if (IX_SUCCESS == status)
  779. {
  780. /*
  781. * If download was successful, store image Id in list of
  782. * currently loaded images. If a critical error occured
  783. * during download, record that the NPE has an invalid image
  784. */
  785. status = ixNpeDlNpeMgrImageLoad (npeId, imageCodePtr, TRUE);
  786. if (IX_SUCCESS == status)
  787. {
  788. ixNpeDlNpeState[npeId].validImage = TRUE;
  789. ixNpeDlStats.successfulDownloads++;
  790. status = ixNpeDlNpeExecutionStart (npeId);
  791. }
  792. else if ((status == IX_NPEDL_CRITICAL_NPE_ERR) ||
  793. (status == IX_NPEDL_CRITICAL_MICROCODE_ERR))
  794. {
  795. ixNpeDlNpeState[npeId].validImage = FALSE;
  796. ixNpeDlStats.criticalFailDownloads++;
  797. }
  798. /* NOTE - The following section of code is here to support
  799. * a deprecated function ixNpeDlLoadedImageGet(). When that
  800. * function is removed from the API, this code should be revised.
  801. */
  802. ixNpeDlNpeState[npeId].imageId.npeId = npeId;
  803. ixNpeDlNpeState[npeId].imageId.functionalityId =
  804. IX_NPEDL_FUNCTIONID_FROM_IMAGEID_GET(imageId);
  805. ixNpeDlNpeState[npeId].imageId.major =
  806. IX_NPEDL_MAJOR_FROM_IMAGEID_GET(imageId);
  807. ixNpeDlNpeState[npeId].imageId.minor =
  808. IX_NPEDL_MINOR_FROM_IMAGEID_GET(imageId);
  809. } /* end of if(IX_SUCCESS) */ /* condition: image located successfully in microcode image */
  810. } /* end of if-else(npeId-deviceId) */ /* condition: parameter checks ok */
  811. IX_NPEDL_TRACE1 (IX_NPEDL_FN_ENTRY_EXIT,
  812. "Exiting ixNpeDlNpeInitAndStartInternal : "
  813. "status = %d\n", status);
  814. return status;
  815. }
  816. /*
  817. * Function definition: ixNpeDlCustomImageNpeInitAndStart
  818. */
  819. PUBLIC IX_STATUS
  820. ixNpeDlCustomImageNpeInitAndStart (UINT32 *imageLibrary,
  821. UINT32 imageId)
  822. {
  823. IX_STATUS status;
  824. if (imageLibrary == NULL)
  825. {
  826. status = IX_NPEDL_PARAM_ERR;
  827. IX_NPEDL_ERROR_REPORT ("ixNpeDlCustomImageNpeInitAndStart "
  828. "- invalid parameter\n");
  829. }
  830. else
  831. {
  832. status = ixNpeDlNpeInitAndStartInternal (imageLibrary, imageId);
  833. } /* end of if-else(imageLibrary) */
  834. return status;
  835. }
  836. /*
  837. * Function definition: ixNpeDlNpeInitAndStart
  838. */
  839. PUBLIC IX_STATUS
  840. ixNpeDlNpeInitAndStart (UINT32 imageId)
  841. {
  842. return ixNpeDlNpeInitAndStartInternal (NULL, imageId);
  843. }
  844. /*
  845. * Function definition: ixNpeDlLoadedImageFunctionalityGet
  846. */
  847. PUBLIC IX_STATUS
  848. ixNpeDlLoadedImageFunctionalityGet (IxNpeDlNpeId npeId,
  849. UINT8 *functionalityId)
  850. {
  851. /* Check input parameters */
  852. if ((npeId >= IX_NPEDL_NPEID_MAX) || (npeId < 0))
  853. {
  854. IX_NPEDL_ERROR_REPORT ("ixNpeDlLoadedImageFunctionalityGet "
  855. "- invalid parameter\n");
  856. return IX_NPEDL_PARAM_ERR;
  857. }
  858. if (functionalityId == NULL)
  859. {
  860. IX_NPEDL_ERROR_REPORT ("ixNpeDlLoadedImageFunctionalityGet "
  861. "- invalid parameter\n");
  862. return IX_NPEDL_PARAM_ERR;
  863. }
  864. if (ixNpeDlNpeState[npeId].validImage)
  865. {
  866. *functionalityId = ixNpeDlNpeState[npeId].imageId.functionalityId;
  867. return IX_SUCCESS;
  868. }
  869. else
  870. {
  871. return IX_FAIL;
  872. }
  873. }