summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/bloblist.c142
-rw-r--r--common/board_f.c4
-rw-r--r--common/spl/Kconfig2
3 files changed, 76 insertions, 72 deletions
diff --git a/common/bloblist.c b/common/bloblist.c
index d084be89958..51ae9cc50a5 100644
--- a/common/bloblist.c
+++ b/common/bloblist.c
@@ -448,6 +448,7 @@ int bloblist_new(ulong addr, uint size, uint flags, uint align_log2)
hdr->align_log2 = align_log2 ? align_log2 : BLOBLIST_BLOB_ALIGN_LOG2;
hdr->chksum = 0;
gd->bloblist = hdr;
+ gd->flags |= GD_FLG_BLOBLIST_READY;
return 0;
}
@@ -475,6 +476,7 @@ int bloblist_check(ulong addr, uint size)
return log_msg_ret("Bad checksum", -EIO);
}
gd->bloblist = hdr;
+ gd->flags |= GD_FLG_BLOBLIST_READY;
return 0;
}
@@ -576,90 +578,88 @@ int __weak xferlist_from_boot_arg(ulong __always_unused *addr)
return -ENOENT;
}
-int bloblist_init(void)
+bool bloblist_exists(void)
{
- bool fixed = IS_ENABLED(CONFIG_BLOBLIST_FIXED);
- int ret = 0;
- ulong addr = 0, size;
+ int ret;
+ ulong addr = 0;
/* Check if a valid transfer list passed in */
- if (!xferlist_from_boot_arg(&addr)) {
- size = bloblist_get_total_size();
- } else {
- /*
- * If U-Boot is not in the first phase, an existing bloblist must
- * be at a fixed address.
- */
- bool from_addr = fixed && !xpl_is_first_phase();
-
- /*
- * If Firmware Handoff is mandatory but no transfer list is
- * observed, report it as an error.
- */
- if (IS_ENABLED(CONFIG_BLOBLIST_PASSAGE_MANDATORY))
- return -ENOENT;
+ if (!xferlist_from_boot_arg(&addr))
+ goto found;
- ret = -ENOENT;
-
- if (xpl_prev_phase() == PHASE_TPL &&
- !IS_ENABLED(CONFIG_TPL_BLOBLIST))
- from_addr = false;
- if (fixed)
- addr = IF_ENABLED_INT(CONFIG_BLOBLIST_FIXED,
- CONFIG_BLOBLIST_ADDR);
- size = CONFIG_BLOBLIST_SIZE;
-
- if (from_addr)
- ret = bloblist_check(addr, size);
+ /*
+ * If Firmware Handoff is mandatory but no transfer list is
+ * observed, report it as an error.
+ */
+ if (IS_ENABLED(CONFIG_BLOBLIST_PASSAGE_MANDATORY))
+ return false;
- if (ret)
- log_warning("Bloblist at %lx not found (err=%d)\n",
- addr, ret);
- else
- /* Get the real size */
- size = gd->bloblist->total_size;
- }
+ /*
+ * We have checked for a valid transfer list being passed. At this
+ * point, if we do not have a fixed address for the bloblist, we cannot
+ * be provided with one.
+ */
+ if (xpl_is_first_phase() || !IS_ENABLED(CONFIG_BLOBLIST_FIXED))
+ return false;
- if (ret) {
- /*
- * If we don't have a bloblist from a fixed address, or the one
- * in the fixed address is not valid. we must allocate the
- * memory for it now.
- */
- if (CONFIG_IS_ENABLED(BLOBLIST_ALLOC)) {
- void *ptr = memalign(BLOBLIST_ALIGN, size);
+ /*
+ * Check for a valid list as the configured address.
+ */
+ addr = IF_ENABLED_INT(CONFIG_BLOBLIST_FIXED,
+ CONFIG_BLOBLIST_ADDR);
+ ret = bloblist_check(addr, CONFIG_BLOBLIST_SIZE);
+ if (!ret)
+ goto found;
- if (!ptr)
- return log_msg_ret("alloc", -ENOMEM);
- addr = map_to_sysmem(ptr);
- } else if (!fixed) {
- return log_msg_ret("BLOBLIST_FIXED is not enabled",
- ret);
- }
- log_debug("Creating new bloblist size %lx at %lx\n", size,
- addr);
- ret = bloblist_new(addr, size, 0, 0);
- } else {
- log_debug("Found existing bloblist size %lx at %lx\n", size,
- addr);
- }
-
- if (ret)
- return log_msg_ret("ini", ret);
- gd->flags |= GD_FLG_BLOBLIST_READY;
+ log_debug("Bloblist at %lx not found (err=%d)\n", addr, ret);
+ return false;
+found:
#ifdef DEBUG
bloblist_show_stats();
bloblist_show_list();
#endif
-
- return 0;
+ return true;
}
-int bloblist_maybe_init(void)
+int bloblist_init(void)
{
- if (CONFIG_IS_ENABLED(BLOBLIST) && !(gd->flags & GD_FLG_BLOBLIST_READY))
- return bloblist_init();
+ int ret;
+ ulong addr = 0, size = CONFIG_BLOBLIST_SIZE;
+
+ if (gd->flags & GD_FLG_BLOBLIST_READY) {
+ log_debug("Found existing bloblist size %x at %p\n",
+ gd->bloblist->total_size, gd->bloblist);
+ return 0;
+ }
+
+ /*
+ * If Firmware Handoff is mandatory but no transfer list has been
+ * observed by fdtdec_setup, report it as an error.
+ */
+ if (IS_ENABLED(CONFIG_BLOBLIST_PASSAGE_MANDATORY))
+ return -ENOENT;
+
+ /*
+ * If we don't have an existing bloblist, we either need
+ * to allocate one now, or initialize the fixed address
+ * space as a bloblist.
+ */
+ if (CONFIG_IS_ENABLED(BLOBLIST_ALLOC)) {
+ void *ptr = memalign(BLOBLIST_ALIGN, size);
+
+ if (!ptr)
+ return log_msg_ret("alloc", -ENOMEM);
+ addr = map_to_sysmem(ptr);
+ } else
+ addr = IF_ENABLED_INT(CONFIG_BLOBLIST_FIXED,
+ CONFIG_BLOBLIST_ADDR);
+
+ log_debug("Creating new bloblist size %lx at %lx\n", size,
+ addr);
+ ret = bloblist_new(addr, size, 0, 0);
+ if (ret)
+ return log_msg_ret("ini", ret);
return 0;
}
@@ -687,7 +687,9 @@ int bloblist_check_reg_conv(ulong rfdt, ulong rzero, ulong rsig, ulong xlist)
return ret;
if (rfdt != (ulong)bloblist_find(BLOBLISTT_CONTROL_FDT, 0)) {
- gd->bloblist = NULL; /* Reset the gd bloblist pointer */
+ /* Remove this bloblist from gd */
+ gd->bloblist = NULL;
+ gd->flags &= ~GD_FLG_BLOBLIST_READY;
return -EIO;
}
diff --git a/common/board_f.c b/common/board_f.c
index ce87c619e68..c39e3b940d3 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -894,7 +894,9 @@ static void initcall_run_f(void)
INITCALL(log_init);
INITCALL(initf_bootstage); /* uses its own timer, so does not need DM */
INITCALL(event_init);
- INITCALL(bloblist_maybe_init);
+#if CONFIG_IS_ENABLED(BLOBLIST)
+ INITCALL(bloblist_init);
+#endif
INITCALL(setup_spl_handoff);
#if CONFIG_IS_ENABLED(CONSOLE_RECORD_INIT_F)
INITCALL(console_record_init);
diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index 5fa94098e49..cc819344cad 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -220,7 +220,7 @@ source "common/spl/Kconfig.nxp"
config HANDOFF
bool "Pass hand-off information from SPL to U-Boot proper"
- depends on BLOBLIST
+ depends on BLOBLIST_FIXED
help
It is useful to be able to pass information from SPL to U-Boot
proper to preserve state that is known in SPL and is needed in U-Boot.