IxNpeMhConfig_p.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531
  1. /**
  2. * @file IxNpeMhConfig_p.h
  3. *
  4. * @author Intel Corporation
  5. * @date 18 Jan 2002
  6. *
  7. * @brief This file contains the private API for the Configuration module.
  8. *
  9. *
  10. * @par
  11. * IXP400 SW Release version 2.0
  12. *
  13. * -- Copyright Notice --
  14. *
  15. * @par
  16. * Copyright 2001-2005, Intel Corporation.
  17. * All rights reserved.
  18. *
  19. * @par
  20. * SPDX-License-Identifier: BSD-3-Clause
  21. * @par
  22. * -- End of Copyright Notice --
  23. */
  24. /**
  25. * @defgroup IxNpeMhConfig_p IxNpeMhConfig_p
  26. *
  27. * @brief The private API for the Configuration module.
  28. *
  29. * @{
  30. */
  31. #ifndef IXNPEMHCONFIG_P_H
  32. #define IXNPEMHCONFIG_P_H
  33. #include "IxOsal.h"
  34. #include "IxNpeMh.h"
  35. #include "IxNpeMhMacros_p.h"
  36. /*
  37. * inline definition
  38. */
  39. /* enable function inlining for performances */
  40. #ifdef IXNPEMHSOLICITEDCBMGR_C
  41. /* Non-inline functions will be defined in this translation unit.
  42. Reason is that in GNU Compiler, if the Optimization is turn off, all extern inline
  43. functions will not be compiled.
  44. */
  45. # ifndef __wince
  46. # ifndef IXNPEMHCONFIG_INLINE
  47. # define IXNPEMHCONFIG_INLINE
  48. # endif
  49. # else
  50. # ifndef IXNPEMHCONFIG_INLINE
  51. # define IXNPEMHCONFIG_INLINE IX_OSAL_INLINE_EXTERN
  52. # endif
  53. # endif /* __wince*/
  54. #else
  55. # ifndef IXNPEMHCONFIG_INLINE
  56. # define IXNPEMHCONFIG_INLINE IX_OSAL_INLINE_EXTERN
  57. # endif /* IXNPEMHCONFIG_INLINE */
  58. #endif /* IXNPEMHSOLICITEDCBMGR_C */
  59. /*
  60. * Typedefs and #defines, etc.
  61. */
  62. typedef void (*IxNpeMhConfigIsr) (int); /**< ISR function pointer */
  63. /**
  64. * @struct IxNpeMhConfigNpeInfo
  65. *
  66. * @brief This structure is used to maintain the configuration information
  67. * associated with an NPE.
  68. */
  69. typedef struct
  70. {
  71. IxOsalMutex mutex; /**< mutex */
  72. UINT32 interruptId; /**< interrupt ID */
  73. UINT32 virtualRegisterBase; /**< register virtual base address */
  74. UINT32 statusRegister; /**< status register virtual address */
  75. UINT32 controlRegister; /**< control register virtual address */
  76. UINT32 inFifoRegister; /**< inFIFO register virutal address */
  77. UINT32 outFifoRegister; /**< outFIFO register virtual address */
  78. IxNpeMhConfigIsr isr; /**< isr routine for handling interrupt */
  79. BOOL oldInterruptState; /**< old interrupt state (true => enabled) */
  80. } IxNpeMhConfigNpeInfo;
  81. /*
  82. * #defines for function return types, etc.
  83. */
  84. /**< NPE register base address */
  85. #define IX_NPEMH_NPE_BASE (IX_OSAL_IXP400_PERIPHERAL_PHYS_BASE)
  86. #define IX_NPEMH_NPEA_OFFSET (0x6000) /**< NPE-A register base offset */
  87. #define IX_NPEMH_NPEB_OFFSET (0x7000) /**< NPE-B register base offset */
  88. #define IX_NPEMH_NPEC_OFFSET (0x8000) /**< NPE-C register base offset */
  89. #define IX_NPEMH_NPESTAT_OFFSET (0x002C) /**< NPE status register offset */
  90. #define IX_NPEMH_NPECTL_OFFSET (0x0030) /**< NPE control register offset */
  91. #define IX_NPEMH_NPEFIFO_OFFSET (0x0038) /**< NPE FIFO register offset */
  92. /** NPE-A register base address */
  93. #define IX_NPEMH_NPEA_BASE (IX_NPEMH_NPE_BASE + IX_NPEMH_NPEA_OFFSET)
  94. /** NPE-B register base address */
  95. #define IX_NPEMH_NPEB_BASE (IX_NPEMH_NPE_BASE + IX_NPEMH_NPEB_OFFSET)
  96. /** NPE-C register base address */
  97. #define IX_NPEMH_NPEC_BASE (IX_NPEMH_NPE_BASE + IX_NPEMH_NPEC_OFFSET)
  98. /* NPE-A configuration */
  99. /** NPE-A interrupt */
  100. #define IX_NPEMH_NPEA_INT (IX_OSAL_IXP400_NPEA_IRQ_LVL)
  101. /** NPE-A FIFO register */
  102. #define IX_NPEMH_NPEA_FIFO (IX_NPEMH_NPEA_BASE + IX_NPEMH_NPEFIFO_OFFSET)
  103. /** NPE-A control register */
  104. #define IX_NPEMH_NPEA_CTL (IX_NPEMH_NPEA_BASE + IX_NPEMH_NPECTL_OFFSET)
  105. /** NPE-A status register */
  106. #define IX_NPEMH_NPEA_STAT (IX_NPEMH_NPEA_BASE + IX_NPEMH_NPESTAT_OFFSET)
  107. /* NPE-B configuration */
  108. /** NPE-B interrupt */
  109. #define IX_NPEMH_NPEB_INT (IX_OSAL_IXP400_NPEB_IRQ_LVL)
  110. /** NPE-B FIFO register */
  111. #define IX_NPEMH_NPEB_FIFO (IX_NPEMH_NPEB_BASE + IX_NPEMH_NPEFIFO_OFFSET)
  112. /** NPE-B control register */
  113. #define IX_NPEMH_NPEB_CTL (IX_NPEMH_NPEB_BASE + IX_NPEMH_NPECTL_OFFSET)
  114. /** NPE-B status register */
  115. #define IX_NPEMH_NPEB_STAT (IX_NPEMH_NPEB_BASE + IX_NPEMH_NPESTAT_OFFSET)
  116. /* NPE-C configuration */
  117. /** NPE-C interrupt */
  118. #define IX_NPEMH_NPEC_INT (IX_OSAL_IXP400_NPEC_IRQ_LVL)
  119. /** NPE-C FIFO register */
  120. #define IX_NPEMH_NPEC_FIFO (IX_NPEMH_NPEC_BASE + IX_NPEMH_NPEFIFO_OFFSET)
  121. /** NPE-C control register */
  122. #define IX_NPEMH_NPEC_CTL (IX_NPEMH_NPEC_BASE + IX_NPEMH_NPECTL_OFFSET)
  123. /** NPE-C status register */
  124. #define IX_NPEMH_NPEC_STAT (IX_NPEMH_NPEC_BASE + IX_NPEMH_NPESTAT_OFFSET)
  125. /* NPE control register bit definitions */
  126. #define IX_NPEMH_NPE_CTL_OFE (1 << 16) /**< OutFifoEnable */
  127. #define IX_NPEMH_NPE_CTL_IFE (1 << 17) /**< InFifoEnable */
  128. #define IX_NPEMH_NPE_CTL_OFEWE (1 << 24) /**< OutFifoEnableWriteEnable */
  129. #define IX_NPEMH_NPE_CTL_IFEWE (1 << 25) /**< InFifoEnableWriteEnable */
  130. /* NPE status register bit definitions */
  131. #define IX_NPEMH_NPE_STAT_OFNE (1 << 16) /**< OutFifoNotEmpty */
  132. #define IX_NPEMH_NPE_STAT_IFNF (1 << 17) /**< InFifoNotFull */
  133. #define IX_NPEMH_NPE_STAT_OFNF (1 << 18) /**< OutFifoNotFull */
  134. #define IX_NPEMH_NPE_STAT_IFNE (1 << 19) /**< InFifoNotEmpty */
  135. #define IX_NPEMH_NPE_STAT_MBINT (1 << 20) /**< Mailbox interrupt */
  136. #define IX_NPEMH_NPE_STAT_IFINT (1 << 21) /**< InFifo interrupt */
  137. #define IX_NPEMH_NPE_STAT_OFINT (1 << 22) /**< OutFifo interrupt */
  138. #define IX_NPEMH_NPE_STAT_WFINT (1 << 23) /**< WatchFifo interrupt */
  139. /**
  140. * Variable declarations. Externs are followed by static variables.
  141. */
  142. extern IxNpeMhConfigNpeInfo ixNpeMhConfigNpeInfo[IX_NPEMH_NUM_NPES];
  143. /*
  144. * Prototypes for interface functions.
  145. */
  146. /**
  147. * @fn void ixNpeMhConfigInitialize (
  148. IxNpeMhNpeInterrupts npeInterrupts)
  149. *
  150. * @brief This function initialises the Configuration module.
  151. *
  152. * @param IxNpeMhNpeInterrupts npeInterrupts (in) - whether or not to
  153. * service the NPE "outFIFO not empty" interrupts.
  154. *
  155. * @return No return value.
  156. */
  157. void ixNpeMhConfigInitialize (
  158. IxNpeMhNpeInterrupts npeInterrupts);
  159. /**
  160. * @fn void ixNpeMhConfigUninit (void)
  161. *
  162. * @brief This function uninitialises the Configuration module.
  163. *
  164. * @return No return value.
  165. */
  166. void ixNpeMhConfigUninit (void);
  167. /**
  168. * @fn void ixNpeMhConfigIsrRegister (
  169. IxNpeMhNpeId npeId,
  170. IxNpeMhConfigIsr isr)
  171. *
  172. * @brief This function registers an ISR to handle NPE "outFIFO not
  173. * empty" interrupts.
  174. *
  175. * @param IxNpeMhNpeId npeId (in) - the ID of the NPE whose interrupt will
  176. * be handled.
  177. * @param IxNpeMhConfigIsr isr (in) - the ISR function pointer that the
  178. * interrupt will trigger.
  179. *
  180. * @return No return value.
  181. */
  182. void ixNpeMhConfigIsrRegister (
  183. IxNpeMhNpeId npeId,
  184. IxNpeMhConfigIsr isr);
  185. /**
  186. * @fn BOOL ixNpeMhConfigNpeInterruptEnable (
  187. IxNpeMhNpeId npeId)
  188. *
  189. * @brief This function enables a NPE's "outFIFO not empty" interrupt.
  190. *
  191. * @param IxNpeMhNpeId npeId (in) - the ID of the NPE whose interrupt will
  192. * be enabled.
  193. *
  194. * @return Returns the previous state of the interrupt (true => enabled).
  195. */
  196. BOOL ixNpeMhConfigNpeInterruptEnable (
  197. IxNpeMhNpeId npeId);
  198. /**
  199. * @fn BOOL ixNpeMhConfigNpeInterruptDisable (
  200. IxNpeMhNpeId npeId)
  201. *
  202. * @brief This function disables a NPE's "outFIFO not empty" interrupt
  203. *
  204. * @param IxNpeMhNpeId npeId (in) - the ID of the NPE whose interrupt will
  205. * be disabled.
  206. *
  207. * @return Returns the previous state of the interrupt (true => enabled).
  208. */
  209. BOOL ixNpeMhConfigNpeInterruptDisable (
  210. IxNpeMhNpeId npeId);
  211. /**
  212. * @fn IxNpeMhMessageId ixNpeMhConfigMessageIdGet (
  213. IxNpeMhMessage message)
  214. *
  215. * @brief This function gets the ID of a message.
  216. *
  217. * @param IxNpeMhMessage message (in) - the message to get the ID of.
  218. *
  219. * @return the ID of the message
  220. */
  221. IxNpeMhMessageId ixNpeMhConfigMessageIdGet (
  222. IxNpeMhMessage message);
  223. /**
  224. * @fn BOOL ixNpeMhConfigNpeIdIsValid (
  225. IxNpeMhNpeId npeId)
  226. *
  227. * @brief This function checks to see if a NPE ID is valid.
  228. *
  229. * @param IxNpeMhNpeId npeId (in) - the NPE ID to validate.
  230. *
  231. * @return true if the NPE ID is valid, otherwise false.
  232. */
  233. BOOL ixNpeMhConfigNpeIdIsValid (
  234. IxNpeMhNpeId npeId);
  235. /**
  236. * @fn void ixNpeMhConfigLockGet (
  237. IxNpeMhNpeId npeId)
  238. *
  239. * @brief This function gets a lock for exclusive NPE interaction, and
  240. * disables the NPE's "outFIFO not empty" interrupt.
  241. *
  242. * @param IxNpeMhNpeId npeId (in) - The ID of the NPE for which to get the
  243. * lock and disable its interrupt.
  244. *
  245. * @return No return value.
  246. */
  247. void ixNpeMhConfigLockGet (
  248. IxNpeMhNpeId npeId);
  249. /**
  250. * @fn void ixNpeMhConfigLockRelease (
  251. IxNpeMhNpeId npeId)
  252. *
  253. * @brief This function releases a lock for exclusive NPE interaction, and
  254. * enables the NPE's "outFIFO not empty" interrupt.
  255. *
  256. * @param IxNpeMhNpeId npeId (in) - The ID of the NPE for which to release
  257. * the lock and enable its interrupt.
  258. *
  259. * @return No return value.
  260. */
  261. void ixNpeMhConfigLockRelease (
  262. IxNpeMhNpeId npeId);
  263. /**
  264. * @fn BOOL ixNpeMhConfigInFifoIsEmpty (
  265. IxNpeMhNpeId npeId)
  266. *
  267. * @brief This inline function checks if a NPE's inFIFO is empty.
  268. *
  269. * @param IxNpeMhNpeId npeId (in) - The ID of the NPE for which the inFIFO
  270. * will be checked.
  271. *
  272. * @return true if the inFIFO is empty, otherwise false.
  273. */
  274. IXNPEMHCONFIG_INLINE BOOL ixNpeMhConfigInFifoIsEmpty (
  275. IxNpeMhNpeId npeId);
  276. /**
  277. * @fn BOOL ixNpeMhConfigInFifoIsFull (
  278. IxNpeMhNpeId npeId)
  279. *
  280. * @brief This inline function checks if a NPE's inFIFO is full.
  281. *
  282. * @param IxNpeMhNpeId npeId (in) - The ID of the NPE for which the inFIFO
  283. * will be checked.
  284. *
  285. * @return true if the inFIFO is full, otherwise false.
  286. */
  287. IXNPEMHCONFIG_INLINE BOOL ixNpeMhConfigInFifoIsFull (
  288. IxNpeMhNpeId npeId);
  289. /**
  290. * @fn BOOL ixNpeMhConfigOutFifoIsEmpty (
  291. IxNpeMhNpeId npeId)
  292. *
  293. * @brief This inline function checks if a NPE's outFIFO is empty.
  294. *
  295. * @param IxNpeMhNpeId npeId (in) - The ID of the NPE for which the outFIFO
  296. * will be checked.
  297. *
  298. * @return true if the outFIFO is empty, otherwise false.
  299. */
  300. IXNPEMHCONFIG_INLINE BOOL ixNpeMhConfigOutFifoIsEmpty (
  301. IxNpeMhNpeId npeId);
  302. /**
  303. * @fn BOOL ixNpeMhConfigOutFifoIsFull (
  304. IxNpeMhNpeId npeId)
  305. *
  306. * @brief This inline function checks if a NPE's outFIFO is full.
  307. *
  308. * @param IxNpeMhNpeId npeId (in) - The ID of the NPE for which the outFIFO
  309. * will be checked.
  310. *
  311. * @return true if the outFIFO is full, otherwise false.
  312. */
  313. IXNPEMHCONFIG_INLINE BOOL ixNpeMhConfigOutFifoIsFull (
  314. IxNpeMhNpeId npeId);
  315. /**
  316. * @fn IX_STATUS ixNpeMhConfigInFifoWrite (
  317. IxNpeMhNpeId npeId,
  318. IxNpeMhMessage message)
  319. *
  320. * @brief This function writes a message to a NPE's inFIFO. The caller
  321. * must first check that the NPE's inFifo is not full. After writing the first
  322. * word of the message, this function will keep polling NPE's inFIFO is not
  323. * full to write the second word. If inFIFO is not available after maximum
  324. * retries (IX_NPE_MH_MAX_NUM_OF_RETRIES), this function will return TIMEOUT
  325. * status to indicate NPE hang / halt.
  326. *
  327. * @param IxNpeMhNpeId npeId (in) - The ID of the NPE for which the inFIFO
  328. * will be written to.
  329. * @param IxNpeMhMessage message (in) - The message to write.
  330. *
  331. * @return The function returns a status indicating success, failure or timeout.
  332. */
  333. IX_STATUS ixNpeMhConfigInFifoWrite (
  334. IxNpeMhNpeId npeId,
  335. IxNpeMhMessage message);
  336. /**
  337. * @fn IX_STATUS ixNpeMhConfigOutFifoRead (
  338. IxNpeMhNpeId npeId,
  339. IxNpeMhMessage *message)
  340. *
  341. * @brief This function reads a message from a NPE's outFIFO. The caller
  342. * must first check that the NPE's outFifo is not empty. After reading the first
  343. * word of the message, this function will keep polling NPE's outFIFO is not
  344. * empty to read the second word. If outFIFO is empty after maximum
  345. * retries (IX_NPE_MH_MAX_NUM_OF_RETRIES), this function will return TIMEOUT
  346. * status to indicate NPE hang / halt.
  347. *
  348. * @param IxNpeMhNpeId npeId (in) - The ID of the NPE for which the outFIFO
  349. * will be read from.
  350. * @param IxNpeMhMessage message (out) - The message read.
  351. *
  352. * @return The function returns a status indicating success, failure or timeout.
  353. */
  354. IX_STATUS ixNpeMhConfigOutFifoRead (
  355. IxNpeMhNpeId npeId,
  356. IxNpeMhMessage *message);
  357. /**
  358. * @fn void ixNpeMhConfigShow (
  359. IxNpeMhNpeId npeId)
  360. *
  361. * @brief This function will display the current state of the Configuration
  362. * module.
  363. *
  364. * @param IxNpeMhNpeId npeId (in) - The ID of the NPE to display state
  365. * information for.
  366. *
  367. * @return No return value.
  368. */
  369. void ixNpeMhConfigShow (
  370. IxNpeMhNpeId npeId);
  371. /**
  372. * @fn void ixNpeMhConfigShowReset (
  373. IxNpeMhNpeId npeId)
  374. *
  375. * @brief This function will reset the current state of the Configuration
  376. * module.
  377. *
  378. * @param IxNpeMhNpeId npeId (in) - The ID of the NPE to reset state
  379. * information for.
  380. *
  381. * @return No return value.
  382. */
  383. void ixNpeMhConfigShowReset (
  384. IxNpeMhNpeId npeId);
  385. /*
  386. * Inline functions
  387. */
  388. /*
  389. * This inline function checks if a NPE's inFIFO is empty.
  390. */
  391. IXNPEMHCONFIG_INLINE
  392. BOOL ixNpeMhConfigInFifoIsEmpty (
  393. IxNpeMhNpeId npeId)
  394. {
  395. UINT32 ifne;
  396. volatile UINT32 *statusReg =
  397. (UINT32 *)ixNpeMhConfigNpeInfo[npeId].statusRegister;
  398. /* get the IFNE (InFifoNotEmpty) bit of the status register */
  399. IX_NPEMH_REGISTER_READ_BITS (statusReg, &ifne, IX_NPEMH_NPE_STAT_IFNE);
  400. /* if the IFNE status bit is unset then the inFIFO is empty */
  401. return (ifne == 0);
  402. }
  403. /*
  404. * This inline function checks if a NPE's inFIFO is full.
  405. */
  406. IXNPEMHCONFIG_INLINE
  407. BOOL ixNpeMhConfigInFifoIsFull (
  408. IxNpeMhNpeId npeId)
  409. {
  410. UINT32 ifnf;
  411. volatile UINT32 *statusReg =
  412. (UINT32 *)ixNpeMhConfigNpeInfo[npeId].statusRegister;
  413. /* get the IFNF (InFifoNotFull) bit of the status register */
  414. IX_NPEMH_REGISTER_READ_BITS (statusReg, &ifnf, IX_NPEMH_NPE_STAT_IFNF);
  415. /* if the IFNF status bit is unset then the inFIFO is full */
  416. return (ifnf == 0);
  417. }
  418. /*
  419. * This inline function checks if a NPE's outFIFO is empty.
  420. */
  421. IXNPEMHCONFIG_INLINE
  422. BOOL ixNpeMhConfigOutFifoIsEmpty (
  423. IxNpeMhNpeId npeId)
  424. {
  425. UINT32 ofne;
  426. volatile UINT32 *statusReg =
  427. (UINT32 *)ixNpeMhConfigNpeInfo[npeId].statusRegister;
  428. /* get the OFNE (OutFifoNotEmpty) bit of the status register */
  429. IX_NPEMH_REGISTER_READ_BITS (statusReg, &ofne, IX_NPEMH_NPE_STAT_OFNE);
  430. /* if the OFNE status bit is unset then the outFIFO is empty */
  431. return (ofne == 0);
  432. }
  433. /*
  434. * This inline function checks if a NPE's outFIFO is full.
  435. */
  436. IXNPEMHCONFIG_INLINE
  437. BOOL ixNpeMhConfigOutFifoIsFull (
  438. IxNpeMhNpeId npeId)
  439. {
  440. UINT32 ofnf;
  441. volatile UINT32 *statusReg =
  442. (UINT32 *)ixNpeMhConfigNpeInfo[npeId].statusRegister;
  443. /* get the OFNF (OutFifoNotFull) bit of the status register */
  444. IX_NPEMH_REGISTER_READ_BITS (statusReg, &ofnf, IX_NPEMH_NPE_STAT_OFNF);
  445. /* if the OFNF status bit is unset then the outFIFO is full */
  446. return (ofnf == 0);
  447. }
  448. #endif /* IXNPEMHCONFIG_P_H */
  449. /**
  450. * @} defgroup IxNpeMhConfig_p
  451. */