- if (info->read(info, sector + get_aligned_image_offset(info, offset),
- nr_sectors, (void*)load_ptr) != nr_sectors)
- return -EIO;
- debug("image dst=%lx, offset=%lx, size=%lx\n", load_ptr, offset,
- (unsigned long)length);
+ load_ptr = (load_addr + align_len) & ~align_len;
+ length = len;
+
+ overhead = get_aligned_image_overhead(info, offset);
+ nr_sectors = get_aligned_image_size(info, length, offset);
+
+ if (info->read(info,
+ sector + get_aligned_image_offset(info, offset),
+ nr_sectors, (void *)load_ptr) != nr_sectors)
+ return -EIO;
+
+ debug("External data: dst=%lx, offset=%x, size=%lx\n",
+ load_ptr, offset, (unsigned long)length);
+ src = (void *)load_ptr + overhead;
+ } else {
+ /* Embedded data */
+ if (fit_image_get_data(fit, node, &data, &length)) {
+ puts("Cannot get image data/size\n");
+ return -ENOENT;
+ }
+ debug("Embedded data: dst=%lx, size=%lx\n", load_addr,
+ (unsigned long)length);
+ src = (void *)data;
+ }