• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  * Copyright (c) 2004, 2008 IBM Corporation
3  * Copyright (c) 2008, 2009 Pattrick Hueper <phueper@hueper.net>
4  *
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are
9  * met:
10  *
11  * Redistributions of source code must retain the above copyright
12  *   notice, this list of conditions and the following disclaimer.
13  *
14  * Redistributions in binary form must reproduce the above copyright
15  *   notice, this list of conditions and the following disclaimer
16  *   in the documentation and/or other materials provided with the
17  *   distribution.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  *
31  * Contributors:
32  *     IBM Corporation - initial implementation
33  *****************************************************************************/
34 
35 #include "debug.h"
36 
37 u32 debug_flags = 0;
38 
39 void
dump(u8 * addr,u32 len)40 dump(u8 *addr, u32 len)
41 {
42 	printf("\n%s(%p, %x):\n", __func__, addr, len);
43 	while (len) {
44 		unsigned int tmpCnt = len;
45 		unsigned char x;
46 		if (tmpCnt > 8)
47 			tmpCnt = 8;
48 		printf("\n%p: ", addr);
49 		// print hex
50 		while (tmpCnt--) {
51 			set_ci();
52 			x = *addr++;
53 			clr_ci();
54 			printf("%02x ", x);
55 		}
56 		tmpCnt = len;
57 		if (tmpCnt > 8)
58 			tmpCnt = 8;
59 		len -= tmpCnt;
60 		//reset addr ptr to print ascii
61 		addr = addr - tmpCnt;
62 		// print ascii
63 		while (tmpCnt--) {
64 			set_ci();
65 			x = *addr++;
66 			clr_ci();
67 			if ((x < 32) || (x >= 127)) {
68 				//non-printable char
69 				x = '.';
70 			}
71 			printf("%c", x);
72 		}
73 	}
74 	printf("\n");
75 }
76