IxNpeDlMacros_p.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414
  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. * Redistribution and use in source and binary forms, with or without
  21. * modification, are permitted provided that the following conditions
  22. * are met:
  23. * 1. Redistributions of source code must retain the above copyright
  24. * notice, this list of conditions and the following disclaimer.
  25. * 2. Redistributions in binary form must reproduce the above copyright
  26. * notice, this list of conditions and the following disclaimer in the
  27. * documentation and/or other materials provided with the distribution.
  28. * 3. Neither the name of the Intel Corporation nor the names of its contributors
  29. * may be used to endorse or promote products derived from this software
  30. * without specific prior written permission.
  31. *
  32. * @par
  33. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
  34. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  35. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  36. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
  37. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  38. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  39. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  40. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  41. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  42. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  43. * SUCH DAMAGE.
  44. *
  45. * @par
  46. * -- End of Copyright Notice --
  47. */
  48. /**
  49. * @defgroup IxNpeDlMacros_p IxNpeDlMacros_p
  50. *
  51. * @brief Macros for the IxNpeDl component.
  52. *
  53. * @{
  54. */
  55. #ifndef IXNPEDLMACROS_P_H
  56. #define IXNPEDLMACROS_P_H
  57. /*
  58. * Put the user defined include files required.
  59. */
  60. #if (CPU != XSCALE)
  61. /* To support IxNpeDl unit tests... */
  62. #include <stdio.h>
  63. #include "test/IxNpeDlTestReg.h"
  64. #else
  65. #include "IxOsal.h"
  66. #endif
  67. /*
  68. * Typedefs
  69. */
  70. /**
  71. * @typedef IxNpeDlTraceTypes
  72. * @brief Enumeration defining IxNpeDl trace levels
  73. */
  74. typedef enum
  75. {
  76. IX_NPEDL_TRACE_OFF, /**< no trace */
  77. IX_NPEDL_DEBUG, /**< debug */
  78. IX_NPEDL_FN_ENTRY_EXIT /**< function entry/exit */
  79. } IxNpeDlTraceTypes;
  80. /*
  81. * #defines and macros.
  82. */
  83. /* Implementation of the following macros for use with IxNpeDl unit test code */
  84. #if (CPU != XSCALE)
  85. /**
  86. * @def IX_NPEDL_TRACE_LEVEL
  87. *
  88. * @brief IxNpeDl debug trace level
  89. */
  90. #define IX_NPEDL_TRACE_LEVEL IX_NPEDL_FN_ENTRY_EXIT
  91. /**
  92. * @def IX_NPEDL_ERROR_REPORT
  93. *
  94. * @brief Mechanism for reporting IxNpeDl software errors
  95. *
  96. * @param char* [in] STR - Error string to report
  97. *
  98. * This macro simply prints the error string passed.
  99. * Intended for use with IxNpeDl unit test code.
  100. *
  101. * @return none
  102. */
  103. #define IX_NPEDL_ERROR_REPORT(STR) printf ("IxNpeDl ERROR: %s\n", (STR));
  104. /**
  105. * @def IX_NPEDL_WARNING_REPORT
  106. *
  107. * @brief Mechanism for reporting IxNpeDl software errors
  108. *
  109. * @param char* [in] STR - Error string to report
  110. *
  111. * This macro simply prints the error string passed.
  112. * Intended for use with IxNpeDl unit test code.
  113. *
  114. * @return none
  115. */
  116. #define IX_NPEDL_WARNING_REPORT(STR) printf ("IxNpeDl WARNING: %s\n", (STR));
  117. /**
  118. * @def IX_NPEDL_TRACE0
  119. *
  120. * @brief Mechanism for tracing debug for the IxNpeDl component, for no arguments
  121. *
  122. * @param unsigned [in] LEVEL - one of IxNpeDlTraceTypes enumerated values
  123. * @param char* [in] STR - Trace string
  124. *
  125. * This macro simply prints the trace string passed, if the level is supported.
  126. * Intended for use with IxNpeDl unit test code.
  127. *
  128. * @return none
  129. */
  130. #define IX_NPEDL_TRACE0(LEVEL, STR) \
  131. { \
  132. if (LEVEL <= IX_NPEDL_TRACE_LEVEL) \
  133. { \
  134. printf ("IxNpeDl TRACE: "); \
  135. printf ((STR)); \
  136. printf ("\n"); \
  137. } \
  138. }
  139. /**
  140. * @def IX_NPEDL_TRACE1
  141. *
  142. * @brief Mechanism for tracing debug for the IxNpeDl component, with 1 argument
  143. *
  144. * @param unsigned [in] LEVEL - one of IxNpeDlTraceTypes enumerated values
  145. * @param char* [in] STR - Trace string
  146. * @param argType [in] ARG1 - 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_TRACE1(LEVEL, STR, ARG1) \
  154. { \
  155. if (LEVEL <= IX_NPEDL_TRACE_LEVEL) \
  156. { \
  157. printf ("IxNpeDl TRACE: "); \
  158. printf (STR, ARG1); \
  159. printf ("\n"); \
  160. } \
  161. }
  162. /**
  163. * @def IX_NPEDL_TRACE2
  164. *
  165. * @brief Mechanism for tracing debug for the IxNpeDl component, with 2 arguments
  166. *
  167. * @param unsigned [in] LEVEL - one of IxNpeDlTraceTypes enumerated values
  168. * @param char* [in] STR - Trace string
  169. * @param argType [in] ARG1 - Argument to trace
  170. * @param argType [in] ARG2 - Argument to trace
  171. *
  172. * This macro simply prints the trace string passed, if the level is supported.
  173. * Intended for use with IxNpeDl unit test code.
  174. *
  175. * @return none
  176. */
  177. #define IX_NPEDL_TRACE2(LEVEL, STR, ARG1, ARG2) \
  178. { \
  179. if (LEVEL <= IX_NPEDL_TRACE_LEVEL) \
  180. { \
  181. printf ("IxNpeDl TRACE: "); \
  182. printf (STR, ARG1, ARG2); \
  183. printf ("\n"); \
  184. } \
  185. }
  186. /**
  187. * @def IX_NPEDL_REG_WRITE
  188. *
  189. * @brief Mechanism for writing to a memory-mapped register
  190. *
  191. * @param UINT32 [in] base - Base memory address for this NPE's registers
  192. * @param UINT32 [in] offset - Offset from base memory address
  193. * @param UINT32 [in] value - Value to write to register
  194. *
  195. * This macro calls a function from Unit Test code to write a register. This
  196. * allows extra flexibility for unit testing of the IxNpeDl component.
  197. *
  198. * @return none
  199. */
  200. #define IX_NPEDL_REG_WRITE(base, offset, value) \
  201. { \
  202. ixNpeDlTestRegWrite (base, offset, value); \
  203. }
  204. /**
  205. * @def IX_NPEDL_REG_READ
  206. *
  207. * @brief Mechanism for reading from a memory-mapped register
  208. *
  209. * @param UINT32 [in] base - Base memory address for this NPE's registers
  210. * @param UINT32 [in] offset - Offset from base memory address
  211. * @param UINT32 *[out] value - Value read from register
  212. *
  213. * This macro calls a function from Unit Test code to read a register. This
  214. * allows extra flexibility for unit testing of the IxNpeDl component.
  215. *
  216. * @return none
  217. */
  218. #define IX_NPEDL_REG_READ(base, offset, value) \
  219. { \
  220. ixNpeDlTestRegRead (base, offset, value); \
  221. }
  222. /* Implementation of the following macros when integrated with IxOsal */
  223. #else /* #if (CPU != XSCALE) */
  224. /**
  225. * @def IX_NPEDL_TRACE_LEVEL
  226. *
  227. * @brief IxNpeDl debug trace level
  228. */
  229. #define IX_NPEDL_TRACE_LEVEL IX_NPEDL_DEBUG
  230. /**
  231. * @def IX_NPEDL_ERROR_REPORT
  232. *
  233. * @brief Mechanism for reporting IxNpeDl software errors
  234. *
  235. * @param char* [in] STR - Error string to report
  236. *
  237. * This macro is used to report IxNpeDl software errors.
  238. *
  239. * @return none
  240. */
  241. #define IX_NPEDL_ERROR_REPORT(STR) \
  242. ixOsalLog (IX_OSAL_LOG_LVL_ERROR, IX_OSAL_LOG_DEV_STDERR, STR, 0, 0, 0, 0, 0, 0);
  243. /**
  244. * @def IX_NPEDL_WARNING_REPORT
  245. *
  246. * @brief Mechanism for reporting IxNpeDl software warnings
  247. *
  248. * @param char* [in] STR - Warning string to report
  249. *
  250. * This macro is used to report IxNpeDl software warnings.
  251. *
  252. * @return none
  253. */
  254. #define IX_NPEDL_WARNING_REPORT(STR) \
  255. ixOsalLog (IX_OSAL_LOG_LVL_WARNING, IX_OSAL_LOG_DEV_STDOUT, STR, 0, 0, 0, 0, 0, 0);
  256. /**
  257. * @def IX_NPEDL_TRACE0
  258. *
  259. * @brief Mechanism for tracing debug for the IxNpeDl component, for no arguments
  260. *
  261. * @param unsigned [in] LEVEL - one of IxNpeDlTraceTypes enumerated values
  262. * @param char* [in] STR - Trace string
  263. *
  264. * This macro simply prints the trace string passed, if the level is supported.
  265. *
  266. * @return none
  267. */
  268. #define IX_NPEDL_TRACE0(LEVEL, STR) \
  269. { \
  270. if (LEVEL <= IX_NPEDL_TRACE_LEVEL) \
  271. { \
  272. if (LEVEL == IX_NPEDL_FN_ENTRY_EXIT) \
  273. { \
  274. ixOsalLog (IX_OSAL_LOG_LVL_DEBUG3, IX_OSAL_LOG_DEV_STDOUT, STR, 0, 0, 0, 0, 0, 0); \
  275. } \
  276. else if (LEVEL == IX_NPEDL_DEBUG) \
  277. { \
  278. ixOsalLog (IX_OSAL_LOG_LVL_MESSAGE, IX_OSAL_LOG_DEV_STDOUT, STR, 0, 0, 0, 0, 0, 0); \
  279. } \
  280. } \
  281. }
  282. /**
  283. * @def IX_NPEDL_TRACE1
  284. *
  285. * @brief Mechanism for tracing debug for the IxNpeDl component, with 1 argument
  286. *
  287. * @param unsigned [in] LEVEL - one of IxNpeDlTraceTypes enumerated values
  288. * @param char* [in] STR - Trace string
  289. * @param argType [in] ARG1 - Argument to trace
  290. *
  291. * This macro simply prints the trace string passed, if the level is supported.
  292. *
  293. * @return none
  294. */
  295. #define IX_NPEDL_TRACE1(LEVEL, STR, ARG1) \
  296. { \
  297. if (LEVEL <= IX_NPEDL_TRACE_LEVEL) \
  298. { \
  299. if (LEVEL == IX_NPEDL_FN_ENTRY_EXIT) \
  300. { \
  301. ixOsalLog (IX_OSAL_LOG_LVL_DEBUG3, IX_OSAL_LOG_DEV_STDOUT, STR, ARG1, 0, 0, 0, 0, 0); \
  302. } \
  303. else if (LEVEL == IX_NPEDL_DEBUG) \
  304. { \
  305. ixOsalLog (IX_OSAL_LOG_LVL_MESSAGE, IX_OSAL_LOG_DEV_STDOUT, STR, ARG1, 0, 0, 0, 0, 0); \
  306. } \
  307. } \
  308. }
  309. /**
  310. * @def IX_NPEDL_TRACE2
  311. *
  312. * @brief Mechanism for tracing debug for the IxNpeDl component, with 2 arguments
  313. *
  314. * @param unsigned [in] LEVEL - one of IxNpeDlTraceTypes enumerated values
  315. * @param char* [in] STR - Trace string
  316. * @param argType [in] ARG1 - Argument to trace
  317. * @param argType [in] ARG2 - Argument to trace
  318. *
  319. * This macro simply prints the trace string passed, if the level is supported.
  320. *
  321. * @return none
  322. */
  323. #define IX_NPEDL_TRACE2(LEVEL, STR, ARG1, ARG2) \
  324. { \
  325. if (LEVEL <= IX_NPEDL_TRACE_LEVEL) \
  326. { \
  327. if (LEVEL == IX_NPEDL_FN_ENTRY_EXIT) \
  328. { \
  329. ixOsalLog (IX_OSAL_LOG_LVL_DEBUG3, IX_OSAL_LOG_DEV_STDOUT, STR, ARG1, ARG2, 0, 0, 0, 0); \
  330. } \
  331. else if (LEVEL == IX_NPEDL_DEBUG) \
  332. { \
  333. ixOsalLog (IX_OSAL_LOG_LVL_MESSAGE, IX_OSAL_LOG_DEV_STDOUT, STR, ARG1, ARG2, 0, 0, 0, 0); \
  334. } \
  335. } \
  336. }
  337. /**
  338. * @def IX_NPEDL_REG_WRITE
  339. *
  340. * @brief Mechanism for writing to a memory-mapped register
  341. *
  342. * @param UINT32 [in] base - Base memory address for this NPE's registers
  343. * @param UINT32 [in] offset - Offset from base memory address
  344. * @param UINT32 [in] value - Value to write to register
  345. *
  346. * This macro forms the address of the register from base address + offset, and
  347. * dereferences that address to write the contents of the register.
  348. *
  349. * @return none
  350. */
  351. #define IX_NPEDL_REG_WRITE(base, offset, value) \
  352. IX_OSAL_WRITE_LONG(((base) + (offset)), (value))
  353. /**
  354. * @def IX_NPEDL_REG_READ
  355. *
  356. * @brief Mechanism for reading from a memory-mapped register
  357. *
  358. * @param UINT32 [in] base - Base memory address for this NPE's registers
  359. * @param UINT32 [in] offset - Offset from base memory address
  360. * @param UINT32 *[out] value - Value read from register
  361. *
  362. * This macro forms the address of the register from base address + offset, and
  363. * dereferences that address to read the register contents.
  364. *
  365. * @return none
  366. */
  367. #define IX_NPEDL_REG_READ(base, offset, value) \
  368. *(value) = IX_OSAL_READ_LONG(((base) + (offset)))
  369. #endif /* #if (CPU != XSCALE) */
  370. #endif /* IXNPEDLMACROS_P_H */
  371. /**
  372. * @} defgroup IxNpeDlMacros_p
  373. */