mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] boot: allow prioritizing boot entry providers
@ 2025-12-11 20:42 Ahmad Fatoum
  0 siblings, 0 replies; only message in thread
From: Ahmad Fatoum @ 2025-12-11 20:42 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

It's not unusual for an EFI system partition to both have boot loader
spec entries and an EFI application at the default payload path for
removable media.

In that case, we will want to establish a fixed order for boot entries,
so add an optional priority field for this purpose. The default priority
is 0 and providers can sort themself higher or lower.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 common/boot.c  | 10 +++++++++-
 include/boot.h |  1 +
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/common/boot.c b/common/boot.c
index 1059e6d995d3..a8a92057844b 100644
--- a/common/boot.c
+++ b/common/boot.c
@@ -282,9 +282,17 @@ static int bootscript_scan_path(struct bootentries *bootentries, const char *pat
 
 static LIST_HEAD(bootentry_providers);
 
+static int bootentry_provider_sort(struct list_head *_a, struct list_head *_b)
+{
+	struct bootentry_provider *a = container_of(_a, struct bootentry_provider, list);
+	struct bootentry_provider *b = container_of(_b, struct bootentry_provider, list);
+
+	return compare3(b->priority, a->priority); /* descending order */
+}
+
 int bootentry_register_provider(struct bootentry_provider *p)
 {
-	list_add(&p->list, &bootentry_providers);
+	list_add_sort(&p->list, &bootentry_providers, bootentry_provider_sort);
 	return 0;
 }
 
diff --git a/include/boot.h b/include/boot.h
index ae32b9ead93f..e6309b65a0c3 100644
--- a/include/boot.h
+++ b/include/boot.h
@@ -28,6 +28,7 @@ int bootentries_add_entry(struct bootentries *entries, struct bootentry *entry);
 struct bootentry_provider {
 	const char *name;
 	int (*generate)(struct bootentries *bootentries, const char *name);
+	int priority;
 	/* internal fields */
 	struct list_head list;
 };
-- 
2.47.3




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2025-12-11 20:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-11 20:42 [PATCH] boot: allow prioritizing boot entry providers Ahmad Fatoum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox