summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYe Li <ye.li@nxp.com>2017-11-08 23:14:48 -0600
committerYe Li <ye.li@nxp.com>2017-11-13 01:10:25 -0600
commitf1baf7a661e7c7969f1929871d5e1d1b5268ba04 (patch)
tree3bbcf325b5a42b10ce90328eaa5399e4dc1ba69d
parenta0cba5678b10827bc4b5e4fb2e40945a5c332baa (diff)
MLK-16787-3 SPL: Add FIT data-position property support
For external data, FIT has a optional property "data-position" which can set the external data to a fixed offset to FIT beginning. Add the support for this property in SPL FIT. Signed-off-by: Ye Li <ye.li@nxp.com> Reviewed-by: Peng Fan <peng.fan@nxp.com>
-rw-r--r--common/image-fit.c24
-rw-r--r--common/spl/spl_fit.c11
-rw-r--r--include/image.h2
3 files changed, 35 insertions, 2 deletions
diff --git a/common/image-fit.c b/common/image-fit.c
index 109ecfaacc..900329e945 100644
--- a/common/image-fit.c
+++ b/common/image-fit.c
@@ -802,6 +802,30 @@ int fit_image_get_data_offset(const void *fit, int noffset, int *data_offset)
}
/**
+ * Get 'data-position' property from a given image node.
+ *
+ * @fit: pointer to the FIT image header
+ * @noffset: component image node offset
+ * @data_position: holds the data-position property
+ *
+ * returns:
+ * 0, on success
+ * -ENOENT if the property could not be found
+ */
+int fit_image_get_data_position(const void *fit, int noffset, int *data_position)
+{
+ const fdt32_t *val;
+
+ val = fdt_getprop(fit, noffset, FIT_DATA_POSITION_PROP, NULL);
+ if (!val)
+ return -ENOENT;
+
+ *data_position = fdt32_to_cpu(*val);
+
+ return 0;
+}
+
+/**
* Get 'data-size' property from a given image node.
*
* @fit: pointer to the FIT image header
diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index 32d9ee5901..c915b4b149 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -143,6 +143,7 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
int align_len = ARCH_DMA_MINALIGN - 1;
uint8_t image_comp = -1, type = -1;
const void *data;
+ bool external_data = false;
if (IS_ENABLED(CONFIG_SPL_OS_BOOT) && IS_ENABLED(CONFIG_SPL_GZIP)) {
if (fit_image_get_comp(fit, node, &image_comp))
@@ -159,9 +160,15 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
if (fit_image_get_load(fit, node, &load_addr))
load_addr = image_info->load_addr;
- if (!fit_image_get_data_offset(fit, node, &offset)) {
- /* External data */
+ if (!fit_image_get_data_position(fit, node, &offset)) {
+ external_data = true;
+ } else if (!fit_image_get_data_offset(fit, node, &offset)) {
offset += base_offset;
+ external_data = true;
+ }
+
+ if (external_data) {
+ /* External data */
if (fit_image_get_data_size(fit, node, &len))
return -ENOENT;
diff --git a/include/image.h b/include/image.h
index f8a532b98c..6d60de8512 100644
--- a/include/image.h
+++ b/include/image.h
@@ -868,6 +868,7 @@ int bootz_setup(ulong image, ulong *start, ulong *end);
/* image node */
#define FIT_DATA_PROP "data"
+#define FIT_DATA_POSITION_PROP "data-position"
#define FIT_DATA_OFFSET_PROP "data-offset"
#define FIT_DATA_SIZE_PROP "data-size"
#define FIT_TIMESTAMP_PROP "timestamp"
@@ -949,6 +950,7 @@ int fit_image_get_entry(const void *fit, int noffset, ulong *entry);
int fit_image_get_data(const void *fit, int noffset,
const void **data, size_t *size);
int fit_image_get_data_offset(const void *fit, int noffset, int *data_offset);
+int fit_image_get_data_position(const void *fit, int noffset, int *data_position);
int fit_image_get_data_size(const void *fit, int noffset, int *data_size);
int fit_image_hash_get_algo(const void *fit, int noffset, char **algo);