mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-21 04:14:34 +00:00
vsprintf.c: add GUID printing
This works (roughly) the same way as linux's, but we currently always print lower-case (ie. we just keep %pUB and %pUL for compat with linux), mostly just because that is what uuid_bin_to_str() supports. %pUb: 01020304-0506-0708-090a-0b0c0d0e0f10 %pUl: 04030201-0605-0807-090a-0b0c0d0e0f10 It will be used by a later efi_loader paths for efi variables and for device-path-to-text protocol, and also quite useful for debug prints of protocol GUIDs. Signed-off-by: Rob Clark <robdclark@gmail.com> Tested-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
274325c509
commit
22ada0c8e6
3 changed files with 46 additions and 2 deletions
|
@ -35,6 +35,7 @@ EXT_COBJ-y += lib/string.o
|
||||||
EXT_COBJ-y += lib/time.o
|
EXT_COBJ-y += lib/time.o
|
||||||
EXT_COBJ-y += lib/vsprintf.o
|
EXT_COBJ-y += lib/vsprintf.o
|
||||||
EXT_COBJ-y += lib/charset.o
|
EXT_COBJ-y += lib/charset.o
|
||||||
|
EXT_COBJ-$(CONFIG_LIB_UUID) += lib/uuid.o
|
||||||
EXT_SOBJ-$(CONFIG_PPC) += arch/powerpc/lib/ppcstring.o
|
EXT_SOBJ-$(CONFIG_PPC) += arch/powerpc/lib/ppcstring.o
|
||||||
ifeq ($(ARCH),arm)
|
ifeq ($(ARCH),arm)
|
||||||
EXT_SOBJ-$(CONFIG_USE_ARCH_MEMSET) += arch/arm/lib/memset.o
|
EXT_SOBJ-$(CONFIG_USE_ARCH_MEMSET) += arch/arm/lib/memset.o
|
||||||
|
|
|
@ -58,6 +58,7 @@
|
||||||
|
|
||||||
#if (CONFIG_IS_ENABLED(PARTITION_UUIDS) || \
|
#if (CONFIG_IS_ENABLED(PARTITION_UUIDS) || \
|
||||||
CONFIG_IS_ENABLED(EFI_PARTITION) || \
|
CONFIG_IS_ENABLED(EFI_PARTITION) || \
|
||||||
|
CONFIG_IS_ENABLED(EFI_LOADER) || \
|
||||||
defined(CONFIG_RANDOM_UUID) || \
|
defined(CONFIG_RANDOM_UUID) || \
|
||||||
defined(CONFIG_CMD_UUID) || \
|
defined(CONFIG_CMD_UUID) || \
|
||||||
defined(CONFIG_BOOTP_PXE)) && \
|
defined(CONFIG_BOOTP_PXE)) && \
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
#include <charset.h>
|
#include <charset.h>
|
||||||
|
#include <uuid.h>
|
||||||
|
|
||||||
#include <div64.h>
|
#include <div64.h>
|
||||||
#define noinline __attribute__((noinline))
|
#define noinline __attribute__((noinline))
|
||||||
|
@ -366,6 +367,40 @@ static char *ip4_addr_string(char *buf, char *end, u8 *addr, int field_width,
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_LIB_UUID
|
||||||
|
/*
|
||||||
|
* This works (roughly) the same way as linux's, but we currently always
|
||||||
|
* print lower-case (ie. we just keep %pUB and %pUL for compat with linux),
|
||||||
|
* mostly just because that is what uuid_bin_to_str() supports.
|
||||||
|
*
|
||||||
|
* %pUb: 01020304-0506-0708-090a-0b0c0d0e0f10
|
||||||
|
* %pUl: 04030201-0605-0807-090a-0b0c0d0e0f10
|
||||||
|
*/
|
||||||
|
static char *uuid_string(char *buf, char *end, u8 *addr, int field_width,
|
||||||
|
int precision, int flags, const char *fmt)
|
||||||
|
{
|
||||||
|
char uuid[UUID_STR_LEN + 1];
|
||||||
|
int str_format = UUID_STR_FORMAT_STD;
|
||||||
|
|
||||||
|
switch (*(++fmt)) {
|
||||||
|
case 'L':
|
||||||
|
case 'l':
|
||||||
|
str_format = UUID_STR_FORMAT_GUID;
|
||||||
|
break;
|
||||||
|
case 'B':
|
||||||
|
case 'b':
|
||||||
|
/* this is the default */
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
uuid_bin_to_str(addr, uuid, str_format);
|
||||||
|
|
||||||
|
return string(buf, end, uuid, field_width, precision, flags);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Show a '%p' thing. A kernel extension is that the '%p' is followed
|
* Show a '%p' thing. A kernel extension is that the '%p' is followed
|
||||||
* by an extra set of alphanumeric characters that are extended format
|
* by an extra set of alphanumeric characters that are extended format
|
||||||
|
@ -399,8 +434,8 @@ static char *pointer(const char *fmt, char *buf, char *end, void *ptr,
|
||||||
flags);
|
flags);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_CMD_NET
|
|
||||||
switch (*fmt) {
|
switch (*fmt) {
|
||||||
|
#ifdef CONFIG_CMD_NET
|
||||||
case 'a':
|
case 'a':
|
||||||
flags |= SPECIAL | ZEROPAD;
|
flags |= SPECIAL | ZEROPAD;
|
||||||
|
|
||||||
|
@ -430,8 +465,15 @@ static char *pointer(const char *fmt, char *buf, char *end, void *ptr,
|
||||||
precision, flags);
|
precision, flags);
|
||||||
flags &= ~SPECIAL;
|
flags &= ~SPECIAL;
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef CONFIG_LIB_UUID
|
||||||
|
case 'U':
|
||||||
|
return uuid_string(buf, end, ptr, field_width, precision,
|
||||||
|
flags, fmt);
|
||||||
|
#endif
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
flags |= SMALL;
|
flags |= SMALL;
|
||||||
if (field_width == -1) {
|
if (field_width == -1) {
|
||||||
field_width = 2*sizeof(void *);
|
field_width = 2*sizeof(void *);
|
||||||
|
|
Loading…
Add table
Reference in a new issue