2 * Copyright 2013 Google Inc.
4 * See file CREDITS for list of people who contributed to this
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of
10 * the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but without any warranty; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
22 #include <console/console.h>
25 static int isprint(int c
)
27 return (c
>= 32 && c
<= 126);
30 void hexdump(const void *memory
, size_t length
)
36 m
= (uint8_t *) memory
;
38 for (i
= 0; i
< length
; i
+= 16) {
42 for (j
= 0; j
< 16; j
++) {
50 printk(BIOS_DEBUG
, "%p:", memory
+ i
);
51 for (j
= 0; j
< 16; j
++)
52 printk(BIOS_DEBUG
, " %02x", m
[i
+ j
]);
53 printk(BIOS_DEBUG
, " ");
54 for (j
= 0; j
< 16; j
++)
55 printk(BIOS_DEBUG
, "%c",
56 isprint(m
[i
+ j
]) ? m
[i
+ j
] : '.');
57 printk(BIOS_DEBUG
, "\n");
58 } else if (all_zero
== 2) {
59 printk(BIOS_DEBUG
, "...\n");
64 void hexdump32(char LEVEL
, const void *d
, size_t len
)
71 printk(LEVEL
, "%p:", d
);
73 printk(LEVEL
, " 0x%08lx", *(unsigned long *)d
);
79 printk(LEVEL
, "\n\n");