Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <[EMAIL PROTECTED]>
---
 common/Makefile                           |    3 +-
 common/{cmd_autoscript.c => autoscript.c} |   44 --------
 common/cmd_autoscript.c                   |  158 -----------------------------
 3 files changed, 2 insertions(+), 203 deletions(-)
 copy common/{cmd_autoscript.c => autoscript.c} (79%)

diff --git a/common/Makefile b/common/Makefile
index 0c8ef5b..92d7a9e 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -31,7 +31,8 @@ COBJS-y += main.o
 COBJS-$(CONFIG_CMD_BEDBUG) += bedbug.o
 COBJS-y += circbuf.o
 COBJS-$(CONFIG_CMD_AMBAPP) += cmd_ambapp.o
-COBJS-y += cmd_autoscript.o
+COBJS-$(CONFIG_AUTOSCRIPT)$(CONFIG_CMD_AUTOSCRIPT) += autoscript.o
+COBJS-$(CONFIG_CMD_AUTOSCRIPT) += cmd_autoscript.o
 COBJS-$(CONFIG_CMD_BDI) += cmd_bdinfo.o
 COBJS-$(CONFIG_CMD_BEDBUG) += cmd_bedbug.o
 COBJS-$(CONFIG_CMD_BMP) += cmd_bmp.o
diff --git a/common/cmd_autoscript.c b/common/autoscript.c
similarity index 79%
copy from common/cmd_autoscript.c
copy to common/autoscript.c
index 13af93e..e1d4103 100644
--- a/common/cmd_autoscript.c
+++ b/common/autoscript.c
@@ -47,8 +47,6 @@
 #include <hush.h>
 #endif
 
-#if defined(CONFIG_AUTOSCRIPT) || defined(CONFIG_CMD_AUTOSCRIPT)
-
 int
 autoscript (ulong addr, const char *fit_uname)
 {
@@ -199,45 +197,3 @@ autoscript (ulong addr, const char *fit_uname)
        free (cmd);
        return rcode;
 }
