summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorPhilipp Tomsich <philipp.tomsich@theobroma-systems.com>2017-09-13 21:29:33 +0200
committerPhilipp Tomsich <philipp.tomsich@theobroma-systems.com>2017-11-26 00:39:07 +0100
commit9f45aeb937275960405de0f2abca8c665dbb03d4 (patch)
tree682bf81cb76c04cd6a12c5bb888c99165f358392 /common
parentd879616e9e64cf5a9c43dedc30677aa2fa463d64 (diff)
spl: fit: implement fdt_record_loadable
During the loading of more complex FIT images (e.g. when the invoked next stage needs to find additional firmware for a power-management core... or if there are multiple images for different privilege levels started in parallel), it is helpful to create a record of what images are loaded where: if a FDT is loaded for one of the next stages, it can be used to convey the status and location of loadables. This adds a fdt_record_loadable() function that can be invoked to record the status of each loadable below the /fit-images path. Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'common')
-rw-r--r--common/fdt_support.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/common/fdt_support.c b/common/fdt_support.c
index f4f9543d54..6896dcb285 100644
--- a/common/fdt_support.c
+++ b/common/fdt_support.c
@@ -410,6 +410,45 @@ static int fdt_pack_reg(const void *fdt, void *buf, u64 *address, u64 *size,
return p - (char *)buf;
}
+int fdt_record_loadable(void *blob, u32 index, const char *name,
+ uintptr_t load_addr, u32 size, uintptr_t entry_point,
+ const char *type, const char *os)
+{
+ int err, node;
+
+ err = fdt_check_header(blob);
+ if (err < 0) {
+ printf("%s: %s\n", __func__, fdt_strerror(err));
+ return err;
+ }
+
+ /* find or create "/fit-images" node */
+ node = fdt_find_or_add_subnode(blob, 0, "fit-images");
+ if (node < 0)
+ return node;
+
+ /* find or create "/fit-images/<name>" node */
+ node = fdt_find_or_add_subnode(blob, node, name);
+ if (node < 0)
+ return node;
+
+ /*
+ * We record these as 32bit entities, possibly truncating addresses.
+ * However, spl_fit.c is not 64bit safe either: i.e. we should not
+ * have an issue here.
+ */
+ fdt_setprop_u32(blob, node, "load-addr", load_addr);
+ if (entry_point != -1)
+ fdt_setprop_u32(blob, node, "entry-point", entry_point);
+ fdt_setprop_u32(blob, node, "size", size);
+ if (type)
+ fdt_setprop_string(blob, node, "type", type);
+ if (os)
+ fdt_setprop_string(blob, node, "os", os);
+
+ return node;
+}
+
#ifdef CONFIG_NR_DRAM_BANKS
#define MEMORY_BANKS_MAX CONFIG_NR_DRAM_BANKS
#else