return BOOT_DEVICE_RAM;
}
-struct image_header *spl_get_load_buffer(ssize_t offset, size_t size)
+struct legacy_img_hdr *spl_get_load_buffer(ssize_t offset, size_t size)
{
- return (struct image_header *)(CONFIG_SYS_LOAD_ADDR);
+ return (struct legacy_img_hdr *)(CONFIG_SYS_LOAD_ADDR);
}
#ifdef CONFIG_SPL_OS_BOOT
switch (genimg_get_format(buf)) {
#if CONFIG_IS_ENABLED(LEGACY_IMAGE_FORMAT)
case IMAGE_FORMAT_LEGACY:
- return (image_get_image_size((image_header_t *)img_addr)
+ return (image_get_image_size((struct legacy_img_hdr *)img_addr)
+ 0x1000 - 1) & ~(0x1000 - 1);
#endif
#if CONFIG_IS_ENABLED(FIT)
int ret;
u32 offset;
u32 pagesize, size;
- struct image_header *header;
+ struct legacy_img_hdr *header;
u32 image_offset;
ret = rom_api_query_boot_infor(QUERY_IVT_OFF, &offset);
return -1;
}
- header = (struct image_header *)(CONFIG_SPL_IMX_ROMAPI_LOADADDR);
+ header = (struct legacy_img_hdr *)(CONFIG_SPL_IMX_ROMAPI_LOADADDR);
printf("image offset 0x%x, pagesize 0x%x, ivt offset 0x%x\n",
image_offset, pagesize, offset);
offset = spl_romapi_get_uboot_base(image_offset, rom_bt_dev);
- size = ALIGN(sizeof(struct image_header), pagesize);
+ size = ALIGN(sizeof(struct legacy_img_hdr), pagesize);
ret = rom_api_download_image((u8 *)header, offset, size);
if (ret != ROM_API_OKAY) {
* Populate SPL hook to override the default load address used by the SPL
* loader function with a custom address for SYSFW loading.
*/
-struct image_header *spl_get_load_buffer(ssize_t offset, size_t size)
+struct legacy_img_hdr *spl_get_load_buffer(ssize_t offset, size_t size)
{
if (sysfw_loaded)
- return (struct image_header *)(CONFIG_SYS_TEXT_BASE + offset);
+ return (struct legacy_img_hdr *)(CONFIG_SYS_TEXT_BASE + offset);
else if (sysfw_load_address)
return sysfw_load_address;
else
sysfw_loaded = true;
/* Ensure the SYSFW image is in FIT format */
- if (image_get_magic((const image_header_t *)sysfw_load_address) !=
+ if (image_get_magic((const struct legacy_img_hdr *)sysfw_load_address) !=
FDT_MAGIC)
panic("SYSFW image not in FIT format!\n");
{
u32 addr, dpsc_base = 0x1E80000, freq, load_addr, size;
int rcode = 0;
- struct image_header *header;
+ struct legacy_img_hdr *header;
u32 ecrypt_bm_addr = 0;
if (argc < 2)
addr = hextoul(argv[1], NULL);
- header = (struct image_header *)addr;
+ header = (struct legacy_img_hdr *)addr;
if (image_get_magic(header) != IH_MAGIC) {
printf("## Please update monitor image\n");
load_addr = image_get_load(header);
size = image_get_data_size(header);
- memcpy((void *)load_addr, (void *)(addr + sizeof(struct image_header)),
+ memcpy((void *)load_addr, (void *)(addr + sizeof(struct legacy_img_hdr)),
size);
if (argc >= 3)
struct spl_boot_device *bootdev)
{
int ret = 0;
- struct image_header *header;
- header = (struct image_header *)(CONFIG_SYS_TEXT_BASE);
+ struct legacy_img_hdr *header;
uint32_t load_offset = sunxi_get_spl_size();
+ header = (struct legacy_img_hdr *)CONFIG_SYS_TEXT_BASE;
load_offset = max_t(uint32_t, load_offset, CONFIG_SYS_SPI_U_BOOT_OFFS);
spi0_init();
typedef void __noreturn (*image_entry_noargs_t)(void);
struct mmc *mmc;
unsigned long count;
- struct image_header *header;
+ struct legacy_img_hdr *header;
int ret;
/* Set global data pointer */
if (ret)
hang();
- header = (struct image_header *)(CONFIG_SYS_TEXT_BASE -
- sizeof(struct image_header));
+ header = (struct legacy_img_hdr *)(CONFIG_SYS_TEXT_BASE -
+ sizeof(struct legacy_img_hdr));
count = blk_dread(mmc_get_blk_desc(mmc),
CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR,
unsigned long spl_nor_get_uboot_base(void)
{
const struct tpl_info *tpli;
- const image_header_t *hdr;
+ const struct legacy_img_hdr *hdr;
u32 addr;
addr = FLASH_MMAP_BASE + TPL_INFO_OFFSET;
if (tpli->magic == TPL_INFO_MAGIC) {
addr = FLASH_MMAP_BASE + tpli->size;
- hdr = (const image_header_t *)KSEG1ADDR(addr);
+ hdr = (const struct legacy_img_hdr *)KSEG1ADDR(addr);
if (image_get_magic(hdr) == IH_MAGIC) {
addr += sizeof(*hdr) + image_get_size(hdr);
void __noreturn tpl_main(void)
{
- const image_header_t *hdr = (const image_header_t *)__image_copy_end;
+ const struct legacy_img_hdr *hdr = (const struct legacy_img_hdr *)__image_copy_end;
image_entry_noargs_t image_entry;
u32 loadaddr, size;
uintptr_t data;
image_entry = (image_entry_noargs_t)image_get_ep(hdr);
/* Load TPL image to L2 cache */
- data = (uintptr_t)__image_copy_end + sizeof(struct image_header);
+ data = (uintptr_t)__image_copy_end + sizeof(struct legacy_img_hdr);
fill_lock_l2cache(data, loadaddr, size);
/* Jump to SPL */
static int boot_prep_linux(struct bootm_headers *images)
{
char *cmd_line_dest = NULL;
- image_header_t *hdr;
+ struct legacy_img_hdr *hdr;
int is_zimage = 0;
void *data = NULL;
size_t len;
return 0;
}
-struct image_header *spl_get_load_buffer(ssize_t offset, size_t size)
+struct legacy_img_hdr *spl_get_load_buffer(ssize_t offset, size_t size)
{
- return (struct image_header *)(CONFIG_SYS_TEXT_BASE);
+ return (struct legacy_img_hdr *)(CONFIG_SYS_TEXT_BASE);
}
int board_init(void)
void *locate_dtb_in_fit(const void *fit)
{
- struct image_header *header;
+ struct legacy_img_hdr *header;
int size;
int ret;
size = fdt_totalsize(fit);
size = (size + 3) & ~3;
- header = (struct image_header *)fit;
+ header = (struct legacy_img_hdr *)fit;
if (image_get_magic(header) != FDT_MAGIC) {
debug("No FIT image appended to U-boot\n");
* pointer to a legacy image header if valid image was found
* otherwise return NULL
*/
-static image_header_t *image_get_kernel(ulong img_addr, int verify)
+static struct legacy_img_hdr *image_get_kernel(ulong img_addr, int verify)
{
- image_header_t *hdr = (image_header_t *)img_addr;
+ struct legacy_img_hdr *hdr = (struct legacy_img_hdr *)img_addr;
if (!image_check_magic(hdr)) {
puts("Bad Magic Number\n");
ulong *os_data, ulong *os_len)
{
#if CONFIG_IS_ENABLED(LEGACY_IMAGE_FORMAT)
- image_header_t *hdr;
+ struct legacy_img_hdr *hdr;
#endif
ulong img_addr;
const void *buf;
* kernel decompression.
*/
memmove(&images->legacy_hdr_os_copy, hdr,
- sizeof(image_header_t));
+ sizeof(struct legacy_img_hdr));
/* save pointer to image header */
images->legacy_hdr_os = hdr;
static int do_bootm_netbsd(int flag, int argc, char *const argv[],
struct bootm_headers *images)
{
- void (*loader)(struct bd_info *, image_header_t *, char *, char *);
- image_header_t *os_hdr, *hdr;
+ void (*loader)(struct bd_info *bd, struct legacy_img_hdr *hdr,
+ char *console, char *cmdline);
+ struct legacy_img_hdr *os_hdr, *hdr;
ulong kernel_data, kernel_len;
char *cmdline;
cmdline = "";
}
- loader = (void (*)(struct bd_info *, image_header_t *, char *, char *))images->ep;
+ loader = (void (*)(struct bd_info *, struct legacy_img_hdr *, char *, char *))images->ep;
printf("## Transferring control to NetBSD stage-2 loader (at address %08lx) ...\n",
(ulong)loader);
ulong *os_data, ulong *os_len)
{
u32 kernel_addr = android_image_get_kernel_addr(hdr);
- const struct image_header *ihdr = (const struct image_header *)
+ const struct legacy_img_hdr *ihdr = (const struct legacy_img_hdr *)
((uintptr_t)hdr + hdr->page_size);
/*
{
const void *p = (void *)((uintptr_t)hdr + hdr->page_size);
- if (image_get_magic((image_header_t *)p) == IH_MAGIC)
- return image_get_comp((image_header_t *)p);
+ if (image_get_magic((struct legacy_img_hdr *)p) == IH_MAGIC)
+ return image_get_comp((struct legacy_img_hdr *)p);
else if (get_unaligned_le32(p) == LZ4F_MAGIC)
return IH_COMP_LZ4;
else
* pointer to a ramdisk image header, if image was found and valid
* otherwise, return NULL
*/
-static const image_header_t *image_get_ramdisk(ulong rd_addr, u8 arch,
- int verify)
+static const struct legacy_img_hdr *image_get_ramdisk(ulong rd_addr, u8 arch,
+ int verify)
{
- const image_header_t *rd_hdr = (const image_header_t *)rd_addr;
+ const struct legacy_img_hdr *rd_hdr = (const struct legacy_img_hdr *)rd_addr;
if (!image_check_magic(rd_hdr)) {
puts("Bad Magic Number\n");
int genimg_get_format(const void *img_addr)
{
if (CONFIG_IS_ENABLED(LEGACY_IMAGE_FORMAT)) {
- const image_header_t *hdr;
+ const struct legacy_img_hdr *hdr;
- hdr = (const image_header_t *)img_addr;
+ hdr = (const struct legacy_img_hdr *)img_addr;
if (image_check_magic(hdr))
return IMAGE_FORMAT_LEGACY;
}
switch (genimg_get_format(buf)) {
case IMAGE_FORMAT_LEGACY:
if (CONFIG_IS_ENABLED(LEGACY_IMAGE_FORMAT)) {
- const image_header_t *rd_hdr;
+ const struct legacy_img_hdr *rd_hdr;
printf("## Loading init Ramdisk from Legacy Image at %08lx ...\n",
rd_addr);
}
#if CONFIG_IS_ENABLED(LEGACY_IMAGE_FORMAT)
-static const image_header_t *image_get_fdt(ulong fdt_addr)
+static const struct legacy_img_hdr *image_get_fdt(ulong fdt_addr)
{
- const image_header_t *fdt_hdr = map_sysmem(fdt_addr, 0);
+ const struct legacy_img_hdr *fdt_hdr = map_sysmem(fdt_addr, 0);
image_print_contents(fdt_hdr);
switch (genimg_get_format(buf)) {
#if CONFIG_IS_ENABLED(LEGACY_IMAGE_FORMAT)
case IMAGE_FORMAT_LEGACY: {
- const image_header_t *fdt_hdr;
+ const struct legacy_img_hdr *fdt_hdr;
ulong load, load_end;
ulong image_start, image_data, image_end;
/*****************************************************************************/
/* Legacy format routines */
/*****************************************************************************/
-int image_check_hcrc(const image_header_t *hdr)
+int image_check_hcrc(const struct legacy_img_hdr *hdr)
{
ulong hcrc;
ulong len = image_get_header_size();
- image_header_t header;
+ struct legacy_img_hdr header;
/* Copy header so we can blank CRC field for re-calculation */
memmove(&header, (char *)hdr, image_get_header_size());
return (hcrc == image_get_hcrc(hdr));
}
-int image_check_dcrc(const image_header_t *hdr)
+int image_check_dcrc(const struct legacy_img_hdr *hdr)
{
ulong data = image_get_data(hdr);
ulong len = image_get_data_size(hdr);
* returns:
* number of components
*/
-ulong image_multi_count(const image_header_t *hdr)
+ulong image_multi_count(const struct legacy_img_hdr *hdr)
{
ulong i, count = 0;
uint32_t *size;
* data address and size of the component, if idx is valid
* 0 in data and len, if idx is out of range
*/
-void image_multi_getimg(const image_header_t *hdr, ulong idx,
+void image_multi_getimg(const struct legacy_img_hdr *hdr, ulong idx,
ulong *data, ulong *len)
{
int i;
}
}
-static void image_print_type(const image_header_t *hdr)
+static void image_print_type(const struct legacy_img_hdr *hdr)
{
const char __maybe_unused *os, *arch, *type, *comp;
*/
void image_print_contents(const void *ptr)
{
- const image_header_t *hdr = (const image_header_t *)ptr;
+ const struct legacy_img_hdr *hdr = (const struct legacy_img_hdr *)ptr;
const char __maybe_unused *p;
p = IMAGE_INDENT_STRING;
continue;
for (off = 0; off < mtd->size; off += mtd->erasesize) {
- const image_header_t *header;
+ const struct legacy_img_hdr *header;
int ret;
if (nand_block_isbad(mtd, off))
switch (genimg_get_format(buffer)) {
#if defined(CONFIG_LEGACY_IMAGE_FORMAT)
case IMAGE_FORMAT_LEGACY:
- header = (const image_header_t *)buffer;
+ header = (const struct legacy_img_hdr *)buffer;
len = image_get_image_size(header);
nand_imls_legacyimage(mtd, nand_dev, off, len);
ulong cnt;
struct disk_partition info;
#if defined(CONFIG_LEGACY_IMAGE_FORMAT)
- image_header_t *hdr;
+ struct legacy_img_hdr *hdr;
#endif
struct blk_desc *dev_desc;
switch (genimg_get_format((void *) addr)) {
#if defined(CONFIG_LEGACY_IMAGE_FORMAT)
case IMAGE_FORMAT_LEGACY:
- hdr = (image_header_t *) addr;
+ hdr = (struct legacy_img_hdr *)addr;
bootstage_mark(BOOTSTAGE_ID_IDE_FORMAT);
#if defined(CONFIG_LEGACY_IMAGE_FORMAT)
case IMAGE_FORMAT_LEGACY:
{
- image_header_t *hdr = (image_header_t *)fpga_data;
+ struct legacy_img_hdr *hdr = (struct legacy_img_hdr *)fpga_data;
ulong data;
u8 comp;
char *s;
size_t cnt;
#if defined(CONFIG_LEGACY_IMAGE_FORMAT)
- image_header_t *hdr;
+ struct legacy_img_hdr *hdr;
#endif
#if defined(CONFIG_FIT)
const void *fit_hdr = NULL;
switch (genimg_get_format ((void *)addr)) {
#if defined(CONFIG_LEGACY_IMAGE_FORMAT)
case IMAGE_FORMAT_LEGACY:
- hdr = (image_header_t *)addr;
+ hdr = (struct legacy_img_hdr *)addr;
bootstage_mark(BOOTSTAGE_ID_NAND_TYPE);
image_print_contents (hdr);
{
ulong len;
#if defined(CONFIG_LEGACY_IMAGE_FORMAT)
- const image_header_t *hdr;
+ const struct legacy_img_hdr *hdr;
#endif
u32 *data;
int verify;
int part = 0;
#if defined(CONFIG_LEGACY_IMAGE_FORMAT)
ulong count;
- image_header_t *hdr = NULL;
+ struct legacy_img_hdr *hdr = NULL;
#endif
#if defined(CONFIG_FIT)
const char *uname = NULL;
printf("## Copying part %d from legacy image "
"at %08lx ...\n", part, addr);
- hdr = (image_header_t *)addr;
+ hdr = (struct legacy_img_hdr *)addr;
if (!image_check_magic(hdr)) {
printf("Bad Magic Number\n");
return 1;
/* Nothing to do! */
}
-__weak struct image_header *spl_get_load_buffer(ssize_t offset, size_t size)
+__weak struct legacy_img_hdr *spl_get_load_buffer(ssize_t offset, size_t size)
{
return map_sysmem(CONFIG_SYS_TEXT_BASE + offset, 0);
}
#if CONFIG_IS_ENABLED(LOAD_FIT_FULL)
/* Parse and load full fitImage in SPL */
static int spl_load_fit_image(struct spl_image_info *spl_image,
- const struct image_header *header)
+ const struct legacy_img_hdr *header)
{
struct bootm_headers images;
const char *fit_uname_config = NULL;
}
__weak int spl_parse_legacy_header(struct spl_image_info *spl_image,
- const struct image_header *header)
+ const struct legacy_img_hdr *header)
{
/* LEGACY image not supported */
debug("Legacy boot image support not enabled, proceeding to other boot methods\n");
int spl_parse_image_header(struct spl_image_info *spl_image,
const struct spl_boot_device *bootdev,
- const struct image_header *header)
+ const struct legacy_img_hdr *header)
{
#if CONFIG_IS_ENABLED(LOAD_FIT_FULL)
int ret = spl_load_fit_image(spl_image, header);
const char *filename)
{
s32 err;
- struct image_header *header;
+ struct legacy_img_hdr *header;
loff_t filelen, actlen;
struct disk_partition part_info = {};
puts("spl: ext4fs_open failed\n");
goto end;
}
- err = ext4fs_read((char *)header, 0, sizeof(struct image_header), &actlen);
+ err = ext4fs_read((char *)header, 0, sizeof(struct legacy_img_hdr), &actlen);
if (err < 0) {
puts("spl: ext4fs_read failed\n");
goto end;
const char *filename)
{
int err;
- struct image_header *header;
+ struct legacy_img_hdr *header;
err = spl_register_fat_device(block_dev, partition);
if (err)
header = spl_get_load_buffer(-sizeof(*header), sizeof(*header));
- err = file_fat_read(filename, header, sizeof(struct image_header));
+ err = file_fat_read(filename, header, sizeof(struct legacy_img_hdr));
if (err <= 0)
goto end;
if (err <= 0)
goto end;
err = spl_parse_image_header(spl_image, bootdev,
- (struct image_header *)CONFIG_SYS_LOAD_ADDR);
+ (struct legacy_img_hdr *)CONFIG_SYS_LOAD_ADDR);
if (err == -EAGAIN)
return err;
if (err == 0)
#define LZMA_LEN (1 << 20)
int spl_parse_legacy_header(struct spl_image_info *spl_image,
- const struct image_header *header)
+ const struct legacy_img_hdr *header)
{
- u32 header_size = sizeof(struct image_header);
+ u32 header_size = sizeof(struct legacy_img_hdr);
/* check uImage header CRC */
if (IS_ENABLED(CONFIG_SPL_LEGACY_IMAGE_CRC_CHECK) &&
* following switch/case statement in spl_load_legacy_img() away due to
* Dead Code Elimination.
*/
-static inline int spl_image_get_comp(const struct image_header *hdr)
+static inline int spl_image_get_comp(const struct legacy_img_hdr *hdr)
{
if (IS_ENABLED(CONFIG_SPL_LZMA))
return image_get_comp(hdr);
{
__maybe_unused SizeT lzma_len;
__maybe_unused void *src;
- struct image_header hdr;
+ struct legacy_img_hdr hdr;
ulong dataptr;
int ret;
static int mmc_load_legacy(struct spl_image_info *spl_image,
struct spl_boot_device *bootdev,
struct mmc *mmc,
- ulong sector, struct image_header *header)
+ ulong sector, struct legacy_img_hdr *header)
{
u32 image_offset_sectors;
u32 image_size_sectors;
struct mmc *mmc, unsigned long sector)
{
unsigned long count;
- struct image_header *header;
+ struct legacy_img_hdr *header;
struct blk_desc *bd = mmc_get_blk_desc(mmc);
int ret = 0;
static int spl_nand_load_element(struct spl_image_info *spl_image,
struct spl_boot_device *bootdev,
- int offset, struct image_header *header)
+ int offset, struct legacy_img_hdr *header)
{
struct mtd_info *mtd = nand_get_mtd();
int bl_len = mtd ? mtd->writesize : 1;
struct spl_boot_device *bootdev)
{
int err;
- struct image_header *header;
+ struct legacy_img_hdr *header;
int *src __attribute__((unused));
int *dst __attribute__((unused));
static int spl_net_load_image(struct spl_image_info *spl_image,
struct spl_boot_device *bootdev)
{
- struct image_header *header = (struct image_header *)image_load_addr;
+ struct legacy_img_hdr *header = (struct legacy_img_hdr *)image_load_addr;
int rv;
env_init();
static int spl_nor_load_image(struct spl_image_info *spl_image,
struct spl_boot_device *bootdev)
{
- __maybe_unused const struct image_header *header;
+ __maybe_unused const struct legacy_img_hdr *header;
__maybe_unused struct spl_load_info load;
/*
* Load Linux from its location in NOR flash to its defined
* location in SDRAM
*/
- header = (const struct image_header *)CONFIG_SYS_OS_BASE;
+ header = (const struct legacy_img_hdr *)CONFIG_SYS_OS_BASE;
#ifdef CONFIG_SPL_LOAD_FIT
if (image_get_magic(header) == FDT_MAGIC) {
int ret;
memcpy((void *)spl_image->load_addr,
(void *)(CONFIG_SYS_OS_BASE +
- sizeof(struct image_header)),
+ sizeof(struct legacy_img_hdr)),
spl_image->size);
#ifdef CONFIG_SYS_SPL_ARGS_ADDR
spl_image->arg = (void *)CONFIG_SYS_SPL_ARGS_ADDR;
* defined location in SDRAM
*/
#ifdef CONFIG_SPL_LOAD_FIT
- header = (const struct image_header *)spl_nor_get_uboot_base();
+ header = (const struct legacy_img_hdr *)spl_nor_get_uboot_base();
if (image_get_magic(header) == FDT_MAGIC) {
debug("Found FIT format U-Boot\n");
load.bl_len = 1;
static int spl_onenand_load_image(struct spl_image_info *spl_image,
struct spl_boot_device *bootdev)
{
- struct image_header *header;
+ struct legacy_img_hdr *header;
int ret;
debug("spl: onenand\n");
static int spl_ram_load_image(struct spl_image_info *spl_image,
struct spl_boot_device *bootdev)
{
- struct image_header *header;
+ struct legacy_img_hdr *header;
- header = (struct image_header *)CONFIG_SPL_LOAD_FIT_ADDRESS;
+ header = (struct legacy_img_hdr *)CONFIG_SPL_LOAD_FIT_ADDRESS;
if (CONFIG_IS_ENABLED(IMAGE_PRE_LOAD)) {
unsigned long addr = (unsigned long)header;
return ret;
addr += image_load_offset;
- header = (struct image_header *)addr;
+ header = (struct legacy_img_hdr *)addr;
}
#if CONFIG_IS_ENABLED(DFU)
u_boot_pos = (ulong)spl_get_load_buffer(-sizeof(*header),
sizeof(*header));
}
- header = (struct image_header *)map_sysmem(u_boot_pos, 0);
+ header = (struct legacy_img_hdr *)map_sysmem(u_boot_pos, 0);
spl_parse_image_header(spl_image, bootdev, header);
}
struct spl_boot_device *bootdev,
struct blk_desc *stor_dev, unsigned long sector)
{
- struct image_header *header;
+ struct legacy_img_hdr *header;
unsigned long count;
u32 image_size_sectors;
u32 image_offset_sectors;
const char *filename = CONFIG_SPL_FS_LOAD_PAYLOAD_NAME;
int ret;
long fd, len;
- struct image_header *header =
+ struct legacy_img_hdr *header =
spl_get_load_buffer(-sizeof(*header), sizeof(*header));
fd = smh_open(filename, MODE_READ | MODE_BINARY);
}
len = ret;
- ret = smh_read_full(fd, header, sizeof(struct image_header));
+ ret = smh_read_full(fd, header, sizeof(struct legacy_img_hdr));
if (ret) {
log_debug("could not read image header: %d\n", ret);
goto out;
static int spi_load_image_os(struct spl_image_info *spl_image,
struct spl_boot_device *bootdev,
struct spi_flash *flash,
- struct image_header *header)
+ struct legacy_img_hdr *header)
{
int err;
int err = 0;
unsigned int payload_offs;
struct spi_flash *flash;
- struct image_header *header;
+ struct legacy_img_hdr *header;
unsigned int sf_bus = spl_spi_boot_bus();
unsigned int sf_cs = spl_spi_boot_cs();
if (err)
return err;
err = spl_parse_image_header(spl_image, bootdev,
- (struct image_header *)CONFIG_SYS_LOAD_ADDR);
+ (struct legacy_img_hdr *)CONFIG_SYS_LOAD_ADDR);
} else if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
image_get_magic(header) == FDT_MAGIC) {
struct spl_load_info load;
int spl_ubi_load_image(struct spl_image_info *spl_image,
struct spl_boot_device *bootdev)
{
- struct image_header *header;
+ struct legacy_img_hdr *header;
struct ubispl_info info;
struct ubispl_load volumes[2];
int ret = 1;
ret = ubispl_load_volumes(&info, volumes, 2);
if (!ret) {
- header = (struct image_header *)volumes[0].load_addr;
+ header = (struct legacy_img_hdr *)volumes[0].load_addr;
spl_parse_image_header(spl_image, bootdev, header);
puts("Linux loaded.\n");
goto out;
}
#endif
return(spl_parse_image_header(spl_image, bootdev,
- (const struct image_header *)CONFIG_SYS_UBOOT_BASE));
+ (const struct legacy_img_hdr *)CONFIG_SYS_UBOOT_BASE));
}
SPL_LOAD_IMAGE_METHOD("XIP", 0, BOOT_DEVICE_XIP, spl_xip);
int ret;
connection_info_t info;
char buf[BUF_SIZE];
- struct image_header *ih = NULL;
+ struct legacy_img_hdr *ih = NULL;
ulong addr = 0;
info.mode = xyzModem_ymodem;
goto end_stream;
if (IS_ENABLED(CONFIG_SPL_LOAD_FIT_FULL) &&
- image_get_magic((struct image_header *)buf) == FDT_MAGIC) {
+ image_get_magic((struct legacy_img_hdr *)buf) == FDT_MAGIC) {
addr = CONFIG_SYS_LOAD_ADDR;
- ih = (struct image_header *)addr;
+ ih = (struct legacy_img_hdr *)addr;
memcpy((void *)addr, buf, res);
size += res;
if (ret)
return ret;
} else if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
- image_get_magic((struct image_header *)buf) == FDT_MAGIC) {
+ image_get_magic((struct legacy_img_hdr *)buf) == FDT_MAGIC) {
struct spl_load_info load;
struct ymodem_fit_info info;
while ((res = xyzModem_stream_read(buf, BUF_SIZE, &err)) > 0)
size += res;
} else {
- ih = (struct image_header *)buf;
+ ih = (struct legacy_img_hdr *)buf;
ret = spl_parse_image_header(spl_image, bootdev, ih);
if (ret)
goto end_stream;
#endif
addr = spl_image->load_addr;
memcpy((void *)addr, buf, res);
- ih = (struct image_header *)addr;
+ ih = (struct legacy_img_hdr *)addr;
size += res;
addr += res;
#ifdef CONFIG_SPL_GZIP
if (!(IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
- image_get_magic((struct image_header *)buf) == FDT_MAGIC) &&
+ image_get_magic((struct legacy_img_hdr *)buf) == FDT_MAGIC) &&
(ih->ih_comp == IH_COMP_GZIP)) {
if (gunzip((void *)(spl_image->load_addr + sizeof(*ih)),
CONFIG_SYS_BOOTM_LEN,
int external_splash_addr;
int external_splash_size;
bool is_splash_external = false;
- struct image_header *img_header;
+ struct legacy_img_hdr *img_header;
const u32 *fit_header;
u32 fit_size;
- const size_t header_size = sizeof(struct image_header);
+ const size_t header_size = sizeof(struct legacy_img_hdr);
/* Read in image header */
res = splash_storage_read_raw(location, bmp_load_addr, header_size);
if (res < 0)
return res;
- img_header = (struct image_header *)bmp_load_addr;
+ img_header = (struct legacy_img_hdr *)bmp_load_addr;
if (image_get_magic(img_header) != FDT_MAGIC) {
printf("Could not find FDT magic\n");
return -EINVAL;
missing: FDT is not present for legacy platforms, ramdisk is always optional.
Additionally, old uImage format has been extended to support multi sub-images
but the support is limited by simple format of the legacy uImage structure.
-Single binary header 'struct image_header' is not flexible enough to cover all
+Single binary header 'struct legacy_img_hdr' is not flexible enough to cover all
possible scenarios.
All those factors combined clearly show that there is a need for new, more
/* Load image header into buffer */
ret = request_firmware_into_buf(dev,
fpga_loadfs->fpga_fsinfo->filename,
- buffer_p, sizeof(struct image_header),
+ buffer_p, sizeof(struct legacy_img_hdr),
0);
if (ret < 0) {
debug("FPGA: Failed to read image header from flash.\n");
return -ENOENT;
}
- if (image_get_magic((struct image_header *)buffer_p) != FDT_MAGIC) {
+ if (image_get_magic((struct legacy_img_hdr *)buffer_p) != FDT_MAGIC) {
debug("FPGA: No FDT magic was found.\n");
return -EBADF;
}
printf("Found header at 0x%08x\n", sdp_func->jmp_address);
- image_header_t *header =
+ struct legacy_img_hdr *header =
sdp_ptr(sdp_func->jmp_address);
#ifdef CONFIG_SPL_LOAD_FIT
if (image_get_magic(header) == FDT_MAGIC) {
/* only for SPL */
-/* subtract sizeof(struct image_header) */
+/* subtract sizeof(struct legacy_img_hdr) */
#define CONFIG_SYS_UBOOT_BASE (0x130000 - 0x40)
#endif /* __CONFIG_UNIPHIER_H__ */
* Legacy format image header,
* all data in network byte order (aka natural aka bigendian).
*/
-typedef struct image_header {
+struct legacy_img_hdr {
uint32_t ih_magic; /* Image Header Magic Number */
uint32_t ih_hcrc; /* Image Header CRC Checksum */
uint32_t ih_time; /* Image Creation Timestamp */
uint8_t ih_type; /* Image Type */
uint8_t ih_comp; /* Compression Type */
uint8_t ih_name[IH_NMLEN]; /* Image Name */
-} image_header_t;
+};
struct image_info {
ulong start, end; /* start/end of blob */
* then boot_get_ramdisk() and get_fdt() will attempt to get
* data from second and third component accordingly.
*/
- image_header_t *legacy_hdr_os; /* image header pointer */
- image_header_t legacy_hdr_os_copy; /* header copy */
+ struct legacy_img_hdr *legacy_hdr_os; /* image header pointer */
+ struct legacy_img_hdr legacy_hdr_os_copy; /* header copy */
ulong legacy_hdr_valid;
/*
/*******************************************************************/
static inline uint32_t image_get_header_size(void)
{
- return (sizeof(image_header_t));
+ return sizeof(struct legacy_img_hdr);
}
#define image_get_hdr_l(f) \
- static inline uint32_t image_get_##f(const image_header_t *hdr) \
+ static inline uint32_t image_get_##f(const struct legacy_img_hdr *hdr) \
{ \
return uimage_to_cpu(hdr->ih_##f); \
}
image_get_hdr_l(dcrc) /* image_get_dcrc */
#define image_get_hdr_b(f) \
- static inline uint8_t image_get_##f(const image_header_t *hdr) \
+ static inline uint8_t image_get_##f(const struct legacy_img_hdr *hdr) \
{ \
return hdr->ih_##f; \
}
image_get_hdr_b(type) /* image_get_type */
image_get_hdr_b(comp) /* image_get_comp */
-static inline char *image_get_name(const image_header_t *hdr)
+static inline char *image_get_name(const struct legacy_img_hdr *hdr)
{
return (char *)hdr->ih_name;
}
-static inline uint32_t image_get_data_size(const image_header_t *hdr)
+static inline uint32_t image_get_data_size(const struct legacy_img_hdr *hdr)
{
return image_get_size(hdr);
}
* returns:
* image payload data start address
*/
-static inline ulong image_get_data(const image_header_t *hdr)
+static inline ulong image_get_data(const struct legacy_img_hdr *hdr)
{
return ((ulong)hdr + image_get_header_size());
}
-static inline uint32_t image_get_image_size(const image_header_t *hdr)
+static inline uint32_t image_get_image_size(const struct legacy_img_hdr *hdr)
{
return (image_get_size(hdr) + image_get_header_size());
}
-static inline ulong image_get_image_end(const image_header_t *hdr)
+
+static inline ulong image_get_image_end(const struct legacy_img_hdr *hdr)
{
return ((ulong)hdr + image_get_image_size(hdr));
}
#define image_set_hdr_l(f) \
- static inline void image_set_##f(image_header_t *hdr, uint32_t val) \
+ static inline void image_set_##f(struct legacy_img_hdr *hdr, uint32_t val) \
{ \
hdr->ih_##f = cpu_to_uimage(val); \
}
image_set_hdr_l(dcrc) /* image_set_dcrc */
#define image_set_hdr_b(f) \
- static inline void image_set_##f(image_header_t *hdr, uint8_t val) \
+ static inline void image_set_##f(struct legacy_img_hdr *hdr, uint8_t val) \
{ \
hdr->ih_##f = val; \
}
image_set_hdr_b(type) /* image_set_type */
image_set_hdr_b(comp) /* image_set_comp */
-static inline void image_set_name(image_header_t *hdr, const char *name)
+static inline void image_set_name(struct legacy_img_hdr *hdr, const char *name)
{
strncpy(image_get_name(hdr), name, IH_NMLEN);
}
-int image_check_hcrc(const image_header_t *hdr);
-int image_check_dcrc(const image_header_t *hdr);
+int image_check_hcrc(const struct legacy_img_hdr *hdr);
+int image_check_dcrc(const struct legacy_img_hdr *hdr);
#ifndef USE_HOSTCC
ulong env_get_bootm_low(void);
phys_size_t env_get_bootm_size(void);
#endif
void memmove_wd(void *to, void *from, size_t len, ulong chunksz);
-static inline int image_check_magic(const image_header_t *hdr)
+static inline int image_check_magic(const struct legacy_img_hdr *hdr)
{
return (image_get_magic(hdr) == IH_MAGIC);
}
-static inline int image_check_type(const image_header_t *hdr, uint8_t type)
+
+static inline int image_check_type(const struct legacy_img_hdr *hdr, uint8_t type)
{
return (image_get_type(hdr) == type);
}
-static inline int image_check_arch(const image_header_t *hdr, uint8_t arch)
+
+static inline int image_check_arch(const struct legacy_img_hdr *hdr, uint8_t arch)
{
/* Let's assume that sandbox can load any architecture */
if (!tools_build() && IS_ENABLED(CONFIG_SANDBOX))
return (image_get_arch(hdr) == arch) ||
(image_get_arch(hdr) == IH_ARCH_ARM && arch == IH_ARCH_ARM64);
}
-static inline int image_check_os(const image_header_t *hdr, uint8_t os)
+
+static inline int image_check_os(const struct legacy_img_hdr *hdr, uint8_t os)
{
return (image_get_os(hdr) == os);
}
-ulong image_multi_count(const image_header_t *hdr);
-void image_multi_getimg(const image_header_t *hdr, ulong idx,
+ulong image_multi_count(const struct legacy_img_hdr *hdr);
+void image_multi_getimg(const struct legacy_img_hdr *hdr, ulong idx,
ulong *data, ulong *len);
void image_print_contents(const void *hdr);
#ifndef USE_HOSTCC
-static inline int image_check_target_arch(const image_header_t *hdr)
+static inline int image_check_target_arch(const struct legacy_img_hdr *hdr)
{
#ifndef IH_ARCH_DEFAULT
# error "please define IH_ARCH_DEFAULT in your arch asm/u-boot.h"
#include <mmc.h>
struct blk_desc;
-struct image_header;
+struct legacy_img_hdr;
/* Value in r0 indicates we booted from U-Boot */
#define UBOOT_NOT_LOADED_FROM_SPL 0x13578642
#define MMCSD_MODE_EMMCBOOT 3
struct blk_desc;
-struct image_header;
+struct legacy_img_hdr;
struct spl_boot_device;
/*
*/
int spl_parse_image_header(struct spl_image_info *spl_image,
const struct spl_boot_device *bootdev,
- const struct image_header *header);
+ const struct legacy_img_hdr *header);
void spl_board_prepare_for_linux(void);
* 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);
+struct legacy_img_hdr *spl_get_load_buffer(ssize_t offset, size_t size);
void spl_save_restore_data(void);
#endif
};
static inline uint32_t
-optee_image_get_entry_point(const struct image_header *hdr)
+optee_image_get_entry_point(const struct legacy_img_hdr *hdr)
{
struct optee_header *optee_hdr = (struct optee_header *)(hdr + 1);
}
static inline uint32_t
-optee_image_get_load_addr(const struct image_header *hdr)
+optee_image_get_load_addr(const struct legacy_img_hdr *hdr)
{
return optee_image_get_entry_point(hdr) - sizeof(struct optee_header);
}
return 0;
}
-struct image_header *spl_get_load_buffer(ssize_t offset, size_t size)
+struct legacy_img_hdr *spl_get_load_buffer(ssize_t offset, size_t size)
{
return map_sysmem(0x100000, 0);
}
static int spl_test_load(struct unit_test_state *uts)
{
struct spl_image_info image;
- struct image_header *header;
+ struct legacy_img_hdr *header;
struct text_ctx text_ctx;
struct spl_load_info load;
char fname[256];
# Check that the data appears in the file somewhere
self.assertIn(U_BOOT_SPL_DATA, data)
- # Get struct image_header -> ih_name
+ # Get struct legacy_img_hdr -> ih_name
name = data[0x20:0x40]
# Build the filename that we expect to be placed in there, by virtue of
# Check that the data appears in the file somewhere
self.assertIn(U_BOOT_SPL_DATA, data)
- # Get struct image_header -> ih_name
+ # Get struct legacy_img_hdr -> ih_name
name = data[0x20:0x40]
# Build the filename that we expect to be placed in there, by virtue of
#include <u-boot/crc.h>
#include <imximage.h>
-static image_header_t header;
+static struct legacy_img_hdr header;
static int image_check_image_types(uint8_t type)
{
uint32_t len;
const unsigned char *data;
uint32_t checksum;
- image_header_t header;
- image_header_t *hdr = &header;
+ struct legacy_img_hdr header;
+ struct legacy_img_hdr *hdr = &header;
/*
* create copy of header so that we can blank out the
* checksum field for checking - this can't be done
* on the PROT_READ mapped data.
*/
- memcpy(hdr, ptr, sizeof(image_header_t));
+ memcpy(hdr, ptr, sizeof(struct legacy_img_hdr));
if (be32_to_cpu(hdr->ih_magic) != IH_MAGIC) {
debug("%s: Bad Magic Number: \"%s\" is no valid image\n",
}
data = (const unsigned char *)hdr;
- len = sizeof(image_header_t);
+ len = sizeof(struct legacy_img_hdr);
checksum = be32_to_cpu(hdr->ih_hcrc);
hdr->ih_hcrc = cpu_to_be32(0); /* clear for re-calculation */
return -FDT_ERR_BADSTATE;
}
- data = (const unsigned char *)ptr + sizeof(image_header_t);
- len = image_size - sizeof(image_header_t) ;
+ data = (const unsigned char *)ptr + sizeof(struct legacy_img_hdr);
+ len = image_size - sizeof(struct legacy_img_hdr);
checksum = be32_to_cpu(hdr->ih_dcrc);
if (crc32(0, data, len) != checksum) {
uint32_t imagesize;
uint32_t ep;
uint32_t addr;
-
- image_header_t * hdr = (image_header_t *)ptr;
+ struct legacy_img_hdr *hdr = (struct legacy_img_hdr *)ptr;
checksum = crc32(0,
(const unsigned char *)(ptr +
- sizeof(image_header_t)),
- sbuf->st_size - sizeof(image_header_t));
+ sizeof(struct legacy_img_hdr)),
+ sbuf->st_size - sizeof(struct legacy_img_hdr));
time = imagetool_get_source_date(params->cmdname, sbuf->st_mtime);
ep = params->ep;
if (params->type == IH_TYPE_FIRMWARE_IVT)
/* Add size of CSF minus IVT */
- imagesize = sbuf->st_size - sizeof(image_header_t)
+ imagesize = sbuf->st_size - sizeof(struct legacy_img_hdr)
+ 0x2060 - sizeof(flash_header_v2_t);
else
- imagesize = sbuf->st_size - sizeof(image_header_t);
+ imagesize = sbuf->st_size - sizeof(struct legacy_img_hdr);
if (params->os == IH_OS_TEE) {
addr = optee_image_get_load_addr(hdr);
image_set_name(hdr, params->imagename);
checksum = crc32(0, (const unsigned char *)hdr,
- sizeof(image_header_t));
+ sizeof(struct legacy_img_hdr));
image_set_hcrc(hdr, checksum);
}
static int image_extract_subimage(void *ptr, struct image_tool_params *params)
{
- const image_header_t *hdr = (const image_header_t *)ptr;
+ const struct legacy_img_hdr *hdr = (const struct legacy_img_hdr *)ptr;
ulong file_data;
ulong file_len;
U_BOOT_IMAGE_TYPE(
defimage,
"Default Image support",
- sizeof(image_header_t),
+ sizeof(struct legacy_img_hdr),
(void *)&header,
image_check_params,
image_verify_header,
#include <version.h>
#include <u-boot/crc.h>
-static image_header_t header;
+static struct legacy_img_hdr header;
static int fit_add_file_data(struct image_tool_params *params, size_t size_inc,
const char *tmpfile)
U_BOOT_IMAGE_TYPE(
fitimage,
"FIT Image support",
- sizeof(image_header_t),
+ sizeof(struct legacy_img_hdr),
(void *)&header,
fit_check_params,
fit_verify_header,
static int generate_ivt_for_fit(int fd, int fit_offset, uint32_t ep,
uint32_t *fit_load_addr)
{
- image_header_t image_header;
+ struct legacy_img_hdr image_header;
int ret;
uint32_t fit_size, load_addr;
exit(EXIT_FAILURE);
}
- if (read(fd, (char *)&image_header, sizeof(image_header_t)) !=
- sizeof(image_header_t)) {
+ if (read(fd, (char *)&image_header, sizeof(struct legacy_img_hdr)) !=
+ sizeof(struct legacy_img_hdr)) {
fprintf(stderr, "generate_ivt_for_fit read failed: %s\n",
strerror(errno));
exit(EXIT_FAILURE);
close(sld_fd);
file_off = sld_header_off;
- file_off += sbuf.st_size + sizeof(image_header_t);
+ file_off += sbuf.st_size + sizeof(struct legacy_img_hdr);
}
}
if (params.xflag) {
unsigned char *p = NULL;
/*
- * XIP: do not append the image_header_t at the
+ * XIP: do not append the struct legacy_img_hdr at the
* beginning of the file, but consume the space
* reserved for it.
*/
static int mtk_image_verify_mt7621_header(const uint8_t *ptr, int print)
{
- const image_header_t *hdr = (const image_header_t *)ptr;
+ const struct legacy_img_hdr *hdr = (const struct legacy_img_hdr *)ptr;
struct mt7621_nand_header *nhdr;
uint32_t spl_size, crcval;
- image_header_t header;
+ struct legacy_img_hdr header;
int ret;
spl_size = image_get_size(hdr);
static int mtk_image_verify_header(unsigned char *ptr, int image_size,
struct image_tool_params *params)
{
- image_header_t *hdr = (image_header_t *)ptr;
+ struct legacy_img_hdr *hdr = (struct legacy_img_hdr *)ptr;
union lk_hdr *lk = (union lk_hdr *)ptr;
/* nothing to verify for LK image header */
static void mtk_image_print_header(const void *ptr)
{
- image_header_t *hdr = (image_header_t *)ptr;
+ struct legacy_img_hdr *hdr = (struct legacy_img_hdr *)ptr;
union lk_hdr *lk = (union lk_hdr *)ptr;
if (le32_to_cpu(lk->magic) == LK_PART_MAGIC) {
static void mtk_image_set_mt7621_header(void *ptr, off_t filesize,
uint32_t loadaddr)
{
- image_header_t *hdr = (image_header_t *)ptr;
+ struct legacy_img_hdr *hdr = (struct legacy_img_hdr *)ptr;
struct mt7621_stage1_header *shdr;
struct mt7621_nand_header *nhdr;
uint32_t datasize, crcval;