Fix problems with SNTP support;
[platform/kernel/u-boot.git] / common / cmd_nvedit.c
index c404157..578b0ca 100644 (file)
 #include <command.h>
 #include <environment.h>
 #include <watchdog.h>
-#include <cmd_nvedit.h>
+#include <serial.h>
 #include <linux/stddef.h>
 #include <asm/byteorder.h>
 #if (CONFIG_COMMANDS & CFG_CMD_NET)
 #include <net.h>
 #endif
 
-#if !defined(CFG_ENV_IS_IN_NVRAM) && !defined(CFG_ENV_IS_IN_EEPROM) && !defined(CFG_ENV_IS_IN_FLASH) && !defined(CFG_ENV_IS_NOWHERE)
-# error Define one of CFG_ENV_IS_IN_NVRAM, CFG_ENV_IS_IN_EEPROM, CFG_ENV_IS_IN_FLASH, CFG_ENV_IS_NOWHERE
+#if !defined(CFG_ENV_IS_IN_NVRAM)      && \
+    !defined(CFG_ENV_IS_IN_EEPROM)     && \
+    !defined(CFG_ENV_IS_IN_FLASH)      && \
+    !defined(CFG_ENV_IS_IN_DATAFLASH)  && \
+    !defined(CFG_ENV_IS_IN_NAND)       && \
+    !defined(CFG_ENV_IS_NOWHERE)
+# error Define one of CFG_ENV_IS_IN_{NVRAM|EEPROM|FLASH|DATAFLASH|NOWHERE}
 #endif
 
 #define XMK_STR(x)     #x
@@ -180,7 +185,8 @@ int _do_setenv (int flag, int argc, char *argv[])
 #ifndef CONFIG_ENV_OVERWRITE
 
                /*
-                * Ethernet Address and serial# can be set only once
+                * Ethernet Address and serial# can be set only once,
+                * ver is readonly.
                 */
                if ( (strcmp (name, "serial#") == 0) ||
                    ((strcmp (name, "ethaddr") == 0)
@@ -211,6 +217,11 @@ int _do_setenv (int flag, int argc, char *argv[])
                        /* Try assigning specified device */
                        if (console_assign (console, argv[2]) < 0)
                                return 1;
+
+#ifdef CONFIG_SERIAL_MULTI
+                       if (serial_assign (argv[2]) < 0)
+                               return 1;
+#endif
                }
 
                /*
@@ -358,7 +369,7 @@ int _do_setenv (int flag, int argc, char *argv[])
        }
 #endif /* CFG_CMD_NET */
 
-#ifdef CONFIG_AMIGAONEG3SE 
+#ifdef CONFIG_AMIGAONEG3SE
        if (strcmp(argv[1], "vga_fg_color") == 0 ||
            strcmp(argv[1], "vga_bg_color") == 0 ) {
                extern void video_set_color(unsigned char attr);
@@ -530,6 +541,8 @@ int do_saveenv (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 
        return (saveenv() ? 1 : 0);
 }
+
+
 #endif
 
 
@@ -552,3 +565,61 @@ envmatch (uchar *s1, int i2)
                return(i2);
        return(-1);
 }
+
+
+/**************************************************/
+
+U_BOOT_CMD(
+       printenv, CFG_MAXARGS, 1,       do_printenv,
+       "printenv- print environment variables\n",
+       "\n    - print values of all environment variables\n"
+       "printenv name ...\n"
+       "    - print value of environment variable 'name'\n"
+);
+
+U_BOOT_CMD(
+       setenv, CFG_MAXARGS, 0, do_setenv,
+       "setenv  - set environment variables\n",
+       "name value ...\n"
+       "    - set environment variable 'name' to 'value ...'\n"
+       "setenv name\n"
+       "    - delete environment variable 'name'\n"
+);
+
+#if defined(CFG_ENV_IS_IN_NVRAM) || defined(CFG_ENV_IS_IN_EEPROM) || \
+    ((CONFIG_COMMANDS & (CFG_CMD_ENV|CFG_CMD_FLASH)) == \
+      (CFG_CMD_ENV|CFG_CMD_FLASH))
+U_BOOT_CMD(
+       saveenv, 1, 0,  do_saveenv,
+       "saveenv - save environment variables to persistent storage\n",
+       NULL
+);
+
+#endif /* CFG_CMD_ENV */
+
+#if (CONFIG_COMMANDS & CFG_CMD_ASKENV)
+
+U_BOOT_CMD(
+       askenv, CFG_MAXARGS,    1,      do_askenv,
+       "askenv  - get environment variables from stdin\n",
+       "name [message] [size]\n"
+       "    - get environment variable 'name' from stdin (max 'size' chars)\n"
+       "askenv name\n"
+       "    - get environment variable 'name' from stdin\n"
+       "askenv name size\n"
+       "    - get environment variable 'name' from stdin (max 'size' chars)\n"
+       "askenv name [message] size\n"
+       "    - display 'message' string and get environment variable 'name'"
+       "from stdin (max 'size' chars)\n"
+);
+#endif /* CFG_CMD_ASKENV */
+
+#if (CONFIG_COMMANDS & CFG_CMD_RUN)
+int do_run (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
+U_BOOT_CMD(
+       run,    CFG_MAXARGS,    1,      do_run,
+       "run     - run commands in an environment variable\n",
+       "var [...]\n"
+       "    - run the commands in the environment variable(s) 'var'\n"
+);
+#endif  /* CFG_CMD_RUN */