]> git.karo-electronics.de Git - karo-tx-uboot.git/blobdiff - common/cmd_source.c
arm: vf610: Add Vybrid VF610 CPU support
[karo-tx-uboot.git] / common / cmd_source.c
index 32fff5cec819f462fcff9a00691691f4181a8915..f0d7f52bcec0643f5e7ce89fe23b9dba6df96605 100644 (file)
 #include <image.h>
 #include <malloc.h>
 #include <asm/byteorder.h>
+#include <asm/io.h>
 #if defined(CONFIG_8xx)
 #include <mpc8xx.h>
 #endif
-#ifdef CONFIG_SYS_HUSH_PARSER
-#include <hush.h>
-#endif
 
 int
 source (ulong addr, const char *fit_uname)
 {
        ulong           len;
-       image_header_t  *hdr;
+       const image_header_t *hdr;
        ulong           *data;
-       char            *cmd;
-       int             rcode = 0;
        int             verify;
+       void *buf;
 #if defined(CONFIG_FIT)
        const void*     fit_hdr;
        int             noffset;
@@ -61,9 +58,10 @@ source (ulong addr, const char *fit_uname)
 
        verify = getenv_yesno ("verify");
 
-       switch (genimg_get_format ((void *)addr)) {
+       buf = map_sysmem(addr, 0);
+       switch (genimg_get_format(buf)) {
        case IMAGE_FORMAT_LEGACY:
-               hdr = (image_header_t *)addr;
+               hdr = buf;
 
                if (!image_check_magic (hdr)) {
                        puts ("Bad magic number\n");
@@ -109,7 +107,7 @@ source (ulong addr, const char *fit_uname)
                        return 1;
                }
 
-               fit_hdr = (const void *)addr;
+               fit_hdr = buf;
                if (!fit_check_format (fit_hdr)) {
                        puts ("Bad FIT image format\n");
                        return 1;
@@ -151,49 +149,7 @@ source (ulong addr, const char *fit_uname)
        }
 
        debug ("** Script length: %ld\n", len);
-
-       if ((cmd = malloc (len + 1)) == NULL) {
-               return 1;
-       }
-
-       /* make sure cmd is null terminated */
-       memmove (cmd, (char *)data, len);
-       *(cmd + len) = 0;
-
-#ifdef CONFIG_SYS_HUSH_PARSER /*?? */
-       rcode = parse_string_outer (cmd, FLAG_PARSE_SEMICOLON);
-#else
-       {
-               char *line = cmd;
-               char *next = cmd;
-
-               /*
-                * break into individual lines,
-                * and execute each line;
-                * terminate on error.
-                */
-               while (*next) {
-                       if (*next == '\n') {
-                               *next = '\0';
-                               /* run only non-empty commands */
-                               if (*line) {
-                                       debug ("** exec: \"%s\"\n",
-                                               line);
-                                       if (run_command(line, 0) < 0) {
-                                               rcode = 1;
-                                               break;
-                                       }
-                               }
-                               line = next + 1;
-                       }
-                       ++next;
-               }
-               if (rcode == 0 && *line)
-                       rcode = (run_command(line, 0) >= 0);
-       }
-#endif
-       free (cmd);
-       return rcode;
+       return run_command_list((char *)data, len, 0);
 }
 
 /**************************************************/
@@ -224,9 +180,8 @@ do_source (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
        return rcode;
 }
 
-U_BOOT_CMD(
-       source, 2, 0,   do_source,
-       "run script from memory",
+#ifdef CONFIG_SYS_LONGHELP
+static char source_help_text[] =
        "[addr]\n"
        "\t- run script starting at addr\n"
        "\t- A valid image header must be present"
@@ -235,5 +190,11 @@ U_BOOT_CMD(
        "For FIT format uImage addr must include subimage\n"
        "unit name in the form of addr:<subimg_uname>"
 #endif
+       "";
+#endif
+
+U_BOOT_CMD(
+       source, 2, 0,   do_source,
+       "run script from memory", source_help_text
 );
 #endif