blob: 70897062a6fb11e03b76f76213d64f0dd16ee320 [file] [log] [blame]
wdenka68d3ed2002-10-11 08:38:32 +00001/*
2 * (C) Copyright 2000-2002
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4 *
5 * (C) Copyright 2001 Sysgo Real-Time Solutions, GmbH <www.elinos.com>
6 * Andreas Heppel <aheppel@sysgo.de>
7
8 * See file CREDITS for list of people who contributed to this
9 * project.
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License as
13 * published by the Free Software Foundation; either version 2 of
14 * the License, or (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
24 * MA 02111-1307 USA
25 */
26
27/**************************************************************************
28 *
29 * Support for persistent environment data
30 *
31 * The "environment" is stored as a list of '\0' terminated
32 * "name=value" strings. The end of the list is marked by a double
33 * '\0'. New entries are always added at the end. Deleting an entry
34 * shifts the remaining entries to the front. Replacing an entry is a
35 * combination of deleting the old value and adding the new one.
36 *
37 * The environment is preceeded by a 32 bit CRC over the data part.
38 *
39 **************************************************************************
40 */
41
42#include <common.h>
43#include <command.h>
44#include <environment.h>
wdenk2a3cb022002-11-05 21:01:48 +000045#include <watchdog.h>
wdenk281e00a2004-08-01 22:48:16 +000046#include <serial.h>
wdenka68d3ed2002-10-11 08:38:32 +000047#include <linux/stddef.h>
48#include <asm/byteorder.h>
Jon Loeligerc76fe472007-07-08 18:02:23 -050049#if defined(CONFIG_CMD_NET)
wdenka68d3ed2002-10-11 08:38:32 +000050#include <net.h>
51#endif
52
Wolfgang Denkd87080b2006-03-31 18:32:53 +020053DECLARE_GLOBAL_DATA_PTR;
54
wdenk5779d8d2003-12-06 23:55:10 +000055#if !defined(CFG_ENV_IS_IN_NVRAM) && \
56 !defined(CFG_ENV_IS_IN_EEPROM) && \
57 !defined(CFG_ENV_IS_IN_FLASH) && \
58 !defined(CFG_ENV_IS_IN_DATAFLASH) && \
wdenk13a56952004-06-09 14:58:14 +000059 !defined(CFG_ENV_IS_IN_NAND) && \
Kyungmin Parkd7e8ce12007-09-10 17:15:14 +090060 !defined(CFG_ENV_IS_IN_ONENAND) && \
Haavard Skinnemoen8c664972008-05-16 11:10:35 +020061 !defined(CFG_ENV_IS_IN_SPI_FLASH) && \
wdenk5779d8d2003-12-06 23:55:10 +000062 !defined(CFG_ENV_IS_NOWHERE)
Haavard Skinnemoen8c664972008-05-16 11:10:35 +020063# error Define one of CFG_ENV_IS_IN_{NVRAM|EEPROM|FLASH|DATAFLASH|ONENAND|SPI_FLASH|NOWHERE}
wdenka68d3ed2002-10-11 08:38:32 +000064#endif
65
66#define XMK_STR(x) #x
67#define MK_STR(x) XMK_STR(x)
68
69/************************************************************************
70************************************************************************/
71
wdenka68d3ed2002-10-11 08:38:32 +000072/*
73 * Table with supported baudrates (defined in config_xyz.h)
74 */
75static const unsigned long baudrate_table[] = CFG_BAUDRATE_TABLE;
76#define N_BAUDRATES (sizeof(baudrate_table) / sizeof(baudrate_table[0]))
77
78
79/************************************************************************
80 * Command interface: print one or all environment variables
81 */
82
83int do_printenv (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
84{
85 int i, j, k, nxt;
86 int rcode = 0;
87
88 if (argc == 1) { /* Print all env variables */
89 for (i=0; env_get_char(i) != '\0'; i=nxt+1) {
90 for (nxt=i; env_get_char(nxt) != '\0'; ++nxt)
91 ;
92 for (k=i; k<nxt; ++k)
93 putc(env_get_char(k));
94 putc ('\n');
95
96 if (ctrlc()) {
97 puts ("\n ** Abort\n");
98 return 1;
99 }
100 }
101
Wolfgang Denkd5996dd2008-07-13 19:51:00 +0200102 printf("\nEnvironment size: %d/%ld bytes\n",
103 i, (ulong)ENV_SIZE);
wdenka68d3ed2002-10-11 08:38:32 +0000104
105 return 0;
106 }
107
108 for (i=1; i<argc; ++i) { /* print single env variables */
109 char *name = argv[i];
110
111 k = -1;
112
113 for (j=0; env_get_char(j) != '\0'; j=nxt+1) {
114
115 for (nxt=j; env_get_char(nxt) != '\0'; ++nxt)
116 ;
Wolfgang Denk77ddac92005-10-13 16:45:02 +0200117 k = envmatch((uchar *)name, j);
wdenka68d3ed2002-10-11 08:38:32 +0000118 if (k < 0) {
119 continue;
120 }
121 puts (name);
122 putc ('=');
123 while (k < nxt)
124 putc(env_get_char(k++));
125 putc ('\n');
126 break;
127 }
128 if (k < 0) {
129 printf ("## Error: \"%s\" not defined\n", name);
130 rcode ++;
131 }
132 }
133 return rcode;
134}
135
136/************************************************************************
137 * Set a new environment variable,
138 * or replace or delete an existing one.
139 *
140 * This function will ONLY work with a in-RAM copy of the environment
141 */
142
143int _do_setenv (int flag, int argc, char *argv[])
144{
wdenka68d3ed2002-10-11 08:38:32 +0000145 int i, len, oldval;
146 int console = -1;
147 uchar *env, *nxt = NULL;
Wolfgang Denk77ddac92005-10-13 16:45:02 +0200148 char *name;
wdenka68d3ed2002-10-11 08:38:32 +0000149 bd_t *bd = gd->bd;
150
151 uchar *env_data = env_get_addr(0);
152
153 if (!env_data) /* need copy in RAM */
154 return 1;
155
156 name = argv[1];
157
Wolfgang Denk471a7be2006-10-28 01:14:32 +0200158 if (strchr(name, '=')) {
159 printf ("## Error: illegal character '=' in variable name \"%s\"\n", name);
160 return 1;
161 }
162
wdenka68d3ed2002-10-11 08:38:32 +0000163 /*
164 * search if variable with this name already exists
165 */
166 oldval = -1;
167 for (env=env_data; *env; env=nxt+1) {
168 for (nxt=env; *nxt; ++nxt)
169 ;
Wolfgang Denk77ddac92005-10-13 16:45:02 +0200170 if ((oldval = envmatch((uchar *)name, env-env_data)) >= 0)
wdenka68d3ed2002-10-11 08:38:32 +0000171 break;
172 }
173
174 /*
175 * Delete any existing definition
176 */
177 if (oldval >= 0) {
178#ifndef CONFIG_ENV_OVERWRITE
179
180 /*
stroese05875972003-04-04 15:44:49 +0000181 * Ethernet Address and serial# can be set only once,
182 * ver is readonly.
wdenka68d3ed2002-10-11 08:38:32 +0000183 */
Steven A. Falcof6a69552008-06-12 13:24:42 -0400184 if (
Sergey Kubushync74b2102007-08-10 20:26:18 +0200185#ifdef CONFIG_HAS_UID
186 /* Allow serial# forced overwrite with 0xdeaf4add flag */
Steven A. Falcof6a69552008-06-12 13:24:42 -0400187 ((strcmp (name, "serial#") == 0) && (flag != 0xdeaf4add)) ||
Sergey Kubushync74b2102007-08-10 20:26:18 +0200188#else
Steven A. Falcof6a69552008-06-12 13:24:42 -0400189 (strcmp (name, "serial#") == 0) ||
Sergey Kubushync74b2102007-08-10 20:26:18 +0200190#endif
wdenka68d3ed2002-10-11 08:38:32 +0000191 ((strcmp (name, "ethaddr") == 0)
192#if defined(CONFIG_OVERWRITE_ETHADDR_ONCE) && defined(CONFIG_ETHADDR)
Wolfgang Denk77ddac92005-10-13 16:45:02 +0200193 && (strcmp ((char *)env_get_addr(oldval),MK_STR(CONFIG_ETHADDR)) != 0)
wdenka68d3ed2002-10-11 08:38:32 +0000194#endif /* CONFIG_OVERWRITE_ETHADDR_ONCE && CONFIG_ETHADDR */
195 ) ) {
196 printf ("Can't overwrite \"%s\"\n", name);
197 return 1;
198 }
199#endif
200
201 /* Check for console redirection */
202 if (strcmp(name,"stdin") == 0) {
203 console = stdin;
204 } else if (strcmp(name,"stdout") == 0) {
205 console = stdout;
206 } else if (strcmp(name,"stderr") == 0) {
207 console = stderr;
208 }
209
210 if (console != -1) {
211 if (argc < 3) { /* Cannot delete it! */
212 printf("Can't delete \"%s\"\n", name);
213 return 1;
214 }
215
216 /* Try assigning specified device */
217 if (console_assign (console, argv[2]) < 0)
218 return 1;
wdenk281e00a2004-08-01 22:48:16 +0000219
220#ifdef CONFIG_SERIAL_MULTI
221 if (serial_assign (argv[2]) < 0)
222 return 1;
223#endif
wdenka68d3ed2002-10-11 08:38:32 +0000224 }
225
226 /*
227 * Switch to new baudrate if new baudrate is supported
228 */
229 if (strcmp(argv[1],"baudrate") == 0) {
230 int baudrate = simple_strtoul(argv[2], NULL, 10);
231 int i;
232 for (i=0; i<N_BAUDRATES; ++i) {
233 if (baudrate == baudrate_table[i])
234 break;
235 }
236 if (i == N_BAUDRATES) {
237 printf ("## Baudrate %d bps not supported\n",
238 baudrate);
239 return 1;
240 }
241 printf ("## Switch baudrate to %d bps and press ENTER ...\n",
242 baudrate);
243 udelay(50000);
244 gd->baudrate = baudrate;
Bartlomiej Siekac84bad02006-12-20 00:29:43 +0100245#if defined(CONFIG_PPC) || defined(CONFIG_MCF52x2)
wdenkd0fb80c2003-01-11 09:48:40 +0000246 gd->bd->bi_baudrate = baudrate;
247#endif
248
wdenka68d3ed2002-10-11 08:38:32 +0000249 serial_setbrg ();
250 udelay(50000);
251 for (;;) {
252 if (getc() == '\r')
253 break;
254 }
255 }
256
257 if (*++nxt == '\0') {
258 if (env > env_data) {
259 env--;
260 } else {
261 *env = '\0';
262 }
263 } else {
264 for (;;) {
265 *env = *nxt++;
266 if ((*env == '\0') && (*nxt == '\0'))
267 break;
268 ++env;
269 }
270 }
271 *++env = '\0';
272 }
273
274#ifdef CONFIG_NET_MULTI
275 if (strncmp(name, "eth", 3) == 0) {
276 char *end;
277 int num = simple_strtoul(name+3, &end, 10);
278
279 if (strcmp(end, "addr") == 0) {
280 eth_set_enetaddr(num, argv[2]);
281 }
282 }
283#endif
284
285
286 /* Delete only ? */
287 if ((argc < 3) || argv[2] == NULL) {
288 env_crc_update ();
289 return 0;
290 }
291
292 /*
293 * Append new definition at the end
294 */
295 for (env=env_data; *env || *(env+1); ++env)
296 ;
297 if (env > env_data)
298 ++env;
299 /*
300 * Overflow when:
301 * "name" + "=" + "val" +"\0\0" > ENV_SIZE - (env-env_data)
302 */
303 len = strlen(name) + 2;
304 /* add '=' for first arg, ' ' for all others */
305 for (i=2; i<argc; ++i) {
306 len += strlen(argv[i]) + 1;
307 }
308 if (len > (&env_data[ENV_SIZE]-env)) {
309 printf ("## Error: environment overflow, \"%s\" deleted\n", name);
310 return 1;
311 }
312 while ((*env = *name++) != '\0')
313 env++;
314 for (i=2; i<argc; ++i) {
315 char *val = argv[i];
316
317 *env = (i==2) ? '=' : ' ';
318 while ((*++env = *val++) != '\0')
319 ;
320 }
321
322 /* end is marked with double '\0' */
323 *++env = '\0';
324
325 /* Update CRC */
326 env_crc_update ();
327
328 /*
329 * Some variables should be updated when the corresponding
330 * entry in the enviornment is changed
331 */
332
333 if (strcmp(argv[1],"ethaddr") == 0) {
334 char *s = argv[2]; /* always use only one arg */
335 char *e;
336 for (i=0; i<6; ++i) {
337 bd->bi_enetaddr[i] = s ? simple_strtoul(s, &e, 16) : 0;
338 if (s) s = (*e) ? e+1 : e;
339 }
340#ifdef CONFIG_NET_MULTI
341 eth_set_enetaddr(0, argv[2]);
342#endif
343 return 0;
344 }
345
346 if (strcmp(argv[1],"ipaddr") == 0) {
347 char *s = argv[2]; /* always use only one arg */
348 char *e;
349 unsigned long addr;
350 bd->bi_ip_addr = 0;
351 for (addr=0, i=0; i<4; ++i) {
352 ulong val = s ? simple_strtoul(s, &e, 10) : 0;
353 addr <<= 8;
354 addr |= (val & 0xFF);
355 if (s) s = (*e) ? e+1 : e;
356 }
357 bd->bi_ip_addr = htonl(addr);
358 return 0;
359 }
360 if (strcmp(argv[1],"loadaddr") == 0) {
361 load_addr = simple_strtoul(argv[2], NULL, 16);
362 return 0;
363 }
Jon Loeligerc76fe472007-07-08 18:02:23 -0500364#if defined(CONFIG_CMD_NET)
wdenka68d3ed2002-10-11 08:38:32 +0000365 if (strcmp(argv[1],"bootfile") == 0) {
366 copy_filename (BootFile, argv[2], sizeof(BootFile));
367 return 0;
368 }
Jon Loeliger90253172007-07-10 11:02:44 -0500369#endif
wdenkc7de8292002-11-19 11:04:11 +0000370
stroese05875972003-04-04 15:44:49 +0000371#ifdef CONFIG_AMIGAONEG3SE
wdenkc7de8292002-11-19 11:04:11 +0000372 if (strcmp(argv[1], "vga_fg_color") == 0 ||
373 strcmp(argv[1], "vga_bg_color") == 0 ) {
374 extern void video_set_color(unsigned char attr);
375 extern unsigned char video_get_attr(void);
376
377 video_set_color(video_get_attr());
378 return 0;
379 }
380#endif /* CONFIG_AMIGAONEG3SE */
381
wdenka68d3ed2002-10-11 08:38:32 +0000382 return 0;
383}
384
Steven A. Falco75678c82008-06-12 13:22:12 -0400385int setenv (char *varname, char *varvalue)
wdenka68d3ed2002-10-11 08:38:32 +0000386{
387 char *argv[4] = { "setenv", varname, varvalue, NULL };
Jeffrey Mann9ffd4512007-04-23 14:00:11 +0200388 if (varvalue == NULL)
Steven A. Falco75678c82008-06-12 13:22:12 -0400389 return _do_setenv (0, 2, argv);
Jeffrey Mann9ffd4512007-04-23 14:00:11 +0200390 else
Steven A. Falco75678c82008-06-12 13:22:12 -0400391 return _do_setenv (0, 3, argv);
wdenka68d3ed2002-10-11 08:38:32 +0000392}
393
Sergey Kubushync74b2102007-08-10 20:26:18 +0200394#ifdef CONFIG_HAS_UID
395void forceenv (char *varname, char *varvalue)
396{
397 char *argv[4] = { "forceenv", varname, varvalue, NULL };
398 _do_setenv (0xdeaf4add, 3, argv);
399}
400#endif
401
402int do_setenv (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
wdenka68d3ed2002-10-11 08:38:32 +0000403{
404 if (argc < 2) {
405 printf ("Usage:\n%s\n", cmdtp->usage);
406 return 1;
407 }
408
409 return _do_setenv (flag, argc, argv);
410}
411
412/************************************************************************
413 * Prompt for environment variable
414 */
415
Jon Loeligerc76fe472007-07-08 18:02:23 -0500416#if defined(CONFIG_CMD_ASKENV)
wdenka68d3ed2002-10-11 08:38:32 +0000417int do_askenv ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
418{
419 extern char console_buffer[CFG_CBSIZE];
420 char message[CFG_CBSIZE];
421 int size = CFG_CBSIZE - 1;
422 int len;
423 char *local_args[4];
424
425 local_args[0] = argv[0];
426 local_args[1] = argv[1];
427 local_args[2] = NULL;
428 local_args[3] = NULL;
429
430 if (argc < 2) {
431 printf ("Usage:\n%s\n", cmdtp->usage);
432 return 1;
433 }
434 /* Check the syntax */
435 switch (argc) {
436 case 1:
437 printf ("Usage:\n%s\n", cmdtp->usage);
438 return 1;
439
440 case 2: /* askenv envname */
441 sprintf (message, "Please enter '%s':", argv[1]);
442 break;
443
444 case 3: /* askenv envname size */
445 sprintf (message, "Please enter '%s':", argv[1]);
446 size = simple_strtoul (argv[2], NULL, 10);
447 break;
448
449 default: /* askenv envname message1 ... messagen size */
450 {
451 int i;
452 int pos = 0;
453
454 for (i = 2; i < argc - 1; i++) {
455 if (pos) {
456 message[pos++] = ' ';
457 }
458 strcpy (message+pos, argv[i]);
459 pos += strlen(argv[i]);
460 }
461 message[pos] = '\0';
462 size = simple_strtoul (argv[argc - 1], NULL, 10);
463 }
464 break;
465 }
466
467 if (size >= CFG_CBSIZE)
468 size = CFG_CBSIZE - 1;
469
470 if (size <= 0)
471 return 1;
472
473 /* prompt for input */
474 len = readline (message);
475
476 if (size < len)
477 console_buffer[size] = '\0';
478
479 len = 2;
480 if (console_buffer[0] != '\0') {
481 local_args[2] = console_buffer;
482 len = 3;
483 }
484
485 /* Continue calling setenv code */
486 return _do_setenv (flag, len, local_args);
487}
Jon Loeliger90253172007-07-10 11:02:44 -0500488#endif
wdenka68d3ed2002-10-11 08:38:32 +0000489
490/************************************************************************
491 * Look up variable from environment,
492 * return address of storage for that variable,
493 * or NULL if not found
494 */
495
Wolfgang Denk77ddac92005-10-13 16:45:02 +0200496char *getenv (char *name)
wdenka68d3ed2002-10-11 08:38:32 +0000497{
498 int i, nxt;
499
wdenk2a3cb022002-11-05 21:01:48 +0000500 WATCHDOG_RESET();
501
wdenka68d3ed2002-10-11 08:38:32 +0000502 for (i=0; env_get_char(i) != '\0'; i=nxt+1) {
503 int val;
504
505 for (nxt=i; env_get_char(nxt) != '\0'; ++nxt) {
506 if (nxt >= CFG_ENV_SIZE) {
507 return (NULL);
508 }
509 }
Wolfgang Denk77ddac92005-10-13 16:45:02 +0200510 if ((val=envmatch((uchar *)name, i)) < 0)
wdenka68d3ed2002-10-11 08:38:32 +0000511 continue;
Wolfgang Denk77ddac92005-10-13 16:45:02 +0200512 return ((char *)env_get_addr(val));
wdenka68d3ed2002-10-11 08:38:32 +0000513 }
514
515 return (NULL);
516}
517
Wolfgang Denk77ddac92005-10-13 16:45:02 +0200518int getenv_r (char *name, char *buf, unsigned len)
wdenka68d3ed2002-10-11 08:38:32 +0000519{
520 int i, nxt;
521
522 for (i=0; env_get_char(i) != '\0'; i=nxt+1) {
523 int val, n;
524
525 for (nxt=i; env_get_char(nxt) != '\0'; ++nxt) {
526 if (nxt >= CFG_ENV_SIZE) {
527 return (-1);
528 }
529 }
Wolfgang Denk77ddac92005-10-13 16:45:02 +0200530 if ((val=envmatch((uchar *)name, i)) < 0)
wdenka68d3ed2002-10-11 08:38:32 +0000531 continue;
532 /* found; copy out */
533 n = 0;
534 while ((len > n++) && (*buf++ = env_get_char(val++)) != '\0')
535 ;
536 if (len == n)
537 *buf = '\0';
538 return (n);
539 }
540 return (-1);
541}
542
Jean-Christophe PLAGNIOL-VILLARD00b48a42008-02-23 12:15:56 +0100543#if ((defined(CFG_ENV_IS_IN_NVRAM) || defined(CFG_ENV_IS_IN_EEPROM) \
Jon Loeliger65c450b2007-06-11 19:01:54 -0500544 || (defined(CONFIG_CMD_ENV) && defined(CONFIG_CMD_FLASH)) \
Kyungmin Parkd7e8ce12007-09-10 17:15:14 +0900545 || (defined(CONFIG_CMD_ENV) && defined(CONFIG_CMD_NAND)) \
Jean-Christophe PLAGNIOL-VILLARD00b48a42008-02-23 12:15:56 +0100546 || (defined(CONFIG_CMD_ENV) && defined(CONFIG_CMD_ONENAND))) \
547 && !defined(CFG_ENV_IS_NOWHERE))
wdenka68d3ed2002-10-11 08:38:32 +0000548int do_saveenv (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
549{
550 extern char * env_name_spec;
551
552 printf ("Saving Environment to %s...\n", env_name_spec);
553
554 return (saveenv() ? 1 : 0);
555}
wdenk8bde7f72003-06-27 21:31:46 +0000556
wdenka68d3ed2002-10-11 08:38:32 +0000557#endif
558
559
560/************************************************************************
561 * Match a name / name=value pair
562 *
563 * s1 is either a simple 'name', or a 'name=value' pair.
564 * i2 is the environment index for a 'name2=value2' pair.
565 * If the names match, return the index for the value2, else NULL.
566 */
567
Rafal Jaworowski26a41792008-01-09 18:05:27 +0100568int envmatch (uchar *s1, int i2)
wdenka68d3ed2002-10-11 08:38:32 +0000569{
570
571 while (*s1 == env_get_char(i2++))
572 if (*s1++ == '=')
573 return(i2);
574 if (*s1 == '\0' && env_get_char(i2-1) == '=')
575 return(i2);
576 return(-1);
577}
wdenk8bde7f72003-06-27 21:31:46 +0000578
579
580/**************************************************/
581
wdenk0d498392003-07-01 21:06:45 +0000582U_BOOT_CMD(
583 printenv, CFG_MAXARGS, 1, do_printenv,
wdenk8bde7f72003-06-27 21:31:46 +0000584 "printenv- print environment variables\n",
585 "\n - print values of all environment variables\n"
586 "printenv name ...\n"
587 " - print value of environment variable 'name'\n"
588);
589
wdenk0d498392003-07-01 21:06:45 +0000590U_BOOT_CMD(
591 setenv, CFG_MAXARGS, 0, do_setenv,
wdenk8bde7f72003-06-27 21:31:46 +0000592 "setenv - set environment variables\n",
593 "name value ...\n"
594 " - set environment variable 'name' to 'value ...'\n"
595 "setenv name\n"
596 " - delete environment variable 'name'\n"
597);
598
Jean-Christophe PLAGNIOL-VILLARD00b48a42008-02-23 12:15:56 +0100599#if ((defined(CFG_ENV_IS_IN_NVRAM) || defined(CFG_ENV_IS_IN_EEPROM) \
Jon Loeliger65c450b2007-06-11 19:01:54 -0500600 || (defined(CONFIG_CMD_ENV) && defined(CONFIG_CMD_FLASH)) \
Kyungmin Parkd7e8ce12007-09-10 17:15:14 +0900601 || (defined(CONFIG_CMD_ENV) && defined(CONFIG_CMD_NAND)) \
Jean-Christophe PLAGNIOL-VILLARD00b48a42008-02-23 12:15:56 +0100602 || (defined(CONFIG_CMD_ENV) && defined(CONFIG_CMD_ONENAND))) \
603 && !defined(CFG_ENV_IS_NOWHERE))
wdenk0d498392003-07-01 21:06:45 +0000604U_BOOT_CMD(
605 saveenv, 1, 0, do_saveenv,
wdenk8bde7f72003-06-27 21:31:46 +0000606 "saveenv - save environment variables to persistent storage\n",
607 NULL
608);
609
Jon Loeliger90253172007-07-10 11:02:44 -0500610#endif
wdenk8bde7f72003-06-27 21:31:46 +0000611
Jon Loeligerc76fe472007-07-08 18:02:23 -0500612#if defined(CONFIG_CMD_ASKENV)
wdenk8bde7f72003-06-27 21:31:46 +0000613
wdenk0d498392003-07-01 21:06:45 +0000614U_BOOT_CMD(
615 askenv, CFG_MAXARGS, 1, do_askenv,
wdenk8bde7f72003-06-27 21:31:46 +0000616 "askenv - get environment variables from stdin\n",
617 "name [message] [size]\n"
618 " - get environment variable 'name' from stdin (max 'size' chars)\n"
619 "askenv name\n"
620 " - get environment variable 'name' from stdin\n"
621 "askenv name size\n"
622 " - get environment variable 'name' from stdin (max 'size' chars)\n"
623 "askenv name [message] size\n"
624 " - display 'message' string and get environment variable 'name'"
625 "from stdin (max 'size' chars)\n"
626);
Jon Loeliger90253172007-07-10 11:02:44 -0500627#endif
wdenk8bde7f72003-06-27 21:31:46 +0000628
Jon Loeligerc76fe472007-07-08 18:02:23 -0500629#if defined(CONFIG_CMD_RUN)
wdenk8bde7f72003-06-27 21:31:46 +0000630int do_run (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
wdenk0d498392003-07-01 21:06:45 +0000631U_BOOT_CMD(
632 run, CFG_MAXARGS, 1, do_run,
wdenk8bde7f72003-06-27 21:31:46 +0000633 "run - run commands in an environment variable\n",
634 "var [...]\n"
635 " - run the commands in the environment variable(s) 'var'\n"
636);
Jon Loeliger90253172007-07-10 11:02:44 -0500637#endif