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:
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user