This allows board- or functionality-specific (like EFI loader support) to invoke a specific bootentry provider by name.
Reviewed-by: Sascha Hauer <[email protected]> Signed-off-by: Ahmad Fatoum <[email protected]> --- v1 -> v2: - add Sascha's R-b --- arch/arm/boards/protonic-imx6/board.c | 1 + common/blspec.c | 1 + common/boot.c | 15 +++++++++++++++ common/bootchooser.c | 1 + common/bootdef.c | 1 + include/boot.h | 2 ++ 6 files changed, 21 insertions(+) diff --git a/arch/arm/boards/protonic-imx6/board.c b/arch/arm/boards/protonic-imx6/board.c index 80558ce15817..c15a349c8a88 100644 --- a/arch/arm/boards/protonic-imx6/board.c +++ b/arch/arm/boards/protonic-imx6/board.c @@ -461,6 +461,7 @@ static int prt_imx6_bootentry_generate(struct bootentries *bootentries, } static struct bootentry_provider prt_imx6_bootentry_provider = { + .name = "prt-imx6", .generate = prt_imx6_bootentry_generate, }; diff --git a/common/blspec.c b/common/blspec.c index bc2c3204ad62..624e4c115272 100644 --- a/common/blspec.c +++ b/common/blspec.c @@ -639,6 +639,7 @@ static int blspec_bootentry_generate(struct bootentries *bootentries, } static struct bootentry_provider blspec_bootentry_provider = { + .name = "blspec", .generate = blspec_bootentry_generate, }; diff --git a/common/boot.c b/common/boot.c index 14525d31ae2d..1059e6d995d3 100644 --- a/common/boot.c +++ b/common/boot.c @@ -288,6 +288,21 @@ int bootentry_register_provider(struct bootentry_provider *p) return 0; } +struct bootentry_provider *get_bootentry_provider(const char *name) +{ + struct bootentry_provider *p; + + if (!name) + return NULL; + + list_for_each_entry(p, &bootentry_providers, list) { + if (streq_ptr(p->name, name)) + return p; + } + + return NULL; +} + /* * nfs_find_mountpath - Check if a given url is already mounted */ diff --git a/common/bootchooser.c b/common/bootchooser.c index a79eee8ca2c4..2905a0ca677e 100644 --- a/common/bootchooser.c +++ b/common/bootchooser.c @@ -962,6 +962,7 @@ static int bootchooser_add_entry(struct bootentries *entries, const char *name) } static struct bootentry_provider bootchooser_entry_provider = { + .name = "bootchooser", .generate = bootchooser_add_entry, }; diff --git a/common/bootdef.c b/common/bootdef.c index e8140d3a6bce..85471d92d3c5 100644 --- a/common/bootdef.c +++ b/common/bootdef.c @@ -31,6 +31,7 @@ static int bootdef_add_entry(struct bootentries *entries, const char *name) } static struct bootentry_provider bootdef_entry_provider = { + .name = "bootdef", .generate = bootdef_add_entry, }; diff --git a/include/boot.h b/include/boot.h index c1676364cadc..ae32b9ead93f 100644 --- a/include/boot.h +++ b/include/boot.h @@ -26,12 +26,14 @@ struct bootentry { int bootentries_add_entry(struct bootentries *entries, struct bootentry *entry); struct bootentry_provider { + const char *name; int (*generate)(struct bootentries *bootentries, const char *name); /* internal fields */ struct list_head list; }; int bootentry_register_provider(struct bootentry_provider *provider); +struct bootentry_provider *get_bootentry_provider(const char *name); #define bootentries_for_each_entry(bootentries, entry) \ list_for_each_entry(entry, &bootentries->entries, list) -- 2.47.3
