From: Mayuresh Chitale <mchitale@ventanamicro.com>
To: u-boot@lists.denx.de
Cc: Mayuresh Chitale <mchitale@ventanamicro.com>,
Simon Glass <sjg@chromium.org>,
Heinrich Schuchardt <xypron.glpk@gmx.de>,
Bin Meng <bmeng@tinylab.org>, Johan Jonker <jbx6244@gmail.com>,
Joshua Watt <jpewhacker@gmail.com>,
Tobias Waldekranz <tobias@waldekranz.com>,
Marek Vasut <marek.vasut+renesas@mailbox.org>,
Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Subject: [PATCH v3 1/2] part: Add a function to find ESP partition
Date: Mon, 22 Jan 2024 16:40:21 +0530 [thread overview]
Message-ID: <20240122111022.229805-2-mchitale@ventanamicro.com> (raw)
In-Reply-To: <20240122111022.229805-1-mchitale@ventanamicro.com>
If a disk has an EFI system partition (ESP) then it can be used to
locate the boot files. Add a function to find the ESP.
Signed-off-by: Mayuresh Chitale <mchitale@ventanamicro.com>
Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
---
Changes in v3:
- Fix part_get_esp signature and header in part.h
disk/part.c | 16 ++++++++++++++++
include/part.h | 13 +++++++++++++
2 files changed, 29 insertions(+)
diff --git a/disk/part.c b/disk/part.c
index 36b88205eca..6b1fbc18637 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -848,3 +848,19 @@ int part_get_bootable(struct blk_desc *desc)
return 0;
}
+
+int part_get_esp(struct blk_desc *desc)
+{
+ struct disk_partition info;
+ int p;
+
+ for (p = 1; p <= MAX_SEARCH_PARTITIONS; p++) {
+ int ret;
+
+ ret = part_get_info(desc, p, &info);
+ if (!ret && (info.bootable & PART_EFI_SYSTEM_PARTITION))
+ return p;
+ }
+
+ return 0;
+}
diff --git a/include/part.h b/include/part.h
index db34bc6bb7d..1aa6fe44ffb 100644
--- a/include/part.h
+++ b/include/part.h
@@ -690,6 +690,14 @@ int part_get_type_by_name(const char *name);
*/
int part_get_bootable(struct blk_desc *desc);
+/**
+ * part_get_esp() - Find the EFI system partition
+ *
+ * @desc: Block-device descriptor
+ * Return: the EFI system partition, or 0 if there is none
+ */
+int part_get_esp(struct blk_desc *desc);
+
#else
static inline int part_driver_get_count(void)
{ return 0; }
@@ -700,6 +708,11 @@ static inline struct part_driver *part_driver_get_first(void)
static inline bool part_get_bootable(struct blk_desc *desc)
{ return false; }
+static inline int part_get_esp(struct blk_desc *desc)
+{
+ return 0;
+}
+
#endif /* CONFIG_PARTITIONS */
#endif /* _PART_H */
--
2.34.1
next prev parent reply other threads:[~2024-01-22 11:10 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-22 11:10 [PATCH v3 0/2] SPL EBBR - EFI System Partition support Mayuresh Chitale
2024-01-22 11:10 ` Mayuresh Chitale [this message]
2024-01-22 11:10 ` [PATCH v3 2/2] spl: Add support for booting from ESP Mayuresh Chitale
2024-03-01 23:33 ` Tom Rini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240122111022.229805-2-mchitale@ventanamicro.com \
--to=mchitale@ventanamicro.com \
--cc=bmeng@tinylab.org \
--cc=heinrich.schuchardt@canonical.com \
--cc=jbx6244@gmail.com \
--cc=jpewhacker@gmail.com \
--cc=marek.vasut+renesas@mailbox.org \
--cc=sjg@chromium.org \
--cc=tobias@waldekranz.com \
--cc=u-boot@lists.denx.de \
--cc=xypron.glpk@gmx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox