/* Nothing to do! */
}
+__weak struct image_header *spl_get_load_buffer(ssize_t offset, size_t size)
+{
+ return (struct image_header *)(CONFIG_SYS_TEXT_BASE + offset);
+}
+
void spl_set_header_raw_uboot(struct spl_image_info *spl_image)
{
ulong u_boot_pos = binman_sym(ulong, u_boot_any, image_pos);
loff_t filelen, actlen;
disk_partition_t part_info = {};
- header = (struct image_header *)(CONFIG_SYS_TEXT_BASE -
- sizeof(struct image_header));
+ header = spl_get_load_buffer(-sizeof(*header), sizeof(*header));
if (part_get_info(block_dev, partition, &part_info)) {
printf("spl: no partition table found\n");
if (err)
goto end;
- header = (struct image_header *)(CONFIG_SYS_TEXT_BASE -
- sizeof(struct image_header));
+ header = spl_get_load_buffer(-sizeof(*header), sizeof(*header));
err = file_fat_read(filename, header, sizeof(struct image_header));
if (err <= 0)
struct spl_image_info image_info;
int node = -1;
int images, ret;
- int base_offset, align_len = ARCH_DMA_MINALIGN - 1;
+ int base_offset, hsize, align_len = ARCH_DMA_MINALIGN - 1;
int index = 0;
/*
* For FIT with data embedded, data is loaded as part of FIT image.
* For FIT with external data, data is not loaded in this step.
*/
- fit = (void *)((CONFIG_SYS_TEXT_BASE - size - info->bl_len -
- align_len) & ~align_len);
+ hsize = (size + info->bl_len + align_len) & ~align_len;
+ fit = spl_get_load_buffer(-hsize, hsize);
sectors = get_aligned_image_size(info, size, 0);
count = info->read(info, sector, sectors, fit);
debug("fit read sector %lx, sectors=%d, dst=%p, count=%lu\n",
{
unsigned long count;
struct image_header *header;
+ struct blk_desc *bd = mmc_get_blk_desc(mmc);
int ret = 0;
- header = (struct image_header *)(CONFIG_SYS_TEXT_BASE -
- sizeof(struct image_header));
+ header = spl_get_load_buffer(-sizeof(*header), bd->blksz);
/* read image header to find the image size & load address */
- count = blk_dread(mmc_get_blk_desc(mmc), sector, 1, header);
+ count = blk_dread(bd, sector, 1, header);
debug("hdr read sector %lx, count=%lu\n", sector, count);
if (count == 0) {
ret = -EIO;
#endif
nand_init();
- /*use CONFIG_SYS_TEXT_BASE as temporary storage area */
- header = (struct image_header *)(CONFIG_SYS_TEXT_BASE);
+ header = spl_get_load_buffer(0, sizeof(*header));
+
#ifdef CONFIG_SPL_OS_BOOT
if (!spl_start_uboot()) {
/*
debug("spl: onenand\n");
- /*use CONFIG_SYS_TEXT_BASE as temporary storage area */
- header = (struct image_header *)(CONFIG_SYS_TEXT_BASE);
+ header = spl_get_load_buffer(0, CONFIG_SYS_ONENAND_PAGE_SIZE);
/* Load u-boot */
onenand_spl_load_image(CONFIG_SYS_ONENAND_U_BOOT_OFFS,
CONFIG_SYS_ONENAND_PAGE_SIZE, (void *)header);
* No binman support or no information. For now, fix it
* to the address pointed to by U-Boot.
*/
- u_boot_pos = CONFIG_SYS_TEXT_BASE -
- sizeof(struct image_header);
+ header = spl_get_load_buffer(-sizeof(*header),
+ sizeof(*header));
+
}
header = (struct image_header *)map_sysmem(u_boot_pos, 0);
return -ENODEV;
}
- /* use CONFIG_SYS_TEXT_BASE as temporary storage area */
- header = (struct image_header *)(CONFIG_SYS_TEXT_BASE);
+ header = spl_get_load_buffer(-sizeof(*header), 0x40);
#if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
payload_offs = fdtdec_get_config_int(gd->fdt_blob,
puts("Loading Linux failed, falling back to U-Boot.\n");
}
#endif
- header = (struct image_header *)
- (CONFIG_SYS_TEXT_BASE - sizeof(struct image_header));
+ header = spl_get_load_buffer(-sizeof(*header), sizeof(header));
volumes[0].vol_id = CONFIG_SPL_UBI_LOAD_MONITOR_ID;
volumes[0].load_addr = (void *)header;
* the boot-payload
*/
void spl_perform_fixups(struct spl_image_info *spl_image);
+
+/*
+ * spl_get_load_buffer() - get buffer for loading partial image data
+ *
+ * Returns memory area which can be populated by partial image data,
+ * ie. uImage or fitImage header.
+ */
+struct image_header *spl_get_load_buffer(ssize_t offset, size_t size);
+
#endif