mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-11 07:34:31 +00:00
efi_selftest: allow printing MAC addresses
Add %pm as format string to print a MAC address. This is helpful when analyzing network problems. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Alexander Graf <agraf@suse.de>
This commit is contained in:
parent
9820c2f30c
commit
1b6332597f
1 changed files with 40 additions and 1 deletions
|
@ -12,6 +12,37 @@
|
||||||
struct efi_simple_text_output_protocol *con_out;
|
struct efi_simple_text_output_protocol *con_out;
|
||||||
struct efi_simple_input_interface *con_in;
|
struct efi_simple_input_interface *con_in;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Print a MAC address to an u16 string
|
||||||
|
*
|
||||||
|
* @pointer: mac address
|
||||||
|
* @buf: pointer to buffer address
|
||||||
|
* on return position of terminating zero word
|
||||||
|
*/
|
||||||
|
static void mac(void *pointer, u16 **buf)
|
||||||
|
{
|
||||||
|
int i, j;
|
||||||
|
u16 c;
|
||||||
|
u8 *p = (u8 *)pointer;
|
||||||
|
u8 byte;
|
||||||
|
u16 *pos = *buf;
|
||||||
|
|
||||||
|
for (i = 0; i < ARP_HLEN; ++i) {
|
||||||
|
if (i)
|
||||||
|
*pos++ = ':';
|
||||||
|
byte = p[i];
|
||||||
|
for (j = 4; j >= 0; j -= 4) {
|
||||||
|
c = (byte >> j) & 0x0f;
|
||||||
|
c += '0';
|
||||||
|
if (c > '9')
|
||||||
|
c += 'a' - '9' - 1;
|
||||||
|
*pos++ = c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*pos = 0;
|
||||||
|
*buf = pos;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Print a pointer to an u16 string
|
* Print a pointer to an u16 string
|
||||||
*
|
*
|
||||||
|
@ -146,7 +177,15 @@ void efi_st_printf(const char *fmt, ...)
|
||||||
int2dec(va_arg(args, s32), &pos);
|
int2dec(va_arg(args, s32), &pos);
|
||||||
break;
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
|
++c;
|
||||||
|
switch (*c) {
|
||||||
|
case 'm':
|
||||||
|
mac(va_arg(args, void*), &pos);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
--c;
|
||||||
pointer(va_arg(args, void*), &pos);
|
pointer(va_arg(args, void*), &pos);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
s = va_arg(args, const char *);
|
s = va_arg(args, const char *);
|
||||||
|
|
Loading…
Reference in a new issue