mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-24 21:54:01 +00:00
cmd: env: add env load command
Add the new command env load to load the environment from the current location gd->env_load_prio. Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
This commit is contained in:
parent
466d9855d4
commit
0115dd3a6a
4 changed files with 55 additions and 0 deletions
|
@ -604,6 +604,12 @@ config CMD_NVEDIT_INFO
|
|||
[-q] : quiet output
|
||||
The result of multiple evaluations will be combined with AND.
|
||||
|
||||
config CMD_NVEDIT_LOAD
|
||||
bool "env load"
|
||||
help
|
||||
Load all environment variables from the compiled-in persistent
|
||||
storage.
|
||||
|
||||
endmenu
|
||||
|
||||
menu "Memory commands"
|
||||
|
|
14
cmd/nvedit.c
14
cmd/nvedit.c
|
@ -794,6 +794,14 @@ U_BOOT_CMD(
|
|||
);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_CMD_NVEDIT_LOAD)
|
||||
static int do_env_load(struct cmd_tbl *cmdtp, int flag, int argc,
|
||||
char *const argv[])
|
||||
{
|
||||
return env_reload() ? 1 : 0;
|
||||
}
|
||||
#endif
|
||||
#endif /* CONFIG_SPL_BUILD */
|
||||
|
||||
int env_match(uchar *s1, int i2)
|
||||
|
@ -1346,6 +1354,9 @@ static struct cmd_tbl cmd_env_sub[] = {
|
|||
#endif
|
||||
#if defined(CONFIG_CMD_NVEDIT_INFO)
|
||||
U_BOOT_CMD_MKENT(info, 3, 0, do_env_info, "", ""),
|
||||
#endif
|
||||
#if defined(CONFIG_CMD_NVEDIT_LOAD)
|
||||
U_BOOT_CMD_MKENT(load, 1, 0, do_env_load, "", ""),
|
||||
#endif
|
||||
U_BOOT_CMD_MKENT(print, CONFIG_SYS_MAXARGS, 1, do_env_print, "", ""),
|
||||
#if defined(CONFIG_CMD_RUN)
|
||||
|
@ -1442,6 +1453,9 @@ static char env_help_text[] =
|
|||
"env erase - erase environment\n"
|
||||
#endif
|
||||
#endif
|
||||
#if defined(CONFIG_CMD_NVEDIT_LOAD)
|
||||
"env load - load environment\n"
|
||||
#endif
|
||||
#if defined(CONFIG_CMD_NVEDIT_EFI)
|
||||
"env set -e [-nv][-bs][-rt][-at][-a][-i addr,size][-v] name [arg ...]\n"
|
||||
" - set UEFI variable; unset if '-i' or 'arg' not specified\n"
|
||||
|
|
28
env/env.c
vendored
28
env/env.c
vendored
|
@ -230,6 +230,34 @@ int env_load(void)
|
|||
return -ENODEV;
|
||||
}
|
||||
|
||||
int env_reload(void)
|
||||
{
|
||||
struct env_driver *drv;
|
||||
|
||||
drv = env_driver_lookup(ENVOP_LOAD, gd->env_load_prio);
|
||||
if (drv) {
|
||||
int ret;
|
||||
|
||||
printf("Loading Environment from %s... ", drv->name);
|
||||
|
||||
if (!env_has_inited(drv->location)) {
|
||||
printf("not initialized\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
ret = drv->load();
|
||||
if (ret)
|
||||
printf("Failed (%d)\n", ret);
|
||||
else
|
||||
printf("OK\n");
|
||||
|
||||
if (!ret)
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
int env_save(void)
|
||||
{
|
||||
struct env_driver *drv;
|
||||
|
|
|
@ -265,6 +265,13 @@ int env_set_default_vars(int nvars, char *const vars[], int flags);
|
|||
*/
|
||||
int env_load(void);
|
||||
|
||||
/**
|
||||
* env_reload() - Re-Load the environment from current storage
|
||||
*
|
||||
* @return 0 if OK, -ve on error
|
||||
*/
|
||||
int env_reload(void);
|
||||
|
||||
/**
|
||||
* env_save() - Save the environment to storage
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue