]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - common/cmd_bootm.c
ARM: remove obsolete at91rm9200
[karo-tx-uboot.git] / common / cmd_bootm.c
index 995e378359d9438a0fc36a367b4387bcb1abd23b..272d879bebc2036a244794e6631da9cf3dc551cc 100644 (file)
@@ -77,8 +77,9 @@ static int image_info (unsigned long addr);
 
 #if defined(CONFIG_CMD_IMLS)
 #include <flash.h>
+#include <mtd/cfi_flash.h>
 extern flash_info_t flash_info[]; /* info for FLASH chips */
-static int do_imls (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
+static int do_imls (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
 #endif
 
 #ifdef CONFIG_SILENT_CONSOLE
@@ -90,9 +91,8 @@ static image_header_t *image_get_kernel (ulong img_addr, int verify);
 static int fit_check_kernel (const void *fit, int os_noffset, int verify);
 #endif
 
-static void *boot_get_kernel (cmd_tbl_t *cmdtp, int flag,int argc, char *argv[],
+static void *boot_get_kernel (cmd_tbl_t *cmdtp, int flag,int argc, char * const argv[],
                bootm_headers_t *images, ulong *os_data, ulong *os_len);
-extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
 
 /*
  *  Continue booting an OS image; caller already has:
@@ -102,7 +102,7 @@ extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
  *  - loaded (first part of) image to header load address,
  *  - disabled interrupts.
  */
-typedef int boot_os_fn (int flag, int argc, char *argv[],
+typedef int boot_os_fn (int flag, int argc, char * const argv[],
                        bootm_headers_t *images); /* pointers to os/initrd/fdt */
 
 #ifdef CONFIG_BOOTM_LINUX
@@ -118,11 +118,14 @@ extern void lynxkdi_boot (image_header_t *);
 #ifdef CONFIG_BOOTM_RTEMS
 static boot_os_fn do_bootm_rtems;
 #endif
+#if defined(CONFIG_BOOTM_OSE)
+static boot_os_fn do_bootm_ose;
+#endif
 #if defined(CONFIG_CMD_ELF)
 static boot_os_fn do_bootm_vxworks;
 static boot_os_fn do_bootm_qnxelf;
-int do_bootvx (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
-int do_bootelf (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
+int do_bootvx (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
+int do_bootelf (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
 #endif
 #if defined(CONFIG_INTEGRITY)
 static boot_os_fn do_bootm_integrity;
@@ -141,6 +144,9 @@ static boot_os_fn *boot_os[] = {
 #ifdef CONFIG_BOOTM_RTEMS
        [IH_OS_RTEMS] = do_bootm_rtems,
 #endif
+#if defined(CONFIG_BOOTM_OSE)
+       [IH_OS_OSE] = do_bootm_ose,
+#endif
 #if defined(CONFIG_CMD_ELF)
        [IH_OS_VXWORKS] = do_bootm_vxworks,
        [IH_OS_QNX] = do_bootm_qnxelf,
@@ -150,7 +156,6 @@ static boot_os_fn *boot_os[] = {
 #endif
 };
 
-ulong load_addr = CONFIG_SYS_LOAD_ADDR;        /* Default Load Address */
 static bootm_headers_t images;         /* pointers to os/initrd/fdt images */
 
 /* Allow for arch specific config before we boot */
@@ -174,8 +179,6 @@ void arch_preboot_os(void) __attribute__((weak, alias("__arch_preboot_os")));
   #define IH_INITRD_ARCH IH_ARCH_MICROBLAZE
 #elif defined(__mips__)
   #define IH_INITRD_ARCH IH_ARCH_MIPS
-#elif defined(__nios__)
-  #define IH_INITRD_ARCH IH_ARCH_NIOS
 #elif defined(__nios2__)
   #define IH_INITRD_ARCH IH_ARCH_NIOS2
 #elif defined(__PPC__)
@@ -208,7 +211,7 @@ static void bootm_start_lmb(void)
 #endif
 }
 
-static int bootm_start(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+static int bootm_start(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
        void            *os_hdr;
        int             ret;
@@ -303,7 +306,6 @@ static int bootm_start(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
                }
 
 #if defined(CONFIG_OF_LIBFDT)
-#if defined(CONFIG_PPC) || defined(CONFIG_M68K) || defined(CONFIG_SPARC)
                /* find flattened device tree */
                ret = boot_get_fdt (flag, argc, argv, &images,
                                    &images.ft_addr, &images.ft_len);
@@ -313,7 +315,6 @@ static int bootm_start(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
                }
 
                set_working_fdt_addr(images.ft_addr);
-#endif
 #endif
        }
 
@@ -335,20 +336,20 @@ static int bootm_load_os(image_info_t os, ulong *load_end, int boot_progress)
        ulong image_start = os.image_start;
        ulong image_len = os.image_len;
        uint unc_len = CONFIG_SYS_BOOTM_LEN;
+#if defined(CONFIG_LZMA) || defined(CONFIG_LZO)
+       int ret;
+#endif /* defined(CONFIG_LZMA) || defined(CONFIG_LZO) */
 
        const char *type_name = genimg_get_type_name (os.type);
 
        switch (comp) {
        case IH_COMP_NONE:
-               if (load == blob_start) {
+               if (load == blob_start || load == image_start) {
                        printf ("   XIP %s ... ", type_name);
                } else {
                        printf ("   Loading %s ... ", type_name);
-
-                       if (load != image_start) {
-                               memmove_wd ((void *)load,
-                                               (void *)image_start, image_len, CHUNKSZ);
-                       }
+                       memmove_wd ((void *)load, (void *)image_start,
+                                       image_len, CHUNKSZ);
                }
                *load_end = load + image_len;
                puts("OK\n");
@@ -391,12 +392,14 @@ static int bootm_load_os(image_info_t os, ulong *load_end, int boot_progress)
                break;
 #endif /* CONFIG_BZIP2 */
 #ifdef CONFIG_LZMA
-       case IH_COMP_LZMA:
+       case IH_COMP_LZMA: {
+               SizeT lzma_len = unc_len;
                printf ("   Uncompressing %s ... ", type_name);
 
-               int ret = lzmaBuffToBuffDecompress(
-                       (unsigned char *)load, &unc_len,
+               ret = lzmaBuffToBuffDecompress(
+                       (unsigned char *)load, &lzma_len,
                        (unsigned char *)image_start, image_len);
+               unc_len = lzma_len;
                if (ret != SZ_OK) {
                        printf ("LZMA: uncompress or overwrite error %d "
                                "- must RESET board to recover\n", ret);
@@ -405,12 +408,13 @@ static int bootm_load_os(image_info_t os, ulong *load_end, int boot_progress)
                }
                *load_end = load + unc_len;
                break;
+       }
 #endif /* CONFIG_LZMA */
 #ifdef CONFIG_LZO
        case IH_COMP_LZO:
                printf ("   Uncompressing %s ... ", type_name);
 
-               int ret = lzop_decompress((const unsigned char *)image_start,
+               ret = lzop_decompress((const unsigned char *)image_start,
                                          image_len, (unsigned char *)load,
                                          &unc_len);
                if (ret != LZO_E_OK) {
@@ -443,10 +447,10 @@ static int bootm_load_os(image_info_t os, ulong *load_end, int boot_progress)
        return 0;
 }
 
-static int bootm_start_standalone(ulong iflag, int argc, char *argv[])
+static int bootm_start_standalone(ulong iflag, int argc, char * const argv[])
 {
        char  *s;
-       int   (*appl)(int, char *[]);
+       int   (*appl)(int, char * const []);
 
        /* Don't start if "autostart" is set to "no" */
        if (((s = getenv("autostart")) != NULL) && (strcmp(s, "no") == 0)) {
@@ -455,7 +459,7 @@ static int bootm_start_standalone(ulong iflag, int argc, char *argv[])
                setenv("filesize", buf);
                return 0;
        }
-       appl = (int (*)(int, char *[]))ntohl(images.ep);
+       appl = (int (*)(int, char * const []))ntohl(images.ep);
        (*appl)(argc-1, &argv[1]);
 
        return 0;
@@ -463,10 +467,10 @@ static int bootm_start_standalone(ulong iflag, int argc, char *argv[])
 
 /* we overload the cmd field with our state machine info instead of a
  * function pointer */
-cmd_tbl_t cmd_bootm_sub[] = {
+static cmd_tbl_t cmd_bootm_sub[] = {
        U_BOOT_CMD_MKENT(start, 0, 1, (void *)BOOTM_STATE_START, "", ""),
        U_BOOT_CMD_MKENT(loados, 0, 1, (void *)BOOTM_STATE_LOADOS, "", ""),
-#if defined(CONFIG_PPC) || defined(CONFIG_M68K) || defined(CONFIG_SPARC)
+#ifdef CONFIG_SYS_BOOT_RAMDISK_HIGH
        U_BOOT_CMD_MKENT(ramdisk, 0, 1, (void *)BOOTM_STATE_RAMDISK, "", ""),
 #endif
 #ifdef CONFIG_OF_LIBFDT
@@ -478,7 +482,7 @@ cmd_tbl_t cmd_bootm_sub[] = {
        U_BOOT_CMD_MKENT(go, 0, 1, (void *)BOOTM_STATE_OS_GO, "", ""),
 };
 
-int do_bootm_subcommand (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+int do_bootm_subcommand (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
        int ret = 0;
        int state;
@@ -496,17 +500,14 @@ int do_bootm_subcommand (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
                        argv++;
                        return bootm_start(cmdtp, flag, argc, argv);
                }
-       }
-       /* Unrecognized command */
-       else {
-               cmd_usage(cmdtp);
-               return 1;
+       } else {
+               /* Unrecognized command */
+               return cmd_usage(cmdtp);
        }
 
        if (images.state >= state) {
                printf ("Trying to execute a command out of order\n");
-               cmd_usage(cmdtp);
-               return 1;
+               return cmd_usage(cmdtp);
        }
 
        images.state |= state;
@@ -525,7 +526,7 @@ int do_bootm_subcommand (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
                        lmb_reserve(&images.lmb, images.os.load,
                                        (load_end - images.os.load));
                        break;
-#if defined(CONFIG_PPC) || defined(CONFIG_M68K) || defined(CONFIG_SPARC)
+#ifdef CONFIG_SYS_BOOT_RAMDISK_HIGH
                case BOOTM_STATE_RAMDISK:
                {
                        ulong rd_len = images.rd_end - images.rd_start;
@@ -543,11 +544,12 @@ int do_bootm_subcommand (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
                }
                        break;
 #endif
-#if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_SYS_BOOTMAPSZ)
+#if defined(CONFIG_OF_LIBFDT)
                case BOOTM_STATE_FDT:
                {
-                       ulong bootmap_base = getenv_bootm_low();
-                       ret = boot_relocate_fdt(&images.lmb, bootmap_base,
+                       boot_fdt_add_mem_rsv_regions(&images.lmb,
+                                                    images.ft_addr);
+                       ret = boot_relocate_fdt(&images.lmb,
                                &images.ft_addr, &images.ft_len);
                        break;
                }
@@ -581,13 +583,13 @@ int do_bootm_subcommand (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 /* bootm - boot application image from image in memory */
 /*******************************************************************/
 
-int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
        ulong           iflag;
        ulong           load_end = 0;
        int             ret;
        boot_os_fn      *boot_fn;
-#ifndef CONFIG_RELOC_FIXUP_WORKS
+#ifdef CONFIG_NEEDS_MANUAL_RELOC
        static int relocated = 0;
 
        /* relocate boot function table */
@@ -640,15 +642,6 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
        usb_stop();
 #endif
 
-#ifdef CONFIG_AMIGAONEG3SE
-       /*
-        * We've possible left the caches enabled during
-        * bios emulation, so turn them off again
-        */
-       icache_disable();
-       dcache_disable();
-#endif
-
        ret = bootm_load_os(images.os, &load_end, 1);
 
        if (ret < 0) {
@@ -715,6 +708,21 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
        return 1;
 }
 
+int bootm_maybe_autostart(cmd_tbl_t *cmdtp, const char *cmd)
+{
+       const char *ep = getenv("autostart");
+
+       if (ep && !strcmp(ep, "yes")) {
+               char *local_args[2];
+               local_args[0] = (char *)cmd;
+               local_args[1] = NULL;
+               printf("Automatic boot of image at addr 0x%08lX ...\n", load_addr);
+               return do_bootm(cmdtp, 0, 1, local_args);
+       }
+
+       return 0;
+}
+
 /**
  * image_get_kernel - verify legacy format kernel image
  * @img_addr: in RAM address of the legacy format image to be verified
@@ -825,7 +833,7 @@ static int fit_check_kernel (const void *fit, int os_noffset, int verify)
  *     pointer to image header if valid image was found, plus kernel start
  *     address and length, otherwise NULL
  */
-static void *boot_get_kernel (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
+static void *boot_get_kernel (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[],
                bootm_headers_t *images, ulong *os_data, ulong *os_len)
 {
        image_header_t  *hdr;
@@ -1026,7 +1034,7 @@ U_BOOT_CMD(
 /* bootd - boot default image */
 /*******************************************************************/
 #if defined(CONFIG_CMD_BOOTD)
-int do_bootd (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+int do_bootd (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
        int rcode = 0;
 
@@ -1061,7 +1069,7 @@ U_BOOT_CMD(
 /* iminfo - print header info for a requested image */
 /*******************************************************************/
 #if defined(CONFIG_CMD_IMI)
-int do_iminfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+int do_iminfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
        int     arg;
        ulong   addr;
@@ -1148,7 +1156,7 @@ U_BOOT_CMD(
 /* imls - list all images found in flash */
 /*******************************************************************/
 #if defined(CONFIG_CMD_IMLS)
-int do_imls (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+int do_imls (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
        flash_info_t *info;
        int i, j;
@@ -1251,7 +1259,7 @@ static void fixup_silent_linux ()
 /*******************************************************************/
 
 #ifdef CONFIG_BOOTM_NETBSD
-static int do_bootm_netbsd (int flag, int argc, char *argv[],
+static int do_bootm_netbsd (int flag, int argc, char * const argv[],
                            bootm_headers_t *images)
 {
        void (*loader)(bd_t *, image_header_t *, char *, char *);
@@ -1339,7 +1347,7 @@ static int do_bootm_netbsd (int flag, int argc, char *argv[],
 #endif /* CONFIG_BOOTM_NETBSD*/
 
 #ifdef CONFIG_LYNXKDI
-static int do_bootm_lynxkdi (int flag, int argc, char *argv[],
+static int do_bootm_lynxkdi (int flag, int argc, char * const argv[],
                             bootm_headers_t *images)
 {
        image_header_t *hdr = &images->legacy_hdr_os_copy;
@@ -1361,7 +1369,7 @@ static int do_bootm_lynxkdi (int flag, int argc, char *argv[],
 #endif /* CONFIG_LYNXKDI */
 
 #ifdef CONFIG_BOOTM_RTEMS
-static int do_bootm_rtems (int flag, int argc, char *argv[],
+static int do_bootm_rtems (int flag, int argc, char * const argv[],
                           bootm_headers_t *images)
 {
        void (*entry_point)(bd_t *);
@@ -1393,8 +1401,41 @@ static int do_bootm_rtems (int flag, int argc, char *argv[],
 }
 #endif /* CONFIG_BOOTM_RTEMS */
 
+#if defined(CONFIG_BOOTM_OSE)
+static int do_bootm_ose (int flag, int argc, char * const argv[],
+                          bootm_headers_t *images)
+{
+       void (*entry_point)(void);
+
+       if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
+               return 1;
+
+#if defined(CONFIG_FIT)
+       if (!images->legacy_hdr_valid) {
+               fit_unsupported_reset ("OSE");
+               return 1;
+       }
+#endif
+
+       entry_point = (void (*)(void))images->ep;
+
+       printf ("## Transferring control to OSE (at address %08lx) ...\n",
+               (ulong)entry_point);
+
+       show_boot_progress (15);
+
+       /*
+        * OSE Parameters:
+        *   None
+        */
+       (*entry_point)();
+
+       return 1;
+}
+#endif /* CONFIG_BOOTM_OSE */
+
 #if defined(CONFIG_CMD_ELF)
-static int do_bootm_vxworks (int flag, int argc, char *argv[],
+static int do_bootm_vxworks (int flag, int argc, char * const argv[],
                             bootm_headers_t *images)
 {
        char str[80];
@@ -1416,7 +1457,7 @@ static int do_bootm_vxworks (int flag, int argc, char *argv[],
        return 1;
 }
 
-static int do_bootm_qnxelf(int flag, int argc, char *argv[],
+static int do_bootm_qnxelf(int flag, int argc, char * const argv[],
                            bootm_headers_t *images)
 {
        char *local_args[2];
@@ -1442,7 +1483,7 @@ static int do_bootm_qnxelf(int flag, int argc, char *argv[],
 #endif
 
 #ifdef CONFIG_INTEGRITY
-static int do_bootm_integrity (int flag, int argc, char *argv[],
+static int do_bootm_integrity (int flag, int argc, char * const argv[],
                           bootm_headers_t *images)
 {
        void (*entry_point)(void);