/drivers/staging/ath6kl/include/a_debug.h

https://bitbucket.org/cyanogenmod/android_kernel_asus_tf300t · C Header · 195 lines · 82 code · 30 blank · 83 comment · 0 complexity · 1a1dee5b16021017c01bfe4f201f44d5 MD5 · raw file

  1. //------------------------------------------------------------------------------
  2. // <copyright file="a_debug.h" company="Atheros">
  3. // Copyright (c) 2004-2010 Atheros Corporation. All rights reserved.
  4. //
  5. //
  6. // Permission to use, copy, modify, and/or distribute this software for any
  7. // purpose with or without fee is hereby granted, provided that the above
  8. // copyright notice and this permission notice appear in all copies.
  9. //
  10. // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  11. // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  12. // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  13. // ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  14. // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  15. // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  16. // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  17. //
  18. //
  19. //------------------------------------------------------------------------------
  20. //==============================================================================
  21. // Author(s): ="Atheros"
  22. //==============================================================================
  23. #ifndef _A_DEBUG_H_
  24. #define _A_DEBUG_H_
  25. #ifdef __cplusplus
  26. extern "C" {
  27. #endif /* __cplusplus */
  28. #include <a_osapi.h>
  29. /* standard debug print masks bits 0..7 */
  30. #define ATH_DEBUG_ERR (1 << 0) /* errors */
  31. #define ATH_DEBUG_WARN (1 << 1) /* warnings */
  32. #define ATH_DEBUG_INFO (1 << 2) /* informational (module startup info) */
  33. #define ATH_DEBUG_TRC (1 << 3) /* generic function call tracing */
  34. #define ATH_DEBUG_RSVD1 (1 << 4)
  35. #define ATH_DEBUG_RSVD2 (1 << 5)
  36. #define ATH_DEBUG_RSVD3 (1 << 6)
  37. #define ATH_DEBUG_RSVD4 (1 << 7)
  38. #define ATH_DEBUG_MASK_DEFAULTS (ATH_DEBUG_ERR | ATH_DEBUG_WARN)
  39. #define ATH_DEBUG_ANY 0xFFFF
  40. /* other aliases used throughout */
  41. #define ATH_DEBUG_ERROR ATH_DEBUG_ERR
  42. #define ATH_LOG_ERR ATH_DEBUG_ERR
  43. #define ATH_LOG_INF ATH_DEBUG_INFO
  44. #define ATH_LOG_TRC ATH_DEBUG_TRC
  45. #define ATH_DEBUG_TRACE ATH_DEBUG_TRC
  46. #define ATH_DEBUG_INIT ATH_DEBUG_INFO
  47. /* bits 8..31 are module-specific masks */
  48. #define ATH_DEBUG_MODULE_MASK_SHIFT 8
  49. /* macro to make a module-specific masks */
  50. #define ATH_DEBUG_MAKE_MODULE_MASK(index) (1 << (ATH_DEBUG_MODULE_MASK_SHIFT + (index)))
  51. void DebugDumpBytes(u8 *buffer, u16 length, char *pDescription);
  52. /* Debug support on a per-module basis
  53. *
  54. * Usage:
  55. *
  56. * Each module can utilize it's own debug mask variable. A set of commonly used
  57. * masks are provided (ERRORS, WARNINGS, TRACE etc..). It is up to each module
  58. * to define module-specific masks using the macros above.
  59. *
  60. * Each module defines a single debug mask variable debug_XXX where the "name" of the module is
  61. * common to all C-files within that module. This requires every C-file that includes a_debug.h
  62. * to define the module name in that file.
  63. *
  64. * Example:
  65. *
  66. * #define ATH_MODULE_NAME htc
  67. * #include "a_debug.h"
  68. *
  69. * This will define a debug mask structure called debug_htc and all debug macros will reference this
  70. * variable.
  71. *
  72. * A module can define module-specific bit masks using the ATH_DEBUG_MAKE_MODULE_MASK() macro:
  73. *
  74. * #define ATH_DEBUG_MY_MASK1 ATH_DEBUG_MAKE_MODULE_MASK(0)
  75. * #define ATH_DEBUG_MY_MASK2 ATH_DEBUG_MAKE_MODULE_MASK(1)
  76. *
  77. * The instantiation of the debug structure should be made by the module. When a module is
  78. * instantiated, the module can set a description string, a default mask and an array of description
  79. * entries containing information on each module-defined debug mask.
  80. * NOTE: The instantiation is statically allocated, only one instance can exist per module.
  81. *
  82. * Example:
  83. *
  84. *
  85. * #define ATH_DEBUG_BMI ATH_DEBUG_MAKE_MODULE_MASK(0)
  86. *
  87. * #ifdef DEBUG
  88. * static struct ath_debug_mask_description bmi_debug_desc[] = {
  89. * { ATH_DEBUG_BMI , "BMI Tracing"}, <== description of the module specific mask
  90. * };
  91. *
  92. * ATH_DEBUG_INSTANTIATE_MODULE_VAR(bmi,
  93. * "bmi" <== module name
  94. * "Boot Manager Interface", <== description of module
  95. * ATH_DEBUG_MASK_DEFAULTS, <== defaults
  96. * ATH_DEBUG_DESCRIPTION_COUNT(bmi_debug_desc),
  97. * bmi_debug_desc);
  98. *
  99. * #endif
  100. *
  101. * A module can optionally register it's debug module information in order for other tools to change the
  102. * bit mask at runtime. A module can call A_REGISTER_MODULE_DEBUG_INFO() in it's module
  103. * init code. This macro can be called multiple times without consequence. The debug info maintains
  104. * state to indicate whether the information was previously registered.
  105. *
  106. * */
  107. #define ATH_DEBUG_MAX_MASK_DESC_LENGTH 32
  108. #define ATH_DEBUG_MAX_MOD_DESC_LENGTH 64
  109. struct ath_debug_mask_description {
  110. u32 Mask;
  111. char Description[ATH_DEBUG_MAX_MASK_DESC_LENGTH];
  112. };
  113. #define ATH_DEBUG_INFO_FLAGS_REGISTERED (1 << 0)
  114. typedef struct _ATH_DEBUG_MODULE_DBG_INFO{
  115. struct _ATH_DEBUG_MODULE_DBG_INFO *pNext;
  116. char ModuleName[16];
  117. char ModuleDescription[ATH_DEBUG_MAX_MOD_DESC_LENGTH];
  118. u32 Flags;
  119. u32 CurrentMask;
  120. int MaxDescriptions;
  121. struct ath_debug_mask_description *pMaskDescriptions; /* pointer to array of descriptions */
  122. } ATH_DEBUG_MODULE_DBG_INFO;
  123. #define ATH_DEBUG_DESCRIPTION_COUNT(d) (int)((sizeof((d))) / (sizeof(struct ath_debug_mask_description)))
  124. #define GET_ATH_MODULE_DEBUG_VAR_NAME(s) _XGET_ATH_MODULE_NAME_DEBUG_(s)
  125. #define GET_ATH_MODULE_DEBUG_VAR_MASK(s) _XGET_ATH_MODULE_NAME_DEBUG_(s).CurrentMask
  126. #define _XGET_ATH_MODULE_NAME_DEBUG_(s) debug_ ## s
  127. #ifdef ATH_DEBUG_MODULE
  128. /* for source files that will instantiate the debug variables */
  129. #define ATH_DEBUG_INSTANTIATE_MODULE_VAR(s,name,moddesc,initmask,count,descriptions) \
  130. ATH_DEBUG_MODULE_DBG_INFO GET_ATH_MODULE_DEBUG_VAR_NAME(s) = \
  131. {NULL,(name),(moddesc),0,(initmask),count,(descriptions)}
  132. #ifdef ATH_MODULE_NAME
  133. extern ATH_DEBUG_MODULE_DBG_INFO GET_ATH_MODULE_DEBUG_VAR_NAME(ATH_MODULE_NAME);
  134. #define AR_DEBUG_LVL_CHECK(lvl) (GET_ATH_MODULE_DEBUG_VAR_MASK(ATH_MODULE_NAME) & (lvl))
  135. #endif /* ATH_MODULE_NAME */
  136. #define ATH_DEBUG_SET_DEBUG_MASK(s,lvl) GET_ATH_MODULE_DEBUG_VAR_MASK(s) = (lvl)
  137. #define ATH_DEBUG_DECLARE_EXTERN(s) \
  138. extern ATH_DEBUG_MODULE_DBG_INFO GET_ATH_MODULE_DEBUG_VAR_NAME(s)
  139. #define AR_DEBUG_PRINTBUF(buffer, length, desc) DebugDumpBytes(buffer,length,desc)
  140. #define AR_DEBUG_ASSERT A_ASSERT
  141. void a_dump_module_debug_info(ATH_DEBUG_MODULE_DBG_INFO *pInfo);
  142. void a_register_module_debug_info(ATH_DEBUG_MODULE_DBG_INFO *pInfo);
  143. #define A_DUMP_MODULE_DEBUG_INFO(s) a_dump_module_debug_info(&(GET_ATH_MODULE_DEBUG_VAR_NAME(s)))
  144. #define A_REGISTER_MODULE_DEBUG_INFO(s) a_register_module_debug_info(&(GET_ATH_MODULE_DEBUG_VAR_NAME(s)))
  145. #else /* !ATH_DEBUG_MODULE */
  146. /* NON ATH_DEBUG_MODULE */
  147. #define ATH_DEBUG_INSTANTIATE_MODULE_VAR(s,name,moddesc,initmask,count,descriptions)
  148. #define AR_DEBUG_LVL_CHECK(lvl) 0
  149. #define AR_DEBUG_PRINTBUF(buffer, length, desc)
  150. #define AR_DEBUG_ASSERT(test)
  151. #define ATH_DEBUG_DECLARE_EXTERN(s)
  152. #define ATH_DEBUG_SET_DEBUG_MASK(s,lvl)
  153. #define A_DUMP_MODULE_DEBUG_INFO(s)
  154. #define A_REGISTER_MODULE_DEBUG_INFO(s)
  155. #endif
  156. int a_get_module_mask(char *module_name, u32 *pMask);
  157. int a_set_module_mask(char *module_name, u32 Mask);
  158. void a_dump_module_debug_info_by_name(char *module_name);
  159. void a_module_debug_support_init(void);
  160. void a_module_debug_support_cleanup(void);
  161. #include "../os/linux/include/debug_linux.h"
  162. #ifdef __cplusplus
  163. }
  164. #endif /* __cplusplus */
  165. #endif