Skip to contentSkip to conversation

add FIT data-position & data-offset property support

PATCH Superseded Kelvin Cheung 2 participants 4 messages May 18, 2018 – May 23, 2018

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 add FIT data-position & data-offset property support

Add FIT data-position & data-offset property support for bootm, which were already supported in SPL.

---

Changes for v2:
create fit_image_get_data_and_size() to remove duplicated code

---
 common/image-fit.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++---
 include/image.h    |  2 ++
 2 files changed, 53 insertions(+), 3 deletions(-)
common/image-fit.c +51 -3
index 5b93dce..bc22d8f 100644
@@ -391,7 +391,7 @@ void fit_image_print(const void *fit, int image_noffset, const char *p)
 	fit_image_get_comp(fit, image_noffset, &comp);
 	printf("%s  Compression:  %s\n", p, genimg_get_comp_name(comp));
 
-	ret = fit_image_get_data(fit, image_noffset, &data, &size);
+	ret = fit_image_get_data_and_size(fit, image_noffset, &data, &size);
 
 #ifndef USE_HOSTCC
 	printf("%s  Data Start:   ", p);
@@ -856,6 +856,54 @@ int fit_image_get_data_size(const void *fit, int noffset, int *data_size)
 }
 
 /**
+ * fit_image_get_data - get data and its size including
+ *			both embedded and external data
+ * @fit: pointer to the FIT format image header
+ * @noffset: component image node offset
+ * @data: double pointer to void, will hold data property's data address
+ * @size: pointer to size_t, will hold data property's data size
+ *
+ * fit_image_get_data() finds data and its size including
+ * both embedded and external data. If the property is found
+ * its data start address and size are returned to the caller.
+ *
+ * returns:
+ *     0, on success
+ *     otherwise, on failure
+ */
+int fit_image_get_data_and_size(const void *fit, int noffset,
+				const void **data, size_t *size)
+{
+	bool external_data = false;
+	int offset;
+	int len;
+	int ret;
+
+	if (!fit_image_get_data_position(fit, noffset, &offset)) {
+		external_data = true;
+	} else if (!fit_image_get_data_offset(fit, noffset, &offset)) {
+		external_data = true;
+		/*
+		 * For FIT with external data, figure out where
+		 * the external images start. This is the base
+		 * for the data-offset properties in each image.
+		 */
+		offset += ((fdt_totalsize(fit) + 3) & ~3);
+	}
+
+	if (external_data) {
+		debug("External Data\n");
+		ret = fit_image_get_data_size(fit, noffset, &len);
+		*data = fit + offset;
+		*size = len;
+	} else {
+		ret = fit_image_get_data(fit, noffset, data, size);
+	}
+
+	return ret;
+}
+
+/**
  * fit_image_hash_get_algo - get hash algorithm name
  * @fit: pointer to the FIT format image header
  * @noffset: hash node offset
@@ -1153,7 +1201,7 @@ int fit_image_verify(const void *fit, int image_noffset)
 	char		*err_msg = "";
 
 	/* Get image data and data length */
-	if (fit_image_get_data(fit, image_noffset, &data, &size)) {
+	if (fit_image_get_data_and_size(fit, image_noffset, &data, &size)) {
 		err_msg = "Can't get image data/size";
 		printf("error!\n%s for '%s' hash node in '%s' image node\n",
 		       err_msg, fit_get_name(fit, noffset, NULL),
@@ -1875,7 +1923,7 @@ int fit_image_load(bootm_headers_t *images, ulong addr,
 	bootstage_mark(bootstage_id + BOOTSTAGE_SUB_CHECK_ALL_OK);
 
 	/* get image data address and length */
-	if (fit_image_get_data(fit, noffset, &buf, &size)) {
+	if (fit_image_get_data_and_size(fit, noffset, &buf, &size)) {
 		printf("Could not find %s subimage data!\n", prop_name);
 		bootstage_error(bootstage_id + BOOTSTAGE_SUB_GET_DATA);
 		return -ENOENT;
include/image.h +2 -0
index df701e3..1aed910 100644
@@ -987,6 +987,8 @@ 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_get_data_and_size(const void *fit, int noffset,
+				const void **data, size_t *size);
 
 int fit_image_hash_get_algo(const void *fit, int noffset, char **algo);
 int fit_image_hash_get_value(const void *fit, int noffset, uint8_t **value,
Signature · 1 line
1.9.1
#1 lore raw

PATCH v2 1/1 add FIT data-position & data-offset property support

Hi,

Quoted 6 lines · Kelvin Cheung

Add FIT data-position & data-offset property support for bootm, which were already supported in SPL.

---

Quoted 7 lines

Changes for v2:
create fit_image_get_data_and_size() to remove duplicated code

---
 common/image-fit.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++---
 include/image.h    |  2 ++
 2 files changed, 53 insertions(+), 3 deletions(-)

How can we get this feature integrated into the tests?

Regards,
Simon

#2 lore raw

PATCH v2 1/1 add FIT data-position & data-offset property support

Hi Simon,

2018-05-23 7:30 GMT+08:00 Simon Glass <[email protected]>:

Quoted 15 lines

Hi,

Quoted 11 lines · Kelvin Cheung

Add FIT data-position & data-offset property support for bootm, which were already supported in SPL.

---

Changes for v2:
create fit_image_get_data_and_size() to remove duplicated code

---
 common/image-fit.c | 54 ++++++++++++++++++++++++++++++

+++++++++++++++++++++---

Quoted 8 lines
Quoted 2 lines
 include/image.h    |  2 ++
 2 files changed, 53 insertions(+), 3 deletions(-)

How can we get this feature integrated into the tests?

Do you mean the test scripts under test dir?

BTW, I updated this patch to v3 several days ago.
Thanks!

Quoted 3 lines

Regards,
Simon

Signature · 3 lines
Best regards,

Kelvin Cheung
#3 lore raw

PATCH v2 1/1 add FIT data-position & data-offset property support

Hi Kelvin,

Quoted 23 lines · Kelvin Cheung

Hi Simon,

2018-05-23 7:30 GMT+08:00 Simon Glass <[email protected]>:

Quoted 19 lines

Hi,

Quoted 14 lines · Kelvin Cheung

Add FIT data-position & data-offset property support for bootm, which were already supported in SPL.

---

Changes for v2:
create fit_image_get_data_and_size() to remove duplicated code

---
 common/image-fit.c | 54
+++++++++++++++++++++++++++++++++++++++++++++++++++---
 include/image.h    |  2 ++
 2 files changed, 53 insertions(+), 3 deletions(-)
Quoted 5 lines
Quoted 4 lines

How can we get this feature integrated into the tests?

Do you mean the test scripts under test dir?

I mean the test_fit.py test.

Quoted 2 lines

BTW, I updated this patch to v3 several days ago.

OK, well please take a look at the test.

Regards,
Simon