return ret;
}
- ret = spl_parse_image_header((void *)CONFIG_SYS_TEXT_BASE);
+ ret = spl_parse_image_header(&spl_image, (void *)CONFIG_SYS_TEXT_BASE);
if (ret)
return ret;
spl_image->name = "U-Boot";
}
-int spl_parse_image_header(const struct image_header *header)
+int spl_parse_image_header(struct spl_image_info *spl_image,
+ const struct image_header *header)
{
u32 header_size = sizeof(struct image_header);
if (image_get_magic(header) == IH_MAGIC) {
- if (spl_image.flags & SPL_COPY_PAYLOAD_ONLY) {
+ if (spl_image->flags & SPL_COPY_PAYLOAD_ONLY) {
/*
* On some system (e.g. powerpc), the load-address and
* entry-point is located at address 0. We can't load
* to 0-0x40. So skip header in this case.
*/
- spl_image.load_addr = image_get_load(header);
- spl_image.entry_point = image_get_ep(header);
- spl_image.size = image_get_data_size(header);
+ spl_image->load_addr = image_get_load(header);
+ spl_image->entry_point = image_get_ep(header);
+ spl_image->size = image_get_data_size(header);
} else {
- spl_image.entry_point = image_get_load(header);
+ spl_image->entry_point = image_get_load(header);
/* Load including the header */
- spl_image.load_addr = spl_image.entry_point -
+ spl_image->load_addr = spl_image->entry_point -
header_size;
- spl_image.size = image_get_data_size(header) +
+ spl_image->size = image_get_data_size(header) +
header_size;
}
- spl_image.os = image_get_os(header);
- spl_image.name = image_get_name(header);
+ spl_image->os = image_get_os(header);
+ spl_image->name = image_get_name(header);
debug("spl: payload image: %.*s load addr: 0x%x size: %d\n",
- (int)sizeof(spl_image.name), spl_image.name,
- spl_image.load_addr, spl_image.size);
+ (int)sizeof(spl_image->name), spl_image->name,
+ spl_image->load_addr, spl_image->size);
} else {
#ifdef CONFIG_SPL_PANIC_ON_RAW_IMAGE
/*
ulong start, end;
if (!bootz_setup((ulong)header, &start, &end)) {
- spl_image.name = "Linux";
- spl_image.os = IH_OS_LINUX;
- spl_image.load_addr = CONFIG_SYS_LOAD_ADDR;
- spl_image.entry_point = CONFIG_SYS_LOAD_ADDR;
- spl_image.size = end - start;
+ spl_image->name = "Linux";
+ spl_image->os = IH_OS_LINUX;
+ spl_image->load_addr = CONFIG_SYS_LOAD_ADDR;
+ spl_image->entry_point = CONFIG_SYS_LOAD_ADDR;
+ spl_image->size = end - start;
debug("spl: payload zImage, load addr: 0x%x size: %d\n",
- spl_image.load_addr, spl_image.size);
+ spl_image->load_addr, spl_image->size);
return 0;
}
#endif
/* Signature not found - assume u-boot.bin */
debug("mkimage signature not found - ih_magic = %x\n",
header->ih_magic);
- spl_set_header_raw_uboot(&spl_image);
+ spl_set_header_raw_uboot(spl_image);
#endif
}
return 0;
header = (struct image_header *)
(CONFIG_SYS_TEXT_BASE - sizeof(struct image_header));
- spl_parse_image_header(header);
+ spl_parse_image_header(&spl_image, header);
}
return 0;
goto end;
}
- err = spl_parse_image_header(header);
+ err = spl_parse_image_header(&spl_image, header);
if (err < 0) {
puts("spl: ext: failed to parse image header\n");
goto end;
return spl_load_simple_fit(&load, 0, header);
} else {
- err = spl_parse_image_header(header);
+ err = spl_parse_image_header(&spl_image, header);
if (err)
goto end;
unsigned long count;
int ret;
- ret = spl_parse_image_header(header);
+ ret = spl_parse_image_header(&spl_image, header);
if (ret)
return ret;
load.read = spl_nand_fit_read;
return spl_load_simple_fit(&load, offset, header);
} else {
- err = spl_parse_image_header(header);
+ err = spl_parse_image_header(&spl_image, header);
if (err)
return err;
return nand_spl_load_image(offset, spl_image.size,
/* load linux */
nand_spl_load_image(CONFIG_SYS_NAND_SPL_KERNEL_OFFS,
sizeof(*header), (void *)header);
- err = spl_parse_image_header(header);
+ err = spl_parse_image_header(&spl_image, header);
if (err)
return err;
if (header->ih_os == IH_OS_LINUX) {
printf("Problem booting with BOOTP\n");
return rv;
}
- return spl_parse_image_header((struct image_header *)load_addr);
+ return spl_parse_image_header(&spl_image,
+ (struct image_header *)load_addr);
}
if (image_get_os(header) == IH_OS_LINUX) {
/* happy - was a Linux */
- ret = spl_parse_image_header(header);
+ ret = spl_parse_image_header(&spl_image, header);
if (ret)
return ret;
* Load real U-Boot from its location in NOR flash to its
* defined location in SDRAM
*/
- ret = spl_parse_image_header(
+ ret = spl_parse_image_header(&spl_image,
(const struct image_header *)CONFIG_SYS_UBOOT_BASE);
if (ret)
return ret;
/* Load u-boot */
onenand_spl_load_image(CONFIG_SYS_ONENAND_U_BOOT_OFFS,
CONFIG_SYS_ONENAND_PAGE_SIZE, (void *)header);
- ret = spl_parse_image_header(header);
+ ret = spl_parse_image_header(&spl_image, header);
if (ret)
return ret;
onenand_spl_load_image(CONFIG_SYS_ONENAND_U_BOOT_OFFS,
ret = ubispl_load_volumes(&info, volumes, 2);
if (!ret) {
header = (struct image_header *)volumes[0].load_addr;
- spl_parse_image_header(header);
+ spl_parse_image_header(&spl_image, header);
puts("Linux loaded.\n");
goto out;
}
ret = ubispl_load_volumes(&info, volumes, 1);
if (!ret)
- spl_parse_image_header(header);
+ spl_parse_image_header(&spl_image, header);
out:
#ifdef CONFIG_SPL_NAND_SUPPORT
if (boot_device == BOOT_DEVICE_NAND)
while ((res = xyzModem_stream_read(buf, BUF_SIZE, &err)) > 0)
size += res;
} else {
- spl_parse_image_header((struct image_header *)buf);
- ret = spl_parse_image_header((struct image_header *)buf);
+ spl_parse_image_header(&spl_image, (struct image_header *)buf);
+ ret = spl_parse_image_header(&spl_image,
+ (struct image_header *)buf);
if (ret)
return ret;
addr = spl_image.load_addr;
if (image_get_magic(header) != IH_MAGIC)
return -1;
- err = spl_parse_image_header(header);
+ err = spl_parse_image_header(&spl_image, header);
if (err)
return err;
CONFIG_SYS_SPI_U_BOOT_OFFS,
header);
} else {
- err = spl_parse_image_header(header);
+ err = spl_parse_image_header(&spl_image, header);
if (err)
return err;
err = spi_flash_read(flash, CONFIG_SYS_SPI_U_BOOT_OFFS,
spi0_init();
spi0_read_data((void *)header, CONFIG_SYS_SPI_U_BOOT_OFFS, 0x40);
- err = spl_parse_image_header(header);
+ err = spl_parse_image_header(&spl_image, header);
if (err)
return err;
* config options: CONFIG_SYS_MONITOR_LEN, CONFIG_SYS_UBOOT_START,
* CONFIG_SYS_TEXT_BASE.
*
- * @spl_image: Image to set up
+ * @spl_image: Image description to set up
*/
void spl_set_header_raw_uboot(struct spl_image_info *spl_image);
-int spl_parse_image_header(const struct image_header *header);
+/**
+ * spl_parse_image_header() - parse the image header and set up info
+ *
+ * This parses the legacy image header information at @header and sets up
+ * @spl_image according to what is found. If no image header is found, then
+ * a raw image or bootz is assumed. If CONFIG_SPL_PANIC_ON_RAW_IMAGE is
+ * enabled, then this causes a panic. If CONFIG_SPL_ABORT_ON_RAW_IMAGE is
+ * enabled then U-Boot gives up. Otherwise U-Boot sets up the image using
+ * spl_set_header_raw_uboot(), or possibly the bootz header.
+ *
+ * @spl_image: Image description to set up
+ * @header image header to parse
+ * @return 0 if a header was correctly parsed, -ve on error
+ */
+int spl_parse_image_header(struct spl_image_info *spl_image,
+ const struct image_header *header);
+
void spl_board_prepare_for_linux(void);
void spl_board_prepare_for_boot(void);
int spl_board_ubi_load_image(u32 boot_device);