aboutsummaryrefslogtreecommitdiff
path: root/disk
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2023-01-17 10:47:41 -0700
committerTom Rini <trini@konsulko.com>2023-01-23 18:11:40 -0500
commitdcffa4428d0359fd09348fc05cf5b5ce2db38c5f (patch)
tree4768322f3c36e6a8537b5df083ab68b44b2fd071 /disk
parent4146c823fc27c1a4e06d1d25e0a2d4644948a5fc (diff)
downloadu-boot-dcffa4428d0359fd09348fc05cf5b5ce2db38c5f.zip
u-boot-dcffa4428d0359fd09348fc05cf5b5ce2db38c5f.tar.gz
u-boot-dcffa4428d0359fd09348fc05cf5b5ce2db38c5f.tar.bz2
part: Add a function to find the first bootable partition
If a disk has a bootable partition we are expected to use it to locate the boot files. Add a function to find it. To test this, update mmc1 to have two paritions, fixing up other tests accordingly. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'disk')
-rw-r--r--disk/part.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/disk/part.c b/disk/part.c
index 5ee60a7..d449635 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -770,3 +770,19 @@ void part_set_generic_name(const struct blk_desc *dev_desc,
sprintf(name, "%s%c%d", devtype, 'a' + dev_desc->devnum, part_num);
}
+
+int part_get_bootable(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)
+ return p;
+ }
+
+ return 0;
+}