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>,
Sean Anderson <sean.anderson@seco.com>,
Tom Rini <trini@konsulko.com>,
Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Subject: [PATCH v1 1/2] part: Add a function to find ESP partition
Date: Thu, 14 Sep 2023 15:38:20 +0530 [thread overview]
Message-ID: <20230914100821.755904-2-mchitale@ventanamicro.com> (raw)
In-Reply-To: <20230914100821.755904-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>
---
disk/part.c | 16 ++++++++++++++++
include/part.h | 10 ++++++++++
2 files changed, 26 insertions(+)
diff --git a/disk/part.c b/disk/part.c
index 72241b7b23..2be0866671 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -841,3 +841,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 db34bc6bb7..036f9fd762 100644
--- a/include/part.h
+++ b/include/part.h
@@ -689,6 +689,13 @@ int part_get_type_by_name(const char *name);
* @return first bootable partition, or 0 if there is none
*/
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)
@@ -700,6 +707,9 @@ static inline struct part_driver *part_driver_get_first(void)
static inline bool part_get_bootable(struct blk_desc *desc)
{ return false; }
+static 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:[~2023-09-14 12:21 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-14 10:08 [PATCH v1 0/2] SPL EBBR - EFI System Partition support Mayuresh Chitale
2023-09-14 10:08 ` Mayuresh Chitale [this message]
2023-09-14 16:29 ` [PATCH v1 1/2] part: Add a function to find ESP partition Tom Rini
2023-09-21 11:35 ` mchitale
2023-09-14 10:08 ` [PATCH v1 2/2] spl: Add support for booting from ESP Mayuresh Chitale
2023-09-14 16:29 ` Tom Rini
2023-09-21 11:33 ` mchitale
2023-09-21 15:43 ` Tom Rini
2023-09-14 14:15 ` [PATCH v1 0/2] SPL EBBR - EFI System Partition support Heinrich Schuchardt
2023-09-14 14:36 ` Sean Anderson
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=20230914100821.755904-2-mchitale@ventanamicro.com \
--to=mchitale@ventanamicro.com \
--cc=heinrich.schuchardt@canonical.com \
--cc=sean.anderson@seco.com \
--cc=sjg@chromium.org \
--cc=trini@konsulko.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