#include <linux/log2.h>
#include <asm/unaligned.h>
+#define MAX_LINE_LENGTH_BYTES 64
+
const char hex_asc[] = "0123456789abcdef";
const char hex_asc_upper[] = "0123456789ABCDEF";
int ascii_column;
int ret;
- if (rowsize != 16 && rowsize != 32)
+ if (!rowsize)
rowsize = 16;
+ else
+ rowsize = min(rowsize, MAX_LINE_LENGTH_BYTES);
if (len > rowsize) /* limit to one line at a time */
len = rowsize;
return ascii ? ascii_column + len : (groupsize * 2 + 1) * ngroups - 1;
}
-void print_hex_dump(const char *prefix_str, int prefix_type, int rowsize,
- int groupsize, const void *buf, size_t len, bool ascii)
+int print_hex_dump(const char *prefix_str, int prefix_type, int rowsize,
+ int groupsize, const void *buf, size_t len, bool ascii)
{
const u8 *ptr = buf;
int i, linelen, remaining = len;
- char linebuf[32 * 3 + 2 + 32 + 1];
+ char linebuf[MAX_LINE_LENGTH_BYTES * 3 + 2 + MAX_LINE_LENGTH_BYTES + 1];
- if (rowsize != 16 && rowsize != 32)
+ if (!rowsize)
rowsize = 16;
+ else
+ rowsize = min(rowsize, MAX_LINE_LENGTH_BYTES);
for (i = 0; i < len; i += rowsize) {
linelen = min(remaining, rowsize);
printf("%s%s\n", prefix_str, linebuf);
break;
}
+ if (!IS_ENABLED(CONFIG_SPL_BUILD) && ctrlc())
+ return -EINTR;
}
+
+ return 0;
}
void print_hex_dump_bytes(const char *prefix_str, int prefix_type,
* Some code in U-Boot copy-pasted from Linux kernel uses both
* functions below so to keep stuff compilable we keep these stubs here.
*/
-void print_hex_dump(const char *prefix_str, int prefix_type, int rowsize,
- int groupsize, const void *buf, size_t len, bool ascii)
+int print_hex_dump(const char *prefix_str, int prefix_type, int rowsize,
+ int groupsize, const void *buf, size_t len, bool ascii)
{
+ return -ENOSYS;
}
void print_hex_dump_bytes(const char *prefix_str, int prefix_type,