#include <common.h>
#include <command.h>
#include <environment.h>
-#include <cmd_nvedit.h>
+#include <watchdog.h>
+#include <serial.h>
#include <linux/stddef.h>
#include <asm/byteorder.h>
-#if (CONFIG_COMMANDS & CFG_CMD_NET)
+#if defined(CONFIG_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
+DECLARE_GLOBAL_DATA_PTR;
+
+#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_IN_ONENAND) && \
+ !defined(CFG_ENV_IS_NOWHERE)
+# error Define one of CFG_ENV_IS_IN_{NVRAM|EEPROM|FLASH|DATAFLASH|ONENAND|NOWHERE}
#endif
#define XMK_STR(x) #x
/************************************************************************
************************************************************************/
-/* Function that returns a character from the environment */
-extern uchar (*env_get_char)(int);
-
/* Function that returns a pointer to a value from the environment */
/* (Only memory version supported / needed). */
extern uchar *env_get_addr(int);
/************************************************************************
************************************************************************/
-static int envmatch (uchar *, int);
-
/*
* Table with supported baudrates (defined in config_xyz.h)
*/
for (nxt=j; env_get_char(nxt) != '\0'; ++nxt)
;
- k = envmatch(name, j);
+ k = envmatch((uchar *)name, j);
if (k < 0) {
continue;
}
int _do_setenv (int flag, int argc, char *argv[])
{
- DECLARE_GLOBAL_DATA_PTR;
-
int i, len, oldval;
int console = -1;
uchar *env, *nxt = NULL;
- uchar *name;
+ char *name;
bd_t *bd = gd->bd;
uchar *env_data = env_get_addr(0);
name = argv[1];
+ if (strchr(name, '=')) {
+ printf ("## Error: illegal character '=' in variable name \"%s\"\n", name);
+ return 1;
+ }
+
/*
* search if variable with this name already exists
*/
for (env=env_data; *env; env=nxt+1) {
for (nxt=env; *nxt; ++nxt)
;
- if ((oldval = envmatch(name, env-env_data)) >= 0)
+ if ((oldval = envmatch((uchar *)name, env-env_data)) >= 0)
break;
}
#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.
*/
+#ifdef CONFIG_HAS_UID
+ /* Allow serial# forced overwrite with 0xdeaf4add flag */
+ if ( ((strcmp (name, "serial#") == 0) && (flag != 0xdeaf4add)) ||
+#else
if ( (strcmp (name, "serial#") == 0) ||
+#endif
((strcmp (name, "ethaddr") == 0)
#if defined(CONFIG_OVERWRITE_ETHADDR_ONCE) && defined(CONFIG_ETHADDR)
- && (strcmp (env_get_addr(oldval),MK_STR(CONFIG_ETHADDR)) != 0)
+ && (strcmp ((char *)env_get_addr(oldval),MK_STR(CONFIG_ETHADDR)) != 0)
#endif /* CONFIG_OVERWRITE_ETHADDR_ONCE && CONFIG_ETHADDR */
) ) {
printf ("Can't overwrite \"%s\"\n", name);
/* 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
}
/*
baudrate);
udelay(50000);
gd->baudrate = baudrate;
+#if defined(CONFIG_PPC) || defined(CONFIG_MCF52x2)
+ gd->bd->bi_baudrate = baudrate;
+#endif
+
serial_setbrg ();
udelay(50000);
for (;;) {
load_addr = simple_strtoul(argv[2], NULL, 16);
return 0;
}
-#if (CONFIG_COMMANDS & CFG_CMD_NET)
+#if defined(CONFIG_CMD_NET)
if (strcmp(argv[1],"bootfile") == 0) {
copy_filename (BootFile, argv[2], sizeof(BootFile));
return 0;
}
-#endif /* CFG_CMD_NET */
+#endif
+
+#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);
+ extern unsigned char video_get_attr(void);
+
+ video_set_color(video_get_attr());
+ return 0;
+ }
+#endif /* CONFIG_AMIGAONEG3SE */
+
return 0;
}
void setenv (char *varname, char *varvalue)
{
char *argv[4] = { "setenv", varname, varvalue, NULL };
- _do_setenv (0, 3, argv);
+ if (varvalue == NULL)
+ _do_setenv (0, 2, argv);
+ else
+ _do_setenv (0, 3, argv);
}
-int do_setenv ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+#ifdef CONFIG_HAS_UID
+void forceenv (char *varname, char *varvalue)
+{
+ char *argv[4] = { "forceenv", varname, varvalue, NULL };
+ _do_setenv (0xdeaf4add, 3, argv);
+}
+#endif
+
+int do_setenv (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
if (argc < 2) {
printf ("Usage:\n%s\n", cmdtp->usage);
* Prompt for environment variable
*/
-#if (CONFIG_COMMANDS & CFG_CMD_ASKENV)
+#if defined(CONFIG_CMD_ASKENV)
int do_askenv ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
extern char console_buffer[CFG_CBSIZE];
/* Continue calling setenv code */
return _do_setenv (flag, len, local_args);
}
-#endif /* CFG_CMD_ASKENV */
+#endif
/************************************************************************
* Look up variable from environment,
* or NULL if not found
*/
-char *getenv (uchar *name)
+char *getenv (char *name)
{
int i, nxt;
+ WATCHDOG_RESET();
+
for (i=0; env_get_char(i) != '\0'; i=nxt+1) {
int val;
return (NULL);
}
}
- if ((val=envmatch(name, i)) < 0)
+ if ((val=envmatch((uchar *)name, i)) < 0)
continue;
- return (env_get_addr(val));
+ return ((char *)env_get_addr(val));
}
return (NULL);
}
-int getenv_r (uchar *name, uchar *buf, unsigned len)
+int getenv_r (char *name, char *buf, unsigned len)
{
int i, nxt;
return (-1);
}
}
- if ((val=envmatch(name, i)) < 0)
+ if ((val=envmatch((uchar *)name, i)) < 0)
continue;
/* found; copy out */
n = 0;
return (-1);
}
-#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))
+#if ((defined(CFG_ENV_IS_IN_NVRAM) || defined(CFG_ENV_IS_IN_EEPROM) \
+ || (defined(CONFIG_CMD_ENV) && defined(CONFIG_CMD_FLASH)) \
+ || (defined(CONFIG_CMD_ENV) && defined(CONFIG_CMD_NAND)) \
+ || (defined(CONFIG_CMD_ENV) && defined(CONFIG_CMD_ONENAND))) \
+ && !defined(CFG_ENV_IS_NOWHERE))
int do_saveenv (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
extern char * env_name_spec;
return (saveenv() ? 1 : 0);
}
+
#endif
* If the names match, return the index for the value2, else NULL.
*/
-static int
-envmatch (uchar *s1, int i2)
+int envmatch (uchar *s1, int i2)
{
while (*s1 == env_get_char(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) \
+ || (defined(CONFIG_CMD_ENV) && defined(CONFIG_CMD_FLASH)) \
+ || (defined(CONFIG_CMD_ENV) && defined(CONFIG_CMD_NAND)) \
+ || (defined(CONFIG_CMD_ENV) && defined(CONFIG_CMD_ONENAND))) \
+ && !defined(CFG_ENV_IS_NOWHERE))
+U_BOOT_CMD(
+ saveenv, 1, 0, do_saveenv,
+ "saveenv - save environment variables to persistent storage\n",
+ NULL
+);
+
+#endif
+
+#if defined(CONFIG_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
+
+#if defined(CONFIG_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