OLD | NEW |
(Empty) | |
| 1 //------------------------------------------------------------------------------ |
| 2 // <copyright file="a_debug.h" company="Atheros"> |
| 3 // Copyright (c) 2004-2008 Atheros Corporation. All rights reserved. |
| 4 // |
| 5 // This program is free software; you can redistribute it and/or modify |
| 6 // it under the terms of the GNU General Public License version 2 as |
| 7 // published by the Free Software Foundation; |
| 8 // |
| 9 // Software distributed under the License is distributed on an "AS |
| 10 // IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or |
| 11 // implied. See the License for the specific language governing |
| 12 // rights and limitations under the License. |
| 13 // |
| 14 // |
| 15 //------------------------------------------------------------------------------ |
| 16 //============================================================================== |
| 17 // Author(s): ="Atheros" |
| 18 //============================================================================== |
| 19 #ifndef _A_DEBUG_H_ |
| 20 #define _A_DEBUG_H_ |
| 21 |
| 22 #ifdef __cplusplus |
| 23 extern "C" { |
| 24 #endif /* __cplusplus */ |
| 25 |
| 26 #include <a_types.h> |
| 27 #include <a_osapi.h> |
| 28 |
| 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 |
| 39 #define ATH_DEBUG_MASK_DEFAULTS (ATH_DEBUG_ERR | ATH_DEBUG_WARN) |
| 40 #define ATH_DEBUG_ANY 0xFFFF |
| 41 |
| 42 /* other aliases used throughout */ |
| 43 #define ATH_DEBUG_ERROR ATH_DEBUG_ERR |
| 44 #define ATH_LOG_ERR ATH_DEBUG_ERR |
| 45 #define ATH_LOG_INF ATH_DEBUG_INFO |
| 46 #define ATH_LOG_TRC ATH_DEBUG_TRC |
| 47 #define ATH_DEBUG_TRACE ATH_DEBUG_TRC |
| 48 #define ATH_DEBUG_INIT ATH_DEBUG_INFO |
| 49 |
| 50 /* bits 8..31 are module-specific masks */ |
| 51 #define ATH_DEBUG_MODULE_MASK_SHIFT 8 |
| 52 |
| 53 /* macro to make a module-specific masks */ |
| 54 #define ATH_DEBUG_MAKE_MODULE_MASK(index) (1 << (ATH_DEBUG_MODULE_MASK_SHIFT +
(index))) |
| 55 |
| 56 void DebugDumpBytes(A_UCHAR *buffer, A_UINT16 length, char *pDescription); |
| 57 |
| 58 /* Debug support on a per-module basis |
| 59 * |
| 60 * Usage: |
| 61 * |
| 62 * Each module can utilize it's own debug mask variable. A set of commonly us
ed |
| 63 * masks are provided (ERRORS, WARNINGS, TRACE etc..). It is up to each modul
e |
| 64 * to define module-specific masks using the macros above. |
| 65 * |
| 66 * Each module defines a single debug mask variable debug_XXX where the "name"
of the module is |
| 67 * common to all C-files within that module. This requires every C-file that
includes a_debug.h |
| 68 * to define the module name in that file. |
| 69 * |
| 70 * Example: |
| 71 * |
| 72 * #define ATH_MODULE_NAME htc |
| 73 * #include "a_debug.h" |
| 74 * |
| 75 * This will define a debug mask structure called debug_htc and all debug macr
os will reference this |
| 76 * variable. |
| 77 * |
| 78 * A module can define module-specific bit masks using the ATH_DEBUG_MAKE_MODU
LE_MASK() macro: |
| 79 * |
| 80 * #define ATH_DEBUG_MY_MASK1 ATH_DEBUG_MAKE_MODULE_MASK(0) |
| 81 * #define ATH_DEBUG_MY_MASK2 ATH_DEBUG_MAKE_MODULE_MASK(1) |
| 82 * |
| 83 * The instantiation of the debug structure should be made by the module. Whe
n a module is |
| 84 * instantiated, the module can set a description string, a default mask and a
n array of description |
| 85 * entries containing information on each module-defined debug mask. |
| 86 * NOTE: The instantiation is statically allocated, only one instance can exis
t per module. |
| 87 * |
| 88 * Example: |
| 89 * |
| 90 * |
| 91 * #define ATH_DEBUG_BMI ATH_DEBUG_MAKE_MODULE_MASK(0) |
| 92 * |
| 93 * #ifdef DEBUG |
| 94 * static ATH_DEBUG_MASK_DESCRIPTION bmi_debug_desc[] = { |
| 95 * { ATH_DEBUG_BMI , "BMI Tracing"}, <== description of the module speci
fic mask |
| 96 * }; |
| 97 * |
| 98 * ATH_DEBUG_INSTANTIATE_MODULE_VAR(bmi, |
| 99 * "bmi" <== module name |
| 100 * "Boot Manager Interface", <== description
of module |
| 101 * ATH_DEBUG_MASK_DEFAULTS, <== defa
ults |
| 102 * ATH_DEBUG_DESCRIPTION_COUNT(bmi_debug_desc
), |
| 103 * bmi_debug_desc); |
| 104 * |
| 105 * #endif |
| 106 * |
| 107 * A module can optionally register it's debug module information in order for
other tools to change the |
| 108 * bit mask at runtime. A module can call A_REGISTER_MODULE_DEBUG_INFO() in i
t's module |
| 109 * init code. This macro can be called multiple times without consequence. Th
e debug info maintains |
| 110 * state to indicate whether the information was previously registered. |
| 111 * |
| 112 * */ |
| 113 |
| 114 #define ATH_DEBUG_MAX_MASK_DESC_LENGTH 32 |
| 115 #define ATH_DEBUG_MAX_MOD_DESC_LENGTH 64 |
| 116 |
| 117 typedef struct { |
| 118 A_UINT32 Mask; |
| 119 A_CHAR Description[ATH_DEBUG_MAX_MASK_DESC_LENGTH]; |
| 120 } ATH_DEBUG_MASK_DESCRIPTION; |
| 121 |
| 122 #define ATH_DEBUG_INFO_FLAGS_REGISTERED (1 << 0) |
| 123 |
| 124 typedef struct _ATH_DEBUG_MODULE_DBG_INFO{ |
| 125 struct _ATH_DEBUG_MODULE_DBG_INFO *pNext; |
| 126 A_CHAR ModuleName[16]; |
| 127 A_CHAR ModuleDescription[ATH_DEBUG_MAX_MOD_DESC_LENGTH]
; |
| 128 A_UINT32 Flags; |
| 129 A_UINT32 CurrentMask; |
| 130 int MaxDescriptions; |
| 131 ATH_DEBUG_MASK_DESCRIPTION *pMaskDescriptions; /* pointer to array of descr
iptions */ |
| 132 } ATH_DEBUG_MODULE_DBG_INFO; |
| 133 |
| 134 #define ATH_DEBUG_DESCRIPTION_COUNT(d) (int)((sizeof((d))) / (sizeof(ATH_DEBUG_
MASK_DESCRIPTION))) |
| 135 |
| 136 #define GET_ATH_MODULE_DEBUG_VAR_NAME(s) _XGET_ATH_MODULE_NAME_DEBUG_(s) |
| 137 #define GET_ATH_MODULE_DEBUG_VAR_MASK(s) _XGET_ATH_MODULE_NAME_DEBUG_(s).Current
Mask |
| 138 #define _XGET_ATH_MODULE_NAME_DEBUG_(s) debug_ ## s |
| 139 |
| 140 #ifdef DEBUG |
| 141 |
| 142 /* for source files that will instantiate the debug variables */ |
| 143 #define ATH_DEBUG_INSTANTIATE_MODULE_VAR(s,name,moddesc,initmask,count,descripti
ons) \ |
| 144 ATH_DEBUG_MODULE_DBG_INFO GET_ATH_MODULE_DEBUG_VAR_NAME(s) = \ |
| 145 {NULL,(name),(moddesc),0,(initmask),count,(descriptions)} |
| 146 |
| 147 #ifdef ATH_MODULE_NAME |
| 148 extern ATH_DEBUG_MODULE_DBG_INFO GET_ATH_MODULE_DEBUG_VAR_NAME(ATH_MODULE_NAME); |
| 149 #define AR_DEBUG_LVL_CHECK(lvl) (GET_ATH_MODULE_DEBUG_VAR_MASK(ATH_MODULE_NAME)
& (lvl)) |
| 150 #endif /* ATH_MODULE_NAME */ |
| 151 |
| 152 #define ATH_DEBUG_SET_DEBUG_MASK(s,lvl) GET_ATH_MODULE_DEBUG_VAR_MASK(s) = (lvl) |
| 153 |
| 154 #define ATH_DEBUG_DECLARE_EXTERN(s) \ |
| 155 extern ATH_DEBUG_MODULE_DBG_INFO GET_ATH_MODULE_DEBUG_VAR_NAME(s) |
| 156 |
| 157 #define AR_DEBUG_PRINTBUF(buffer, length, desc) DebugDumpBytes(buffer,length,des
c) |
| 158 |
| 159 |
| 160 #define AR_DEBUG_ASSERT A_ASSERT |
| 161 |
| 162 void a_dump_module_debug_info(ATH_DEBUG_MODULE_DBG_INFO *pInfo); |
| 163 void a_register_module_debug_info(ATH_DEBUG_MODULE_DBG_INFO *pInfo); |
| 164 #define A_DUMP_MODULE_DEBUG_INFO(s) a_dump_module_debug_info(&(GET_ATH_MODULE_DE
BUG_VAR_NAME(s))) |
| 165 #define A_REGISTER_MODULE_DEBUG_INFO(s) a_register_module_debug_info(&(GET_ATH_M
ODULE_DEBUG_VAR_NAME(s))) |
| 166 |
| 167 #else /* !DEBUG */ |
| 168 /* NON DEBUG */ |
| 169 #define ATH_DEBUG_INSTANTIATE_MODULE_VAR(s,name,moddesc,initmask,count,descripti
ons) |
| 170 #define AR_DEBUG_LVL_CHECK(lvl) 0 |
| 171 #define AR_DEBUG_PRINTBUF(buffer, length, desc) |
| 172 #define AR_DEBUG_ASSERT(test) |
| 173 #define ATH_DEBUG_DECLARE_EXTERN(s) |
| 174 #define ATH_DEBUG_SET_DEBUG_MASK(s,lvl) |
| 175 #define A_DUMP_MODULE_DEBUG_INFO(s) |
| 176 #define A_REGISTER_MODULE_DEBUG_INFO(s) |
| 177 |
| 178 #endif |
| 179 |
| 180 A_STATUS a_get_module_mask(A_CHAR *module_name, A_UINT32 *pMask); |
| 181 A_STATUS a_set_module_mask(A_CHAR *module_name, A_UINT32 Mask); |
| 182 void a_dump_module_debug_info_by_name(A_CHAR *module_name); |
| 183 void a_module_debug_support_init(void); |
| 184 void a_module_debug_support_cleanup(void); |
| 185 |
| 186 #ifdef UNDER_NWIFI |
| 187 #include "../os/windows/include/debug.h" |
| 188 #endif |
| 189 |
| 190 #ifdef ATHR_CE_LEGACY |
| 191 #include "../os/windows/include/debug.h" |
| 192 #endif |
| 193 |
| 194 #if defined(__linux__) && !defined(LINUX_EMULATION) |
| 195 #include "../os/linux/include/debug_linux.h" |
| 196 #endif |
| 197 |
| 198 #ifdef REXOS |
| 199 #include "../os/rexos/include/common/debug_rexos.h" |
| 200 #endif |
| 201 |
| 202 #if defined ART_WIN |
| 203 #include "../os/win_art/include/debug_win.h" |
| 204 #endif |
| 205 |
| 206 #ifdef WIN_NWF |
| 207 #include <debug_win.h> |
| 208 #endif |
| 209 |
| 210 |
| 211 #ifdef __cplusplus |
| 212 } |
| 213 #endif /* __cplusplus */ |
| 214 |
| 215 #endif |
OLD | NEW |