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_NOWHERE)
-# error Define one of CFG_ENV_IS_IN_{NVRAM|EEPROM|FLASH|DATAFLASH|NOWHERE}
+#if !defined(CONFIG_ENV_IS_IN_EEPROM) && \
+ !defined(CONFIG_ENV_IS_IN_FLASH) && \
+ !defined(CONFIG_ENV_IS_IN_DATAFLASH) && \
+ !defined(CONFIG_ENV_IS_IN_MG_DISK) && \
+ !defined(CONFIG_ENV_IS_IN_NAND) && \
+ !defined(CONFIG_ENV_IS_IN_NVRAM) && \
+ !defined(CONFIG_ENV_IS_IN_ONENAND) && \
+ !defined(CONFIG_ENV_IS_IN_SPI_FLASH) && \
+ !defined(CONFIG_ENV_IS_NOWHERE)
+# error Define one of CONFIG_ENV_IS_IN_{EEPROM|FLASH|DATAFLASH|ONENAND|\
+SPI_FLASH|MG_DISK|NVRAM|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);
-
-/* Function that updates CRC of the enironment */
-extern void env_crc_update (void);
-
-/************************************************************************
-************************************************************************/
-
-static int envmatch (uchar *, int);
-
/*
* Table with supported baudrates (defined in config_xyz.h)
*/
-static const unsigned long baudrate_table[] = CFG_BAUDRATE_TABLE;
+static const unsigned long baudrate_table[] = CONFIG_SYS_BAUDRATE_TABLE;
#define N_BAUDRATES (sizeof(baudrate_table) / sizeof(baudrate_table[0]))
+static int env_id = 1;
+int get_env_id (void)
+{
+ return env_id;
+}
/************************************************************************
* Command interface: print one or all environment variables
*/
}
}
- printf("\nEnvironment size: %d/%d bytes\n", i, ENV_SIZE);
+ printf("\nEnvironment size: %d/%ld bytes\n",
+ i, (ulong)ENV_SIZE);
return 0;
}
return 1;
}
+ env_id++;
/*
* search if variable with this name already exists
*/
* Ethernet Address and serial# can be set only once,
* ver is readonly.
*/
+ if (
#ifdef CONFIG_HAS_UID
/* Allow serial# forced overwrite with 0xdeaf4add flag */
- if ( ((strcmp (name, "serial#") == 0) && (flag != 0xdeaf4add)) ||
+ ((strcmp (name, "serial#") == 0) && (flag != 0xdeaf4add)) ||
#else
- if ( (strcmp (name, "serial#") == 0) ||
+ (strcmp (name, "serial#") == 0) ||
#endif
((strcmp (name, "ethaddr") == 0)
#if defined(CONFIG_OVERWRITE_ETHADDR_ONCE) && defined(CONFIG_ETHADDR)
return 1;
}
+#ifdef CONFIG_CONSOLE_MUX
+ i = iomux_doenv(console, argv[2]);
+ if (i)
+ return i;
+#else
/* Try assigning specified device */
if (console_assign (console, argv[2]) < 0)
return 1;
if (serial_assign (argv[2]) < 0)
return 1;
#endif
+#endif /* CONFIG_CONSOLE_MUX */
}
/*
*++env = '\0';
}
-#ifdef CONFIG_NET_MULTI
- if (strncmp(name, "eth", 3) == 0) {
- char *end;
- int num = simple_strtoul(name+3, &end, 10);
-
- if (strcmp(end, "addr") == 0) {
- eth_set_enetaddr(num, argv[2]);
- }
- }
-#endif
-
-
/* Delete only ? */
if ((argc < 3) || argv[2] == NULL) {
env_crc_update ();
* entry in the enviornment is changed
*/
- if (strcmp(argv[1],"ethaddr") == 0) {
- char *s = argv[2]; /* always use only one arg */
- char *e;
- for (i=0; i<6; ++i) {
- bd->bi_enetaddr[i] = s ? simple_strtoul(s, &e, 16) : 0;
- if (s) s = (*e) ? e+1 : e;
- }
-#ifdef CONFIG_NET_MULTI
- eth_set_enetaddr(0, argv[2]);
-#endif
+ if (strcmp(argv[1],"ethaddr") == 0)
return 0;
- }
if (strcmp(argv[1],"ipaddr") == 0) {
char *s = argv[2]; /* always use only one arg */
return 0;
}
-void setenv (char *varname, char *varvalue)
+int setenv (char *varname, char *varvalue)
{
char *argv[4] = { "setenv", varname, varvalue, NULL };
if (varvalue == NULL)
- _do_setenv (0, 2, argv);
+ return _do_setenv (0, 2, argv);
else
- _do_setenv (0, 3, argv);
+ return _do_setenv (0, 3, argv);
}
#ifdef CONFIG_HAS_UID
int do_setenv (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
if (argc < 2) {
- printf ("Usage:\n%s\n", cmdtp->usage);
+ cmd_usage(cmdtp);
return 1;
}
#if defined(CONFIG_CMD_ASKENV)
int do_askenv ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
- extern char console_buffer[CFG_CBSIZE];
- char message[CFG_CBSIZE];
- int size = CFG_CBSIZE - 1;
+ extern char console_buffer[CONFIG_SYS_CBSIZE];
+ char message[CONFIG_SYS_CBSIZE];
+ int size = CONFIG_SYS_CBSIZE - 1;
int len;
char *local_args[4];
local_args[3] = NULL;
if (argc < 2) {
- printf ("Usage:\n%s\n", cmdtp->usage);
+ cmd_usage(cmdtp);
return 1;
}
/* Check the syntax */
switch (argc) {
case 1:
- printf ("Usage:\n%s\n", cmdtp->usage);
+ cmd_usage(cmdtp);
return 1;
case 2: /* askenv envname */
break;
}
- if (size >= CFG_CBSIZE)
- size = CFG_CBSIZE - 1;
+ if (size >= CONFIG_SYS_CBSIZE)
+ size = CONFIG_SYS_CBSIZE - 1;
if (size <= 0)
return 1;
int val;
for (nxt=i; env_get_char(nxt) != '\0'; ++nxt) {
- if (nxt >= CFG_ENV_SIZE) {
+ if (nxt >= CONFIG_ENV_SIZE) {
return (NULL);
}
}
int val, n;
for (nxt=i; env_get_char(nxt) != '\0'; ++nxt) {
- if (nxt >= CFG_ENV_SIZE) {
+ if (nxt >= CONFIG_ENV_SIZE) {
return (-1);
}
}
return (-1);
}
-#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))
+#if defined(CONFIG_CMD_SAVEENV) && !defined(CONFIG_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);
}
+U_BOOT_CMD(
+ saveenv, 1, 0, do_saveenv,
+ "save environment variables to persistent storage",
+ NULL
+);
+
#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++))
/**************************************************/
U_BOOT_CMD(
- printenv, CFG_MAXARGS, 1, do_printenv,
- "printenv- print environment variables\n",
+ printenv, CONFIG_SYS_MAXARGS, 1, do_printenv,
+ "print environment variables",
"\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",
+ setenv, CONFIG_SYS_MAXARGS, 0, do_setenv,
+ "set environment variables",
"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))
-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",
+ askenv, CONFIG_SYS_MAXARGS, 1, do_askenv,
+ "get environment variables from stdin",
"name [message] [size]\n"
" - get environment variable 'name' from stdin (max 'size' chars)\n"
"askenv name\n"
#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",
+ run, CONFIG_SYS_MAXARGS, 1, do_run,
+ "run commands in an environment variable",
"var [...]\n"
" - run the commands in the environment variable(s) 'var'\n"
);