void env_relocate(void);
/**
- * env_match() - Match a name / name=value pair
- *
- * This is used prior to relocation for finding envrionment variables
- *
- * @name: A simple 'name', or a 'name=value' pair.
- * @index: The environment index for a 'name2=value2' pair.
- * @return index for the value if the names match, else -1.
- */
-int env_match(unsigned char *name, int index);
-
-/**
* env_get() - Look up the value of an environment variable
*
* In U-Boot proper this can be called before relocation (which is when the
*/
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)
*
* support reading the value (slowly) and some will not.
*
* @varname: Variable to look up
- * @return value of variable, or NULL if not found
+ * @return actual length of the variable value excluding the terminating
+ * NULL-byte, or -1 if the variable is not found
*/
int env_get_f(const char *name, char *buf, unsigned int len);
int env_get_yesno(const char *var);
/**
+ * env_get_autostart() - Check if autostart is enabled
+ *
+ * @return true if the "autostart" env var exists and is set to "yes"
+ */
+bool env_get_autostart(void);
+
+/**
* env_set() - set an environment variable
*
* This sets or deletes the value of an environment variable. For setting the
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
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
* @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
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
void env_set_default(const char *s, int flags);
/**
- * env_get_char() - Get a character from the early environment
- *
- * This reads from the pre-relocation environment
+ * env_reloc() - Relocate the 'env' sub-commands
*
- * @index: Index of character to read (0 = first)
- * @return character read, or -ve on error
+ * This is used for those unfortunate archs with crappy toolchains
*/
-int env_get_char(int index);
+void env_reloc(void);
+
/**
- * env_reloc() - Relocate the 'env' sub-commands
+ * env_import_fdt() - Import environment values from device tree blob
*
- * This is used for those unfortunate archs with crappy toolchains
+ * 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.
*/
-void env_reloc(void);
+#ifdef CONFIG_ENV_IMPORT_FDT
+void env_import_fdt(void);
+#else
+static inline void env_import_fdt(void) {}
+#endif
#endif