Skip to content
Snippets Groups Projects
Commit df6f1b89 authored by Marian Balakowicz's avatar Marian Balakowicz
Browse files

[new uImage] Fix component handling for legacy multi component images


Use uint32_t when accessing size table in image_multi_count() and
image_multi_getimg() for multi component images.

Add missing uimage_to_cpu() endianness conversion.

Signed-off-by: default avatarMarian Balakowicz <m8@semihalf.com>
parent 570abb0a
No related branches found
No related tags found
No related merge requests found
...@@ -224,11 +224,11 @@ int image_check_dcrc_wd (image_header_t *hdr, ulong chunksz) ...@@ -224,11 +224,11 @@ int image_check_dcrc_wd (image_header_t *hdr, ulong chunksz)
ulong image_multi_count (image_header_t *hdr) ulong image_multi_count (image_header_t *hdr)
{ {
ulong i, count = 0; ulong i, count = 0;
ulong *size; uint32_t *size;
/* get start of the image payload, which in case of multi /* get start of the image payload, which in case of multi
* component images that points to a table of component sizes */ * component images that points to a table of component sizes */
size = (ulong *)image_get_data (hdr); size = (uint32_t *)image_get_data (hdr);
/* count non empty slots */ /* count non empty slots */
for (i = 0; size[i]; ++i) for (i = 0; size[i]; ++i)
...@@ -258,7 +258,7 @@ void image_multi_getimg (image_header_t *hdr, ulong idx, ...@@ -258,7 +258,7 @@ void image_multi_getimg (image_header_t *hdr, ulong idx,
ulong *data, ulong *len) ulong *data, ulong *len)
{ {
int i; int i;
ulong *size; uint32_t *size;
ulong offset, tail, count, img_data; ulong offset, tail, count, img_data;
/* get number of component */ /* get number of component */
...@@ -266,24 +266,24 @@ void image_multi_getimg (image_header_t *hdr, ulong idx, ...@@ -266,24 +266,24 @@ void image_multi_getimg (image_header_t *hdr, ulong idx,
/* get start of the image payload, which in case of multi /* get start of the image payload, which in case of multi
* component images that points to a table of component sizes */ * component images that points to a table of component sizes */
size = (ulong *)image_get_data (hdr); size = (uint32_t *)image_get_data (hdr);
/* get address of the proper component data start, which means /* get address of the proper component data start, which means
* skipping sizes table (add 1 for last, null entry) */ * skipping sizes table (add 1 for last, null entry) */
img_data = image_get_data (hdr) + (count + 1) * sizeof (ulong); img_data = image_get_data (hdr) + (count + 1) * sizeof (uint32_t);
if (idx < count) { if (idx < count) {
*len = size[idx]; *len = uimage_to_cpu (size[idx]);
offset = 0; offset = 0;
tail = 0; tail = 0;
/* go over all indices preceding requested component idx */ /* go over all indices preceding requested component idx */
for (i = 0; i < idx; i++) { for (i = 0; i < idx; i++) {
/* add up i-th component size */ /* add up i-th component size */
offset += size[i]; offset += uimage_to_cpu (size[i]);
/* add up alignment for i-th component */ /* add up alignment for i-th component */
tail += (4 - size[i] % 4); tail += (4 - uimage_to_cpu (size[i]) % 4);
} }
/* calculate idx-th component data address */ /* calculate idx-th component data address */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment