]> git.ipfire.org Git - people/ms/u-boot.git/blobdiff - common/cmd_bootm.c
* Cleanup lowboot code for MPC5200
[people/ms/u-boot.git] / common / cmd_bootm.c
index 45c4f33be986a1ccda30dd61bce7e5438a3a1cad..34a74ce2c5a6fd0fcdfdb3acfc107b74f5ffdb08 100644 (file)
@@ -117,6 +117,9 @@ static boot_os_Fcn do_bootm_linux;
 #else
 extern boot_os_Fcn do_bootm_linux;
 #endif
+#ifdef CONFIG_SILENT_CONSOLE
+static void fixup_silent_linux (void);
+#endif
 static boot_os_Fcn do_bootm_netbsd;
 static boot_os_Fcn do_bootm_rtems;
 #if (CONFIG_COMMANDS & CFG_CMD_ELF)
@@ -146,7 +149,7 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
        uint    unc_len = 0x400000;
        int     i, verify;
        char    *name, *s;
-       int     (*appl)(cmd_tbl_t *, int, int, char *[]);
+       int     (*appl)(int, char *[]);
        image_header_t *hdr = &header;
 
        s = getenv ("verify");
@@ -202,7 +205,7 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
        SHOW_BOOT_PROGRESS (3);
 
        /* for multi-file images we need the data part, too */
-       print_image_hdr (hdr);
+       print_image_hdr ((image_header_t *)addr);
 
        data = addr + sizeof(image_header_t);
        len  = ntohl(hdr->ih_size);
@@ -235,6 +238,10 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
        if (hdr->ih_arch != IH_CPU_I386)
 #elif defined(__mips__)
        if (hdr->ih_arch != IH_CPU_MIPS)
+#elif defined(__nios__)
+       if (hdr->ih_arch != IH_CPU_NIOS)
+#elif defined(__M68K__)
+       if (hdr->ih_arch != IH_CPU_M68K)
 #else
 # error Unknown CPU type
 #endif
