[Concept,v2,13/18] efi: app: Implement %pD in the app

Message ID 20250820112340.147082-14-sjg@u-boot.org
State New
Headers
Series efi: Move towards the EFI app booting EFI applications |

Commit Message

Simon Glass Aug. 20, 2025, 11:23 a.m. UTC
  From: Simon Glass <sjg@chromium.org>

This printf() extension is useful for the app. Add an implementation of
efi_dp_str() so that it works as expected.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 lib/efi/Kconfig        | 12 +++++++++++-
 lib/efi_client/efi.c   | 15 +++++++++++++++
 lib/efi_loader/Kconfig |  7 -------
 3 files changed, 26 insertions(+), 8 deletions(-)
  

Patch

diff --git a/lib/efi/Kconfig b/lib/efi/Kconfig
index 16de786b1e2..ed12741f61a 100644
--- a/lib/efi/Kconfig
+++ b/lib/efi/Kconfig
@@ -11,12 +11,22 @@  config EFI
 
 	  This is used to provide libraries shared by both.
 
+if EFI_LOADER
+
 config EFI_BINARY_EXEC
 	bool "Execute UEFI binary"
 	default y
-	depends on EFI_LOADER
 	help
 	  Select this option if you want to execute the UEFI binary after
 	  loading it with U-Boot load commands or other methods.
 	  You may enable CMD_BOOTEFI_BINARY so that you can use bootefi
 	  command to do that.
+
+config EFI_DEVICE_PATH_TO_TEXT
+	bool "Device path to text protocol"
+	default y
+	help
+	  The device path to text protocol converts device nodes and paths to
+	  human readable strings.
+
+endif # EFI_LOADER
diff --git a/lib/efi_client/efi.c b/lib/efi_client/efi.c
index e2cc9d3eae3..739010e60e3 100644
--- a/lib/efi_client/efi.c
+++ b/lib/efi_client/efi.c
@@ -196,3 +196,18 @@  void efi_free_pool(void *ptr)
 
 	efi_free(priv, ptr);
 }
+
+/* helper for debug prints.. efi_free_pool() the result. */
+uint16_t *efi_dp_str(struct efi_device_path *dp)
+{
+	struct efi_priv *priv = efi_get_priv();
+	u16 *val;
+
+	if (!priv->efi_dp_to_text)
+		return NULL;
+
+	val = priv->efi_dp_to_text->convert_device_path_to_text(dp, true,
+								true);
+
+	return val;
+}
diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
index 6f67e4897f3..c2bb9375df4 100644
--- a/lib/efi_loader/Kconfig
+++ b/lib/efi_loader/Kconfig
@@ -356,13 +356,6 @@  endmenu
 
 menu "UEFI protocol support"
 
-config EFI_DEVICE_PATH_TO_TEXT
-	bool "Device path to text protocol"
-	default y
-	help
-	  The device path to text protocol converts device nodes and paths to
-	  human readable strings.
-
 config EFI_DEVICE_PATH_UTIL
 	bool "Device path utilities protocol"
 	default y