mirror of
https://github.com/Stichting-MINIX-Research-Foundation/u-boot.git
synced 2025-09-08 11:36:21 -04:00
[new uImage] Add image_get_kernel() routine
Legacy image specific verification is factored out to a separate helper routine to keep get_kernel() generic and simple. Signed-off-by: Marian Balakowicz <m8@semihalf.com> Acked-by: Kumar Gala <galak@kernel.crashing.org>
This commit is contained in:
parent
8a5ea3e616
commit
1efd43601f
@ -285,6 +285,57 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get_kernel - find kernel image
|
||||||
|
* @os_data: pointer to a ulong variable, will hold os data start address
|
||||||
|
* @os_len: pointer to a ulong variable, will hold os data length
|
||||||
|
*
|
||||||
|
* get_kernel() tries to find a kernel image, verifies its integrity
|
||||||
|
* and locates kernel data.
|
||||||
|
*
|
||||||
|
* returns:
|
||||||
|
* pointer to image header if valid image was found, plus kernel start
|
||||||
|
* address and length, otherwise NULL
|
||||||
|
*/
|
||||||
|
static image_header_t *image_get_kernel (ulong img_addr, int verify)
|
||||||
|
{
|
||||||
|
image_header_t *hdr = (image_header_t *)img_addr;
|
||||||
|
|
||||||
|
if (!image_check_magic(hdr)) {
|
||||||
|
puts ("Bad Magic Number\n");
|
||||||
|
show_boot_progress (-1);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
show_boot_progress (2);
|
||||||
|
|
||||||
|
if (!image_check_hcrc (hdr)) {
|
||||||
|
puts ("Bad Header Checksum\n");
|
||||||
|
show_boot_progress (-2);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
show_boot_progress (3);
|
||||||
|
image_print_contents (hdr);
|
||||||
|
|
||||||
|
if (verify) {
|
||||||
|
puts (" Verifying Checksum ... ");
|
||||||
|
if (!image_check_dcrc (hdr)) {
|
||||||
|
printf ("Bad Data CRC\n");
|
||||||
|
show_boot_progress (-3);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
puts ("OK\n");
|
||||||
|
}
|
||||||
|
show_boot_progress (4);
|
||||||
|
|
||||||
|
if (!image_check_target_arch (hdr)) {
|
||||||
|
printf ("Unsupported Architecture 0x%x\n", image_get_arch (hdr));
|
||||||
|
show_boot_progress (-4);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return hdr;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get_kernel - find kernel image
|
* get_kernel - find kernel image
|
||||||
* @os_data: pointer to a ulong variable, will hold os data start address
|
* @os_data: pointer to a ulong variable, will hold os data start address
|
||||||
@ -339,40 +390,9 @@ static void *get_kernel (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
|
|||||||
case IMAGE_FORMAT_LEGACY:
|
case IMAGE_FORMAT_LEGACY:
|
||||||
|
|
||||||
debug ("* kernel: legacy format image\n");
|
debug ("* kernel: legacy format image\n");
|
||||||
hdr = (image_header_t *)img_addr;
|
hdr = image_get_kernel (img_addr, images->verify);
|
||||||
|
if (!hdr)
|
||||||
if (!image_check_magic(hdr)) {
|
|
||||||
puts ("Bad Magic Number\n");
|
|
||||||
show_boot_progress (-1);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
show_boot_progress (2);
|
|
||||||
|
|
||||||
if (!image_check_hcrc (hdr)) {
|
|
||||||
puts ("Bad Header Checksum\n");
|
|
||||||
show_boot_progress (-2);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
show_boot_progress (3);
|
|
||||||
image_print_contents (hdr);
|
|
||||||
|
|
||||||
if (images->verify) {
|
|
||||||
puts (" Verifying Checksum ... ");
|
|
||||||
if (!image_check_dcrc (hdr)) {
|
|
||||||
printf ("Bad Data CRC\n");
|
|
||||||
show_boot_progress (-3);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
puts ("OK\n");
|
|
||||||
}
|
|
||||||
show_boot_progress (4);
|
|
||||||
|
|
||||||
if (!image_check_target_arch (hdr)) {
|
|
||||||
printf ("Unsupported Architecture 0x%x\n", image_get_arch (hdr));
|
|
||||||
show_boot_progress (-4);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
show_boot_progress (5);
|
show_boot_progress (5);
|
||||||
|
|
||||||
switch (image_get_type (hdr)) {
|
switch (image_get_type (hdr)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user