#include <fdt_support.h>
#endif
-extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
-
#ifdef CONFIG_CMD_BDI
extern int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
#endif
*
* returns:
* pointer to a ramdisk image header, if image was found and valid
- * otherwise, board is reset
+ * otherwise, return NULL
*/
static image_header_t* image_get_ramdisk (cmd_tbl_t *cmdtp, int flag,
int argc, char *argv[],
if (!image_check_magic (rd_hdr)) {
puts ("Bad Magic Number\n");
show_boot_progress (-10);
- do_reset (cmdtp, flag, argc, argv);
+ return NULL;
}
if (!image_check_hcrc (rd_hdr)) {
puts ("Bad Header Checksum\n");
show_boot_progress (-11);
- do_reset (cmdtp, flag, argc, argv);
+ return NULL;
}
show_boot_progress (10);
if (!image_check_dcrc_wd (rd_hdr, CHUNKSZ)) {
puts ("Bad Data CRC\n");
show_boot_progress (-12);
- do_reset (cmdtp, flag, argc, argv);
+ return NULL;
}
puts("OK\n");
}
printf ("No Linux %s Ramdisk Image\n",
image_get_arch_name(arch));
show_boot_progress (-13);
- do_reset (cmdtp, flag, argc, argv);
+ return NULL;
}
return rd_hdr;
* rd_start and rd_end are set to ramdisk start/end addresses if
* ramdisk image is found and valid
* rd_start and rd_end are set to 0 if no ramdisk exists
- * board is reset if ramdisk image is found but corrupted
+ * return 1 if ramdisk image is found but corrupted
*/
-void get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
+int get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
bootm_headers_t *images, uint8_t arch,
ulong *rd_start, ulong *rd_end)
{
rd_hdr = image_get_ramdisk (cmdtp, flag, argc, argv,
rd_addr, arch, images->verify);
+ if (rd_hdr == NULL) {
+ *rd_start = 0;
+ *rd_end = 0;
+ return 1;
+ }
+
rd_data = image_get_data (rd_hdr);
rd_len = image_get_data_size (rd_hdr);
rd_load = image_get_load (rd_hdr);
fit_hdr = (void *)rd_addr;
debug ("* ramdisk: FIT format image\n");
fit_unsupported_reset ("ramdisk");
- do_reset (cmdtp, flag, argc, argv);
+ return 1;
#endif
default:
printf ("Wrong Image Format for %s command\n",
}
debug (" ramdisk start = 0x%08lx, ramdisk end = 0x%08lx\n",
*rd_start, *rd_end);
+
+ return 0;
}
#if defined(CONFIG_PPC) || defined(CONFIG_M68K)
DECLARE_GLOBAL_DATA_PTR;
+extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
+
#define PHYSADDR(x) x
#define LINUX_MAX_ENVS 256
ulong rd_data_start, rd_data_end, rd_len;
ulong initrd_start, initrd_end;
+ int ret;
ulong cmd_start, cmd_end;
bd_t *kbd;
kernel = (void (*)(bd_t *, ulong, ulong, ulong, ulong))ep;
/* find ramdisk */
- get_ramdisk (cmdtp, flag, argc, argv, images,
+ ret = get_ramdisk (cmdtp, flag, argc, argv, images,
IH_ARCH_M68K, &rd_data_start, &rd_data_end);
+ if (ret)
+ goto error;
+
rd_len = rd_data_end - rd_data_start;
alloc_current = ramdisk_high (alloc_current, rd_data_start, rd_len,
sp_limit, get_sp (), &initrd_start, &initrd_end);
*/
(*kernel) (kbd, initrd_start, initrd_end, cmd_start, cmd_end);
/* does not return */
+ return ;
+
+error:
+ do_reset (cmdtp, flag, argc, argv);
+ return ;
}
static ulong get_sp (void)
#include <fdt_support.h>
static void fdt_error (const char *msg);
-static void get_fdt (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
+static int get_fdt (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
bootm_headers_t *images, char **of_flat_tree, ulong *of_size);
static ulong fdt_relocate (ulong alloc_current,
cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
#if defined(CONFIG_OF_LIBFDT)
/* find flattened device tree */
- get_fdt (cmdtp, flag, argc, argv, images, &of_flat_tree, &of_size);
+ ret = get_fdt (cmdtp, flag, argc, argv, images, &of_flat_tree, &of_size);
+
+ if (ret)
+ goto error;
#endif
if (!of_size) {
#if defined(CONFIG_FIT)
} else if (images->fit_uname_os) {
fit_unsupported_reset ("PPC linux bootm");
- do_reset (cmdtp, flag, argc, argv);
+ goto error;
#endif
} else {
puts ("Could not find kernel entry point!\n");
- do_reset (cmdtp, flag, argc, argv);
+ goto error;
}
kernel = (void (*)(bd_t *, ulong, ulong, ulong, ulong))ep;
/* find ramdisk */
- get_ramdisk (cmdtp, flag, argc, argv, images,
+ ret = get_ramdisk (cmdtp, flag, argc, argv, images,
IH_ARCH_PPC, &rd_data_start, &rd_data_end);
+ if (ret)
+ goto error;
+
rd_len = rd_data_end - rd_data_start;
#if defined(CONFIG_OF_LIBFDT)
/* pass in dummy initrd info, we'll fix up later */
if (fdt_chosen(of_flat_tree, rd_data_start, rd_data_end, 0) < 0) {
fdt_error ("/chosen node create failed");
- do_reset (cmdtp, flag, argc, argv);
+ goto error;
}
#ifdef CONFIG_OF_HAS_UBOOT_ENV
if (fdt_env(of_flat_tree) < 0) {
fdt_error ("/u-boot-env node create failed");
- do_reset (cmdtp, flag, argc, argv);
+ goto error;
}
#endif
#ifdef CONFIG_OF_HAS_BD_T
if (fdt_bd_t(of_flat_tree) < 0) {
fdt_error ("/bd_t node create failed");
- do_reset (cmdtp, flag, argc, argv);
+ goto error;
}
#endif
#ifdef CONFIG_OF_BOARD_SETUP
initrd_end - initrd_start + 1);
if (ret < 0) {
printf("fdt_chosen: %s\n", fdt_strerror(ret));
- do_reset (cmdtp, flag, argc, argv);
+ goto error;
}
do_fixup_by_path_u32(of_flat_tree, "/chosen",
*/
(*kernel) (kbd, initrd_start, initrd_end, cmd_start, cmd_end);
/* does not return */
+ return ;
+
+error:
+ do_reset (cmdtp, flag, argc, argv);
+ return ;
}
static ulong get_sp (void)
return fdt_hdr;
}
-static void get_fdt (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
+static int get_fdt (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
bootm_headers_t *images, char **of_flat_tree, ulong *of_size)
{
ulong fdt_addr;
fdt_addr);
fdt_hdr = image_get_fdt (fdt_addr);
if (!fdt_hdr)
- do_reset (cmdtp, flag, argc, argv);
+ goto error;
/*
* move image data to the load address,
if ((load_start < image_end) && (load_end > image_start)) {
fdt_error ("fdt overwritten");
- do_reset (cmdtp, flag, argc, argv);
+ goto error;
}
memmove ((void *)image_get_load (fdt_hdr),
(void *)image_get_data (fdt_hdr),
fit_hdr = (void *)fdt_addr;
debug ("* fdt: FIT format image\n");
fit_unsupported_reset ("PPC fdt");
- do_reset (cmdtp, flag, argc, argv);
+ goto error;
} else
#endif
{
break;
default:
fdt_error ("Did not find a cmdline Flattened Device Tree");
- do_reset (cmdtp, flag, argc, argv);
+ goto error;
}
printf (" Booting using the fdt blob at 0x%x\n", fdt_blob);
if (fdt_check_header (fdt_blob) != 0) {
fdt_error ("image is not a fdt");
- do_reset (cmdtp, flag, argc, argv);
+ goto error;
}
if (be32_to_cpu (fdt_totalsize (fdt_blob)) != fdt_len) {
fdt_error ("fdt size != image size");
- do_reset (cmdtp, flag, argc, argv);
+ goto error;
}
} else {
fdt_error ("Did not find a Flattened Device Tree "
"in a legacy multi-component image");
- do_reset (cmdtp, flag, argc, argv);
+ goto error;
}
} else {
debug ("## No Flattened Device Tree\n");
*of_flat_tree = NULL;
*of_size = 0;
- return;
+ return 0;
}
*of_flat_tree = fdt_blob;
*of_size = be32_to_cpu (fdt_totalsize (fdt_blob));
debug (" of_flat_tree at 0x%08lx size 0x%08lx\n",
*of_flat_tree, *of_size);
+
+ return 0;
+
+error:
+ do_reset (cmdtp, flag, argc, argv);
+ return 1;
}
static ulong fdt_relocate (ulong alloc_current,
if (fdt_check_header (fdt_blob) != 0) {
fdt_error ("image is not a fdt");
- do_reset (cmdtp, flag, argc, argv);
+ goto error;
}
#ifndef CFG_NO_FLASH
err = fdt_open_into (fdt_blob, (void *)of_start, of_len);
if (err != 0) {
fdt_error ("fdt move failed");
- do_reset (cmdtp, flag, argc, argv);
+ goto error;
}
puts ("OK\n");
}
return new_alloc_current;
+
+error:
+ do_reset (cmdtp, flag, argc, argv);
+ return 1;
}
#endif