-
-#endif
-
-/**************************************************/
-#if defined(CONFIG_CMD_AUTOSCRIPT)
-int
-do_autoscript (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
-{
-       ulong addr;
-       int rcode;
-       const char *fit_uname = NULL;
-
-       /* Find script image */
-       if (argc < 2) {
-               addr = CFG_LOAD_ADDR;
-               debug ("*  autoscr: default load address = 0x%08lx\n", addr);
-#if defined(CONFIG_FIT)
-       } else if (fit_parse_subimage (argv[1], load_addr, &addr, &fit_uname)) {
-               debug ("*  autoscr: subimage '%s' from FIT image at 0x%08lx\n",
-                               fit_uname, addr);
-#endif
-       } else {
-               addr = simple_strtoul(argv[1], NULL, 16);
-               debug ("*  autoscr: cmdline image address = 0x%08lx\n", addr);
-       }
-
-       printf ("## Executing script at %08lx\n", addr);
-       rcode = autoscript (addr, fit_uname);
-       return rcode;
-}
-
-U_BOOT_CMD(
-       autoscr, 2, 0,  do_autoscript,
-       "autoscr - run script from memory\n",
-       "[addr] - run script starting at addr"
-       " - A valid autoscr header must be present\n"
-#if defined(CONFIG_FIT)
-       "For FIT format uImage addr must include subimage\n"
-       "unit name in the form of addr:<subimg_uname>\n"
-#endif
-);
-#endif
diff --git a/common/cmd_autoscript.c b/common/cmd_autoscript.c
index 13af93e..2b6a525 100644
--- a/common/cmd_autoscript.c
+++ b/common/cmd_autoscript.c
@@ -47,163 +47,6 @@
 #include <hush.h>
 #endif
 
-#if defined(CONFIG_AUTOSCRIPT) || defined(CONFIG_CMD_AUTOSCRIPT)
-
-int
-autoscript (ulong addr, const char *fit_uname)
-{
-       ulong           len;
-       image_header_t  *hdr;
-       ulong           *data;
-       char            *cmd;
-       int             rcode = 0;
-       int             verify;
-#if defined(CONFIG_FIT)
-       const void*     fit_hdr;
-       int             noffset;
-       const void      *fit_data;
-       size_t          fit_len;
-#endif
-
-       verify = getenv_yesno ("verify");
-
-       switch (genimg_get_format ((void *)addr)) {
-       case IMAGE_FORMAT_LEGACY:
-               hdr = (image_header_t *)addr;
-
-               if (!image_check_magic (hdr)) {
-                       puts ("Bad magic number\n");
-                       return 1;
-               }
-
-               if (!image_check_hcrc (hdr)) {
-                       puts ("Bad header crc\n");
-                       return 1;
-               }
-
-               if (verify) {
-                       if (!image_check_dcrc (hdr)) {
-                               puts ("Bad data crc\n");
-                               return 1;
-                       }
-               }
-
-               if (!image_check_type (hdr, IH_TYPE_SCRIPT)) {
-                       puts ("Bad image type\n");
-                       return 1;
-               }
-
-               /* get length of script */
-               data = (ulong *)image_get_data (hdr);
-
-               if ((len = uimage_to_cpu (*data)) == 0) {
-                       puts ("Empty Script\n");
-                       return 1;
-               }
-
-               /*
-                * scripts are just multi-image files with one component, seek
-                * past the zero-terminated sequence of image lengths to get
-                * to the actual image data
-                */
-               while (*data++);
-               break;
-#if defined(CONFIG_FIT)
-       case IMAGE_FORMAT_FIT:
-               if (fit_uname == NULL) {
-                       puts ("No FIT subimage unit name\n");
-                       return 1;
-               }
-
-               fit_hdr = (const void *)addr;
-               if (!fit_check_format (fit_hdr)) {
-                       puts ("Bad FIT image format\n");
-                       return 1;
-               }
-
-               /* get script component image node offset */
-               noffset = fit_image_get_node (fit_hdr, fit_uname);
-               if (noffset < 0) {
-                       printf ("Can't find '%s' FIT subimage\n", fit_uname);
-                       return 1;
-               }
-
-               if (!fit_image_check_type (fit_hdr, noffset, IH_TYPE_SCRIPT)) {
-                       puts ("Not a image image\n");
-                       return 1;
-               }
-
-               /* verify integrity */
-               if (verify) {
-                       if (!fit_image_check_hashes (fit_hdr, noffset)) {
-                               puts ("Bad Data Hash\n");
-                               return 1;
-                       }
-               }
-
-               /* get script subimage data address and length */
-               if (fit_image_get_data (fit_hdr, noffset, &fit_data, &fit_len)) 
{
-                       puts ("Could not find script subimage data\n");
-                       return 1;
-               }
-
-               data = (ulong *)fit_data;
-               len = (ulong)fit_len;
-               break;
-#endif
-       default:
-               puts ("Wrong image format for autoscript\n");
-               return 1;
-       }
-
-       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 CFG_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 ((next - line) > 1) {
-                                       debug ("** exec: \"%s\"\n",
-                                               line);
-                                       if (run_command (line, 0) < 0) {
-                                               rcode = 1;
-                                               break;
-                                       }
-                               }
-                               line = next + 1;
-                       }
-                       ++next;
-               }
-       }
-#endif
-       free (cmd);
-       return rcode;
-}
-
-#endif
-
-/**************************************************/
-#if defined(CONFIG_CMD_AUTOSCRIPT)
 int
 do_autoscript (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 {
@@ -240,4 +83,3 @@ U_BOOT_CMD(
        "unit name in the form of addr:<subimg_uname>\n"
 #endif
 );
-#endif
-- 
1.5.6.3

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to