* [U-Boot] [PATCH v2 1/1] vsprintf.c: add EFI device path printing
@ 2017-11-23 21:59 Heinrich Schuchardt
2017-11-26 13:17 ` Wolfgang Denk
0 siblings, 1 reply; 2+ messages in thread
From: Heinrich Schuchardt @ 2017-11-23 21:59 UTC (permalink / raw)
To: u-boot
For debugging efi_loader we need the capability to print EFI
device paths. With this patch we can write:
debug("device path: %pD", dp);
A possible output would be
device path: /MemoryMapped(0x0,0x3ff93a82,0x3ff93a82)
Cc: Wolfgang Denk <wd@denx.de>
Suggested-by: Rob Clark <robdclark@gmail.com>
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
I propose Alex picks up this patch for the EFI tree.
v2
Panic if out of memory.
Wolfgang suggested not to silently ignore an out of memory
situation.
---
lib/vsprintf.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+), 0 deletion(-)
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index dd572d2868..1135817fd8 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -18,6 +18,7 @@
#include <common.h>
#include <charset.h>
+#include <efi_loader.h>
#include <uuid.h>
#include <div64.h>
@@ -292,6 +293,22 @@ static char *string16(char *buf, char *end, u16 *s, int field_width,
return buf;
}
+#ifdef CONFIG_EFI_LOADER
+static char *device_path_string(char *buf, char *end, void *dp, int field_width,
+ int precision, int flags)
+{
+ u16 *str = efi_dp_str((struct efi_device_path *)dp);
+
+ /* Do not silently ignore out of memory situation */
+ if (!str && dp)
+ panic("efi_dp_str: out of memory");
+
+ buf = string16(buf, end, str, field_width, precision, flags);
+ efi_free_pool(str);
+ return buf;
+}
+#endif
+
#ifdef CONFIG_CMD_NET
static const char hex_asc[] = "0123456789abcdef";
#define hex_asc_lo(x) hex_asc[((x) & 0x0f)]
@@ -435,6 +452,11 @@ static char *pointer(const char *fmt, char *buf, char *end, void *ptr,
#endif
switch (*fmt) {
+#ifdef CONFIG_EFI_LOADER
+ case 'D':
+ return device_path_string(buf, end, ptr, field_width,
+ precision, flags);
+#endif
#ifdef CONFIG_CMD_NET
case 'a':
flags |= SPECIAL | ZEROPAD;
--
2.14.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [U-Boot] [PATCH v2 1/1] vsprintf.c: add EFI device path printing
2017-11-23 21:59 [U-Boot] [PATCH v2 1/1] vsprintf.c: add EFI device path printing Heinrich Schuchardt
@ 2017-11-26 13:17 ` Wolfgang Denk
0 siblings, 0 replies; 2+ messages in thread
From: Wolfgang Denk @ 2017-11-26 13:17 UTC (permalink / raw)
To: u-boot
Dear Heinrich,
In message <20171123215901.8992-1-xypron.glpk@gmx.de> you wrote:
>
> +#ifdef CONFIG_EFI_LOADER
> +static char *device_path_string(char *buf, char *end, void *dp, int field_width,
> + int precision, int flags)
> +{
> + u16 *str = efi_dp_str((struct efi_device_path *)dp);
> +
> + /* Do not silently ignore out of memory situation */
> + if (!str && dp)
> + panic("efi_dp_str: out of memory");
> +
> + buf = string16(buf, end, str, field_width, precision, flags);
> + efi_free_pool(str);
> + return buf;
> +}
I think this would be much clearer if you wrote:
u16 *str;
if (dp == NULL)
return "<NULL>";
str = efi_dp_str((struct efi_device_path *)dp);
if (str == NULL)
panic("device_path_string(): out of memory");
buf = string16(buf, end, str, field_width, precision, flags);
efi_free_pool(str);
return buf;
Thanks.
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
grep me no patterns and I'll tell you no lines.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-11-26 13:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-23 21:59 [U-Boot] [PATCH v2 1/1] vsprintf.c: add EFI device path printing Heinrich Schuchardt
2017-11-26 13:17 ` Wolfgang Denk
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.