The blspec.compatible.extra variable will be used to specify extra compatibles that are also used to match during bootloader specification entry parsing. This means that even if your internal barebox device tree machine compatible is "vendor,bareboxcompatible", but your bootloader specification device tree contains "vendor,linuxcompatible", it is possible to boot this entry by setting blspec.compatible.extra to "vendor,linuxcompatible". More than one compatible is possible as well, the compatibles will need to be space separated (since "," is already used for the vendor hardware distinction). Signed-off-by: Rouven Czerwinski <r.czerwinski@xxxxxxxxxxxxxx> --- common/blspec.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/common/blspec.c b/common/blspec.c index f8d47f20d2..e361a02333 100644 --- a/common/blspec.c +++ b/common/blspec.c @@ -19,10 +19,20 @@ #include <net.h> #include <fs.h> #include <of.h> +#include <magicvar.h> +#include <linux/list.h> #include <linux/stat.h> #include <linux/err.h> #include <mtd/ubi-user.h> +struct list_head *blspec_extra_list; +char *blspec_extra_string; + +struct blspec_extra_entry { + char *compatible; + struct list_head list; +}; + /* * blspec_entry_var_set - set a variable to a value */ @@ -830,8 +840,54 @@ static int blspec_bootentry_provider(struct bootentries *bootentries, return found; } +static int blspec_extra_set(struct param_d *p, void *priv) +{ + struct blspec_extra_entry *entry, *tmp; + char *str = blspec_extra_string; + char *temp = str; + unsigned int len; + + if (blspec_extra_list) { + list_for_each_entry_safe(entry, tmp, blspec_extra_list, list) { + list_del(&entry->list); + free(entry->compatible); + free(entry); + } + blspec_extra_list = NULL; + } + + while(str++) { + if (*str == ' ' || *str == 0) { + len = temp - str; + if(len > 126) { + len = 127; + } + entry = calloc(1, sizeof(struct blspec_extra_entry)); + entry->compatible = xzalloc(len + 1); + memcpy(entry->compatible, temp, len); + + if (blspec_extra_list == NULL) { + INIT_LIST_HEAD(&entry->list); + blspec_extra_list = &entry->list; + } else { + list_add_tail(&entry->list, blspec_extra_list); + } + + temp = str + 1; + } + if (*str == 0) + break; + } + + return 0; +} + static int blspec_init(void) { + dev_add_param_string(&global_device, "blspec.compatible.extra", + blspec_extra_set, NULL, &blspec_extra_string, blspec_extra_list); return bootentry_register_provider(blspec_bootentry_provider); } device_initcall(blspec_init); + +BAREBOX_MAGICVAR(global.blspec.compatible.extra, "Extra compatible to also match during bootloader entry matching"); -- 2.42.0