X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=include%2Fenv.h;h=d5e2bcb530f03f23c8cae862dc44fca530117d5e;hb=49c8ef0e45a91ec894ef15e7d043dafe8f1c5efd;hp=a74a261337e640024f1a6ebac5eb4d9014a37d2b;hpb=88c7a0a8c2ce6b503ff5d5509effb2a9f844993e;p=platform%2Fkernel%2Fu-boot.git diff --git a/include/env.h b/include/env.h index a74a261..d5e2bcb 100644 --- a/include/env.h +++ b/include/env.h @@ -9,6 +9,7 @@ #ifndef __ENV_H #define __ENV_H +#include #include #include @@ -112,6 +113,16 @@ int env_match(unsigned char *name, int index); */ char *env_get(const char *varname); +/* + * Like env_get, but prints an error if envvar isn't defined in the + * environment. It always returns what env_get does, so it can be used in + * place of env_get without changing error handling otherwise. + * + * @varname: Variable to look up + * @return value of variable, or NULL if not found + */ +char *from_env(const char *envvar); + /** * env_get_f() - Look up the value of an environment variable (early) * @@ -255,6 +266,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 * * @return 0 if OK, -ve on error @@ -269,6 +287,13 @@ int env_save(void); int env_erase(void); /** + * env_select() - Select the environment storage + * + * @return 0 if OK, -ve on error + */ +int env_select(const char *name); + +/** * env_import() - Import from a binary representation into hash table * * This imports the environment from a buffer. The format for each variable is @@ -277,10 +302,11 @@ int env_erase(void); * @buf: Buffer containing the environment (struct environemnt_s *) * @check: non-zero to check the CRC at the start of the environment, 0 to * ignore it + * @flags: Flags controlling matching (H_... - see search.h) * @return 0 if imported successfully, -ENOMSG if the CRC was bad, -EIO if * something else went wrong */ -int env_import(const char *buf, int check); +int env_import(const char *buf, int check, int flags); /** * env_export() - Export the environment to a buffer @@ -293,16 +319,34 @@ int env_import(const char *buf, int check); int env_export(struct environment_s *env_out); /** + * env_check_redund() - check the two redundant environments + * and find out, which is the valid one. + * + * @buf1: First environment (struct environemnt_s *) + * @buf1_read_fail: 0 if buf1 is valid, non-zero if invalid + * @buf2: Second environment (struct environemnt_s *) + * @buf2_read_fail: 0 if buf2 is valid, non-zero if invalid + * @return 0 if OK, + * -EIO if no environment is valid, + * -ENOMSG if the CRC was bad + */ + +int env_check_redund(const char *buf1, int buf1_read_fail, + const char *buf2, int buf2_read_fail); + +/** * env_import_redund() - Select and import one of two redundant environments * * @buf1: First environment (struct environemnt_s *) * @buf1_read_fail: 0 if buf1 is valid, non-zero if invalid * @buf2: Second environment (struct environemnt_s *) * @buf2_read_fail: 0 if buf2 is valid, non-zero if invalid + * @flags: Flags controlling matching (H_... - see search.h) * @return 0 if OK, -EIO if no environment is valid, -ENOMSG if the CRC was bad */ int env_import_redund(const char *buf1, int buf1_read_fail, - const char *buf2, int buf2_read_fail); + const char *buf2, int buf2_read_fail, + int flags); /** * env_get_default() - Look up a variable from the default environment @@ -332,4 +376,18 @@ int env_get_char(int index); */ void env_reloc(void); + +/** + * env_import_fdt() - Import environment values from device tree blob + * + * This uses the value of the environment variable "env_fdt_path" as a + * path to an fdt node, whose property/value pairs are added to the + * environment. + */ +#ifdef CONFIG_ENV_IMPORT_FDT +void env_import_fdt(void); +#else +static inline void env_import_fdt(void) {} +#endif + #endif