Stefan Reinauer | 38cd29e | 2009-08-11 21:28:25 +0000 | [diff] [blame] | 1 | /****************************************************************************** |
| 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 Reinauer | 38cd29e | 2009-08-11 21:28:25 +0000 | [diff] [blame] | 14 | #include "debug.h" |
| 15 | |
| 16 | u32 debug_flags = 0; |
| 17 | |
| 18 | void |
| 19 | dump(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 | } |