mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-14 08:57:58 +00:00
[new uImage] POWERPC: Add image_get_fdt() routine
FDT blob may be passed either: (1) raw (2) or embedded in the legacy uImage (3) or embedded in the new uImage. For the (2) case embedding image must be verified before we get FDT from it. This patch factors out legacy image specific verification routine to the separate helper routine. Signed-off-by: Marian Balakowicz <m8@semihalf.com> Acked-by: Kumar Gala <galak@kernel.crashing.org>
This commit is contained in:
parent
1efd43601f
commit
ff0734cff0
1 changed files with 44 additions and 32 deletions
|
@ -237,6 +237,39 @@ static void fdt_error (const char *msg)
|
||||||
puts (" - must RESET the board to recover.\n");
|
puts (" - must RESET the board to recover.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static image_header_t *image_get_fdt (ulong fdt_addr)
|
||||||
|
{
|
||||||
|
image_header_t *fdt_hdr = (image_header_t *)fdt_addr;
|
||||||
|
|
||||||
|
image_print_contents (fdt_hdr);
|
||||||
|
|
||||||
|
puts (" Verifying Checksum ... ");
|
||||||
|
if (!image_check_hcrc (fdt_hdr)) {
|
||||||
|
fdt_error ("fdt header checksum invalid");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!image_check_dcrc (fdt_hdr)) {
|
||||||
|
fdt_error ("fdt checksum invalid");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
puts ("OK\n");
|
||||||
|
|
||||||
|
if (!image_check_type (fdt_hdr, IH_TYPE_FLATDT)) {
|
||||||
|
fdt_error ("uImage is not a fdt");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (image_get_comp (fdt_hdr) != IH_COMP_NONE) {
|
||||||
|
fdt_error ("uImage is compressed");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (fdt_check_header ((char *)image_get_data (fdt_hdr)) != 0) {
|
||||||
|
fdt_error ("uImage data is not a fdt");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return fdt_hdr;
|
||||||
|
}
|
||||||
|
|
||||||
static void get_fdt (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
|
static void get_fdt (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
|
||||||
bootm_headers_t *images, char **of_flat_tree, ulong *of_size)
|
bootm_headers_t *images, char **of_flat_tree, ulong *of_size)
|
||||||
{
|
{
|
||||||
|
@ -297,12 +330,17 @@ static void get_fdt (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
|
||||||
case IMAGE_FORMAT_LEGACY:
|
case IMAGE_FORMAT_LEGACY:
|
||||||
debug ("* fdt: legacy format image\n");
|
debug ("* fdt: legacy format image\n");
|
||||||
|
|
||||||
fdt_hdr = (image_header_t *)fdt_addr;
|
/* verify fdt_addr points to a valid image header */
|
||||||
printf ("## Flattened Device Tree Legacy Image at %08lx\n",
|
printf ("## Flattened Device Tree Legacy Image at %08lx\n",
|
||||||
fdt_hdr);
|
fdt_addr);
|
||||||
|
fdt_hdr = image_get_fdt (fdt_addr);
|
||||||
image_print_contents (fdt_hdr);
|
if (!fdt_hdr)
|
||||||
|
do_reset (cmdtp, flag, argc, argv);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* move image data to the load address,
|
||||||
|
* make sure we don't overwrite initial image
|
||||||
|
*/
|
||||||
image_start = (ulong)fdt_hdr;
|
image_start = (ulong)fdt_hdr;
|
||||||
image_end = image_get_image_end (fdt_hdr);
|
image_end = image_get_image_end (fdt_hdr);
|
||||||
|
|
||||||
|
@ -313,35 +351,9 @@ static void get_fdt (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
|
||||||
fdt_error ("fdt overwritten");
|
fdt_error ("fdt overwritten");
|
||||||
do_reset (cmdtp, flag, argc, argv);
|
do_reset (cmdtp, flag, argc, argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
puts (" Verifying Checksum ... ");
|
|
||||||
if (!image_check_hcrc (fdt_hdr)) {
|
|
||||||
fdt_error ("fdt header checksum invalid");
|
|
||||||
do_reset (cmdtp, flag, argc, argv);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!image_check_dcrc (fdt_hdr)) {
|
|
||||||
fdt_error ("fdt checksum invalid");
|
|
||||||
do_reset (cmdtp, flag, argc, argv);
|
|
||||||
}
|
|
||||||
puts ("OK\n");
|
|
||||||
|
|
||||||
if (!image_check_type (fdt_hdr, IH_TYPE_FLATDT)) {
|
|
||||||
fdt_error ("uImage is not a fdt");
|
|
||||||
do_reset (cmdtp, flag, argc, argv);
|
|
||||||
}
|
|
||||||
if (image_get_comp (fdt_hdr) != IH_COMP_NONE) {
|
|
||||||
fdt_error ("uImage is compressed");
|
|
||||||
do_reset (cmdtp, flag, argc, argv);
|
|
||||||
}
|
|
||||||
if (fdt_check_header ((char *)image_get_data (fdt_hdr)) != 0) {
|
|
||||||
fdt_error ("uImage data is not a fdt");
|
|
||||||
do_reset (cmdtp, flag, argc, argv);
|
|
||||||
}
|
|
||||||
|
|
||||||
memmove ((void *)image_get_load (fdt_hdr),
|
memmove ((void *)image_get_load (fdt_hdr),
|
||||||
(void *)image_get_data (fdt_hdr),
|
(void *)image_get_data (fdt_hdr),
|
||||||
image_get_data_size (fdt_hdr));
|
image_get_data_size (fdt_hdr));
|
||||||
|
|
||||||
fdt_blob = (char *)image_get_load (fdt_hdr);
|
fdt_blob = (char *)image_get_load (fdt_hdr);
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue