projects
/
oweals
/
u-boot.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
OMAP3: igep00x0: Fix boot hang and add support for status LED.
[oweals/u-boot.git]
/
common
/
cmd_nvedit.c
diff --git
a/common/cmd_nvedit.c
b/common/cmd_nvedit.c
index 5bcc324675eb7535c9e103cd473134122b83e376..855808c3e4a4d58bc3437da32725a3b725face01 100644
(file)
--- a/
common/cmd_nvedit.c
+++ b/
common/cmd_nvedit.c
@@
-25,6
+25,7
@@
*/
#include <common.h>
*/
#include <common.h>
+#include <cli.h>
#include <command.h>
#include <environment.h>
#include <search.h>
#include <command.h>
#include <environment.h>
#include <search.h>
@@
-33,6
+34,7
@@
#include <watchdog.h>
#include <linux/stddef.h>
#include <asm/byteorder.h>
#include <watchdog.h>
#include <linux/stddef.h>
#include <asm/byteorder.h>
+#include <asm/io.h>
DECLARE_GLOBAL_DATA_PTR;
DECLARE_GLOBAL_DATA_PTR;
@@
-407,7
+409,7
@@
int do_env_ask(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
return 1;
/* prompt for input */
return 1;
/* prompt for input */
- len = readline(message);
+ len =
cli_
readline(message);
if (size < len)
console_buffer[size] = '\0';
if (size < len)
console_buffer[size] = '\0';
@@
-590,7
+592,7
@@
static int do_env_edit(cmd_tbl_t *cmdtp, int flag, int argc,
else
buffer[0] = '\0';
else
buffer[0] = '\0';
- if (readline_into_buffer("edit: ", buffer, 0) < 0)
+ if (
cli_
readline_into_buffer("edit: ", buffer, 0) < 0)
return 1;
return setenv(argv[1], buffer);
return 1;
return setenv(argv[1], buffer);
@@
-846,7
+848,8
@@
static int do_env_export(cmd_tbl_t *cmdtp, int flag,
int argc, char * const argv[])
{
char buf[32];
int argc, char * const argv[])
{
char buf[32];
- char *addr, *cmd, *res;
+ ulong addr;
+ char *ptr, *cmd, *res;
size_t size = 0;
ssize_t len;
env_t *envp;
size_t size = 0;
ssize_t len;
env_t *envp;
@@
-891,10
+894,11
@@
NXTARG: ;
if (argc < 1)
return CMD_RET_USAGE;
if (argc < 1)
return CMD_RET_USAGE;
- addr = (char *)simple_strtoul(argv[0], NULL, 16);
+ addr = simple_strtoul(argv[0], NULL, 16);
+ ptr = map_sysmem(addr, size);
if (size)
if (size)
- memset(
add
r, '\0', size);
+ memset(
pt
r, '\0', size);
argc--;
argv++;
argc--;
argv++;
@@
-902,7
+906,7
@@
NXTARG: ;
if (sep) { /* export as text file */
len = hexport_r(&env_htab, sep,
H_MATCH_KEY | H_MATCH_IDENT,
if (sep) { /* export as text file */
len = hexport_r(&env_htab, sep,
H_MATCH_KEY | H_MATCH_IDENT,
- &
add
r, size, argc, argv);
+ &
pt
r, size, argc, argv);
if (len < 0) {
error("Cannot export environment: errno = %d\n", errno);
return 1;
if (len < 0) {
error("Cannot export environment: errno = %d\n", errno);
return 1;
@@
-913,12
+917,12
@@
NXTARG: ;
return 0;
}
return 0;
}
- envp = (env_t *)
add
r;
+ envp = (env_t *)
pt
r;
if (chk) /* export as checksum protected block */
res = (char *)envp->data;
else /* export as raw binary data */
if (chk) /* export as checksum protected block */
res = (char *)envp->data;
else /* export as raw binary data */
- res =
add
r;
+ res =
pt
r;
len = hexport_r(&env_htab, '\0',
H_MATCH_KEY | H_MATCH_IDENT,
len = hexport_r(&env_htab, '\0',
H_MATCH_KEY | H_MATCH_IDENT,
@@
-946,11
+950,15
@@
sep_err:
#ifdef CONFIG_CMD_IMPORTENV
/*
#ifdef CONFIG_CMD_IMPORTENV
/*
- * env import [-d] [-t | -b | -c] addr [size]
+ * env import [-d] [-t
[-r]
| -b | -c] addr [size]
* -d: delete existing environment before importing;
* otherwise overwrite / append to existion definitions
* -t: assume text format; either "size" must be given or the
* text data must be '\0' terminated
* -d: delete existing environment before importing;
* otherwise overwrite / append to existion definitions
* -t: assume text format; either "size" must be given or the
* text data must be '\0' terminated
+ * -r: handle CRLF like LF, that means exported variables with
+ * a content which ends with \r won't get imported. Used
+ * to import text files created with editors which are using CRLF
+ * for line endings. Only effective in addition to -t.
* -b: assume binary format ('\0' separated, "\0\0" terminated)
* -c: assume checksum protected environment format
* addr: memory address to read from
* -b: assume binary format ('\0' separated, "\0\0" terminated)
* -c: assume checksum protected environment format
* addr: memory address to read from
@@
-960,11
+968,13
@@
sep_err:
static int do_env_import(cmd_tbl_t *cmdtp, int flag,
int argc, char * const argv[])
{
static int do_env_import(cmd_tbl_t *cmdtp, int flag,
int argc, char * const argv[])
{
- char *cmd, *addr;
+ ulong addr;
+ char *cmd, *ptr;
char sep = '\n';
int chk = 0;
int fmt = 0;
int del = 0;
char sep = '\n';
int chk = 0;
int fmt = 0;
int del = 0;
+ int crlf_is_lf = 0;
size_t size;
cmd = *argv;
size_t size;
cmd = *argv;
@@
-989,6
+999,9
@@
static int do_env_import(cmd_tbl_t *cmdtp, int flag,
goto sep_err;
sep = '\n';
break;
goto sep_err;
sep = '\n';
break;
+ case 'r': /* handle CRLF like LF */
+ crlf_is_lf = 1;
+ break;
case 'd':
del = 1;
break;
case 'd':
del = 1;
break;
@@
-1004,12
+1017,19
@@
static int do_env_import(cmd_tbl_t *cmdtp, int flag,
if (!fmt)
printf("## Warning: defaulting to text format\n");
if (!fmt)
printf("## Warning: defaulting to text format\n");
- addr = (char *)simple_strtoul(argv[0], NULL, 16);
+ if (sep != '\n' && crlf_is_lf )
+ crlf_is_lf = 0;
+
+ addr = simple_strtoul(argv[0], NULL, 16);
+ ptr = map_sysmem(addr, 0);
if (argc == 2) {
size = simple_strtoul(argv[1], NULL, 16);
if (argc == 2) {
size = simple_strtoul(argv[1], NULL, 16);
+ } else if (argc == 1 && chk) {
+ puts("## Error: external checksum format must pass size\n");
+ return CMD_RET_FAILURE;
} else {
} else {
- char *s =
add
r;
+ char *s =
pt
r;
size = 0;
size = 0;
@@
-1029,7
+1049,7
@@
static int do_env_import(cmd_tbl_t *cmdtp, int flag,
if (chk) {
uint32_t crc;
if (chk) {
uint32_t crc;
- env_t *ep = (env_t *)
add
r;
+ env_t *ep = (env_t *)
pt
r;
size -= offsetof(env_t, data);
memcpy(&crc, &ep->crc, sizeof(crc));
size -= offsetof(env_t, data);
memcpy(&crc, &ep->crc, sizeof(crc));
@@
-1038,11
+1058,11
@@
static int do_env_import(cmd_tbl_t *cmdtp, int flag,
puts("## Error: bad CRC, import failed\n");
return 1;
}
puts("## Error: bad CRC, import failed\n");
return 1;
}
-
add
r = (char *)ep->data;
+
pt
r = (char *)ep->data;
}
}
- if (himport_r(&env_htab,
add
r, size, sep, del ? 0 : H_NOCLEAR,
- 0, NULL) == 0) {
+ if (himport_r(&env_htab,
pt
r, size, sep, del ? 0 : H_NOCLEAR,
+
crlf_is_lf,
0, NULL) == 0) {
error("Environment import failed: errno = %d\n", errno);
return 1;
}
error("Environment import failed: errno = %d\n", errno);
return 1;
}
@@
-1171,7
+1191,7
@@
static char env_help_text[] =
#endif
#endif
#if defined(CONFIG_CMD_IMPORTENV)
#endif
#endif
#if defined(CONFIG_CMD_IMPORTENV)
- "env import [-d] [-t | -b | -c] addr [size] - import environment\n"
+ "env import [-d] [-t
[-r]
| -b | -c] addr [size] - import environment\n"
#endif
"env print [-a | name ...] - print environment\n"
#if defined(CONFIG_CMD_RUN)
#endif
"env print [-a | name ...] - print environment\n"
#if defined(CONFIG_CMD_RUN)