> +/**
> + * gen_get_image - get image from special storage (if necessary)
> + * @img_addr: image start address
> + *
> + * gen_get_image() checks if provided image start adddress is located
> + * in a dataflash storage. If so, image is moved to a system RAM  
> memory.
> + *
> + * returns:
> + *     image start address after possible relocation from special  
> storage
> + */
> +ulong gen_get_image (ulong img_addr)
> +{
> +     ulong ram_addr, h_size, d_size;
> +
> +     h_size = image_get_header_size ();
> +#if defined(CONFIG_FIT)
> +     if (sizeof(struct fdt_header) > h_size)
> +             h_size = sizeof(struct fdt_header);
> +#endif
> +
> +#ifdef CONFIG_HAS_DATAFLASH
> +     if (addr_dataflash (img_addr)){
> +             ram_addr = CFG_LOAD_ADDR;
> +             debug ("   Reading image header from dataflash address "
> +                     "%08lx to RAM address %08lx\n", img_addr, ram_addr);
> +             read_dataflash (img_addr, h_size, (char *)ram_addr);
> +     } else
> +#endif
> +     ram_addr = img_addr;

can we not early out at this point?

> +
> +     switch (gen_image_get_format ((void *)ram_addr)) {
> +     case IMAGE_FORMAT_LEGACY:
> +             d_size = image_get_data_size ((image_header_t *)ram_addr);
> +             debug ("   Legacy format image found at 0x%08lx, size 
> 0x%08lx\n",
> +                             ram_addr, d_size);
> +             break;
> +#if defined(CONFIG_FIT)
> +     case IMAGE_FORMAT_FIT:
> +             d_size = fdt_totalsize((void *)ram_addr) - h_size;
> +             debug ("   FIT/FDT format image found at 0x%08lx, size 
> 0x%08lx\n",
> +                             ram_addr, d_size);
> +
> +             break;
> +#endif
> +     default:
> +             printf ("   No valid image found at 0x%08lx\n", img_addr);
> +             return ram_addr;
> +     }
> +
> +#ifdef CONFIG_HAS_DATAFLASH
> +     if (addr_dataflash (img_addr)) {
> +             debug ("   Reading image remaining data from dataflash address "
> +                     "%08lx to RAM address %08lx\n", img_addr + h_size,
> +                     ram_addr + h_size);
> +
> +             read_dataflash (img_addr + h_size, d_size,
> +                             (char *)(ram_addr + h_size));
> +     }
> +#endif
> +
> +     return ram_addr;
> +}

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
U-Boot-Users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/u-boot-users

Reply via email to