mb/hardkernel/odroid-h4: Correct number of jacks in hda_verb.c
[coreboot.git] / src / lib / hexdump.c
blob533411f6f697b9c34caccf9c58b80448e3bc18e5
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 #include <console/console.h>
4 #include <ctype.h>
5 #include <lib.h>
7 void hexdump(const void *memory, size_t length)
9 size_t i, j;
10 uint8_t *line;
11 int all_zero = 0;
12 int all_one = 0;
13 size_t num_bytes;
15 for (i = 0; i < length; i += 16) {
16 num_bytes = MIN(length - i, 16);
17 line = ((uint8_t *)memory) + i;
19 all_zero++;
20 all_one++;
21 for (j = 0; j < num_bytes; j++) {
22 if (line[j] != 0) {
23 all_zero = 0;
24 break;
28 for (j = 0; j < num_bytes; j++) {
29 if (line[j] != 0xff) {
30 all_one = 0;
31 break;
35 if ((all_zero < 2) && (all_one < 2)) {
36 printk(BIOS_DEBUG, "%p:", memory + i);
37 for (j = 0; j < num_bytes; j++)
38 printk(BIOS_DEBUG, " %02x", line[j]);
39 for (; j < 16; j++)
40 printk(BIOS_DEBUG, " ");
41 printk(BIOS_DEBUG, " ");
42 for (j = 0; j < num_bytes; j++)
43 printk(BIOS_DEBUG, "%c",
44 isprint(line[j]) ? line[j] : '.');
45 printk(BIOS_DEBUG, "\n");
46 } else if ((all_zero == 2) || (all_one == 2)) {
47 printk(BIOS_DEBUG, "...\n");