diff --git a/env/common.c b/env/common.c index 1c75fd3133..d477e4e664 100644 --- a/env/common.c +++ b/env/common.c @@ -107,6 +107,22 @@ int set_default_vars(int nvars, char * const vars[]) H_NOCLEAR | H_INTERACTIVE, 0, nvars, vars); } +int set_board_env(const char *vars, int size, int flags, bool ready) +{ + if (himport_r(&env_htab, (char *)vars, size, '\0', + flags, 0, 0, NULL) == 0) { + pr_err("Environment import failed\n"); + return -1; + } + + if (ready) { + gd->flags |= GD_FLG_ENV_READY; + gd->flags |= GD_FLG_ENV_DEFAULT; + } + + return 0; +} + #ifdef CONFIG_ENV_AES #include /** diff --git a/include/environment.h b/include/environment.h index e328ac22fb..c2aa553c71 100644 --- a/include/environment.h +++ b/include/environment.h @@ -289,6 +289,9 @@ char *env_get_default(const char *name); /* [re]set to the default environment */ void set_default_env(const char *s); +/* [re]set to the board environment */ +int set_board_env(const char *vars, int size, int flags, bool ready); + /* [re]set individual variables to their value in the default environment */ int set_default_vars(int nvars, char * const vars[]);