From patchwork Thu Aug 28 02:07:17 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 157 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346891; bh=OEwibsZiBXLCu+i4WkVPXrH3Tq90zXbANVmnJowgIyY=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=LdDCeMk3KfLBnwvTdw/lOPDqjH23CCmq11sciRDep1y6q067U6Mg6ei8FqVA08k3A 6fJCoEWtL5PaW8maIcjNCY9XmHUX03R4ktVMOZQw09z5nqqu6FdihFKOkx9zK1ef2v zd6DYhk2E8JoBEEtkx3vk5zs4EkLcEdmKw6sih4TPkpIFvUaR83A5Wq5Cjp2zfgIZ5 CZZ6Mdh/J5oQFU21/5DiwTAd0n8ENON/0MKc5yD592mU5k/xSMKsbzwwL7gf+hfzjo ywna2y/O5hmupxMKir0olwsHGx36hLPcVvHO3I2OhSnSIeut6n+qCFpW6fWiij5zZU AOt+FY0HyrM2Q== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C8B556777E for ; Wed, 27 Aug 2025 20:08:11 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id YYQ1vcn4614m for ; Wed, 27 Aug 2025 20:08:11 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346890; bh=OEwibsZiBXLCu+i4WkVPXrH3Tq90zXbANVmnJowgIyY=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=vbv1FgQDizPnYBhyrpQwCQFWA7/Bq1aScTx69JMUAYvPKobIZTzJrWFTXBk5DDmnz rM4iRlVbZaVbbwQN+kx2i0IihfyCLY5j89Zb5uls78ccekcWntJFbu3lAgB4R22eMh 5aL0whCZFc+8nIJiMnhUO3dPgNH7sMSVAQGbwIMdnwTO7DqGDgbUyIoZ+JSVXMuD5F ISqCjgi4dxq11SlSBLrP86k3bwitIQmZCES/8R6+HOMCuDV8FDm0w2H6O2XfsYox/a ZC8qvAYUPgTDfIKkMxaVOOsDZXQT3OO05zlULB0bCbf0Aud03hggBSau3XjAFI3M8y BsxpP9NUW71qA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 05BE767834 for ; Wed, 27 Aug 2025 20:08:10 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346887; bh=OV9O8a3rWPf3+xo2IMantD6UHs6NgSSeuhgaau5B/5c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pGcZug0rcyDeQIJtJsxJpTKZhIwz4Ju4kFyHzxFshZl2NbmUourgSGa2Ad1UCE+oQ EuYd0XU34lFmR33yiU/Q5GkiIDiqrS7n6d1uS6n/HpXuIESeE6HsDLwR/i8amhSUiG JspbOqgK59Tx3obWGq9jHh1hBjMq6/Nd9826NcDrFxA4KqfaEKQUL12x1k8yqYDc3M dh/O+NBwFGKh9kI1Dj3iZvcju7hkcLcqKNOBgOoCyLPT91RSdrhY/Fwj1cP7V9DRa2 UvU/cFn15juMhXN/RFlSTzuHC4CuZqAySXZYboIVLu4BWePCStlfid7BafZzqUu++x eIgmlRb3jUe6g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id BA2386743E; Wed, 27 Aug 2025 20:08:07 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id bEqdJI3baT8u; Wed, 27 Aug 2025 20:08:07 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346887; bh=VAoEwHr+VrgPWkeyin/sSkz19Ct5J5+kFRr5Dp33WDg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pIYaJUFEjktGWi7E9aHSY1zu6/oU8Ju2k3mOQhP5WchiG3Lm9FcxsCfTdr6G0Cm/i Q8mpRGZuw4xzpYcW7QKNqvJP9JtTBaIh2HMk+cvObrC/19MxPJOfG2y0hznr2aRfmL 2ShUP27OVNbx5WY59nrCjhyYnBCIR0oZCojyLXJnJGTOoLL0FfZeIu0E4cmFv5O2sL IrMBcWy9QvecxRtVDzL/mfZsdt5X9nE/w/ifNX3untgl2hzvePAoL6369eGdVb2jmU uRCY/P7j45pm0cdW8l6h5NZAX3JjVEKOLcvMWOcnuwno2ERRcPY7ng6S1TF9yyYumh /4unehu1SzwOQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 00FAB6777E; Wed, 27 Aug 2025 20:08:06 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Wed, 27 Aug 2025 20:07:17 -0600 Message-ID: <20250828020732.981415-15-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250828020732.981415-1-sjg@u-boot.org> References: <20250828020732.981415-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: J62B6KPWOFHE2IRIM3XGN5IX4WJYL7LM X-Message-ID-Hash: J62B6KPWOFHE2IRIM3XGN5IX4WJYL7LM X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 14/20] efi: Add an efi subcommand to show the loaded image List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Sometimes it is useful to see the device-path of the app itself. Add a new 'efi image' command for this. Signed-off-by: Simon Glass --- cmd/efi.c | 15 +++++++++++++++ doc/usage/cmd/efi.rst | 14 ++++++++++++++ include/efi.h | 2 ++ 3 files changed, 31 insertions(+) diff --git a/cmd/efi.c b/cmd/efi.c index 91feec1c051..c59219ddf01 100644 --- a/cmd/efi.c +++ b/cmd/efi.c @@ -17,6 +17,19 @@ DECLARE_GLOBAL_DATA_PTR; +static int do_efi_image(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + struct efi_priv *priv = efi_get_priv(); + struct efi_loaded_image *lim = priv->loaded_image; + u16 *path; + + path = efi_dp_str(lim->file_path); + printf("Loaded-image path: %ls\n", path); + + return 0; +} + static int h_cmp_entry(const void *v1, const void *v2) { const struct efi_mem_desc *desc1 = v1; @@ -186,6 +199,7 @@ static int do_efi_tables(struct cmd_tbl *cmdtp, int flag, int argc, } static struct cmd_tbl efi_commands[] = { + U_BOOT_CMD_MKENT(image, 1, 1, do_efi_image, "", ""), U_BOOT_CMD_MKENT(mem, 1, 1, do_efi_mem, "", ""), U_BOOT_CMD_MKENT(tables, 1, 1, do_efi_tables, "", ""), }; @@ -211,6 +225,7 @@ static int do_efi(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) U_BOOT_CMD( efi, 3, 1, do_efi, "EFI access", + "image Dump loaded-image info\n" "mem [all] Dump memory information [include boot services]\n" "tables Dump tables" ); diff --git a/doc/usage/cmd/efi.rst b/doc/usage/cmd/efi.rst index b19d36188a9..e5d8913c94b 100644 --- a/doc/usage/cmd/efi.rst +++ b/doc/usage/cmd/efi.rst @@ -12,6 +12,7 @@ Synopsis :: + efi image efi mem [all] efi tables @@ -26,6 +27,16 @@ information. When running as an EFI payload, EFI boot services have been stopped, so it uses the information collected by the boot stub before that happened. +efi image +~~~~~~~~~ + +This shows the loaded image path information for the currently running EFI +application. The loaded image protocol provides access to the device path +from which the image was loaded. + +The output shows the file path in EFI device path format, displayed as a +human-readable Unicode string. + efi mem ~~~~~~~ @@ -71,6 +82,9 @@ Example :: + => efi image + Loaded-image path: u-boot-app.efi + => efi mem EFI table at 0, memory map 000000001ad38b60, size 1260, key a79, version 1, descr. size 0x30 # Type Physical Virtual Size Attributes diff --git a/include/efi.h b/include/efi.h index 2ca7cc30d52..530b127bde4 100644 --- a/include/efi.h +++ b/include/efi.h @@ -881,4 +881,6 @@ int efi_dp_from_bootdev(const struct udevice *dev, int efi_read_var(const u16 *name, const efi_guid_t *guid, u32 *attrp, struct abuf *buf, u64 *timep); +uint16_t *efi_dp_str(struct efi_device_path *dp); + #endif /* _LINUX_EFI_H */