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 /*----------------------------------------------------------------------------*/
98 IN PUINT_8 pucStartAddr,
102 ASSERT(pucStartAddr);
104 LOG_FUNC("DUMP8 ADDRESS: %08lx, Length: %ld\n", (UINT_32)pucStartAddr, u4Length);
106 while (u4Length > 0) {
107 if (u4Length >= 16) {
108 LOG_FUNC("(%08lx) %02x %02x %02x %02x %02x %02x %02x %02x - %02x %02x %02x %02x %02x %02x %02x %02x\n",
109 (UINT_32)pucStartAddr,
110 pucStartAddr[ 0], pucStartAddr[ 1], pucStartAddr[ 2], pucStartAddr[ 3],
111 pucStartAddr[ 4], pucStartAddr[ 5], pucStartAddr[ 6], pucStartAddr[ 7],
112 pucStartAddr[ 8], pucStartAddr[ 9], pucStartAddr[10], pucStartAddr[11],
113 pucStartAddr[12], pucStartAddr[13], pucStartAddr[14], pucStartAddr[15]);
120 LOG_FUNC("(%08lx) %02x\n",
121 (UINT_32)pucStartAddr,
125 LOG_FUNC("(%08lx) %02x %02x\n",
126 (UINT_32)pucStartAddr,
127 pucStartAddr[ 0], pucStartAddr[ 1]);
130 LOG_FUNC("(%08lx) %02x %02x %02x\n",
131 (UINT_32)pucStartAddr,
132 pucStartAddr[ 0], pucStartAddr[ 1], pucStartAddr[ 2]);
135 LOG_FUNC("(%08lx) %02x %02x %02x %02x\n",
136 (UINT_32)pucStartAddr,
137 pucStartAddr[ 0], pucStartAddr[ 1], pucStartAddr[ 2], pucStartAddr[ 3]);
140 LOG_FUNC("(%08lx) %02x %02x %02x %02x %02x\n",
141 (UINT_32)pucStartAddr,
142 pucStartAddr[ 0], pucStartAddr[ 1], pucStartAddr[ 2], pucStartAddr[ 3],
146 LOG_FUNC("(%08lx) %02x %02x %02x %02x %02x %02x\n",
147 (UINT_32)pucStartAddr,
148 pucStartAddr[ 0], pucStartAddr[ 1], pucStartAddr[ 2], pucStartAddr[ 3],
149 pucStartAddr[ 4], pucStartAddr[ 5]);
152 LOG_FUNC("(%08lx) %02x %02x %02x %02x %02x %02x %02x\n",
153 (UINT_32)pucStartAddr,
154 pucStartAddr[ 0], pucStartAddr[ 1], pucStartAddr[ 2], pucStartAddr[ 3],
155 pucStartAddr[ 4], pucStartAddr[ 5], pucStartAddr[ 6]);
158 LOG_FUNC("(%08lx) %02x %02x %02x %02x %02x %02x %02x %02x\n",
159 (UINT_32)pucStartAddr,
160 pucStartAddr[ 0], pucStartAddr[ 1], pucStartAddr[ 2], pucStartAddr[ 3],
161 pucStartAddr[ 4], pucStartAddr[ 5], pucStartAddr[ 6], pucStartAddr[ 7]);
164 LOG_FUNC("(%08lx) %02x %02x %02x %02x %02x %02x %02x %02x - %02x\n",
165 (UINT_32)pucStartAddr,
166 pucStartAddr[ 0], pucStartAddr[ 1], pucStartAddr[ 2], pucStartAddr[ 3],
167 pucStartAddr[ 4], pucStartAddr[ 5], pucStartAddr[ 6], pucStartAddr[ 7],
171 LOG_FUNC("(%08lx) %02x %02x %02x %02x %02x %02x %02x %02x - %02x %02x\n",
172 (UINT_32)pucStartAddr,
173 pucStartAddr[ 0], pucStartAddr[ 1], pucStartAddr[ 2], pucStartAddr[ 3],
174 pucStartAddr[ 4], pucStartAddr[ 5], pucStartAddr[ 6], pucStartAddr[ 7],
175 pucStartAddr[ 8], pucStartAddr[ 9]);
178 LOG_FUNC("(%08lx) %02x %02x %02x %02x %02x %02x %02x %02x - %02x %02x %02x\n",
179 (UINT_32)pucStartAddr,
180 pucStartAddr[ 0], pucStartAddr[ 1], pucStartAddr[ 2], pucStartAddr[ 3],
181 pucStartAddr[ 4], pucStartAddr[ 5], pucStartAddr[ 6], pucStartAddr[ 7],
182 pucStartAddr[ 8], pucStartAddr[ 9], pucStartAddr[10]);
185 LOG_FUNC("(%08lx) %02x %02x %02x %02x %02x %02x %02x %02x - %02x %02x %02x %02x\n",
186 (UINT_32)pucStartAddr,
187 pucStartAddr[ 0], pucStartAddr[ 1], pucStartAddr[ 2], pucStartAddr[ 3],
188 pucStartAddr[ 4], pucStartAddr[ 5], pucStartAddr[ 6], pucStartAddr[ 7],
189 pucStartAddr[ 8], pucStartAddr[ 9], pucStartAddr[10], pucStartAddr[11]);
192 LOG_FUNC("(%08lx) %02x %02x %02x %02x %02x %02x %02x %02x - %02x %02x %02x %02x %02x\n",
193 (UINT_32)pucStartAddr,
194 pucStartAddr[ 0], pucStartAddr[ 1], pucStartAddr[ 2], pucStartAddr[ 3],
195 pucStartAddr[ 4], pucStartAddr[ 5], pucStartAddr[ 6], pucStartAddr[ 7],
196 pucStartAddr[ 8], pucStartAddr[ 9], pucStartAddr[10], pucStartAddr[11],
200 LOG_FUNC("(%08lx) %02x %02x %02x %02x %02x %02x %02x %02x - %02x %02x %02x %02x %02x %02x\n",
201 (UINT_32)pucStartAddr,
202 pucStartAddr[ 0], pucStartAddr[ 1], pucStartAddr[ 2], pucStartAddr[ 3],
203 pucStartAddr[ 4], pucStartAddr[ 5], pucStartAddr[ 6], pucStartAddr[ 7],
204 pucStartAddr[ 8], pucStartAddr[ 9], pucStartAddr[10], pucStartAddr[11],
205 pucStartAddr[12], pucStartAddr[13]);
208 LOG_FUNC("(%08lx) %02x %02x %02x %02x %02x %02x %02x %02x - %02x %02x %02x %02x %02x %02x %02x\n",
209 (UINT_32)pucStartAddr,
210 pucStartAddr[ 0], pucStartAddr[ 1], pucStartAddr[ 2], pucStartAddr[ 3],
211 pucStartAddr[ 4], pucStartAddr[ 5], pucStartAddr[ 6], pucStartAddr[ 7],
212 pucStartAddr[ 8], pucStartAddr[ 9], pucStartAddr[10], pucStartAddr[11],
213 pucStartAddr[12], pucStartAddr[13], pucStartAddr[14]);
225 } /* end of dumpMemory8() */
228 /*----------------------------------------------------------------------------*/
230 * \brief This routine is called to dump a segment of memory in double words.
232 * \param[in] pucStartAddr Pointer to the starting address of the memory to be dumped.
233 * \param[in] u4Length Length of the memory to be dumped.
237 /*----------------------------------------------------------------------------*/
240 IN PUINT_32 pu4StartAddr,
246 ASSERT(pu4StartAddr);
248 LOG_FUNC("DUMP32 ADDRESS: %08lx, Length: %ld\n", (UINT_32)pu4StartAddr, u4Length);
250 if (IS_NOT_ALIGN_4((UINT_32)pu4StartAddr)) {
251 UINT_32 u4ProtrudeLen = sizeof(UINT_32) - ((UINT_32)pu4StartAddr % 4);
254 u4ProtrudeLen = ((u4Length < u4ProtrudeLen) ? u4Length: u4ProtrudeLen);
255 LOG_FUNC("pu4StartAddr is not at DW boundary.\n");
256 pucAddr = (PUINT_8) &pu4StartAddr[0];
258 switch (u4ProtrudeLen) {
260 LOG_FUNC("(%08lx) %02x------\n",
261 (UINT_32)pu4StartAddr,
265 LOG_FUNC("(%08lx) %02x%02x----\n",
266 (UINT_32)pu4StartAddr,
267 pucAddr[1], pucAddr[0]);
270 LOG_FUNC("(%08lx) %02x%02x%02x--\n",
271 (UINT_32)pu4StartAddr,
272 pucAddr[2], pucAddr[1], pucAddr[0]);
278 u4Length -= u4ProtrudeLen;
279 pu4StartAddr = (PUINT_32)((UINT_32)pu4StartAddr + u4ProtrudeLen);
282 while (u4Length > 0) {
283 if (u4Length >= 16) {
284 LOG_FUNC("(%08lx) %08lx %08lx %08lx %08lx\n",
285 (UINT_32)pu4StartAddr,
286 pu4StartAddr[0], pu4StartAddr[1], pu4StartAddr[2], pu4StartAddr[3]);
293 pucAddr = (PUINT_8) &pu4StartAddr[0];
294 LOG_FUNC("(%08lx) ------%02x\n",
295 (UINT_32)pu4StartAddr,
299 pucAddr = (PUINT_8) &pu4StartAddr[0];
300 LOG_FUNC("(%08lx) ----%02x%02x\n",
301 (UINT_32)pu4StartAddr,
302 pucAddr[1], pucAddr[0]);
305 pucAddr = (PUINT_8) &pu4StartAddr[0];
306 LOG_FUNC("(%08lx) --%02x%02x%02x\n",
307 (UINT_32)pu4StartAddr,
308 pucAddr[2], pucAddr[1], pucAddr[0]);
311 LOG_FUNC("(%08lx) %08lx\n",
312 (UINT_32)pu4StartAddr,
316 pucAddr = (PUINT_8) &pu4StartAddr[1];
317 LOG_FUNC("(%08lx) %08lx ------%02x\n",
318 (UINT_32)pu4StartAddr,
323 pucAddr = (PUINT_8) &pu4StartAddr[1];
324 LOG_FUNC("(%08lx) %08lx ----%02x%02x\n",
325 (UINT_32)pu4StartAddr,
327 pucAddr[1], pucAddr[0]);
330 pucAddr = (PUINT_8) &pu4StartAddr[1];
331 LOG_FUNC("(%08lx) %08lx --%02x%02x%02x\n",
332 (UINT_32)pu4StartAddr,
334 pucAddr[2], pucAddr[1], pucAddr[0]);
337 LOG_FUNC("(%08lx) %08lx %08lx\n",
338 (UINT_32)pu4StartAddr,
339 pu4StartAddr[0], pu4StartAddr[1]);
342 pucAddr = (PUINT_8) &pu4StartAddr[2];
343 LOG_FUNC("(%08lx) %08lx %08lx ------%02x\n",
344 (UINT_32)pu4StartAddr,
345 pu4StartAddr[0], pu4StartAddr[1],
349 pucAddr = (PUINT_8) &pu4StartAddr[2];
350 LOG_FUNC("(%08lx) %08lx %08lx ----%02x%02x\n",
351 (UINT_32)pu4StartAddr,
352 pu4StartAddr[0], pu4StartAddr[1],
353 pucAddr[1], pucAddr[0]);
356 pucAddr = (PUINT_8) &pu4StartAddr[2];
357 LOG_FUNC("(%08lx) %08lx %08lx --%02x%02x%02x\n",
358 (UINT_32)pu4StartAddr,
359 pu4StartAddr[0], pu4StartAddr[1],
360 pucAddr[2], pucAddr[1], pucAddr[0]);
363 LOG_FUNC("(%08lx) %08lx %08lx %08lx\n",
364 (UINT_32)pu4StartAddr,
365 pu4StartAddr[0], pu4StartAddr[1], pu4StartAddr[2]);
368 pucAddr = (PUINT_8) &pu4StartAddr[3];
369 LOG_FUNC("(%08lx) %08lx %08lx %08lx ------%02x\n",
370 (UINT_32)pu4StartAddr,
371 pu4StartAddr[0], pu4StartAddr[1], pu4StartAddr[2],
375 pucAddr = (PUINT_8) &pu4StartAddr[3];
376 LOG_FUNC("(%08lx) %08lx %08lx %08lx ----%02x%02x\n",
377 (UINT_32)pu4StartAddr,
378 pu4StartAddr[0], pu4StartAddr[1], pu4StartAddr[2],
379 pucAddr[1], pucAddr[0]);
382 pucAddr = (PUINT_8) &pu4StartAddr[3];
383 LOG_FUNC("(%08lx) %08lx %08lx %08lx --%02x%02x%02x\n",
384 (UINT_32)pu4StartAddr,
385 pu4StartAddr[0], pu4StartAddr[1], pu4StartAddr[2],
386 pucAddr[2], pucAddr[1], pucAddr[0]);
396 } /* end of dumpMemory32() */
397 #elif CFG_SUPPORT_XLOG
399 /*----------------------------------------------------------------------------*/
401 * \brief This routine is called to dump a segment of memory in bytes.
403 * \param[in] pucStartAddr Pointer to the starting address of the memory to be dumped.
404 * \param[in] u4Length Length of the memory to be dumped.
408 /*----------------------------------------------------------------------------*/
411 IN UINT_32 log_level,
412 IN PUINT_8 pucStartAddr,
416 ASSERT(pucStartAddr);
418 if (log_level == ANDROID_LOG_ERROR) {
419 xlog_printk(ANDROID_LOG_ERROR, XLOG_TAG, "DUMP8 ADDRESS: %08lx, Length: %ld\n", (UINT_32)pucStartAddr, u4Length);
421 else if (log_level == ANDROID_LOG_WARN) {
422 xlog_printk(ANDROID_LOG_WARN, XLOG_TAG, "DUMP8 ADDRESS: %08lx, Length: %ld\n", (UINT_32)pucStartAddr, u4Length);
424 else if (log_level == ANDROID_LOG_INFO) {
425 xlog_printk(ANDROID_LOG_INFO, XLOG_TAG, "DUMP8 ADDRESS: %08lx, Length: %ld\n", (UINT_32)pucStartAddr, u4Length);
427 else if (log_level == ANDROID_LOG_DEBUG) {
428 xlog_printk(ANDROID_LOG_DEBUG, XLOG_TAG, "DUMP8 ADDRESS: %08lx, Length: %ld\n", (UINT_32)pucStartAddr, u4Length);
430 else if (log_level == ANDROID_LOG_VERBOSE) {
431 xlog_printk(ANDROID_LOG_VERBOSE, XLOG_TAG, "DUMP8 ADDRESS: %08lx, Length: %ld\n", (UINT_32)pucStartAddr, u4Length);
434 while (u4Length > 0) {
435 if (u4Length >= 16) {
436 XLOG_FUNC(log_level, "%02x %02x %02x %02x %02x %02x %02x %02x - %02x %02x %02x %02x %02x %02x %02x %02x\n",
437 pucStartAddr[ 0], pucStartAddr[ 1], pucStartAddr[ 2], pucStartAddr[ 3],
438 pucStartAddr[ 4], pucStartAddr[ 5], pucStartAddr[ 6], pucStartAddr[ 7],
439 pucStartAddr[ 8], pucStartAddr[ 9], pucStartAddr[10], pucStartAddr[11],
440 pucStartAddr[12], pucStartAddr[13], pucStartAddr[14], pucStartAddr[15]);
447 XLOG_FUNC(log_level, "%02x\n",
451 XLOG_FUNC(log_level, "%02x %02x\n",
452 pucStartAddr[ 0], pucStartAddr[ 1]);
455 XLOG_FUNC(log_level, "%02x %02x %02x\n",
456 pucStartAddr[ 0], pucStartAddr[ 1], pucStartAddr[ 2]);
459 XLOG_FUNC(log_level, "%02x %02x %02x %02x\n",
460 pucStartAddr[ 0], pucStartAddr[ 1], pucStartAddr[ 2], pucStartAddr[ 3]);
463 XLOG_FUNC(log_level, "%02x %02x %02x %02x %02x\n",
464 pucStartAddr[ 0], pucStartAddr[ 1], pucStartAddr[ 2], pucStartAddr[ 3],
468 XLOG_FUNC(log_level, "%02x %02x %02x %02x %02x %02x\n",
469 pucStartAddr[ 0], pucStartAddr[ 1], pucStartAddr[ 2], pucStartAddr[ 3],
470 pucStartAddr[ 4], pucStartAddr[ 5]);
473 XLOG_FUNC(log_level, "%02x %02x %02x %02x %02x %02x %02x\n",
474 pucStartAddr[ 0], pucStartAddr[ 1], pucStartAddr[ 2], pucStartAddr[ 3],
475 pucStartAddr[ 4], pucStartAddr[ 5], pucStartAddr[ 6]);
478 XLOG_FUNC(log_level, "%02x %02x %02x %02x %02x %02x %02x %02x\n",
479 pucStartAddr[ 0], pucStartAddr[ 1], pucStartAddr[ 2], pucStartAddr[ 3],
480 pucStartAddr[ 4], pucStartAddr[ 5], pucStartAddr[ 6], pucStartAddr[ 7]);
483 XLOG_FUNC(log_level, "%02x %02x %02x %02x %02x %02x %02x %02x - %02x\n",
484 pucStartAddr[ 0], pucStartAddr[ 1], pucStartAddr[ 2], pucStartAddr[ 3],
485 pucStartAddr[ 4], pucStartAddr[ 5], pucStartAddr[ 6], pucStartAddr[ 7],
489 XLOG_FUNC(log_level, "%02x %02x %02x %02x %02x %02x %02x %02x - %02x %02x\n",
490 pucStartAddr[ 0], pucStartAddr[ 1], pucStartAddr[ 2], pucStartAddr[ 3],
491 pucStartAddr[ 4], pucStartAddr[ 5], pucStartAddr[ 6], pucStartAddr[ 7],
492 pucStartAddr[ 8], pucStartAddr[ 9]);
495 XLOG_FUNC(log_level, "%02x %02x %02x %02x %02x %02x %02x %02x - %02x %02x %02x\n",
496 pucStartAddr[ 0], pucStartAddr[ 1], pucStartAddr[ 2], pucStartAddr[ 3],
497 pucStartAddr[ 4], pucStartAddr[ 5], pucStartAddr[ 6], pucStartAddr[ 7],
498 pucStartAddr[ 8], pucStartAddr[ 9], pucStartAddr[10]);
501 XLOG_FUNC(log_level, "%02x %02x %02x %02x %02x %02x %02x %02x - %02x %02x %02x %02x\n",
502 pucStartAddr[ 0], pucStartAddr[ 1], pucStartAddr[ 2], pucStartAddr[ 3],
503 pucStartAddr[ 4], pucStartAddr[ 5], pucStartAddr[ 6], pucStartAddr[ 7],
504 pucStartAddr[ 8], pucStartAddr[ 9], pucStartAddr[10], pucStartAddr[11]);
507 XLOG_FUNC(log_level, "%02x %02x %02x %02x %02x %02x %02x %02x - %02x %02x %02x %02x %02x\n",
508 pucStartAddr[ 0], pucStartAddr[ 1], pucStartAddr[ 2], pucStartAddr[ 3],
509 pucStartAddr[ 4], pucStartAddr[ 5], pucStartAddr[ 6], pucStartAddr[ 7],
510 pucStartAddr[ 8], pucStartAddr[ 9], pucStartAddr[10], pucStartAddr[11],
514 XLOG_FUNC(log_level, "%02x %02x %02x %02x %02x %02x %02x %02x - %02x %02x %02x %02x %02x %02x\n",
515 pucStartAddr[ 0], pucStartAddr[ 1], pucStartAddr[ 2], pucStartAddr[ 3],
516 pucStartAddr[ 4], pucStartAddr[ 5], pucStartAddr[ 6], pucStartAddr[ 7],
517 pucStartAddr[ 8], pucStartAddr[ 9], pucStartAddr[10], pucStartAddr[11],
518 pucStartAddr[12], pucStartAddr[13]);
521 XLOG_FUNC(log_level, "%02x %02x %02x %02x %02x %02x %02x %02x - %02x %02x %02x %02x %02x %02x %02x\n",
522 pucStartAddr[ 0], pucStartAddr[ 1], pucStartAddr[ 2], pucStartAddr[ 3],
523 pucStartAddr[ 4], pucStartAddr[ 5], pucStartAddr[ 6], pucStartAddr[ 7],
524 pucStartAddr[ 8], pucStartAddr[ 9], pucStartAddr[10], pucStartAddr[11],
525 pucStartAddr[12], pucStartAddr[13], pucStartAddr[14]);
536 } /* end of dumpMemory8() */