1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 #include <console/console.h>
7 void hexdump(const void *memory
, size_t length
)
15 for (i
= 0; i
< length
; i
+= 16) {
16 num_bytes
= MIN(length
- i
, 16);
17 line
= ((uint8_t *)memory
) + i
;
21 for (j
= 0; j
< num_bytes
; j
++) {
28 for (j
= 0; j
< num_bytes
; j
++) {
29 if (line
[j
] != 0xff) {
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
]);
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");
52 void hexdump32(char LEVEL
, const void *d
, size_t len
)
59 printk(LEVEL
, "%p:", d
);
61 printk(LEVEL
, " 0x%08lx", *(unsigned long *)d
);
67 printk(LEVEL
, "\n\n");