2 ** $Id: //Department/DaVinci/BRANCHES/MT6620_WIFI_DRIVER_V2_3/common/dump.c#1 $
6 \brief Provide memory dump function for debugging.
8 Provide memory dump function for debugging.
17 * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
18 * Adjust code for DBG and CONFIG_XLOG.
21 * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
22 * Using the new XLOG define for dum Memory.
25 * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
26 * Add dumpMemory8 at XLOG support.
30 * [WPD00003833] [MT6620 and MT5931] Driver migration - move to new repository.
32 * 06 06 2010 kevin.huang
33 * [WPD00003832][MT6620 5931] Create driver base
34 * [MT6620 5931] Create driver base
35 ** \main\maintrunk.MT6620WiFiDriver_Prj\2 2009-03-10 19:58:51 GMT mtk01426
40 /*******************************************************************************
41 * C O M P I L E R F L A G S
42 ********************************************************************************
45 /*******************************************************************************
46 * E X T E R N A L R E F E R E N C E S
47 ********************************************************************************
51 /*******************************************************************************
53 ********************************************************************************
56 /*******************************************************************************
58 ********************************************************************************
61 /*******************************************************************************
63 ********************************************************************************
66 /*******************************************************************************
67 * P R I V A T E D A T A
68 ********************************************************************************
71 /*******************************************************************************
73 ********************************************************************************
76 /*******************************************************************************
77 * F U N C T I O N D E C L A R A T I O N S
78 ********************************************************************************
81 /*******************************************************************************
83 ********************************************************************************
86 /*----------------------------------------------------------------------------*/
88 * \brief This routine is called to dump a segment of memory in bytes.
90 * \param[in] pucStartAddr Pointer to the starting address of the memory to be dumped.
91 * \param[in] u4Length Length of the memory to be dumped.
95 /*----------------------------------------------------------------------------*/
96 VOID
dumpMemory8(IN PUINT_8 pucStartAddr
, IN UINT_32 u4Length
)
100 LOG_FUNC("DUMP8 ADDRESS: %08lx, Length: %ld\n", (UINT_32
) pucStartAddr
, u4Length
);
102 while (u4Length
> 0) {
103 if (u4Length
>= 16) {
105 ("(%08lx) %02x %02x %02x %02x %02x %02x %02x %02x - %02x %02x %02x %02x %02x %02x %02x %02x\n",
106 (UINT_32
) pucStartAddr
, pucStartAddr
[0], pucStartAddr
[1],
107 pucStartAddr
[2], pucStartAddr
[3], pucStartAddr
[4], pucStartAddr
[5],
108 pucStartAddr
[6], pucStartAddr
[7], pucStartAddr
[8], pucStartAddr
[9],
109 pucStartAddr
[10], pucStartAddr
[11], pucStartAddr
[12], pucStartAddr
[13],
110 pucStartAddr
[14], pucStartAddr
[15]);
116 LOG_FUNC("(%08lx) %02x\n", (UINT_32
) pucStartAddr
, pucStartAddr
[0]);
119 LOG_FUNC("(%08lx) %02x %02x\n",
120 (UINT_32
) pucStartAddr
, pucStartAddr
[0], pucStartAddr
[1]);
123 LOG_FUNC("(%08lx) %02x %02x %02x\n",
124 (UINT_32
) pucStartAddr
,
125 pucStartAddr
[0], pucStartAddr
[1], pucStartAddr
[2]);
128 LOG_FUNC("(%08lx) %02x %02x %02x %02x\n",
129 (UINT_32
) pucStartAddr
,
130 pucStartAddr
[0], pucStartAddr
[1], pucStartAddr
[2],
134 LOG_FUNC("(%08lx) %02x %02x %02x %02x %02x\n",
135 (UINT_32
) pucStartAddr
,
136 pucStartAddr
[0], pucStartAddr
[1], pucStartAddr
[2],
137 pucStartAddr
[3], pucStartAddr
[4]);
140 LOG_FUNC("(%08lx) %02x %02x %02x %02x %02x %02x\n",
141 (UINT_32
) pucStartAddr
,
142 pucStartAddr
[0], pucStartAddr
[1], pucStartAddr
[2],
143 pucStartAddr
[3], pucStartAddr
[4], pucStartAddr
[5]);
146 LOG_FUNC("(%08lx) %02x %02x %02x %02x %02x %02x %02x\n",
147 (UINT_32
) pucStartAddr
,
148 pucStartAddr
[0], pucStartAddr
[1], pucStartAddr
[2],
149 pucStartAddr
[3], pucStartAddr
[4], pucStartAddr
[5],
153 LOG_FUNC("(%08lx) %02x %02x %02x %02x %02x %02x %02x %02x\n",
154 (UINT_32
) pucStartAddr
,
155 pucStartAddr
[0], pucStartAddr
[1], pucStartAddr
[2],
156 pucStartAddr
[3], pucStartAddr
[4], pucStartAddr
[5],
157 pucStartAddr
[6], pucStartAddr
[7]);
161 ("(%08lx) %02x %02x %02x %02x %02x %02x %02x %02x - %02x\n",
162 (UINT_32
) pucStartAddr
, pucStartAddr
[0], pucStartAddr
[1],
163 pucStartAddr
[2], pucStartAddr
[3], pucStartAddr
[4],
164 pucStartAddr
[5], pucStartAddr
[6], pucStartAddr
[7],
169 ("(%08lx) %02x %02x %02x %02x %02x %02x %02x %02x - %02x %02x\n",
170 (UINT_32
) pucStartAddr
, pucStartAddr
[0], pucStartAddr
[1],
171 pucStartAddr
[2], pucStartAddr
[3], pucStartAddr
[4],
172 pucStartAddr
[5], pucStartAddr
[6], pucStartAddr
[7],
173 pucStartAddr
[8], pucStartAddr
[9]);
177 ("(%08lx) %02x %02x %02x %02x %02x %02x %02x %02x - %02x %02x %02x\n",
178 (UINT_32
) pucStartAddr
, pucStartAddr
[0], pucStartAddr
[1],
179 pucStartAddr
[2], pucStartAddr
[3], pucStartAddr
[4],
180 pucStartAddr
[5], pucStartAddr
[6], pucStartAddr
[7],
181 pucStartAddr
[8], pucStartAddr
[9], pucStartAddr
[10]);
185 ("(%08lx) %02x %02x %02x %02x %02x %02x %02x %02x - %02x %02x %02x %02x\n",
186 (UINT_32
) pucStartAddr
, pucStartAddr
[0], pucStartAddr
[1],
187 pucStartAddr
[2], pucStartAddr
[3], pucStartAddr
[4],
188 pucStartAddr
[5], pucStartAddr
[6], pucStartAddr
[7],
189 pucStartAddr
[8], pucStartAddr
[9], pucStartAddr
[10],
194 ("(%08lx) %02x %02x %02x %02x %02x %02x %02x %02x - %02x %02x %02x %02x %02x\n",
195 (UINT_32
) pucStartAddr
, pucStartAddr
[0], pucStartAddr
[1],
196 pucStartAddr
[2], pucStartAddr
[3], pucStartAddr
[4],
197 pucStartAddr
[5], pucStartAddr
[6], pucStartAddr
[7],
198 pucStartAddr
[8], pucStartAddr
[9], pucStartAddr
[10],
199 pucStartAddr
[11], pucStartAddr
[12]);
203 ("(%08lx) %02x %02x %02x %02x %02x %02x %02x %02x - %02x %02x %02x %02x %02x %02x\n",
204 (UINT_32
) pucStartAddr
, pucStartAddr
[0], pucStartAddr
[1],
205 pucStartAddr
[2], pucStartAddr
[3], pucStartAddr
[4],
206 pucStartAddr
[5], pucStartAddr
[6], pucStartAddr
[7],
207 pucStartAddr
[8], pucStartAddr
[9], pucStartAddr
[10],
208 pucStartAddr
[11], pucStartAddr
[12], pucStartAddr
[13]);
212 ("(%08lx) %02x %02x %02x %02x %02x %02x %02x %02x - %02x %02x %02x %02x %02x %02x %02x\n",
213 (UINT_32
) pucStartAddr
, pucStartAddr
[0], pucStartAddr
[1],
214 pucStartAddr
[2], pucStartAddr
[3], pucStartAddr
[4],
215 pucStartAddr
[5], pucStartAddr
[6], pucStartAddr
[7],
216 pucStartAddr
[8], pucStartAddr
[9], pucStartAddr
[10],
217 pucStartAddr
[11], pucStartAddr
[12], pucStartAddr
[13],
230 } /* end of dumpMemory8() */
233 /*----------------------------------------------------------------------------*/
235 * \brief This routine is called to dump a segment of memory in double words.
237 * \param[in] pucStartAddr Pointer to the starting address of the memory to be dumped.
238 * \param[in] u4Length Length of the memory to be dumped.
242 /*----------------------------------------------------------------------------*/
243 VOID
dumpMemory32(IN PUINT_32 pu4StartAddr
, IN UINT_32 u4Length
)
248 ASSERT(pu4StartAddr
);
250 LOG_FUNC("DUMP32 ADDRESS: %08lx, Length: %ld\n", (UINT_32
) pu4StartAddr
, u4Length
);
252 if (IS_NOT_ALIGN_4((UINT_32
) pu4StartAddr
)) {
253 UINT_32 u4ProtrudeLen
= sizeof(UINT_32
) - ((UINT_32
) pu4StartAddr
% 4);
256 u4ProtrudeLen
= ((u4Length
< u4ProtrudeLen
) ? u4Length
: u4ProtrudeLen
);
257 LOG_FUNC("pu4StartAddr is not at DW boundary.\n");
258 pucAddr
= (PUINT_8
) &pu4StartAddr
[0];
260 switch (u4ProtrudeLen
) {
262 LOG_FUNC("(%08lx) %02x------\n", (UINT_32
) pu4StartAddr
, pucAddr
[0]);
265 LOG_FUNC("(%08lx) %02x%02x----\n",
266 (UINT_32
) pu4StartAddr
, pucAddr
[1], pucAddr
[0]);
269 LOG_FUNC("(%08lx) %02x%02x%02x--\n",
270 (UINT_32
) pu4StartAddr
, pucAddr
[2], pucAddr
[1], pucAddr
[0]);
276 u4Length
-= u4ProtrudeLen
;
277 pu4StartAddr
= (PUINT_32
) ((UINT_32
) pu4StartAddr
+ u4ProtrudeLen
);
280 while (u4Length
> 0) {
281 if (u4Length
>= 16) {
282 LOG_FUNC("(%08lx) %08lx %08lx %08lx %08lx\n",
283 (UINT_32
) pu4StartAddr
,
284 pu4StartAddr
[0], pu4StartAddr
[1], pu4StartAddr
[2],
291 pucAddr
= (PUINT_8
) &pu4StartAddr
[0];
292 LOG_FUNC("(%08lx) ------%02x\n",
293 (UINT_32
) pu4StartAddr
, pucAddr
[0]);
296 pucAddr
= (PUINT_8
) &pu4StartAddr
[0];
297 LOG_FUNC("(%08lx) ----%02x%02x\n",
298 (UINT_32
) pu4StartAddr
, pucAddr
[1], pucAddr
[0]);
301 pucAddr
= (PUINT_8
) &pu4StartAddr
[0];
302 LOG_FUNC("(%08lx) --%02x%02x%02x\n",
303 (UINT_32
) pu4StartAddr
,
304 pucAddr
[2], pucAddr
[1], pucAddr
[0]);
307 LOG_FUNC("(%08lx) %08lx\n",
308 (UINT_32
) pu4StartAddr
, pu4StartAddr
[0]);
311 pucAddr
= (PUINT_8
) &pu4StartAddr
[1];
312 LOG_FUNC("(%08lx) %08lx ------%02x\n",
313 (UINT_32
) pu4StartAddr
, pu4StartAddr
[0], pucAddr
[0]);
316 pucAddr
= (PUINT_8
) &pu4StartAddr
[1];
317 LOG_FUNC("(%08lx) %08lx ----%02x%02x\n",
318 (UINT_32
) pu4StartAddr
,
319 pu4StartAddr
[0], pucAddr
[1], pucAddr
[0]);
322 pucAddr
= (PUINT_8
) &pu4StartAddr
[1];
323 LOG_FUNC("(%08lx) %08lx --%02x%02x%02x\n",
324 (UINT_32
) pu4StartAddr
,
325 pu4StartAddr
[0], pucAddr
[2], pucAddr
[1], pucAddr
[0]);
328 LOG_FUNC("(%08lx) %08lx %08lx\n",
329 (UINT_32
) pu4StartAddr
, pu4StartAddr
[0], pu4StartAddr
[1]);
332 pucAddr
= (PUINT_8
) &pu4StartAddr
[2];
333 LOG_FUNC("(%08lx) %08lx %08lx ------%02x\n",
334 (UINT_32
) pu4StartAddr
,
335 pu4StartAddr
[0], pu4StartAddr
[1], pucAddr
[0]);
338 pucAddr
= (PUINT_8
) &pu4StartAddr
[2];
339 LOG_FUNC("(%08lx) %08lx %08lx ----%02x%02x\n",
340 (UINT_32
) pu4StartAddr
,
341 pu4StartAddr
[0], pu4StartAddr
[1], pucAddr
[1], pucAddr
[0]);
344 pucAddr
= (PUINT_8
) &pu4StartAddr
[2];
345 LOG_FUNC("(%08lx) %08lx %08lx --%02x%02x%02x\n",
346 (UINT_32
) pu4StartAddr
,
347 pu4StartAddr
[0], pu4StartAddr
[1],
348 pucAddr
[2], pucAddr
[1], pucAddr
[0]);
351 LOG_FUNC("(%08lx) %08lx %08lx %08lx\n",
352 (UINT_32
) pu4StartAddr
,
353 pu4StartAddr
[0], pu4StartAddr
[1], pu4StartAddr
[2]);
356 pucAddr
= (PUINT_8
) &pu4StartAddr
[3];
357 LOG_FUNC("(%08lx) %08lx %08lx %08lx ------%02x\n",
358 (UINT_32
) pu4StartAddr
,
359 pu4StartAddr
[0], pu4StartAddr
[1], pu4StartAddr
[2],
363 pucAddr
= (PUINT_8
) &pu4StartAddr
[3];
364 LOG_FUNC("(%08lx) %08lx %08lx %08lx ----%02x%02x\n",
365 (UINT_32
) pu4StartAddr
,
366 pu4StartAddr
[0], pu4StartAddr
[1], pu4StartAddr
[2],
367 pucAddr
[1], pucAddr
[0]);
370 pucAddr
= (PUINT_8
) &pu4StartAddr
[3];
371 LOG_FUNC("(%08lx) %08lx %08lx %08lx --%02x%02x%02x\n",
372 (UINT_32
) pu4StartAddr
,
373 pu4StartAddr
[0], pu4StartAddr
[1], pu4StartAddr
[2],
374 pucAddr
[2], pucAddr
[1], pucAddr
[0]);
384 } /* end of dumpMemory32() */
385 #elif CFG_SUPPORT_XLOG
387 /*----------------------------------------------------------------------------*/
389 * \brief This routine is called to dump a segment of memory in bytes.
391 * \param[in] pucStartAddr Pointer to the starting address of the memory to be dumped.
392 * \param[in] u4Length Length of the memory to be dumped.
396 /*----------------------------------------------------------------------------*/
397 VOID
dumpMemory8(IN UINT_32 log_level
, IN PUINT_8 pucStartAddr
, IN UINT_32 u4Length
)
399 ASSERT(pucStartAddr
);
401 if (log_level
== ANDROID_LOG_ERROR
) {
402 xlog_printk(ANDROID_LOG_ERROR
, XLOG_TAG
, "DUMP8 ADDRESS: %08lx, Length: %ld\n",
403 (UINT_32
) pucStartAddr
, u4Length
);
404 } else if (log_level
== ANDROID_LOG_WARN
) {
405 xlog_printk(ANDROID_LOG_WARN
, XLOG_TAG
, "DUMP8 ADDRESS: %08lx, Length: %ld\n",
406 (UINT_32
) pucStartAddr
, u4Length
);
407 } else if (log_level
== ANDROID_LOG_INFO
) {
408 xlog_printk(ANDROID_LOG_INFO
, XLOG_TAG
, "DUMP8 ADDRESS: %08lx, Length: %ld\n",
409 (UINT_32
) pucStartAddr
, u4Length
);
410 } else if (log_level
== ANDROID_LOG_DEBUG
) {
411 xlog_printk(ANDROID_LOG_DEBUG
, XLOG_TAG
, "DUMP8 ADDRESS: %08lx, Length: %ld\n",
412 (UINT_32
) pucStartAddr
, u4Length
);
413 } else if (log_level
== ANDROID_LOG_VERBOSE
) {
414 xlog_printk(ANDROID_LOG_VERBOSE
, XLOG_TAG
, "DUMP8 ADDRESS: %08lx, Length: %ld\n",
415 (UINT_32
) pucStartAddr
, u4Length
);
418 while (u4Length
> 0) {
419 if (u4Length
>= 16) {
421 "%02x %02x %02x %02x %02x %02x %02x %02x - %02x %02x %02x %02x %02x %02x %02x %02x\n",
422 pucStartAddr
[0], pucStartAddr
[1], pucStartAddr
[2],
423 pucStartAddr
[3], pucStartAddr
[4], pucStartAddr
[5],
424 pucStartAddr
[6], pucStartAddr
[7], pucStartAddr
[8],
425 pucStartAddr
[9], pucStartAddr
[10], pucStartAddr
[11],
426 pucStartAddr
[12], pucStartAddr
[13], pucStartAddr
[14],
433 XLOG_FUNC(log_level
, "%02x\n", pucStartAddr
[0]);
436 XLOG_FUNC(log_level
, "%02x %02x\n",
437 pucStartAddr
[0], pucStartAddr
[1]);
440 XLOG_FUNC(log_level
, "%02x %02x %02x\n",
441 pucStartAddr
[0], pucStartAddr
[1], pucStartAddr
[2]);
444 XLOG_FUNC(log_level
, "%02x %02x %02x %02x\n",
445 pucStartAddr
[0], pucStartAddr
[1], pucStartAddr
[2],
449 XLOG_FUNC(log_level
, "%02x %02x %02x %02x %02x\n",
450 pucStartAddr
[0], pucStartAddr
[1], pucStartAddr
[2],
451 pucStartAddr
[3], pucStartAddr
[4]);
454 XLOG_FUNC(log_level
, "%02x %02x %02x %02x %02x %02x\n",
455 pucStartAddr
[0], pucStartAddr
[1], pucStartAddr
[2],
456 pucStartAddr
[3], pucStartAddr
[4], pucStartAddr
[5]);
459 XLOG_FUNC(log_level
, "%02x %02x %02x %02x %02x %02x %02x\n",
460 pucStartAddr
[0], pucStartAddr
[1], pucStartAddr
[2],
461 pucStartAddr
[3], pucStartAddr
[4], pucStartAddr
[5],
465 XLOG_FUNC(log_level
, "%02x %02x %02x %02x %02x %02x %02x %02x\n",
466 pucStartAddr
[0], pucStartAddr
[1], pucStartAddr
[2],
467 pucStartAddr
[3], pucStartAddr
[4], pucStartAddr
[5],
468 pucStartAddr
[6], pucStartAddr
[7]);
472 "%02x %02x %02x %02x %02x %02x %02x %02x - %02x\n",
473 pucStartAddr
[0], pucStartAddr
[1], pucStartAddr
[2],
474 pucStartAddr
[3], pucStartAddr
[4], pucStartAddr
[5],
475 pucStartAddr
[6], pucStartAddr
[7], pucStartAddr
[8]);
479 "%02x %02x %02x %02x %02x %02x %02x %02x - %02x %02x\n",
480 pucStartAddr
[0], pucStartAddr
[1], pucStartAddr
[2],
481 pucStartAddr
[3], pucStartAddr
[4], pucStartAddr
[5],
482 pucStartAddr
[6], pucStartAddr
[7], pucStartAddr
[8],
487 "%02x %02x %02x %02x %02x %02x %02x %02x - %02x %02x %02x\n",
488 pucStartAddr
[0], pucStartAddr
[1], pucStartAddr
[2],
489 pucStartAddr
[3], pucStartAddr
[4], pucStartAddr
[5],
490 pucStartAddr
[6], pucStartAddr
[7], pucStartAddr
[8],
491 pucStartAddr
[9], pucStartAddr
[10]);
495 "%02x %02x %02x %02x %02x %02x %02x %02x - %02x %02x %02x %02x\n",
496 pucStartAddr
[0], pucStartAddr
[1], pucStartAddr
[2],
497 pucStartAddr
[3], pucStartAddr
[4], pucStartAddr
[5],
498 pucStartAddr
[6], pucStartAddr
[7], pucStartAddr
[8],
499 pucStartAddr
[9], pucStartAddr
[10], pucStartAddr
[11]);
503 "%02x %02x %02x %02x %02x %02x %02x %02x - %02x %02x %02x %02x %02x\n",
504 pucStartAddr
[0], pucStartAddr
[1], pucStartAddr
[2],
505 pucStartAddr
[3], pucStartAddr
[4], pucStartAddr
[5],
506 pucStartAddr
[6], pucStartAddr
[7], pucStartAddr
[8],
507 pucStartAddr
[9], pucStartAddr
[10], pucStartAddr
[11],
512 "%02x %02x %02x %02x %02x %02x %02x %02x - %02x %02x %02x %02x %02x %02x\n",
513 pucStartAddr
[0], pucStartAddr
[1], pucStartAddr
[2],
514 pucStartAddr
[3], pucStartAddr
[4], pucStartAddr
[5],
515 pucStartAddr
[6], pucStartAddr
[7], pucStartAddr
[8],
516 pucStartAddr
[9], pucStartAddr
[10], pucStartAddr
[11],
517 pucStartAddr
[12], pucStartAddr
[13]);
521 "%02x %02x %02x %02x %02x %02x %02x %02x - %02x %02x %02x %02x %02x %02x %02x\n",
522 pucStartAddr
[0], pucStartAddr
[1], pucStartAddr
[2],
523 pucStartAddr
[3], pucStartAddr
[4], pucStartAddr
[5],
524 pucStartAddr
[6], pucStartAddr
[7], pucStartAddr
[8],
525 pucStartAddr
[9], pucStartAddr
[10], pucStartAddr
[11],
526 pucStartAddr
[12], pucStartAddr
[13], pucStartAddr
[14]);
537 } /* end of dumpMemory8() */