2 ** $Id: //Department/DaVinci/BRANCHES/MT6620_WIFI_DRIVER_V2_3/include/debug.h#1 $
6 \brief Definition of SW debugging level.
8 In this file, it describes the definition of various SW debugging levels and
18 * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
19 * fixed the Windows DDK free build compiling error.
22 * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
23 * Adjust code for DBG and CONFIG_XLOG.
26 * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
27 * modify the xlog related code.
30 * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
31 * Using the new XLOG define for dum Memory.
34 * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
35 * Add dumpMemory8 at XLOG support.
38 * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
39 * adding the code for XLOG.
42 * [WCXRP00000969] [MT6620 Wi-Fi][Driver][FW] Channel list for 5G band based on country code
45 * 01 27 2011 tsaiyuan.hsu
46 * [WCXRP00000392] [MT6620 Wi-Fi][Driver] Add Roaming Support
48 * 1. not support 11r, only use strength of signal to determine roaming.
49 * 2. not enable CFG_SUPPORT_ROAMING until completion of full test.
50 * 3. in 6620, adopt work-around to avoid sign extension problem of cck of hw
51 * 4. assume that change of link quality in smooth way.
54 * [WCXRP00000326] [MT6620][Wi-Fi][Driver] check in the binary format gl_sec.o.new instead of use change type!!!
59 * add BOW index for debugging message and passing compilation
63 * adding the wapi code.
67 * [WPD00003833] [MT6620 and MT5931] Driver migration - move to new repository.
69 * 06 21 2010 yarco.yang
70 * [WPD00003837][MT6620]Data Path Refine
71 * Support CFG_MQM_MIGRATION flag
73 * 06 17 2010 yuche.tsai
74 * [WPD00003839][MT6620 5931][P2P] Feature migration
75 * Add one more debug moduel for P2P.
78 * [WPD00003833][MT6620 and MT5931] Driver migration
79 * add management dispatching function table.
82 * [WPD00003833][MT6620 and MT5931] Driver migration
86 * [WPD00003833][MT6620 and MT5931] Driver migration
88 * 2) add ucTxSeqNum for tracking frames which needs TX-DONE awareness
89 * 3) add configuration options for CNM_MEM and RSN modules
90 * 4) add data path for management frames
91 * 5) eliminate rPacketInfo of MSDU_INFO_T
94 * [WPD00003833][MT6620 and MT5931] Driver migration
95 * add debug module index for cnm and ais.
97 * 06 06 2010 kevin.huang
98 * [WPD00003832][MT6620 5931] Create driver base
99 * [MT6620 5931] Create driver base
102 * [WPD00001943]Create WiFi test driver framework on WinXP
103 * add CFG_STARTUP_DEBUG for debugging starting up issue.
106 * [WPD00001943]Create WiFi test driver framework on WinXP
107 * 1) surpress compiler warning
108 * 2) when acqruing LP-own, keep writing WHLPCR whenever OWN is not acquired yet
109 ** \main\maintrunk.MT6620WiFiDriver_Prj\4 2009-10-29 19:47:50 GMT mtk01084
111 ** \main\maintrunk.MT6620WiFiDriver_Prj\3 2009-04-17 18:12:04 GMT mtk01426
112 ** Don't use dynamic memory allocate for debug message
113 ** \main\maintrunk.MT6620WiFiDriver_Prj\2 2009-03-10 20:11:29 GMT mtk01426
121 /*******************************************************************************
122 * C O M P I L E R F L A G S
123 ********************************************************************************
126 #define BUILD_QA_DBG 0
129 /*******************************************************************************
130 * E X T E R N A L R E F E R E N C E S
131 ********************************************************************************
133 #include "gl_typedef.h"
135 #include "linux/xlog.h"
138 extern UINT_8 aucDebugModule[];
139 extern UINT_32 u4DebugModule;
141 /*******************************************************************************
143 ********************************************************************************
145 /* Define debug category (class):
146 * (1) ERROR (2) WARN (3) STATE (4) EVENT (5) TRACE (6) INFO (7) LOUD (8) TEMP
148 #define DBG_CLASS_ERROR BIT(0)
149 #define DBG_CLASS_WARN BIT(1)
150 #define DBG_CLASS_STATE BIT(2)
151 #define DBG_CLASS_EVENT BIT(3)
152 #define DBG_CLASS_TRACE BIT(4)
153 #define DBG_CLASS_INFO BIT(5)
154 #define DBG_CLASS_LOUD BIT(6)
155 #define DBG_CLASS_TEMP BIT(7)
156 #define DBG_CLASS_MASK BITS(0,7)
160 #define DBG_PRINTF_64BIT_DEC "lld"
163 #define DBG_PRINTF_64BIT_DEC "I64d"
166 /*******************************************************************************
168 ********************************************************************************
170 /* Define debug module index */
171 typedef enum _ENUM_DBG_MODULE_T {
172 DBG_INIT_IDX = 0, /* For driver initial */
173 DBG_HAL_IDX, /* For HAL(HW) Layer */
174 DBG_INTR_IDX, /* For Interrupt */
178 DBG_RFTEST_IDX, /* For RF test mode*/
179 DBG_EMU_IDX, /* Developer specific */
181 DBG_SW1_IDX, /* Developer specific */
182 DBG_SW2_IDX, /* Developer specific */
183 DBG_SW3_IDX, /* Developer specific */
184 DBG_SW4_IDX, /* Developer specific */
186 DBG_HEM_IDX, /* HEM */
187 DBG_AIS_IDX, /* AIS */
188 DBG_RLM_IDX, /* RLM */
189 DBG_MEM_IDX, /* RLM */
190 DBG_CNM_IDX, /* CNM */
191 DBG_RSN_IDX, /* RSN */
192 DBG_BSS_IDX, /* BSS */
193 DBG_SCN_IDX, /* SCN */
194 DBG_SAA_IDX, /* SAA */
195 DBG_AAA_IDX, /* AAA */
196 DBG_P2P_IDX, /* P2P */
197 DBG_QM_IDX, /* QUE_MGT */
198 DBG_SEC_IDX, /* SEC */
199 DBG_BOW_IDX, /* BOW */
200 DBG_WAPI_IDX, /* WAPI */
201 DBG_ROAMING_IDX, /* ROAMING */
203 DBG_MODULE_NUM /* Notice the XLOG check */
207 //#define XLOG_DBG_MODULE_IDX 28 /* DBG_MODULE_NUM */
208 //#if (XLOG_DBG_MODULE_IDX != XLOG_DBG_MODULE_IDX)
209 //#error "Please modify the DBG_MODULE_NUM and make sure this include at XLOG"
212 /* Define who owns developer specific index */
213 #define DBG_YARCO_IDX DBG_SW1_IDX
214 #define DBG_KEVIN_IDX DBG_SW2_IDX
215 #define DBG_CMC_IDX DBG_SW3_IDX
216 #define DBG_GEORGE_IDX DBG_SW4_IDX
218 /*******************************************************************************
219 * P U B L I C D A T A
220 ********************************************************************************
223 /*******************************************************************************
224 * P R I V A T E D A T A
225 ********************************************************************************
228 /*******************************************************************************
230 ********************************************************************************
232 /* Debug print format string for the OS system time */
233 #define OS_SYSTIME_DBG_FORMAT "0x%08x"
235 /* Debug print argument for the OS system time */
236 #define OS_SYSTIME_DBG_ARGUMENT(systime) (systime)
238 /* Debug print format string for the MAC Address */
239 #define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
241 /* Debug print argument for the MAC Address */
242 #define MAC2STR(a) ((PUINT_8)a)[0], ((PUINT_8)a)[1], ((PUINT_8)a)[2], \
243 ((PUINT_8)a)[3], ((PUINT_8)a)[4], ((PUINT_8)a)[5]
245 /* The pre-defined format to dump the value of a varaible with its name shown. */
246 #define DUMPVAR(variable, format) (#variable " = " format "\n", variable)
248 /* The pre-defined format to dump the MAC type value with its name shown. */
249 #define DUMPMACADDR(addr) (#addr " = " MACSTR "\n", MAC2STR(addr))
252 /* Basiclly, we just do renaming of KAL functions although they should
253 * be defined as "Nothing to do" if DBG=0. But in some compiler, the macro
254 * syntax does not support #define LOG_FUNC(x,...)
256 * A caller shall not invoke these three macros when DBG=0.
258 #define LOG_FUNC_TIME kalPrint
259 #define LOG_FUNC kalPrint
263 #define TMP_BUF_LEN 256
264 #define TMP_WBUF_LEN (TMP_BUF_LEN * 2)
266 extern PINT_16 g_wbuf_p;
267 extern PINT_8 g_buf_p;
269 /* If __FUNCTION__ is already defined by compiler, we just use it. */
270 #if defined(__FUNCTION__)
271 #define DEBUGFUNC(_Func)
273 #define DEBUGFUNC(_Func) static const char __FUNCTION__[] = _Func;
276 /* The following macros are used for future debug message. */
277 /* TODO(Kevin): We should remove INITLOG/ERRORLOG/WARNLOG macro sooner or later */
278 #define INITLOG(_Fmt) \
280 if (aucDebugModule[DBG_INIT_IDX] & DBG_CLASS_TRACE) { \
281 LOG_FUNC("%s: ", __FUNCTION__); \
286 #define ERRORLOG(_Fmt) \
288 if (aucDebugModule[DBG_INIT_IDX] & DBG_CLASS_ERROR) { \
289 LOG_FUNC("**Error[%s:%d]-", __FILE__, __LINE__); \
294 #define WARNLOG(_Fmt) \
296 if (aucDebugModule[DBG_INIT_IDX] & DBG_CLASS_WARN) { \
297 LOG_FUNC("**Warning[%s:%d]-", __FILE__, __LINE__); \
302 /*lint -save -e960 Multiple use of '#/##' */
303 #define DBGLOG(_Module, _Class, _Fmt) \
305 if (aucDebugModule[DBG_##_Module##_IDX] & DBG_CLASS_##_Class) { \
306 if (DBG_CLASS_##_Class == DBG_CLASS_ERROR) { \
307 LOG_FUNC_TIME("**Error[%s:%d]-", __FILE__, __LINE__); \
308 LOG_FUNC("%s: (" #_Module " " #_Class ") ", __FUNCTION__); \
310 else if (DBG_CLASS_##_Class == DBG_CLASS_WARN) { \
311 LOG_FUNC_TIME("**Warning[%s:%d]-", __FILE__, __LINE__); \
312 LOG_FUNC("%s: (" #_Module " " #_Class ") ", __FUNCTION__); \
314 else if (DBG_CLASS_##_Class == DBG_CLASS_EVENT) { \
317 LOG_FUNC_TIME("%s: (" #_Module " " #_Class ") ", __FUNCTION__); \
323 #define DBGLOG_MEM8(_Module, _Class, _StartAddr, _Length) \
325 if (aucDebugModule[DBG_##_Module##_IDX] & DBG_CLASS_##_Class) { \
326 LOG_FUNC("%s: (" #_Module " " #_Class ")\n", __FUNCTION__); \
327 dumpMemory8((PUINT_8) (_StartAddr), (UINT_32) (_Length)); \
331 #define DBGLOG_MEM32(_Module, _Class, _StartAddr, _Length) \
333 if (aucDebugModule[DBG_##_Module##_IDX] & DBG_CLASS_##_Class) { \
334 LOG_FUNC("%s: (" #_Module " " #_Class ")\n", __FUNCTION__); \
335 dumpMemory32((PUINT_32) (_StartAddr), (UINT_32) (_Length)); \
340 /*lint -save -e961 use of '#undef' is discouraged */
345 #define ASSERT(_exp) \
347 if (!(_exp)) {do {} while (1);} \
350 #define ASSERT(_exp) \
352 if (!(_exp) && !fgIsBusAccessFailed) { \
353 LOG_FUNC("Assertion failed: %s:%d %s\n", __FILE__, __LINE__, #_exp); \
359 #define ASSERT_REPORT(_exp, _fmt) \
361 if (!(_exp) && !fgIsBusAccessFailed) { \
362 LOG_FUNC("Assertion failed: %s:%d %s\n", __FILE__, __LINE__, #_exp); \
368 #define DISP_STRING(_str) _str
372 #define DEBUGFUNC(_Func)
373 #define INITLOG(_Fmt)
374 #define ERRORLOG(_Fmt)
375 #define WARNLOG(_Fmt)
378 #define DBGLOG(_Module, _Class, _Fmt) \
380 _Module##_##_Class##_LOGFUNC _Fmt; \
383 #define DBGLOG(_Module, _Class, _Fmt)
387 #define DBGLOG_MEM8(_Module, _Class, _StartAddr, _Length) \
389 _Module##_##_Class##_LOGFUNC (__FUNCTION__);\
390 _Module##_##_Class##_LOGDUMP8(_StartAddr, _Length); \
393 #define DBGLOG_MEM8(_Module, _Class, _StartAddr, _Length)
395 #define DBGLOG_MEM32(_Module, _Class, _StartAddr, _Length)
400 #if defined(LINUX) /* For debugging in Linux w/o GDB */
401 #define ASSERT(_exp) \
403 if (!(_exp) && !fgIsBusAccessFailed) { \
404 LOG_FUNC("Assertion failed: %s:%d (%s)\n", __FILE__, __LINE__, #_exp); \
409 #define ASSERT_REPORT(_exp, _fmt) \
411 if (!(_exp) && !fgIsBusAccessFailed) { \
412 LOG_FUNC("Assertion failed: %s:%d (%s)\n", __FILE__, __LINE__, #_exp); \
419 #define UNICODE_TEXT(_msg) TEXT(_msg)
420 #define ASSERT(_exp) \
422 if (!(_exp) && !fgIsBusAccessFailed) { \
425 _stprintf(rUbuf, TEXT("Assertion failed: %s:%d %s\n"), \
426 UNICODE_TEXT(__FILE__), \
428 UNICODE_TEXT(#_exp)); \
429 MessageBox(NULL, rUbuf, TEXT("ASSERT!"), MB_OK); \
433 #define ASSERT_REPORT(_exp, _fmt) \
435 if (!(_exp) && !fgIsBusAccessFailed) { \
438 _stprintf(rUbuf, TEXT("Assertion failed: %s:%d %s\n"), \
439 UNICODE_TEXT(__FILE__), \
441 UNICODE_TEXT(#_exp)); \
442 MessageBox(NULL, rUbuf, TEXT("ASSERT!"), MB_OK); \
446 #define ASSERT(_exp) \
448 if (!(_exp) && !fgIsBusAccessFailed) { \
453 #define ASSERT_REPORT(_exp, _fmt) \
455 if (!(_exp) && !fgIsBusAccessFailed) { \
459 #endif /* WINDOWS_CE */
463 #define ASSERT_REPORT(_exp, _fmt)
464 #endif /* BUILD_QA_DBG */
466 #define DISP_STRING(_str) ""
470 #if CFG_STARTUP_DEBUG
472 #define DBGPRINTF kalPrint
474 #define DBGPRINTF DbgPrint
477 #define DBGPRINTF(...)
481 /* The following macro is used for debugging packed structures. */
482 #ifndef DATA_STRUC_INSPECTING_ASSERT
483 #define DATA_STRUC_INSPECTING_ASSERT(expr) \
484 switch (0) {case 0: case (expr): default:;}
487 /*******************************************************************************
488 * F U N C T I O N D E C L A R A T I O N S
489 ********************************************************************************
494 IN PUINT_8 pucStartAddr,
500 IN PUINT_32 pu4StartAddr,
503 #elif CFG_SUPPORT_XLOG
506 IN UINT_32 log_level,
507 IN PUINT_8 pucStartAddr,
512 /*******************************************************************************
514 ********************************************************************************
516 #endif /* _DEBUG_H */