hexdump: Add support for sandbox
The current implementation outputs an address as a pointer. Update the
code to use an address instead, respecting the 32/64 nature of the CPU.
Add some initial tests copied from print_test_display_buffer(), just the
ones that can pass with the current implementation.
Note that for this case print_hex_dump() and print_bufffer() produce the
same result. For now the tests are duplicated sine we have separate
functions.
Signed-off-by: Simon Glass <sjg@chromium.org>
diff --git a/lib/hexdump.c b/lib/hexdump.c
index e31784c..a76ea70 100644
--- a/lib/hexdump.c
+++ b/lib/hexdump.c
@@ -10,6 +10,7 @@
#include <common.h>
#include <hexdump.h>
+#include <mapmem.h>
#include <linux/ctype.h>
#include <linux/compat.h>
#include <linux/log2.h>
@@ -139,7 +140,9 @@
switch (prefix_type) {
case DUMP_PREFIX_ADDRESS:
- printf("%s%p: %s\n", prefix_str, ptr + i, linebuf);
+ printf("%s%0*lx: %s\n", prefix_str,
+ IS_ENABLED(CONFIG_PHYS_64BIT) ? 16 : 8,
+ (ulong)map_to_sysmem(ptr) + i, linebuf);
break;
case DUMP_PREFIX_OFFSET:
printf("%s%.8x: %s\n", prefix_str, i, linebuf);