2 ** $Id: //Department/DaVinci/BRANCHES/MT662X_593X_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
12 /*******************************************************************************
13 * Copyright (c) 2007 MediaTek Inc.
15 * All rights reserved. Copying, compilation, modification, distribution
16 * or any other use whatsoever of this material is strictly prohibited
17 * except in accordance with a Software License Agreement with
19 ********************************************************************************
22 /*******************************************************************************
25 * BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND
26 * AGREES THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK
27 * SOFTWARE") RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE
28 * PROVIDED TO BUYER ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY
29 * DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT
30 * LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
31 * PARTICULAR PURPOSE OR NONINFRINGEMENT. NEITHER DOES MEDIATEK PROVIDE
32 * ANY WARRANTY WHATSOEVER WITH RESPECT TO THE SOFTWARE OF ANY THIRD PARTY
33 * WHICH MAY BE USED BY, INCORPORATED IN, OR SUPPLIED WITH THE MEDIATEK
34 * SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH THIRD PARTY FOR ANY
35 * WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE
36 * FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S SPECIFICATION OR TO
37 * CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
39 * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
40 * LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL
41 * BE, AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT
42 * ISSUE, OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY
43 * BUYER TO MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
45 * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
46 * WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT
47 * OF LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING
48 * THEREOF AND RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN
49 * FRANCISCO, CA, UNDER THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE
51 ********************************************************************************
58 * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
59 * fixed the Windows DDK free build compiling error.
62 * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
63 * Adjust code for DBG and CONFIG_XLOG.
66 * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
67 * modify the xlog related code.
70 * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
71 * Using the new XLOG define for dum Memory.
74 * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
75 * Add dumpMemory8 at XLOG support.
78 * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
79 * adding the code for XLOG.
82 * [WCXRP00000969] [MT6620 Wi-Fi][Driver][FW] Channel list for 5G band based on country code
85 * 01 27 2011 tsaiyuan.hsu
86 * [WCXRP00000392] [MT6620 Wi-Fi][Driver] Add Roaming Support
88 * 1. not support 11r, only use strength of signal to determine roaming.
89 * 2. not enable CFG_SUPPORT_ROAMING until completion of full test.
90 * 3. in 6620, adopt work-around to avoid sign extension problem of cck of hw
91 * 4. assume that change of link quality in smooth way.
94 * [WCXRP00000326] [MT6620][Wi-Fi][Driver] check in the binary format gl_sec.o.new instead of use change type!!!
99 * add BOW index for debugging message and passing compilation
103 * adding the wapi code.
107 * [WPD00003833] [MT6620 and MT5931] Driver migration - move to new repository.
109 * 06 21 2010 yarco.yang
110 * [WPD00003837][MT6620]Data Path Refine
111 * Support CFG_MQM_MIGRATION flag
113 * 06 17 2010 yuche.tsai
114 * [WPD00003839][MT6620 5931][P2P] Feature migration
115 * Add one more debug moduel for P2P.
118 * [WPD00003833][MT6620 and MT5931] Driver migration
119 * add management dispatching function table.
122 * [WPD00003833][MT6620 and MT5931] Driver migration
126 * [WPD00003833][MT6620 and MT5931] Driver migration
127 * 1) migrate assoc.c.
128 * 2) add ucTxSeqNum for tracking frames which needs TX-DONE awareness
129 * 3) add configuration options for CNM_MEM and RSN modules
130 * 4) add data path for management frames
131 * 5) eliminate rPacketInfo of MSDU_INFO_T
134 * [WPD00003833][MT6620 and MT5931] Driver migration
135 * add debug module index for cnm and ais.
137 * 06 06 2010 kevin.huang
138 * [WPD00003832][MT6620 5931] Create driver base
139 * [MT6620 5931] Create driver base
142 * [WPD00001943]Create WiFi test driver framework on WinXP
143 * add CFG_STARTUP_DEBUG for debugging starting up issue.
146 * [WPD00001943]Create WiFi test driver framework on WinXP
147 * 1) surpress compiler warning
148 * 2) when acqruing LP-own, keep writing WHLPCR whenever OWN is not acquired yet
149 ** \main\maintrunk.MT6620WiFiDriver_Prj\4 2009-10-29 19:47:50 GMT mtk01084
151 ** \main\maintrunk.MT6620WiFiDriver_Prj\3 2009-04-17 18:12:04 GMT mtk01426
152 ** Don't use dynamic memory allocate for debug message
153 ** \main\maintrunk.MT6620WiFiDriver_Prj\2 2009-03-10 20:11:29 GMT mtk01426
161 /*******************************************************************************
162 * C O M P I L E R F L A G S
163 ********************************************************************************
166 #define BUILD_QA_DBG 0
169 /*******************************************************************************
170 * E X T E R N A L R E F E R E N C E S
171 ********************************************************************************
173 #include "gl_typedef.h"
175 #include "linux/xlog.h"
178 extern UINT_8 aucDebugModule[];
179 extern UINT_32 u4DebugModule;
181 /*******************************************************************************
183 ********************************************************************************
185 /* Define debug category (class):
186 * (1) ERROR (2) WARN (3) STATE (4) EVENT (5) TRACE (6) INFO (7) LOUD (8) TEMP
188 #define DBG_CLASS_ERROR BIT(0)
189 #define DBG_CLASS_WARN BIT(1)
190 #define DBG_CLASS_STATE BIT(2)
191 #define DBG_CLASS_EVENT BIT(3)
192 #define DBG_CLASS_TRACE BIT(4)
193 #define DBG_CLASS_INFO BIT(5)
194 #define DBG_CLASS_LOUD BIT(6)
195 #define DBG_CLASS_TEMP BIT(7)
196 #define DBG_CLASS_MASK BITS(0,7)
200 #define DBG_PRINTF_64BIT_DEC "lld"
203 #define DBG_PRINTF_64BIT_DEC "I64d"
206 /*******************************************************************************
208 ********************************************************************************
210 /* Define debug module index */
211 typedef enum _ENUM_DBG_MODULE_T {
212 DBG_INIT_IDX = 0, /* For driver initial */
213 DBG_HAL_IDX, /* For HAL(HW) Layer */
214 DBG_INTR_IDX, /* For Interrupt */
218 DBG_RFTEST_IDX, /* For RF test mode*/
219 DBG_EMU_IDX, /* Developer specific */
221 DBG_SW1_IDX, /* Developer specific */
222 DBG_SW2_IDX, /* Developer specific */
223 DBG_SW3_IDX, /* Developer specific */
224 DBG_SW4_IDX, /* Developer specific */
226 DBG_HEM_IDX, /* HEM */
227 DBG_AIS_IDX, /* AIS */
228 DBG_RLM_IDX, /* RLM */
229 DBG_MEM_IDX, /* RLM */
230 DBG_CNM_IDX, /* CNM */
231 DBG_RSN_IDX, /* RSN */
232 DBG_BSS_IDX, /* BSS */
233 DBG_SCN_IDX, /* SCN */
234 DBG_SAA_IDX, /* SAA */
235 DBG_AAA_IDX, /* AAA */
236 DBG_P2P_IDX, /* P2P */
237 DBG_QM_IDX, /* QUE_MGT */
238 DBG_SEC_IDX, /* SEC */
239 DBG_BOW_IDX, /* BOW */
240 DBG_WAPI_IDX, /* WAPI */
241 DBG_ROAMING_IDX, /* ROAMING */
243 DBG_MODULE_NUM /* Notice the XLOG check */
247 //#define XLOG_DBG_MODULE_IDX 28 /* DBG_MODULE_NUM */
248 //#if (XLOG_DBG_MODULE_IDX != XLOG_DBG_MODULE_IDX)
249 //#error "Please modify the DBG_MODULE_NUM and make sure this include at XLOG"
252 /* Define who owns developer specific index */
253 #define DBG_YARCO_IDX DBG_SW1_IDX
254 #define DBG_KEVIN_IDX DBG_SW2_IDX
255 #define DBG_CMC_IDX DBG_SW3_IDX
256 #define DBG_GEORGE_IDX DBG_SW4_IDX
258 /*******************************************************************************
259 * P U B L I C D A T A
260 ********************************************************************************
263 /*******************************************************************************
264 * P R I V A T E D A T A
265 ********************************************************************************
268 /*******************************************************************************
270 ********************************************************************************
272 /* Debug print format string for the OS system time */
273 #define OS_SYSTIME_DBG_FORMAT "0x%08x"
275 /* Debug print argument for the OS system time */
276 #define OS_SYSTIME_DBG_ARGUMENT(systime) (systime)
278 /* Debug print format string for the MAC Address */
279 #define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
281 /* Debug print argument for the MAC Address */
282 #define MAC2STR(a) ((PUINT_8)a)[0], ((PUINT_8)a)[1], ((PUINT_8)a)[2], \
283 ((PUINT_8)a)[3], ((PUINT_8)a)[4], ((PUINT_8)a)[5]
285 /* The pre-defined format to dump the value of a varaible with its name shown. */
286 #define DUMPVAR(variable, format) (#variable " = " format "\n", variable)
288 /* The pre-defined format to dump the MAC type value with its name shown. */
289 #define DUMPMACADDR(addr) (#addr " = " MACSTR "\n", MAC2STR(addr))
292 /* Basiclly, we just do renaming of KAL functions although they should
293 * be defined as "Nothing to do" if DBG=0. But in some compiler, the macro
294 * syntax does not support #define LOG_FUNC(x,...)
296 * A caller shall not invoke these three macros when DBG=0.
298 #define LOG_FUNC_TIME kalPrint
299 #define LOG_FUNC kalPrint
303 #define TMP_BUF_LEN 256
304 #define TMP_WBUF_LEN (TMP_BUF_LEN * 2)
306 extern PINT_16 g_wbuf_p;
307 extern PINT_8 g_buf_p;
309 /* If __FUNCTION__ is already defined by compiler, we just use it. */
310 #if defined(__FUNCTION__)
311 #define DEBUGFUNC(_Func)
313 #define DEBUGFUNC(_Func) static const char __FUNCTION__[] = _Func;
316 /* The following macros are used for future debug message. */
317 /* TODO(Kevin): We should remove INITLOG/ERRORLOG/WARNLOG macro sooner or later */
318 #define INITLOG(_Fmt) \
320 if (aucDebugModule[DBG_INIT_IDX] & DBG_CLASS_TRACE) { \
321 LOG_FUNC("%s: ", __FUNCTION__); \
326 #define ERRORLOG(_Fmt) \
328 if (aucDebugModule[DBG_INIT_IDX] & DBG_CLASS_ERROR) { \
329 LOG_FUNC("**Error[%s:%d]-", __FILE__, __LINE__); \
334 #define WARNLOG(_Fmt) \
336 if (aucDebugModule[DBG_INIT_IDX] & DBG_CLASS_WARN) { \
337 LOG_FUNC("**Warning[%s:%d]-", __FILE__, __LINE__); \
342 /*lint -save -e960 Multiple use of '#/##' */
343 #define DBGLOG(_Module, _Class, _Fmt) \
345 if (aucDebugModule[DBG_##_Module##_IDX] & DBG_CLASS_##_Class) { \
346 if (DBG_CLASS_##_Class == DBG_CLASS_ERROR) { \
347 LOG_FUNC_TIME("**Error[%s:%d]-", __FILE__, __LINE__); \
348 LOG_FUNC("%s: (" #_Module " " #_Class ") ", __FUNCTION__); \
350 else if (DBG_CLASS_##_Class == DBG_CLASS_WARN) { \
351 LOG_FUNC_TIME("**Warning[%s:%d]-", __FILE__, __LINE__); \
352 LOG_FUNC("%s: (" #_Module " " #_Class ") ", __FUNCTION__); \
354 else if (DBG_CLASS_##_Class == DBG_CLASS_EVENT) { \
357 LOG_FUNC_TIME("%s: (" #_Module " " #_Class ") ", __FUNCTION__); \
363 #define DBGLOG_MEM8(_Module, _Class, _StartAddr, _Length) \
365 if (aucDebugModule[DBG_##_Module##_IDX] & DBG_CLASS_##_Class) { \
366 LOG_FUNC("%s: (" #_Module " " #_Class ")\n", __FUNCTION__); \
367 dumpMemory8((PUINT_8) (_StartAddr), (UINT_32) (_Length)); \
371 #define DBGLOG_MEM32(_Module, _Class, _StartAddr, _Length) \
373 if (aucDebugModule[DBG_##_Module##_IDX] & DBG_CLASS_##_Class) { \
374 LOG_FUNC("%s: (" #_Module " " #_Class ")\n", __FUNCTION__); \
375 dumpMemory32((PUINT_32) (_StartAddr), (UINT_32) (_Length)); \
380 /*lint -save -e961 use of '#undef' is discouraged */
385 #define ASSERT(_exp) \
387 if (!(_exp)) {do {} while (1);} \
390 #define ASSERT(_exp) \
392 if (!(_exp) && !fgIsBusAccessFailed) { \
393 LOG_FUNC("Assertion failed: %s:%d %s\n", __FILE__, __LINE__, #_exp); \
399 #define ASSERT_REPORT(_exp, _fmt) \
401 if (!(_exp) && !fgIsBusAccessFailed) { \
402 LOG_FUNC("Assertion failed: %s:%d %s\n", __FILE__, __LINE__, #_exp); \
408 #define DISP_STRING(_str) _str
412 #define DEBUGFUNC(_Func)
413 #define INITLOG(_Fmt)
414 #define ERRORLOG(_Fmt)
415 #define WARNLOG(_Fmt)
418 #define DBGLOG(_Module, _Class, _Fmt) \
420 _Module##_##_Class##_LOGFUNC _Fmt; \
423 #define DBGLOG(_Module, _Class, _Fmt)
427 #define DBGLOG_MEM8(_Module, _Class, _StartAddr, _Length) \
429 _Module##_##_Class##_LOGFUNC (__FUNCTION__);\
430 _Module##_##_Class##_LOGDUMP8(_StartAddr, _Length); \
433 #define DBGLOG_MEM8(_Module, _Class, _StartAddr, _Length)
435 #define DBGLOG_MEM32(_Module, _Class, _StartAddr, _Length)
440 #if defined(LINUX) /* For debugging in Linux w/o GDB */
441 #define ASSERT(_exp) \
443 if (!(_exp) && !fgIsBusAccessFailed) { \
444 LOG_FUNC("Assertion failed: %s:%d (%s)\n", __FILE__, __LINE__, #_exp); \
449 #define ASSERT_REPORT(_exp, _fmt) \
451 if (!(_exp) && !fgIsBusAccessFailed) { \
452 LOG_FUNC("Assertion failed: %s:%d (%s)\n", __FILE__, __LINE__, #_exp); \
459 #define UNICODE_TEXT(_msg) TEXT(_msg)
460 #define ASSERT(_exp) \
462 if (!(_exp) && !fgIsBusAccessFailed) { \
465 _stprintf(rUbuf, TEXT("Assertion failed: %s:%d %s\n"), \
466 UNICODE_TEXT(__FILE__), \
468 UNICODE_TEXT(#_exp)); \
469 MessageBox(NULL, rUbuf, TEXT("ASSERT!"), MB_OK); \
473 #define ASSERT_REPORT(_exp, _fmt) \
475 if (!(_exp) && !fgIsBusAccessFailed) { \
478 _stprintf(rUbuf, TEXT("Assertion failed: %s:%d %s\n"), \
479 UNICODE_TEXT(__FILE__), \
481 UNICODE_TEXT(#_exp)); \
482 MessageBox(NULL, rUbuf, TEXT("ASSERT!"), MB_OK); \
486 #define ASSERT(_exp) \
488 if (!(_exp) && !fgIsBusAccessFailed) { \
493 #define ASSERT_REPORT(_exp, _fmt) \
495 if (!(_exp) && !fgIsBusAccessFailed) { \
499 #endif /* WINDOWS_CE */
503 #define ASSERT_REPORT(_exp, _fmt)
504 #endif /* BUILD_QA_DBG */
506 #define DISP_STRING(_str) ""
510 #if CFG_STARTUP_DEBUG
512 #define DBGPRINTF kalPrint
514 #define DBGPRINTF DbgPrint
517 #define DBGPRINTF(...)
521 /* The following macro is used for debugging packed structures. */
522 #ifndef DATA_STRUC_INSPECTING_ASSERT
523 #define DATA_STRUC_INSPECTING_ASSERT(expr) \
524 switch (0) {case 0: case (expr): default:;}
527 /*******************************************************************************
528 * F U N C T I O N D E C L A R A T I O N S
529 ********************************************************************************
534 IN PUINT_8 pucStartAddr,
540 IN PUINT_32 pu4StartAddr,
543 #elif CFG_SUPPORT_XLOG
546 IN UINT_32 log_level,
547 IN PUINT_8 pucStartAddr,
552 /*******************************************************************************
554 ********************************************************************************
556 #endif /* _DEBUG_H */