@@ -246,17 +253,24 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
        SHOW_BOOT_PROGRESS (5);
 
        switch (hdr->ih_type) {
-       case IH_TYPE_STANDALONE:        name = "Standalone Application";
-                                       break;
-       case IH_TYPE_KERNEL:            name = "Kernel Image";
-                                       break;
-       case IH_TYPE_MULTI:             name = "Multi-File Image";
-                                       len  = ntohl(len_ptr[0]);
-                                       /* OS kernel is always the first image */
-                                       data += 8; /* kernel_len + terminator */
-                                       for (i=1; len_ptr[i]; ++i)
-                                               data += 4;
-                                       break;
+       case IH_TYPE_STANDALONE:
+               name = "Standalone Application";
+               /* A second argument overwrites the load address */
+               if (argc > 2) {
+                       hdr->ih_load = simple_strtoul(argv[2], NULL, 16);
+               }
+               break;
+       case IH_TYPE_KERNEL:
+               name = "Kernel Image";
+               break;
+       case IH_TYPE_MULTI:
+               name = "Multi-File Image";
+               len  = ntohl(len_ptr[0]);
+               /* OS kernel is always the first image */
+               data += 8; /* kernel_len + terminator */
+               for (i=1; len_ptr[i]; ++i)
+                       data += 4;
+               break;
        default: printf ("Wrong Image Type for %s command\n", cmdtp->name);
                SHOW_BOOT_PROGRESS (-5);
                return 1;
@@ -347,10 +361,14 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
                /* load (and uncompress), but don't start if "autostart"
                 * is set to "no"
                 */
-               if (((s = getenv("autostart")) != NULL) && (strcmp(s,"no") == 0))
+               if (((s = getenv("autostart")) != NULL) && (strcmp(s,"no") == 0)) {
+                       char buf[32];
+                       sprintf(buf, "%lX", len);
+                       setenv("filesize", buf);
                        return 0;
-               appl = (int (*)(cmd_tbl_t *, int, int, char *[]))ntohl(hdr->ih_ep);
-               (*appl)(cmdtp, flag, argc-1, &argv[1]);
+               }
+               appl = (int (*)(int, char *[]))ntohl(hdr->ih_ep);
+               (*appl)(argc-1, &argv[1]);
                return 0;
        case IH_TYPE_KERNEL:
        case IH_TYPE_MULTI:
@@ -368,6 +386,9 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
        switch (hdr->ih_os) {
        default:                        /* handled by (original) Linux case */
        case IH_OS_LINUX:
+#ifdef CONFIG_SILENT_CONSOLE
+           fixup_silent_linux();
+#endif
            do_bootm_linux  (cmdtp, flag, argc, argv,
                             addr, len_ptr, verify);
            break;
@@ -422,6 +443,40 @@ U_BOOT_CMD(
        "        'arg' can be the address of an initrd image\n"
 );
 
+#ifdef CONFIG_SILENT_CONSOLE
+static void
+fixup_silent_linux ()
+{
+       DECLARE_GLOBAL_DATA_PTR;
+       char buf[256], *start, *end;
+       char *cmdline = getenv ("bootargs");
+
+       /* Only fix cmdline when requested */
+       if (!(gd->flags & GD_FLG_SILENT))
+               return;
+
+       debug ("before silent fix-up: %s\n", cmdline);
+       if (cmdline) {
+               if ((start = strstr (cmdline, "console=")) != NULL) {
+                       end = strchr (start, ' ');
+                       strncpy (buf, cmdline, (start - cmdline + 8));
+                       if (end)
+                               strcpy (buf + (start - cmdline + 8), end);
+                       else
+                               buf[start - cmdline + 8] = '\0';
+               } else {
+                       strcpy (buf, cmdline);
+                       strcat (buf, " console=");
+               }
+       } else {
+               strcpy (buf, "console=");
+       }
+
+       setenv ("bootargs", buf);
+       debug ("after silent fix-up: %s\n", buf);
+}
+#endif /* CONFIG_SILENT_CONSOLE */
+
 #ifdef CONFIG_PPC
 static void
 do_bootm_linux (cmd_tbl_t *cmdtp, int flag,
@@ -508,16 +563,16 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int flag,
                /* convert all clock information to MHz */
                kbd->bi_intfreq /= 1000000L;
                kbd->bi_busfreq /= 1000000L;
-#if defined(CONFIG_8260)
+#if defined(CONFIG_8260) || defined(CONFIG_MPC8560)
                kbd->bi_cpmfreq /= 1000000L;
                kbd->bi_brgfreq /= 1000000L;
                kbd->bi_sccfreq /= 1000000L;
                kbd->bi_vco     /= 1000000L;
 #endif /* CONFIG_8260 */
-#if defined(CONFIG_MPC5XXXX)
+#if defined(CONFIG_MPC5XXX)
                kbd->bi_ipbfreq /= 1000000L;
                kbd->bi_pcifreq /= 1000000L;
-#endif /* CONFIG_MPC5XXXX */
+#endif /* CONFIG_MPC5XXX */
        }
 
        kernel = (void (*)(bd_t *, ulong, ulong, ulong, ulong))hdr->ih_ep;
@@ -708,7 +763,7 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int flag,
 
        SHOW_BOOT_PROGRESS (15);
 
-#ifdef CFG_INIT_RAM_LOCK
+#if defined(CFG_INIT_RAM_LOCK) && !defined(CONFIG_E500)
        unlock_ram_in_cache();
 #endif
        /*
@@ -1003,7 +1058,7 @@ int do_imls (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
        flash_info_t *info;
        int i, j;
        image_header_t *hdr;
-       ulong checksum;
+       ulong data, len, checksum;
 
        for (i=0, info=&flash_info[0]; i<CFG_MAX_FLASH_BANKS; ++i, ++info) {
                if (info->flash_id == FLASH_UNKNOWN)
@@ -1026,7 +1081,15 @@ int do_imls (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 
                        printf ("Image at %08lX:\n", (ulong)hdr);
                        print_image_hdr( hdr );
-                       putc ('\n');
+
+                       data = (ulong)hdr + sizeof(image_header_t);
+                       len  = ntohl(hdr->ih_size);
+
+                       printf ("   Verifying Checksum ... ");
+                       if (crc32 (0, (char *)data, len) != ntohl(hdr->ih_dcrc)) {
+                               printf ("   Bad Data CRC\n");
+                       }
+                       printf ("OK\n");
 next_sector:           ;
                }
 next_bank:     ;
@@ -1291,4 +1354,3 @@ do_bootm_lynxkdi (cmd_tbl_t *cmdtp, int flag,
 }
 
 #endif /* CONFIG_LYNXKDI */
-