summaryrefslogtreecommitdiffstats
path: root/common/boot.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2017-04-05 16:26:20 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2017-04-06 10:48:41 +0200
commitb9abc5322e2a18828fbfab5e081f846f0c4199cc (patch)
tree71923770685828aeb3d969d1a3c8d06191166d76 /common/boot.c
parent0c7c7fe41fd3a2971dbc0149b91972b6bf6eb38f (diff)
downloadbarebox-b9abc5322e2a18828fbfab5e081f846f0c4199cc.tar.gz
boot: Allow to register boot entry providers
bootentry_create_from_name() takes a name and creates bootentries for it. It tries different providers that interpret the name: blspec, bootchooser or script pathes. Instead of hardcoding the different providers in the function, allow the providers to register themselves. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/boot.c')
-rw-r--r--common/boot.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/common/boot.c b/common/boot.c
index 4306319..f0359cf 100644
--- a/common/boot.c
+++ b/common/boot.c
@@ -244,6 +244,25 @@ static int bootscript_scan_path(struct bootentries *bootentries, const char *pat
return ret;
}
+static LIST_HEAD(bootentry_providers);
+
+struct bootentry_provider {
+ int (*fn)(struct bootentries *bootentries, const char *name);
+ struct list_head list;
+};
+
+int bootentry_register_provider(int (*fn)(struct bootentries *bootentries, const char *name))
+{
+ struct bootentry_provider *p;
+
+ p = xzalloc(sizeof(*p));
+ p->fn = fn;
+
+ list_add_tail(&p->list, &bootentry_providers);
+
+ return 0;
+}
+
/*
* bootentry_create_from_name - create boot entries from a name
*
@@ -261,6 +280,7 @@ static int bootscript_scan_path(struct bootentries *bootentries, const char *pat
int bootentry_create_from_name(struct bootentries *bootentries,
const char *name)
{
+ struct bootentry_provider *p;
int found = 0, ret;
if (IS_ENABLED(CONFIG_BLSPEC)) {
@@ -275,6 +295,12 @@ int bootentry_create_from_name(struct bootentries *bootentries,
}
}
+ list_for_each_entry(p, &bootentry_providers, list) {
+ ret = p->fn(bootentries, name);
+ if (ret > 0)
+ found += ret;
+ }
+
if (IS_ENABLED(CONFIG_BOOTCHOOSER) && !strcmp(name, "bootchooser")) {
ret = bootchooser_create_bootentry(bootentries);
if (ret > 0)