Skip to content

Commit

Permalink
bloblist: Load the bloblist from the previous loader
Browse files Browse the repository at this point in the history
During bloblist initialization, when CONFIG_OF_BOARD is defined,
invoke the platform custom function to load the bloblist via boot
arguments from the previous loader.
If the bloblist exists, copy it into the fixed bloblist memory region.

Signed-off-by: Raymond Mao <raymond.mao@linaro.org>
  • Loading branch information
raymo200915 committed Nov 10, 2023
1 parent ce605f7 commit 858b1dc
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 17 deletions.
31 changes: 14 additions & 17 deletions common/bloblist.c
Original file line number Diff line number Diff line change
Expand Up @@ -477,30 +477,26 @@ 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)
addr = IF_ENABLED_INT(CONFIG_BLOBLIST_FIXED,
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)) {
Expand All @@ -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);
Expand Down
14 changes: 14 additions & 0 deletions include/bloblist.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 858b1dc

Please sign in to comment.