diff --git a/common/bloblist.c b/common/bloblist.c index 1d816d4b695..75a63a4c2e4 100644 --- a/common/bloblist.c +++ b/common/bloblist.c @@ -477,15 +477,8 @@ int bloblist_init(void) bool fixed = IS_ENABLED(CONFIG_BLOBLIST_FIXED); int ret = -ENOENT; ulong addr, size; - bool expected; - - /** - * We don't expect to find an existing bloblist in the first phase of - * U-Boot that runs. Also we have no way to receive the address of an - * allocated bloblist from a previous stage, so it must be at a fixed - * address. - */ - expected = fixed && !u_boot_first_phase(); + bool expected = fixed; + if (spl_prev_phase() == PHASE_TPL && !IS_ENABLED(CONFIG_TPL_BLOBLIST)) expected = false; if (fixed) @@ -493,14 +486,17 @@ int bloblist_init(void) CONFIG_BLOBLIST_ADDR); size = CONFIG_BLOBLIST_SIZE; if (expected) { - ret = bloblist_check(addr, size); - if (ret) { - log_warning("Expected bloblist at %lx not found (err=%d)\n", + if (IS_ENABLED(CONFIG_OF_BOARD)) + /* Get the bloblist from previous loader */ + ret = board_bloblist_from_boot_arg(addr, size); + else + ret = bloblist_check(addr, size); + + if (ret) + log_warning("Bloblist at %lx not found, err=%d\n", addr, ret); - } else { - /* Get the real size, if it is not what we expected */ - size = gd->bloblist->size; - } + else + size = gd->bloblist->max_size; } if (ret) { if (CONFIG_IS_ENABLED(BLOBLIST_ALLOC)) { @@ -510,7 +506,8 @@ int bloblist_init(void) return log_msg_ret("alloc", -ENOMEM); addr = map_to_sysmem(ptr); } else if (!fixed) { - return log_msg_ret("!fixed", ret); + return log_msg_ret("BLOBLIST_FIXED is not enabled", + ret); } log_debug("Creating new bloblist size %lx at %lx\n", size, addr); diff --git a/include/bloblist.h b/include/bloblist.h index 909d931278c..7b7e5bd4013 100644 --- a/include/bloblist.h +++ b/include/bloblist.h @@ -441,6 +441,20 @@ void bloblist_reloc(void *to, uint to_size, void *from, uint from_size); */ int bloblist_init(void); +#if CONFIG_IS_ENABLED(ARCH_QEMU) +int board_bloblist_from_boot_arg(unsigned long addr, unsigned long size); +#else +/* + * A board need to implement this custom function if it needs to retrieve + * bloblist from a previous loader + */ +static inline int board_bloblist_from_boot_arg(unsigned long __always_unused addr, + unsigned long __always_unused size) +{ + return -1; +} +#endif + #if CONFIG_IS_ENABLED(BLOBLIST) /** * bloblist_maybe_init() - Init the bloblist system if not already done