Debug.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. /*****************************************************************
  2. *****************************************************************
  3. *** **
  4. *** (C)Copyright 2005-2006, American Megatrends Inc. **
  5. *** **
  6. *** All Rights Reserved. **
  7. *** **
  8. *** 6145-F, Northbelt Parkway, Norcross, **
  9. *** **
  10. *** Georgia - 30071, USA. Phone-(770)-246-8600. **
  11. *** **
  12. *****************************************************************
  13. *****************************************************************
  14. ******************************************************************
  15. *
  16. * debug.h
  17. * Debug Mode Macros
  18. *
  19. * Author: Govind Kothandapani <govindk@ami.com>
  20. *
  21. ******************************************************************/
  22. #ifndef DEBUG_H
  23. #define DEBUG_h
  24. #include "Types.h"
  25. //#include "dbgout.h"
  26. #define PLATFORM_BREAK while (1)
  27. #ifdef STHU
  28. #define IPMI_INFO(STR, Args...)
  29. #define IPMI_WARNING(STR, Args...)
  30. #define IPMI_ERROR(STR, Args... )
  31. #else
  32. #define IPMI_INFO(STR, Args...) TINFO (STR, ##Args);
  33. #define IPMI_WARNING(STR, Args...) TWARN (STR, ##Args);
  34. #define IPMI_ERROR(STR, Args... ) TCRIT (STR, ##Args);
  35. #endif
  36. #ifdef _DEBUG_
  37. extern void print_buf (INT8U* Buf, INT16U Len);
  38. #if ENABLE_DEBUG_MACROS==0
  39. /*** Turn off all debug macros if they are disabled in the source ***/
  40. #define IPMI_CHECK_POINT(ARG)
  41. #define IPMI_DBG_BREAK
  42. #define IPMI_ASSERT(ARG)
  43. #define IPMI_ASSERT_CONTINUE(ARG)
  44. #define IPMI_DBG_PRINT_STRUCT_3(STRUCT, M1, M2, M3)
  45. #define IPMI_DBG_PRINT_STRUCT_4(STRUCT, M1, M2, M3, M4)
  46. #define IPMI_DBG_PRINT_STRUCT_5(STRUCT, M1, M2, M3, M4, M5)
  47. #define IPMI_DBG_PRINT_STRUCT_6(STRUCT, M1, M2, M3, M4, M5, M6)
  48. #define PRINT_BUF(BUF, LEN)
  49. #if ENABLE_DEBUG_LOG==0
  50. #define IPMI_DBG_PRINT(STR)
  51. #define IPMI_DBG_PRINT_1(FMT, ARG2)
  52. #define IPMI_DBG_PRINT_2(FMT, ARG1, ARG2)
  53. #define IPMI_DBG_PRINT_3(FMT, ARG1, ARG2, ARG3)
  54. #define IPMI_DBG_PRINT_4(FMT, ARG1, ARG2, ARG3, ARG4)
  55. #define IPMI_DBG_PRINT_BUF(BUF, LEN)
  56. #else //ENABLE_DEBUG_LOG
  57. #define IPMI_DBG_PRINT(FMT) PLATFORM_DBGLOGFN(LOG_DEBUG,TDBG_FILE_LINE_FMT FMT,TDBG_FILENAME,TDBG_LINENO)
  58. #define IPMI_DBG_PRINT_1(fmt, args...) PLATFORM_DBGLOGFN(LOG_DEBUG,TDBG_FILE_LINE_FMT fmt,TDBG_FILENAME,TDBG_LINENO,##args)
  59. #define IPMI_DBG_PRINT_2(fmt, args...) PLATFORM_DBGLOGFN(LOG_DEBUG,TDBG_FILE_LINE_FMT fmt,TDBG_FILENAME,TDBG_LINENO,##args)
  60. #define IPMI_DBG_PRINT_3(fmt, args...) PLATFORM_DBGLOGFN(LOG_DEBUG,TDBG_FILE_LINE_FMT fmt,TDBG_FILENAME,TDBG_LINENO,##args)
  61. #define IPMI_DBG_PRINT_4(fmt, args...) PLATFORM_DBGLOGFN(LOG_DEBUG,TDBG_FILE_LINE_FMT fmt,TDBG_FILENAME,TDBG_LINENO,##args)
  62. #define IPMI_DBG_PRINT_BUF(BUF, LEN) PLATFORM_DBGLOGBUFFN(LOG_DEBUG, TDBG_FILENAME,TDBG_LINENO, BUF, LEN)
  63. #endif
  64. #else /* ENABLE_DEBUG_MACROS */
  65. /**
  66. * @def IPMI_DBG_BREAK
  67. * @brief Stops the debugger.
  68. **/
  69. #define IPMI_DBG_BREAK PLATFORM_BREAK
  70. /**
  71. * @def IPMI_ASSERT
  72. * @brief Asserts for a condition to be true. If the condition fails program
  73. * stops executing and the debugger is invoked.
  74. **/
  75. #define IPMI_ASSERT(ARG) \
  76. do \
  77. { \
  78. if (!(ARG)) \
  79. { \
  80. IPMI_WARNING ("Assertion failed at %s line %d\n", \
  81. (_FAR_ char *)__FILE__, __LINE__); \
  82. IPMI_DBG_BREAK; \
  83. } \
  84. \
  85. } while (0)
  86. /**
  87. * @def IPMI_ASSERT_CONTINUE
  88. * @brief Asserts for a condition to be true. If the condition fails program
  89. * continues executing.
  90. **/
  91. #define IPMI_ASSERT_CONTINUE(ARG) \
  92. do \
  93. { \
  94. if (!(ARG)) \
  95. { \
  96. IPMI_WARNING ("Assertion failed at %s line %d\n", \
  97. (_FAR_ char *)__FILE__, __LINE__); \
  98. IPMI_WARNING ("Assertion will be handled later...\n"); \
  99. } \
  100. \
  101. } while (0)
  102. #if ENABLE_DEBUG_LOG==0
  103. /**
  104. * @def IPMI_DBG_PRINT
  105. * @brief A regular printf style debug printing macro. Could take more
  106. * ROM space due to the strings to be stored.
  107. **/
  108. #define IPMI_DBG_PRINT(STR) printf (STR)
  109. #define IPMI_DBG_PRINT_1(FMT, ARG1) printf (FMT, ARG1)
  110. #define IPMI_DBG_PRINT_2(FMT, ARG1, ARG2) printf (FMT, ARG1, ARG2)
  111. #define IPMI_DBG_PRINT_3(FMT, ARG1, ARG2, ARG3) printf (FMT, ARG1, ARG2, ARG3)
  112. #define IPMI_DBG_PRINT_4(FMT, ARG1, ARG2, ARG3, ARG4) printf (FMT, ARG1, ARG2, ARG3, ARG4)
  113. /**
  114. * @def IPMI_DBG_PRINT_BUF
  115. * @brief Prints the buffer.
  116. **/
  117. #define IPMI_DBG_PRINT_BUF(BUF, LEN) print_buf (BUF, LEN);
  118. #define PRINT_BUF(BUF, LEN) print_buf (BUF, LEN);
  119. #else //ENABLE_DEBUG_LOG
  120. #define IPMI_DBG_PRINT(FMT) \
  121. do \
  122. { \
  123. printf (FMT); \
  124. PLATFORM_DBGLOGFN(LOG_DEBUG,TDBG_FILE_LINE_FMT FMT,TDBG_FILENAME,TDBG_LINENO); \
  125. } while (0)
  126. #define IPMI_DBG_PRINT_1(fmt, args...) \
  127. do \
  128. { \
  129. printf (fmt, args); \
  130. PLATFORM_DBGLOGFN(LOG_DEBUG,TDBG_FILE_LINE_FMT fmt,TDBG_FILENAME,TDBG_LINENO,##args); \
  131. } while (0)
  132. #define IPMI_DBG_PRINT_2(fmt, args...) \
  133. do \
  134. { \
  135. printf (fmt, args); \
  136. PLATFORM_DBGLOGFN(LOG_DEBUG,TDBG_FILE_LINE_FMT fmt,TDBG_FILENAME,TDBG_LINENO,##args); \
  137. } while (0)
  138. #define IPMI_DBG_PRINT_3(fmt, args...) \
  139. do \
  140. { \
  141. printf (fmt, args); \
  142. PLATFORM_DBGLOGFN(LOG_DEBUG,TDBG_FILE_LINE_FMT fmt,TDBG_FILENAME,TDBG_LINENO,##args); \
  143. } while (0)
  144. #define IPMI_DBG_PRINT_4(fmt, args...) \
  145. do \
  146. { \
  147. printf (fmt, args); \
  148. PLATFORM_DBGLOGFN(LOG_DEBUG,TDBG_FILE_LINE_FMT fmt,TDBG_FILENAME,TDBG_LINENO,##args); \
  149. } while (0)
  150. #define IPMI_DBG_PRINT_BUF(BUF, LEN) \
  151. do \
  152. { \
  153. print_buf (BUF, LEN); \
  154. PLATFORM_DBGLOGBUFFN(LOG_DEBUG,TDBG_FILENAME,TDBG_LINENO,BUF,LEN) \
  155. } while (0)
  156. #endif //ENABLE_DEBUG_LOG
  157. #endif /* ENABLE_DEBUG_MACROS */
  158. #else /* If DEBUG */
  159. #define IPMI_DBG_PRINT(STR)
  160. #define IPMI_DBG_PRINT_1(FMT, ARG2)
  161. #define IPMI_DBG_PRINT_2(FMT, ARG1, ARG2)
  162. #define IPMI_DBG_PRINT_3(FMT, ARG1, ARG2, ARG3)
  163. #define IPMI_DBG_PRINT_4(FMT, ARG1, ARG2, ARG3, ARG4)
  164. #define IPMI_DBG_BREAK
  165. #define IPMI_ASSERT(ARG)
  166. #define IPMI_ASSERT_CONTINUE(ARG)
  167. #define IPMI_DBG_PRINT_BUF(BUF, LEN)
  168. #define IPMI_DBG_PRINT_STRUCT_3(STRUCT, M1, M2, M3)
  169. #define IPMI_DBG_PRINT_STRUCT_4(STRUCT, M1, M2, M3, M4)
  170. #define IPMI_DBG_PRINT_STRUCT_5(STRUCT, M1, M2, M3, M4, M5)
  171. #define IPMI_DBG_PRINT_STRUCT_6(STRUCT, M1, M2, M3, M4, M5, M6)
  172. #define PRINT_BUF(BUF, LEN)
  173. #define IPMI_DBG_PRINT_BUF(BUF, LEN)
  174. #endif /* If DEBUG */
  175. #endif /* DEBUG_H */