PageRenderTime 23ms CodeModel.GetById 19ms app.highlight 3ms RepoModel.GetById 0ms app.codeStats 0ms

/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
Possible License(s): LGPL-2.0, AGPL-1.0, GPL-2.0
  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
 26#ifdef __cplusplus
 27extern "C" {
 28#endif /* __cplusplus */
 29
 30#include <a_osapi.h>
 31
 32    /* standard debug print masks bits 0..7 */
 33#define ATH_DEBUG_ERR   (1 << 0)   /* errors */
 34#define ATH_DEBUG_WARN  (1 << 1)   /* warnings */
 35#define ATH_DEBUG_INFO  (1 << 2)   /* informational (module startup info) */
 36#define ATH_DEBUG_TRC   (1 << 3)   /* generic function call tracing */
 37#define ATH_DEBUG_RSVD1 (1 << 4)
 38#define ATH_DEBUG_RSVD2 (1 << 5)
 39#define ATH_DEBUG_RSVD3 (1 << 6)
 40#define ATH_DEBUG_RSVD4 (1 << 7)
 41
 42#define ATH_DEBUG_MASK_DEFAULTS  (ATH_DEBUG_ERR | ATH_DEBUG_WARN)
 43#define ATH_DEBUG_ANY  0xFFFF
 44
 45    /* other aliases used throughout */
 46#define ATH_DEBUG_ERROR   ATH_DEBUG_ERR
 47#define ATH_LOG_ERR       ATH_DEBUG_ERR
 48#define ATH_LOG_INF       ATH_DEBUG_INFO
 49#define ATH_LOG_TRC       ATH_DEBUG_TRC
 50#define ATH_DEBUG_TRACE   ATH_DEBUG_TRC
 51#define ATH_DEBUG_INIT    ATH_DEBUG_INFO
 52
 53    /* bits 8..31 are module-specific masks */
 54#define ATH_DEBUG_MODULE_MASK_SHIFT   8
 55
 56    /* macro to make a module-specific masks */
 57#define ATH_DEBUG_MAKE_MODULE_MASK(index)  (1 << (ATH_DEBUG_MODULE_MASK_SHIFT + (index)))
 58
 59void DebugDumpBytes(u8 *buffer, u16 length, char *pDescription);
 60
 61/* Debug support on a per-module basis
 62 *
 63 * Usage:
 64 *
 65 *   Each module can utilize it's own debug mask variable.  A set of commonly used
 66 *   masks are provided (ERRORS, WARNINGS, TRACE etc..).  It is up to each module
 67 *   to define module-specific masks using the macros above.
 68 *
 69 *   Each module defines a single debug mask variable debug_XXX where the "name" of the module is
 70 *   common to all C-files within that module.  This requires every C-file that includes a_debug.h
 71 *   to define the module name in that file.
 72 *
 73 *   Example:
 74 *
 75 *   #define ATH_MODULE_NAME htc
 76 *   #include "a_debug.h"
 77 *
 78 *   This will define a debug mask structure called debug_htc and all debug macros will reference this
 79 *   variable.
 80 *
 81 *   A module can define module-specific bit masks using the ATH_DEBUG_MAKE_MODULE_MASK() macro:
 82 *
 83 *      #define ATH_DEBUG_MY_MASK1  ATH_DEBUG_MAKE_MODULE_MASK(0)
 84 *      #define ATH_DEBUG_MY_MASK2  ATH_DEBUG_MAKE_MODULE_MASK(1)
 85 *
 86 *   The instantiation of the debug structure should be made by the module.  When a module is
 87 *   instantiated, the module can set a description string, a default mask and an array of description
 88 *   entries containing information on each module-defined debug mask.
 89 *   NOTE: The instantiation is statically allocated, only one instance can exist per module.
 90 *
 91 *   Example:
 92 *
 93 *
 94 *   #define ATH_DEBUG_BMI  ATH_DEBUG_MAKE_MODULE_MASK(0)
 95 *
 96 *   #ifdef DEBUG
 97 *   static struct ath_debug_mask_description bmi_debug_desc[] = {
 98 *       { ATH_DEBUG_BMI , "BMI Tracing"},   <== description of the module specific mask
 99 *   };
100 *
101 *   ATH_DEBUG_INSTANTIATE_MODULE_VAR(bmi,
102 *                                    "bmi"  <== module name
103 *                                    "Boot Manager Interface",  <== description of module
104 *                                    ATH_DEBUG_MASK_DEFAULTS,          <== defaults
105 *                                    ATH_DEBUG_DESCRIPTION_COUNT(bmi_debug_desc),
106 *                                    bmi_debug_desc);
107 *
108 *   #endif
109 *
110 *  A module can optionally register it's debug module information in order for other tools to change the
111 *  bit mask at runtime.  A module can call  A_REGISTER_MODULE_DEBUG_INFO() in it's module
112 *  init code.  This macro can be called multiple times without consequence.  The debug info maintains
113 *  state to indicate whether the information was previously registered.
114 *
115 * */
116
117#define ATH_DEBUG_MAX_MASK_DESC_LENGTH   32
118#define ATH_DEBUG_MAX_MOD_DESC_LENGTH    64
119
120struct ath_debug_mask_description {
121    u32 Mask;
122    char Description[ATH_DEBUG_MAX_MASK_DESC_LENGTH];
123};
124
125#define ATH_DEBUG_INFO_FLAGS_REGISTERED (1 << 0)
126
127typedef struct  _ATH_DEBUG_MODULE_DBG_INFO{
128    struct _ATH_DEBUG_MODULE_DBG_INFO *pNext;
129    char ModuleName[16];
130    char ModuleDescription[ATH_DEBUG_MAX_MOD_DESC_LENGTH];
131    u32 Flags;
132    u32 CurrentMask;
133    int                         MaxDescriptions;
134    struct ath_debug_mask_description  *pMaskDescriptions; /* pointer to array of descriptions */
135} ATH_DEBUG_MODULE_DBG_INFO;
136
137#define ATH_DEBUG_DESCRIPTION_COUNT(d)  (int)((sizeof((d))) / (sizeof(struct ath_debug_mask_description)))
138
139#define GET_ATH_MODULE_DEBUG_VAR_NAME(s) _XGET_ATH_MODULE_NAME_DEBUG_(s)
140#define GET_ATH_MODULE_DEBUG_VAR_MASK(s) _XGET_ATH_MODULE_NAME_DEBUG_(s).CurrentMask
141#define _XGET_ATH_MODULE_NAME_DEBUG_(s) debug_ ## s
142
143#ifdef ATH_DEBUG_MODULE
144
145    /* for source files that will instantiate the debug variables */
146#define ATH_DEBUG_INSTANTIATE_MODULE_VAR(s,name,moddesc,initmask,count,descriptions) \
147ATH_DEBUG_MODULE_DBG_INFO GET_ATH_MODULE_DEBUG_VAR_NAME(s) = \
148            {NULL,(name),(moddesc),0,(initmask),count,(descriptions)}
149
150#ifdef ATH_MODULE_NAME
151extern ATH_DEBUG_MODULE_DBG_INFO GET_ATH_MODULE_DEBUG_VAR_NAME(ATH_MODULE_NAME);
152#define AR_DEBUG_LVL_CHECK(lvl) (GET_ATH_MODULE_DEBUG_VAR_MASK(ATH_MODULE_NAME) & (lvl))
153#endif /* ATH_MODULE_NAME */
154
155#define ATH_DEBUG_SET_DEBUG_MASK(s,lvl) GET_ATH_MODULE_DEBUG_VAR_MASK(s) = (lvl)
156
157#define ATH_DEBUG_DECLARE_EXTERN(s) \
158    extern ATH_DEBUG_MODULE_DBG_INFO GET_ATH_MODULE_DEBUG_VAR_NAME(s)
159
160#define AR_DEBUG_PRINTBUF(buffer, length, desc) DebugDumpBytes(buffer,length,desc)
161
162
163#define AR_DEBUG_ASSERT A_ASSERT
164
165void a_dump_module_debug_info(ATH_DEBUG_MODULE_DBG_INFO *pInfo);
166void a_register_module_debug_info(ATH_DEBUG_MODULE_DBG_INFO *pInfo);
167#define A_DUMP_MODULE_DEBUG_INFO(s) a_dump_module_debug_info(&(GET_ATH_MODULE_DEBUG_VAR_NAME(s)))
168#define A_REGISTER_MODULE_DEBUG_INFO(s) a_register_module_debug_info(&(GET_ATH_MODULE_DEBUG_VAR_NAME(s)))
169
170#else /* !ATH_DEBUG_MODULE */
171    /* NON ATH_DEBUG_MODULE */
172#define ATH_DEBUG_INSTANTIATE_MODULE_VAR(s,name,moddesc,initmask,count,descriptions)
173#define AR_DEBUG_LVL_CHECK(lvl) 0
174#define AR_DEBUG_PRINTBUF(buffer, length, desc)
175#define AR_DEBUG_ASSERT(test)
176#define ATH_DEBUG_DECLARE_EXTERN(s)
177#define ATH_DEBUG_SET_DEBUG_MASK(s,lvl)
178#define A_DUMP_MODULE_DEBUG_INFO(s)
179#define A_REGISTER_MODULE_DEBUG_INFO(s)
180
181#endif
182
183int a_get_module_mask(char *module_name, u32 *pMask);
184int a_set_module_mask(char *module_name, u32 Mask);
185void a_dump_module_debug_info_by_name(char *module_name);
186void a_module_debug_support_init(void);
187void a_module_debug_support_cleanup(void);
188
189#include "../os/linux/include/debug_linux.h"
190
191#ifdef __cplusplus
192}
193#endif /* __cplusplus */
194
195#endif