boot: add hexdump helper call

This is not actually used (or even supposed to be used) in clean
codepaths, but is tremendously useful when verifying things work
correctly, as a debugging tool.
This commit is contained in:
Lennart Poettering
2022-08-02 10:28:49 +02:00
parent a67f22c4a7
commit 257bc3ef60
2 changed files with 29 additions and 0 deletions
+25
View File
@@ -637,6 +637,31 @@ __attribute__((noinline)) void debug_break(void) {
}
#endif
#ifdef EFI_DEBUG
void hexdump(const char16_t *prefix, const void *data, UINTN size) {
static const char hex[16] = "0123456789abcdef";
_cleanup_free_ char16_t *buf = NULL;
const uint8_t *d = data;
assert(prefix);
assert(data || size == 0);
/* Debugging helper — please keep this around, even if not used */
buf = xnew(char16_t, size*2+1);
for (UINTN i = 0; i < size; i++) {
buf[i*2] = hex[d[i] >> 4];
buf[i*2+1] = hex[d[i] & 0x0F];
}
buf[size*2] = 0;
log_error_stall(L"%s[%" PRIuN "]: %s", prefix, size, buf);
}
#endif
#if defined(__i386__) || defined(__x86_64__)
static inline uint8_t inb(uint16_t port) {
uint8_t value;
+4
View File
@@ -167,6 +167,10 @@ extern uint8_t _text, _data;
# define debug_hook(identity)
#endif
#ifdef EFI_DEBUG
void hexdump(const char16_t *prefix, const void *data, UINTN size);
#endif
#if defined(__i386__) || defined(__x86_64__)
void beep(UINTN beep_count);
#else