blob: 7cda8af0b1d7a80c7000bdc1224bf3b0db7fdcf9 [file] [log] [blame]
Stefan Reinauer38cd29e2009-08-11 21:28:25 +00001/******************************************************************************
2 * Copyright (c) 2004, 2008 IBM Corporation
3 * Copyright (c) 2008, 2009 Pattrick Hueper <phueper@hueper.net>
4 * All rights reserved.
5 * This program and the accompanying materials
6 * are made available under the terms of the BSD License
7 * which accompanies this distribution, and is available at
8 * http://www.opensource.org/licenses/bsd-license.php
9 *
10 * Contributors:
11 * IBM Corporation - initial implementation
12 *****************************************************************************/
13
Stefan Reinauer38cd29e2009-08-11 21:28:25 +000014#include "debug.h"
15
16u32 debug_flags = 0;
17
18void
19dump(u8 * addr, u32 len)
20{
21 printf("\n%s(%p, %x):\n", __func__, addr, len);
22 while (len) {
23 unsigned int tmpCnt = len;
24 unsigned char x;
25 if (tmpCnt > 8)
26 tmpCnt = 8;
27 printf("\n%p: ", addr);
28 // print hex
29 while (tmpCnt--) {
30 set_ci();
31 x = *addr++;
32 clr_ci();
33 printf("%02x ", x);
34 }
35 tmpCnt = len;
36 if (tmpCnt > 8)
37 tmpCnt = 8;
38 len -= tmpCnt;
39 //reset addr ptr to print ascii
40 addr = addr - tmpCnt;
41 // print ascii
42 while (tmpCnt--) {
43 set_ci();
44 x = *addr++;
45 clr_ci();
46 if ((x < 32) || (x >= 127)) {
47 //non-printable char
48 x = '.';
49 }
50 printf("%c", x);
51 }
52 }
53 printf("\n");
54}