From patchwork Thu Nov 23 21:59:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 840912 X-Patchwork-Delegate: agraf@suse.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3yjYDp0LyTz9s7g for ; Fri, 24 Nov 2017 09:01:13 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id A9DCDC21DE7; Thu, 23 Nov 2017 22:01:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 288EBC21C4A; Thu, 23 Nov 2017 22:01:06 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 6010AC21C4A; Thu, 23 Nov 2017 22:01:04 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) by lists.denx.de (Postfix) with ESMTPS id 0BFFBC21C29 for ; Thu, 23 Nov 2017 22:01:04 +0000 (UTC) Received: from workstation4.fritz.box ([94.114.42.150]) by mail.gmx.com (mrgmx003 [212.227.17.184]) with ESMTPSA (Nemesis) id 0Lx8OH-1fFF2r46On-016gKa; Thu, 23 Nov 2017 23:01:01 +0100 From: Heinrich Schuchardt To: Tom Rini , Alexander Graf Date: Thu, 23 Nov 2017 22:59:01 +0100 Message-Id: <20171123215901.8992-1-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.2 X-Provags-ID: V03:K0:SqW+bq47ksZo8qD+b5icmWAvyasT+MxMlO5NIUTCwpl2Bt1qn/+ N0RDgpVwYfDNHrUEpeOXWsjaUpuqe8Sk40PEFbq17tK9Ka+lhC4f89UkrbQy8txB8vhpD9C hDVfnyWRBAGy0FZxIWVWk1bbD7LRucDByOlH7LEIaplfq5f74BgGGtqTTFzV7ezHi1bQ88j ZtXf869b3zBbjivjFiaeA== X-UI-Out-Filterresults: notjunk:1; V01:K0:6ipFWHXNOcY=:ZhBTddixYi2HAQU9KhNJxN 5c24ZlgtMhgpKkQ7kHosbFwf6g8BKHlQh/EU0dKCrMdPt2iRJwNXx1WBZ8l51OxMd1aWq/z5A nFehir9AOVXqvdN3BrXtaJ6mYQ78HvjLAETR31WhsiX4AMYCCxLE76wbExRM2E0q4kByegHcE QOAjk0DA4U6jvBhrjZ/t48SRkGpGgWl1heFdcUVWdQZexmGp0+ugYtCgRWYwkhScNeTjMOORy DdrRUkiE7oi1vwdz0iw5+B1ONeY1piOxK+F21h5GFe4RoD6Gc23BkN4NnyScSTPOtOOz/owTK P6vAjaTk1ON65K9l0Vf2kiT08fx4vzFZj/EOMJuH9Sy2OE25YLimneuUkM75mwDTYgHXdykN3 CIdx0XhX91uCulneAkLrJ9rdZAu/xtqjSvdFxL4jfRBOu2VX5fLEgdiwDXhIG2Co22967M4NE YrYmWkFufPJDqOQ9x7bb5+6laGUgmzQsejZUbtlO1WrKFTYaZZWNusGX/0gvWU/2Uc/v8zZl8 vU0E0GSGop/tcy8Cn1SLs9wHZngKpkdYH96r26JsFAmT+9NMpLnJGaEg8d7uE8gAHTd8dj3C9 xEDcuab6ssutKcOuLp0Fuwcm1kTWbRBrUg9nf61aM8MdI5FbKhyUyH5E/fyv7m0cO42xAqKmu BVEcZ0slK8BVYoxKixx59njiDIjyw726Z75RWXAghc3HD/K2sXjUF/fRUfmX7DlLd9O9Oklwh lb241Zc5EhtZo+D/D8kksW806KmZwFqxlq2IQZLv+ZUZ3sOAzn5+iVw/C1ctmAQRDgL/Kj93h nORvQ/dL3iDbyWjHxzwmH79k+EIsRx7JOrN5ergorcigg+bQeU= Cc: Heinrich Schuchardt , u-boot@lists.denx.de Subject: [U-Boot] [PATCH v2 1/1] vsprintf.c: add EFI device path printing X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "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 Suggested-by: Rob Clark Signed-off-by: Heinrich Schuchardt --- 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 #include +#include #include #include @@ -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;