projects
/
oweals
/
u-boot.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
usb: host: Move CONFIG_XHCI_FSL to Kconfig
[oweals/u-boot.git]
/
cmd
/
nvedit.c
diff --git
a/cmd/nvedit.c
b/cmd/nvedit.c
index 5ae9d9d5ae36b94335c3acffac86bafecf3e4a35..4e79d03856fec3117e6614c8b544c5022531562a 100644
(file)
--- a/
cmd/nvedit.c
+++ b/
cmd/nvedit.c
@@
-15,7
+15,7
@@
*
* The "environment" is stored on external storage as a list of '\0'
* terminated "name=value" strings. The end of the list is marked by
*
* The "environment" is stored on external storage as a list of '\0'
* terminated "name=value" strings. The end of the list is marked by
- * a double '\0'. The environment is prece
e
ded by a 32 bit CRC over
+ * a double '\0'. The environment is preceded by a 32 bit CRC over
* the data part and, in case of redundant environment, a byte of
* flags.
*
* the data part and, in case of redundant environment, a byte of
* flags.
*
@@
-42,18
+42,19
@@
DECLARE_GLOBAL_DATA_PTR;
#if !defined(CONFIG_ENV_IS_IN_EEPROM) && \
!defined(CONFIG_ENV_IS_IN_FLASH) && \
#if !defined(CONFIG_ENV_IS_IN_EEPROM) && \
!defined(CONFIG_ENV_IS_IN_FLASH) && \
- !defined(CONFIG_ENV_IS_IN_DATAFLASH) && \
!defined(CONFIG_ENV_IS_IN_MMC) && \
!defined(CONFIG_ENV_IS_IN_FAT) && \
!defined(CONFIG_ENV_IS_IN_MMC) && \
!defined(CONFIG_ENV_IS_IN_FAT) && \
+ !defined(CONFIG_ENV_IS_IN_EXT4) && \
!defined(CONFIG_ENV_IS_IN_NAND) && \
!defined(CONFIG_ENV_IS_IN_NVRAM) && \
!defined(CONFIG_ENV_IS_IN_ONENAND) && \
!defined(CONFIG_ENV_IS_IN_NAND) && \
!defined(CONFIG_ENV_IS_IN_NVRAM) && \
!defined(CONFIG_ENV_IS_IN_ONENAND) && \
+ !defined(CONFIG_ENV_IS_IN_SATA) && \
!defined(CONFIG_ENV_IS_IN_SPI_FLASH) && \
!defined(CONFIG_ENV_IS_IN_REMOTE) && \
!defined(CONFIG_ENV_IS_IN_UBI) && \
!defined(CONFIG_ENV_IS_NOWHERE)
!defined(CONFIG_ENV_IS_IN_SPI_FLASH) && \
!defined(CONFIG_ENV_IS_IN_REMOTE) && \
!defined(CONFIG_ENV_IS_IN_UBI) && \
!defined(CONFIG_ENV_IS_NOWHERE)
-# error Define one of CONFIG_ENV_IS_IN_{EEPROM|FLASH|
DATAFLASH|ONENAND
|\
-
SPI_FLASH|NVRAM|MMC|FAT
|REMOTE|UBI} or CONFIG_ENV_IS_NOWHERE
+# error Define one of CONFIG_ENV_IS_IN_{EEPROM|FLASH|
MMC|FAT|EXT4
|\
+
NAND|NVRAM|ONENAND|SATA|SPI_FLASH
|REMOTE|UBI} or CONFIG_ENV_IS_NOWHERE
#endif
/*
#endif
/*
@@
-232,7
+233,6
@@
static int _do_env_set(int flag, int argc, char * const argv[], int env_flag)
}
debug("Final value for argc=%d\n", argc);
name = argv[1];
}
debug("Final value for argc=%d\n", argc);
name = argv[1];
- value = argv[2];
if (strchr(name, '=')) {
printf("## Error: illegal character '='"
if (strchr(name, '=')) {
printf("## Error: illegal character '='"
@@
-282,7
+282,7
@@
static int _do_env_set(int flag, int argc, char * const argv[], int env_flag)
return 0;
}
return 0;
}
-int
setenv
(const char *varname, const char *varvalue)
+int
env_set
(const char *varname, const char *varvalue)
{
const char * const argv[4] = { "setenv", varname, varvalue, NULL };
{
const char * const argv[4] = { "setenv", varname, varvalue, NULL };
@@
-303,12
+303,12
@@
int setenv(const char *varname, const char *varvalue)
* @param value Value to set it to
* @return 0 if ok, 1 on error
*/
* @param value Value to set it to
* @return 0 if ok, 1 on error
*/
-int
setenv
_ulong(const char *varname, ulong value)
+int
env_set
_ulong(const char *varname, ulong value)
{
/* TODO: this should be unsigned */
char *str = simple_itoa(value);
{
/* TODO: this should be unsigned */
char *str = simple_itoa(value);
- return
setenv
(varname, str);
+ return
env_set
(varname, str);
}
/**
}
/**
@@
-318,21
+318,21
@@
int setenv_ulong(const char *varname, ulong value)
* @param value Value to set it to
* @return 0 if ok, 1 on error
*/
* @param value Value to set it to
* @return 0 if ok, 1 on error
*/
-int
setenv
_hex(const char *varname, ulong value)
+int
env_set
_hex(const char *varname, ulong value)
{
char str[17];
sprintf(str, "%lx", value);
{
char str[17];
sprintf(str, "%lx", value);
- return
setenv
(varname, str);
+ return
env_set
(varname, str);
}
}
-ulong
getenv
_hex(const char *varname, ulong default_val)
+ulong
env_get
_hex(const char *varname, ulong default_val)
{
const char *s;
ulong value;
char *endp;
{
const char *s;
ulong value;
char *endp;
- s =
getenv
(varname);
+ s =
env_get
(varname);
if (s)
value = simple_strtoul(s, &endp, 16);
if (!s || endp == s)
if (s)
value = simple_strtoul(s, &endp, 16);
if (!s || endp == s)
@@
-392,15
+392,18
@@
int do_env_ask(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
sprintf(message, "Please enter '%s': ", argv[1]);
} else {
/* env_ask envname message1 ... messagen [size] */
sprintf(message, "Please enter '%s': ", argv[1]);
} else {
/* env_ask envname message1 ... messagen [size] */
- for (i = 2, pos = 0; i < argc; i++) {
+ for (i = 2, pos = 0; i < argc
&& pos+1 < sizeof(message)
; i++) {
if (pos)
message[pos++] = ' ';
if (pos)
message[pos++] = ' ';
- str
cpy(message + pos, argv[i]
);
+ str
ncpy(message + pos, argv[i], sizeof(message) - pos
);
pos += strlen(argv[i]);
}
pos += strlen(argv[i]);
}
- message[pos++] = ' ';
- message[pos] = '\0';
+ if (pos < sizeof(message) - 1) {
+ message[pos++] = ' ';
+ message[pos] = '\0';
+ } else
+ message[CONFIG_SYS_CBSIZE - 1] = '\0';
}
if (size >= CONFIG_SYS_CBSIZE)
}
if (size >= CONFIG_SYS_CBSIZE)
@@
-593,7
+596,7
@@
static int do_env_edit(cmd_tbl_t *cmdtp, int flag, int argc,
return 1;
/* Set read buffer to initial value or empty sting */
return 1;
/* Set read buffer to initial value or empty sting */
- init_val =
getenv
(argv[1]);
+ init_val =
env_get
(argv[1]);
if (init_val)
snprintf(buffer, CONFIG_SYS_CBSIZE, "%s", init_val);
else
if (init_val)
snprintf(buffer, CONFIG_SYS_CBSIZE, "%s", init_val);
else
@@
-621,7
+624,7
@@
static int do_env_edit(cmd_tbl_t *cmdtp, int flag, int argc,
* return address of storage for that variable,
* or NULL if not found
*/
* return address of storage for that variable,
* or NULL if not found
*/
-char *
getenv
(const char *name)
+char *
env_get
(const char *name)
{
if (gd->flags & GD_FLG_ENV_READY) { /* after import into hashtable */
ENTRY e, *ep;
{
if (gd->flags & GD_FLG_ENV_READY) { /* after import into hashtable */
ENTRY e, *ep;
@@
-636,7
+639,7
@@
char *getenv(const char *name)
}
/* restricted capabilities before import */
}
/* restricted capabilities before import */
- if (
getenv
_f(name, (char *)(gd->env_buf), sizeof(gd->env_buf)) > 0)
+ if (
env_get
_f(name, (char *)(gd->env_buf), sizeof(gd->env_buf)) > 0)
return (char *)(gd->env_buf);
return NULL;
return (char *)(gd->env_buf);
return NULL;
@@
-645,7
+648,7
@@
char *getenv(const char *name)
/*
* Look up variable from environment for restricted C runtime env.
*/
/*
* Look up variable from environment for restricted C runtime env.
*/
-int
getenv
_f(const char *name, char *buf, unsigned len)
+int
env_get
_f(const char *name, char *buf, unsigned len)
{
int i, nxt;
{
int i, nxt;
@@
-689,13
+692,13
@@
int getenv_f(const char *name, char *buf, unsigned len)
* found
* @return the decoded value, or default_val if not found
*/
* found
* @return the decoded value, or default_val if not found
*/
-ulong
getenv
_ulong(const char *name, int base, ulong default_val)
+ulong
env_get
_ulong(const char *name, int base, ulong default_val)
{
/*
{
/*
- * We can use
getenv
() here, even before relocation, since the
+ * We can use
env_get
() here, even before relocation, since the
* environment variable value is an integer and thus short.
*/
* environment variable value is an integer and thus short.
*/
- const char *str =
getenv
(name);
+ const char *str =
env_get
(name);
return str ? simple_strtoul(str, NULL, base) : default_val;
}
return str ? simple_strtoul(str, NULL, base) : default_val;
}
@@
-705,9
+708,11
@@
ulong getenv_ulong(const char *name, int base, ulong default_val)
static int do_env_save(cmd_tbl_t *cmdtp, int flag, int argc,
char * const argv[])
{
static int do_env_save(cmd_tbl_t *cmdtp, int flag, int argc,
char * const argv[])
{
-
printf("Saving Environment to %s...\n", env_name_spec
);
+
struct env_driver *env = env_driver_lookup_default(
);
- return saveenv() ? 1 : 0;
+ printf("Saving Environment to %s...\n", env->name);
+
+ return env_save() ? 1 : 0;
}
U_BOOT_CMD(
}
U_BOOT_CMD(
@@
-836,7
+841,7
@@
static int do_env_delete(cmd_tbl_t *cmdtp, int flag,
* With "-c" and size is NOT given, then the export command will
* format the data as currently used for the persistent storage,
* i. e. it will use CONFIG_ENV_SECT_SIZE as output block size and
* With "-c" and size is NOT given, then the export command will
* format the data as currently used for the persistent storage,
* i. e. it will use CONFIG_ENV_SECT_SIZE as output block size and
- * prepend a valid CRC32 checksum and, in case of re
s
undant
+ * prepend a valid CRC32 checksum and, in case of re
d
undant
* environment, a "current" redundancy flag. If size is given, this
* value will be used instead of CONFIG_ENV_SECT_SIZE; again, CRC32
* checksum and redundancy flag will be inserted.
* environment, a "current" redundancy flag. If size is given, this
* value will be used instead of CONFIG_ENV_SECT_SIZE; again, CRC32
* checksum and redundancy flag will be inserted.
@@
-845,12
+850,12
@@
static int do_env_delete(cmd_tbl_t *cmdtp, int flag,
* terminating '\0' byte) will be written; here the optional size
* argument will be used to make sure not to overflow the user
* provided buffer; the command will abort if the size is not
* terminating '\0' byte) will be written; here the optional size
* argument will be used to make sure not to overflow the user
* provided buffer; the command will abort if the size is not
- * sufficient. Any remaini
gn
space will be '\0' padded.
+ * sufficient. Any remaini
ng
space will be '\0' padded.
*
* On successful return, the variable "filesize" will be set.
* Note that filesize includes the trailing/terminating '\0' byte(s).
*
*
* On successful return, the variable "filesize" will be set.
* Note that filesize includes the trailing/terminating '\0' byte(s).
*
- * Usage s
z
enario: create a text snapshot/backup of the current settings:
+ * Usage s
c
enario: create a text snapshot/backup of the current settings:
*
* => env export -t 100000
* => era ${backup_addr} +${filesize}
*
* => env export -t 100000
* => era ${backup_addr} +${filesize}
@@
-924,11
+929,11
@@
NXTARG: ;
H_MATCH_KEY | H_MATCH_IDENT,
&ptr, size, argc, argv);
if (len < 0) {
H_MATCH_KEY | H_MATCH_IDENT,
&ptr, size, argc, argv);
if (len < 0) {
-
erro
r("Cannot export environment: errno = %d\n", errno);
+
pr_er
r("Cannot export environment: errno = %d\n", errno);
return 1;
}
sprintf(buf, "%zX", (size_t)len);
return 1;
}
sprintf(buf, "%zX", (size_t)len);
-
setenv
("filesize", buf);
+
env_set
("filesize", buf);
return 0;
}
return 0;
}
@@
-944,7
+949,7
@@
NXTARG: ;
H_MATCH_KEY | H_MATCH_IDENT,
&res, ENV_SIZE, argc, argv);
if (len < 0) {
H_MATCH_KEY | H_MATCH_IDENT,
&res, ENV_SIZE, argc, argv);
if (len < 0) {
-
erro
r("Cannot export environment: errno = %d\n", errno);
+
pr_er
r("Cannot export environment: errno = %d\n", errno);
return 1;
}
return 1;
}
@@
-954,7
+959,7
@@
NXTARG: ;
envp->flags = ACTIVE_FLAG;
#endif
}
envp->flags = ACTIVE_FLAG;
#endif
}
-
setenv
_hex("filesize", len + offsetof(env_t, data));
+
env_set
_hex("filesize", len + offsetof(env_t, data));
return 0;
return 0;
@@
-968,7
+973,7
@@
sep_err:
/*
* env import [-d] [-t [-r] | -b | -c] addr [size]
* -d: delete existing environment before importing;
/*
* env import [-d] [-t [-r] | -b | -c] addr [size]
* -d: delete existing environment before importing;
- * otherwise overwrite / append to existi
on
definitions
+ * otherwise overwrite / append to existi
ng
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
* -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
@@
-1079,7
+1084,7
@@
static int do_env_import(cmd_tbl_t *cmdtp, int flag,
if (himport_r(&env_htab, ptr, size, sep, del ? 0 : H_NOCLEAR,
crlf_is_lf, 0, NULL) == 0) {
if (himport_r(&env_htab, ptr, size, sep, del ? 0 : H_NOCLEAR,
crlf_is_lf, 0, NULL) == 0) {
-
erro
r("Environment import failed: errno = %d\n", errno);
+
pr_er
r("Environment import failed: errno = %d\n", errno);
return 1;
}
gd->flags |= GD_FLG_ENV_READY;
return 1;
}
gd->flags |= GD_FLG_ENV_READY;