IxNpeDlMacros_p.h 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. /**
  2. * @file IxNpeDlMacros_p.h
  3. *
  4. * @author Intel Corporation
  5. * @date 21 January 2002
  6. *
  7. * @brief This file contains the macros for the IxNpeDl component.
  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 IxNpeDlMacros_p IxNpeDlMacros_p
  26. *
  27. * @brief Macros for the IxNpeDl component.
  28. *
  29. * @{
  30. */
  31. #ifndef IXNPEDLMACROS_P_H
  32. #define IXNPEDLMACROS_P_H
  33. /*
  34. * Put the user defined include files required.
  35. */
  36. #if (CPU != XSCALE)
  37. /* To support IxNpeDl unit tests... */
  38. #include <stdio.h>
  39. #include "test/IxNpeDlTestReg.h"
  40. #else
  41. #include "IxOsal.h"
  42. #endif
  43. /*
  44. * Typedefs
  45. */
  46. /**
  47. * @typedef IxNpeDlTraceTypes
  48. * @brief Enumeration defining IxNpeDl trace levels
  49. */
  50. typedef enum
  51. {
  52. IX_NPEDL_TRACE_OFF, /**< no trace */
  53. IX_NPEDL_DEBUG, /**< debug */
  54. IX_NPEDL_FN_ENTRY_EXIT /**< function entry/exit */
  55. } IxNpeDlTraceTypes;
  56. /*
  57. * #defines and macros.
  58. */
  59. /* Implementation of the following macros for use with IxNpeDl unit test code */
  60. #if (CPU != XSCALE)
  61. /**
  62. * @def IX_NPEDL_TRACE_LEVEL
  63. *
  64. * @brief IxNpeDl debug trace level
  65. */
  66. #define IX_NPEDL_TRACE_LEVEL IX_NPEDL_FN_ENTRY_EXIT
  67. /**
  68. * @def IX_NPEDL_ERROR_REPORT
  69. *
  70. * @brief Mechanism for reporting IxNpeDl software errors
  71. *
  72. * @param char* [in] STR - Error string to report
  73. *
  74. * This macro simply prints the error string passed.
  75. * Intended for use with IxNpeDl unit test code.
  76. *
  77. * @return none
  78. */
  79. #define IX_NPEDL_ERROR_REPORT(STR) printf ("IxNpeDl ERROR: %s\n", (STR));
  80. /**
  81. * @def IX_NPEDL_WARNING_REPORT
  82. *
  83. * @brief Mechanism for reporting IxNpeDl software errors
  84. *
  85. * @param char* [in] STR - Error string to report
  86. *
  87. * This macro simply prints the error string passed.
  88. * Intended for use with IxNpeDl unit test code.
  89. *
  90. * @return none
  91. */
  92. #define IX_NPEDL_WARNING_REPORT(STR) printf ("IxNpeDl WARNING: %s\n", (STR));
  93. /**
  94. * @def IX_NPEDL_TRACE0
  95. *
  96. * @brief Mechanism for tracing debug for the IxNpeDl component, for no arguments
  97. *
  98. * @param unsigned [in] LEVEL - one of IxNpeDlTraceTypes enumerated values
  99. * @param char* [in] STR - Trace string
  100. *
  101. * This macro simply prints the trace string passed, if the level is supported.
  102. * Intended for use with IxNpeDl unit test code.
  103. *
  104. * @return none
  105. */
  106. #define IX_NPEDL_TRACE0(LEVEL, STR) \
  107. { \
  108. if (LEVEL <= IX_NPEDL_TRACE_LEVEL) \
  109. { \
  110. printf ("IxNpeDl TRACE: "); \
  111. printf ((STR)); \
  112. printf ("\n"); \
  113. } \
  114. }
  115. /**
  116. * @def IX_NPEDL_TRACE1
  117. *
  118. * @brief Mechanism for tracing debug for the IxNpeDl component, with 1 argument
  119. *
  120. * @param unsigned [in] LEVEL - one of IxNpeDlTraceTypes enumerated values
  121. * @param char* [in] STR - Trace string
  122. * @param argType [in] ARG1 - Argument to trace
  123. *
  124. * This macro simply prints the trace string passed, if the level is supported.
  125. * Intended for use with IxNpeDl unit test code.
  126. *
  127. * @return none
  128. */
  129. #define IX_NPEDL_TRACE1(LEVEL, STR, ARG1) \
  130. { \
  131. if (LEVEL <= IX_NPEDL_TRACE_LEVEL) \
  132. { \
  133. printf ("IxNpeDl TRACE: "); \
  134. printf (STR, ARG1); \
  135. printf ("\n"); \
  136. } \
  137. }
  138. /**
  139. * @def IX_NPEDL_TRACE2
  140. *
  141. * @brief Mechanism for tracing debug for the IxNpeDl component, with 2 arguments
  142. *
  143. * @param unsigned [in] LEVEL - one of IxNpeDlTraceTypes enumerated values
  144. * @param char* [in] STR - Trace string
  145. * @param argType [in] ARG1 - Argument to trace
  146. * @param argType [in] ARG2 - Argument to trace
  147. *
  148. * This macro simply prints the trace string passed, if the level is supported.
  149. * Intended for use with IxNpeDl unit test code.
  150. *
  151. * @return none
  152. */
  153. #define IX_NPEDL_TRACE2(LEVEL, STR, ARG1, ARG2) \
  154. { \
  155. if (LEVEL <= IX_NPEDL_TRACE_LEVEL) \
  156. { \
  157. printf ("IxNpeDl TRACE: "); \
  158. printf (STR, ARG1, ARG2); \
  159. printf ("\n"); \
  160. } \
  161. }
  162. /**
  163. * @def IX_NPEDL_REG_WRITE
  164. *
  165. * @brief Mechanism for writing to a memory-mapped register
  166. *
  167. * @param UINT32 [in] base - Base memory address for this NPE's registers
  168. * @param UINT32 [in] offset - Offset from base memory address
  169. * @param UINT32 [in] value - Value to write to register
  170. *
  171. * This macro calls a function from Unit Test code to write a register. This
  172. * allows extra flexibility for unit testing of the IxNpeDl component.
  173. *
  174. * @return none
  175. */
  176. #define IX_NPEDL_REG_WRITE(base, offset, value) \
  177. { \
  178. ixNpeDlTestRegWrite (base, offset, value); \
  179. }
  180. /**
  181. * @def IX_NPEDL_REG_READ
  182. *
  183. * @brief Mechanism for reading from a memory-mapped register
  184. *
  185. * @param UINT32 [in] base - Base memory address for this NPE's registers
  186. * @param UINT32 [in] offset - Offset from base memory address
  187. * @param UINT32 *[out] value - Value read from register
  188. *
  189. * This macro calls a function from Unit Test code to read a register. This
  190. * allows extra flexibility for unit testing of the IxNpeDl component.
  191. *
  192. * @return none
  193. */
  194. #define IX_NPEDL_REG_READ(base, offset, value) \
  195. { \
  196. ixNpeDlTestRegRead (base, offset, value); \
  197. }
  198. /* Implementation of the following macros when integrated with IxOsal */
  199. #else /* #if (CPU != XSCALE) */
  200. /**
  201. * @def IX_NPEDL_TRACE_LEVEL
  202. *
  203. * @brief IxNpeDl debug trace level
  204. */
  205. #define IX_NPEDL_TRACE_LEVEL IX_NPEDL_DEBUG
  206. /**
  207. * @def IX_NPEDL_ERROR_REPORT
  208. *
  209. * @brief Mechanism for reporting IxNpeDl software errors
  210. *
  211. * @param char* [in] STR - Error string to report
  212. *
  213. * This macro is used to report IxNpeDl software errors.
  214. *
  215. * @return none
  216. */
  217. #define IX_NPEDL_ERROR_REPORT(STR) \
  218. ixOsalLog (IX_OSAL_LOG_LVL_ERROR, IX_OSAL_LOG_DEV_STDERR, STR, 0, 0, 0, 0, 0, 0);
  219. /**
  220. * @def IX_NPEDL_WARNING_REPORT
  221. *
  222. * @brief Mechanism for reporting IxNpeDl software warnings
  223. *
  224. * @param char* [in] STR - Warning string to report
  225. *
  226. * This macro is used to report IxNpeDl software warnings.
  227. *
  228. * @return none
  229. */
  230. #define IX_NPEDL_WARNING_REPORT(STR) \
  231. ixOsalLog (IX_OSAL_LOG_LVL_WARNING, IX_OSAL_LOG_DEV_STDOUT, STR, 0, 0, 0, 0, 0, 0);
  232. /**
  233. * @def IX_NPEDL_TRACE0
  234. *
  235. * @brief Mechanism for tracing debug for the IxNpeDl component, for no arguments
  236. *
  237. * @param unsigned [in] LEVEL - one of IxNpeDlTraceTypes enumerated values
  238. * @param char* [in] STR - Trace string
  239. *
  240. * This macro simply prints the trace string passed, if the level is supported.
  241. *
  242. * @return none
  243. */
  244. #define IX_NPEDL_TRACE0(LEVEL, STR) \
  245. { \
  246. if (LEVEL <= IX_NPEDL_TRACE_LEVEL) \
  247. { \
  248. if (LEVEL == IX_NPEDL_FN_ENTRY_EXIT) \
  249. { \
  250. ixOsalLog (IX_OSAL_LOG_LVL_DEBUG3, IX_OSAL_LOG_DEV_STDOUT, STR, 0, 0, 0, 0, 0, 0); \
  251. } \
  252. else if (LEVEL == IX_NPEDL_DEBUG) \
  253. { \
  254. ixOsalLog (IX_OSAL_LOG_LVL_MESSAGE, IX_OSAL_LOG_DEV_STDOUT, STR, 0, 0, 0, 0, 0, 0); \
  255. } \
  256. } \
  257. }
  258. /**
  259. * @def IX_NPEDL_TRACE1
  260. *
  261. * @brief Mechanism for tracing debug for the IxNpeDl component, with 1 argument
  262. *
  263. * @param unsigned [in] LEVEL - one of IxNpeDlTraceTypes enumerated values
  264. * @param char* [in] STR - Trace string
  265. * @param argType [in] ARG1 - Argument to trace
  266. *
  267. * This macro simply prints the trace string passed, if the level is supported.
  268. *
  269. * @return none
  270. */
  271. #define IX_NPEDL_TRACE1(LEVEL, STR, ARG1) \
  272. { \
  273. if (LEVEL <= IX_NPEDL_TRACE_LEVEL) \
  274. { \
  275. if (LEVEL == IX_NPEDL_FN_ENTRY_EXIT) \
  276. { \
  277. ixOsalLog (IX_OSAL_LOG_LVL_DEBUG3, IX_OSAL_LOG_DEV_STDOUT, STR, ARG1, 0, 0, 0, 0, 0); \
  278. } \
  279. else if (LEVEL == IX_NPEDL_DEBUG) \
  280. { \
  281. ixOsalLog (IX_OSAL_LOG_LVL_MESSAGE, IX_OSAL_LOG_DEV_STDOUT, STR, ARG1, 0, 0, 0, 0, 0); \
  282. } \
  283. } \
  284. }
  285. /**
  286. * @def IX_NPEDL_TRACE2
  287. *
  288. * @brief Mechanism for tracing debug for the IxNpeDl component, with 2 arguments
  289. *
  290. * @param unsigned [in] LEVEL - one of IxNpeDlTraceTypes enumerated values
  291. * @param char* [in] STR - Trace string
  292. * @param argType [in] ARG1 - Argument to trace
  293. * @param argType [in] ARG2 - Argument to trace
  294. *
  295. * This macro simply prints the trace string passed, if the level is supported.
  296. *
  297. * @return none
  298. */
  299. #define IX_NPEDL_TRACE2(LEVEL, STR, ARG1, ARG2) \
  300. { \
  301. if (LEVEL <= IX_NPEDL_TRACE_LEVEL) \
  302. { \
  303. if (LEVEL == IX_NPEDL_FN_ENTRY_EXIT) \
  304. { \
  305. ixOsalLog (IX_OSAL_LOG_LVL_DEBUG3, IX_OSAL_LOG_DEV_STDOUT, STR, ARG1, ARG2, 0, 0, 0, 0); \
  306. } \
  307. else if (LEVEL == IX_NPEDL_DEBUG) \
  308. { \
  309. ixOsalLog (IX_OSAL_LOG_LVL_MESSAGE, IX_OSAL_LOG_DEV_STDOUT, STR, ARG1, ARG2, 0, 0, 0, 0); \
  310. } \
  311. } \
  312. }
  313. /**
  314. * @def IX_NPEDL_REG_WRITE
  315. *
  316. * @brief Mechanism for writing to a memory-mapped register
  317. *
  318. * @param UINT32 [in] base - Base memory address for this NPE's registers
  319. * @param UINT32 [in] offset - Offset from base memory address
  320. * @param UINT32 [in] value - Value to write to register
  321. *
  322. * This macro forms the address of the register from base address + offset, and
  323. * dereferences that address to write the contents of the register.
  324. *
  325. * @return none
  326. */
  327. #define IX_NPEDL_REG_WRITE(base, offset, value) \
  328. IX_OSAL_WRITE_LONG(((base) + (offset)), (value))
  329. /**
  330. * @def IX_NPEDL_REG_READ
  331. *
  332. * @brief Mechanism for reading from a memory-mapped register
  333. *
  334. * @param UINT32 [in] base - Base memory address for this NPE's registers
  335. * @param UINT32 [in] offset - Offset from base memory address
  336. * @param UINT32 *[out] value - Value read from register
  337. *
  338. * This macro forms the address of the register from base address + offset, and
  339. * dereferences that address to read the register contents.
  340. *
  341. * @return none
  342. */
  343. #define IX_NPEDL_REG_READ(base, offset, value) \
  344. *(value) = IX_OSAL_READ_LONG(((base) + (offset)))
  345. #endif /* #if (CPU != XSCALE) */
  346. #endif /* IXNPEDLMACROS_P_H */
  347. /**
  348. * @} defgroup IxNpeDlMacros_p
  349. */