Simon Glass | af95f20 | 2019-08-01 09:46:40 -0600 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
| 2 | /* |
Simon Glass | db19701 | 2019-08-01 09:47:04 -0600 | [diff] [blame] | 3 | * Common environment functions and definitions |
Simon Glass | af95f20 | 2019-08-01 09:46:40 -0600 | [diff] [blame] | 4 | * |
| 5 | * (C) Copyright 2000-2009 |
| 6 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 7 | */ |
| 8 | |
| 9 | #ifndef __ENV_H |
| 10 | #define __ENV_H |
| 11 | |
Pierre-Jean Texier | 664689f | 2019-08-26 13:06:17 +0200 | [diff] [blame] | 12 | #include <compiler.h> |
Simon Glass | af95f20 | 2019-08-01 09:46:40 -0600 | [diff] [blame] | 13 | #include <stdbool.h> |
Simon Glass | c7694dd | 2019-08-01 09:46:46 -0600 | [diff] [blame] | 14 | #include <linux/types.h> |
Simon Glass | af95f20 | 2019-08-01 09:46:40 -0600 | [diff] [blame] | 15 | |
Simon Glass | 4e9ce8a | 2019-08-01 09:46:58 -0600 | [diff] [blame] | 16 | struct environment_s; |
| 17 | |
Simon Glass | db19701 | 2019-08-01 09:47:04 -0600 | [diff] [blame] | 18 | /* Value for environment validity */ |
| 19 | enum env_valid { |
| 20 | ENV_INVALID, /* No valid environment */ |
| 21 | ENV_VALID, /* First or only environment is valid */ |
| 22 | ENV_REDUND, /* Redundant environment is valid */ |
| 23 | }; |
| 24 | |
Simon Glass | 02cf933 | 2019-08-01 09:47:05 -0600 | [diff] [blame] | 25 | /** enum env_op - environment callback operation */ |
| 26 | enum env_op { |
| 27 | env_op_create, |
| 28 | env_op_delete, |
| 29 | env_op_overwrite, |
| 30 | }; |
| 31 | |
| 32 | /** struct env_clbk_tbl - declares a new callback */ |
| 33 | struct env_clbk_tbl { |
| 34 | const char *name; /* Callback name */ |
| 35 | int (*callback)(const char *name, const char *value, enum env_op op, |
| 36 | int flags); |
| 37 | }; |
| 38 | |
| 39 | /* |
| 40 | * Define a callback that can be associated with variables. |
| 41 | * when associated through the ".callbacks" environment variable, the callback |
| 42 | * will be executed any time the variable is inserted, overwritten, or deleted. |
| 43 | * |
| 44 | * For SPL these are silently dropped to reduce code size, since environment |
| 45 | * callbacks are not supported with SPL. |
| 46 | */ |
| 47 | #ifdef CONFIG_SPL_BUILD |
| 48 | #define U_BOOT_ENV_CALLBACK(name, callback) \ |
| 49 | static inline __maybe_unused void _u_boot_env_noop_##name(void) \ |
| 50 | { \ |
| 51 | (void)callback; \ |
| 52 | } |
| 53 | #else |
| 54 | #define U_BOOT_ENV_CALLBACK(name, callback) \ |
| 55 | ll_entry_declare(struct env_clbk_tbl, name, env_clbk) = \ |
| 56 | {#name, callback} |
| 57 | #endif |
| 58 | |
Simon Glass | d3716dd | 2019-08-01 09:47:08 -0600 | [diff] [blame] | 59 | /** enum env_redund_flags - Flags for the redundand_environment */ |
| 60 | enum env_redund_flags { |
| 61 | ENV_REDUND_OBSOLETE = 0, |
| 62 | ENV_REDUND_ACTIVE = 1, |
| 63 | }; |
| 64 | |
Simon Glass | af95f20 | 2019-08-01 09:46:40 -0600 | [diff] [blame] | 65 | /** |
Simon Glass | f1f0ae6 | 2019-08-01 09:46:41 -0600 | [diff] [blame] | 66 | * env_get_id() - Gets a sequence number for the environment |
| 67 | * |
| 68 | * This value increments every time the environment changes, so can be used an |
| 69 | * an indication of this |
| 70 | * |
Heinrich Schuchardt | 185f812 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 71 | * Return: environment ID |
Simon Glass | f1f0ae6 | 2019-08-01 09:46:41 -0600 | [diff] [blame] | 72 | */ |
| 73 | int env_get_id(void); |
| 74 | |
| 75 | /** |
Simon Glass | 4bfd1f5 | 2019-08-01 09:46:43 -0600 | [diff] [blame] | 76 | * env_init() - Set up the pre-relocation environment |
| 77 | * |
| 78 | * This locates the environment or uses the default if nothing is available. |
| 79 | * This must be called before env_get() will work. |
| 80 | * |
Heinrich Schuchardt | 185f812 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 81 | * Return: 0 if OK, -ENODEV if no environment drivers are enabled |
Simon Glass | 4bfd1f5 | 2019-08-01 09:46:43 -0600 | [diff] [blame] | 82 | */ |
| 83 | int env_init(void); |
| 84 | |
| 85 | /** |
Simon Glass | 3f989e7b | 2019-08-01 09:46:44 -0600 | [diff] [blame] | 86 | * env_relocate() - Set up the post-relocation environment |
| 87 | * |
| 88 | * This loads the environment into RAM so that it can be modified. This is |
| 89 | * called after relocation, before the environment is used |
| 90 | */ |
| 91 | void env_relocate(void); |
| 92 | |
| 93 | /** |
Simon Glass | 7b51b57 | 2019-08-01 09:46:52 -0600 | [diff] [blame] | 94 | * env_get() - Look up the value of an environment variable |
| 95 | * |
| 96 | * In U-Boot proper this can be called before relocation (which is when the |
| 97 | * environment is loaded from storage, i.e. GD_FLG_ENV_READY is 0). In that |
| 98 | * case this function calls env_get_f(). |
| 99 | * |
| 100 | * @varname: Variable to look up |
Heinrich Schuchardt | 185f812 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 101 | * Return: value of variable, or NULL if not found |
Simon Glass | 7b51b57 | 2019-08-01 09:46:52 -0600 | [diff] [blame] | 102 | */ |
| 103 | char *env_get(const char *varname); |
| 104 | |
Patrice Chotard | 1ac2cb9 | 2019-11-25 09:07:36 +0100 | [diff] [blame] | 105 | /* |
| 106 | * Like env_get, but prints an error if envvar isn't defined in the |
| 107 | * environment. It always returns what env_get does, so it can be used in |
| 108 | * place of env_get without changing error handling otherwise. |
| 109 | * |
| 110 | * @varname: Variable to look up |
Heinrich Schuchardt | 185f812 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 111 | * Return: value of variable, or NULL if not found |
Patrice Chotard | 1ac2cb9 | 2019-11-25 09:07:36 +0100 | [diff] [blame] | 112 | */ |
| 113 | char *from_env(const char *envvar); |
| 114 | |
Simon Glass | 7b51b57 | 2019-08-01 09:46:52 -0600 | [diff] [blame] | 115 | /** |
Simon Glass | 3a7d557 | 2019-08-01 09:46:42 -0600 | [diff] [blame] | 116 | * env_get_f() - Look up the value of an environment variable (early) |
| 117 | * |
| 118 | * This function is called from env_get() if the environment has not been |
| 119 | * loaded yet (GD_FLG_ENV_READY flag is 0). Some environment locations will |
| 120 | * support reading the value (slowly) and some will not. |
| 121 | * |
| 122 | * @varname: Variable to look up |
Heinrich Schuchardt | 185f812 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 123 | * Return: actual length of the variable value excluding the terminating |
Marek BehĂșn | 3112ce0 | 2021-10-17 17:36:35 +0200 | [diff] [blame] | 124 | * NULL-byte, or -1 if the variable is not found |
Simon Glass | 3a7d557 | 2019-08-01 09:46:42 -0600 | [diff] [blame] | 125 | */ |
| 126 | int env_get_f(const char *name, char *buf, unsigned int len); |
| 127 | |
| 128 | /** |
Simon Glass | 6bf6dbe | 2019-08-01 09:46:49 -0600 | [diff] [blame] | 129 | * env_get_yesno() - Read an environment variable as a boolean |
| 130 | * |
Heinrich Schuchardt | 185f812 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 131 | * Return: 1 if yes/true (Y/y/T/t), -1 if variable does not exist (i.e. default |
Simon Glass | 6bf6dbe | 2019-08-01 09:46:49 -0600 | [diff] [blame] | 132 | * to true), 0 if otherwise |
| 133 | */ |
| 134 | int env_get_yesno(const char *var); |
| 135 | |
| 136 | /** |
Simon Glass | 7839865 | 2021-10-21 21:08:52 -0600 | [diff] [blame] | 137 | * env_get_autostart() - Check if autostart is enabled |
| 138 | * |
Heinrich Schuchardt | 185f812 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 139 | * Return: true if the "autostart" env var exists and is set to "yes" |
Simon Glass | 7839865 | 2021-10-21 21:08:52 -0600 | [diff] [blame] | 140 | */ |
| 141 | bool env_get_autostart(void); |
| 142 | |
| 143 | /** |
Simon Glass | 9fb625c | 2019-08-01 09:46:51 -0600 | [diff] [blame] | 144 | * env_set() - set an environment variable |
| 145 | * |
| 146 | * This sets or deletes the value of an environment variable. For setting the |
| 147 | * value the variable is created if it does not already exist. |
| 148 | * |
| 149 | * @varname: Variable to adjust |
| 150 | * @value: Value to set for the variable, or NULL or "" to delete the variable |
Heinrich Schuchardt | 185f812 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 151 | * Return: 0 if OK, 1 on error |
Simon Glass | 9fb625c | 2019-08-01 09:46:51 -0600 | [diff] [blame] | 152 | */ |
| 153 | int env_set(const char *varname, const char *value); |
| 154 | |
| 155 | /** |
Simon Glass | 9eef56d | 2019-08-01 09:46:48 -0600 | [diff] [blame] | 156 | * env_get_ulong() - Return an environment variable as an integer value |
| 157 | * |
| 158 | * Most U-Boot environment variables store hex values. For those which store |
| 159 | * (e.g.) base-10 integers, this function can be used to read the value. |
| 160 | * |
| 161 | * @name: Variable to look up |
| 162 | * @base: Base to use (e.g. 10 for base 10, 2 for binary) |
| 163 | * @default_val: Default value to return if no value is found |
Heinrich Schuchardt | 185f812 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 164 | * Return: the value found, or @default_val if none |
Simon Glass | 9eef56d | 2019-08-01 09:46:48 -0600 | [diff] [blame] | 165 | */ |
| 166 | ulong env_get_ulong(const char *name, int base, ulong default_val); |
| 167 | |
| 168 | /** |
Simon Glass | 168068f | 2019-08-01 09:46:47 -0600 | [diff] [blame] | 169 | * env_set_ulong() - set an environment variable to an integer |
| 170 | * |
| 171 | * @varname: Variable to adjust |
| 172 | * @value: Value to set for the variable (will be converted to a string) |
Heinrich Schuchardt | 185f812 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 173 | * Return: 0 if OK, 1 on error |
Simon Glass | 168068f | 2019-08-01 09:46:47 -0600 | [diff] [blame] | 174 | */ |
| 175 | int env_set_ulong(const char *varname, ulong value); |
| 176 | |
| 177 | /** |
Simon Glass | cdbff9f | 2019-08-01 09:46:50 -0600 | [diff] [blame] | 178 | * env_get_hex() - Return an environment variable as a hex value |
| 179 | * |
| 180 | * Decode an environment as a hex number (it may or may not have a 0x |
| 181 | * prefix). If the environment variable cannot be found, or does not start |
| 182 | * with hex digits, the default value is returned. |
| 183 | * |
| 184 | * @varname: Variable to decode |
| 185 | * @default_val: Value to return on error |
| 186 | */ |
| 187 | ulong env_get_hex(const char *varname, ulong default_val); |
| 188 | |
| 189 | /** |
Simon Glass | c7694dd | 2019-08-01 09:46:46 -0600 | [diff] [blame] | 190 | * env_set_hex() - set an environment variable to a hex value |
| 191 | * |
| 192 | * @varname: Variable to adjust |
| 193 | * @value: Value to set for the variable (will be converted to a hex string) |
Heinrich Schuchardt | 185f812 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 194 | * Return: 0 if OK, 1 on error |
Simon Glass | c7694dd | 2019-08-01 09:46:46 -0600 | [diff] [blame] | 195 | */ |
| 196 | int env_set_hex(const char *varname, ulong value); |
| 197 | |
| 198 | /** |
| 199 | * env_set_addr - Set an environment variable to an address in hex |
| 200 | * |
| 201 | * @varname: Environment variable to set |
| 202 | * @addr: Value to set it to |
Heinrich Schuchardt | 185f812 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 203 | * Return: 0 if ok, 1 on error |
Simon Glass | c7694dd | 2019-08-01 09:46:46 -0600 | [diff] [blame] | 204 | */ |
| 205 | static inline int env_set_addr(const char *varname, const void *addr) |
| 206 | { |
| 207 | return env_set_hex(varname, (ulong)addr); |
| 208 | } |
| 209 | |
| 210 | /** |
Simon Glass | af95f20 | 2019-08-01 09:46:40 -0600 | [diff] [blame] | 211 | * env_complete() - return an auto-complete for environment variables |
| 212 | * |
| 213 | * @var: partial name to auto-complete |
| 214 | * @maxv: Maximum number of matches to return |
| 215 | * @cmdv: Returns a list of possible matches |
| 216 | * @maxsz: Size of buffer to use for matches |
| 217 | * @buf: Buffer to use for matches |
| 218 | * @dollar_comp: non-zero to wrap each match in ${...} |
Heinrich Schuchardt | 185f812 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 219 | * Return: number of matches found (in @cmdv) |
Simon Glass | af95f20 | 2019-08-01 09:46:40 -0600 | [diff] [blame] | 220 | */ |
| 221 | int env_complete(char *var, int maxv, char *cmdv[], int maxsz, char *buf, |
| 222 | bool dollar_comp); |
| 223 | |
Simon Glass | b79cf1a | 2019-08-01 09:46:53 -0600 | [diff] [blame] | 224 | /** |
| 225 | * eth_env_get_enetaddr() - Get an ethernet address from the environmnet |
| 226 | * |
| 227 | * @name: Environment variable to get (e.g. "ethaddr") |
| 228 | * @enetaddr: Place to put MAC address (6 bytes) |
Marek Vasut | fbc595b | 2022-12-18 08:05:02 +0100 | [diff] [blame] | 229 | * Return: 1 if OK, 0 on error |
Simon Glass | b79cf1a | 2019-08-01 09:46:53 -0600 | [diff] [blame] | 230 | */ |
| 231 | int eth_env_get_enetaddr(const char *name, uint8_t *enetaddr); |
| 232 | |
| 233 | /** |
| 234 | * eth_env_set_enetaddr() - Set an ethernet address in the environmnet |
| 235 | * |
| 236 | * @name: Environment variable to set (e.g. "ethaddr") |
| 237 | * @enetaddr: Pointer to MAC address to put into the variable (6 bytes) |
Marek Vasut | fbc595b | 2022-12-18 08:05:02 +0100 | [diff] [blame] | 238 | * Return: 0 if OK, non-zero otherwise |
Simon Glass | b79cf1a | 2019-08-01 09:46:53 -0600 | [diff] [blame] | 239 | */ |
| 240 | int eth_env_set_enetaddr(const char *name, const uint8_t *enetaddr); |
| 241 | |
Simon Glass | 03ed918 | 2019-08-01 09:46:55 -0600 | [diff] [blame] | 242 | /** |
Simon Glass | 0b9d8a0 | 2019-08-01 09:46:56 -0600 | [diff] [blame] | 243 | * env_set_default_vars() - reset variables to their default value |
| 244 | * |
| 245 | * This resets individual variables to their value in the default environment |
| 246 | * |
| 247 | * @nvars: Number of variables to set/reset |
| 248 | * @vars: List of variables to set/reset |
| 249 | * @flags: Flags controlling matching (H_... - see search.h) |
| 250 | */ |
| 251 | int env_set_default_vars(int nvars, char *const vars[], int flags); |
| 252 | |
Simon Glass | 4be490a | 2019-08-01 09:46:57 -0600 | [diff] [blame] | 253 | /** |
| 254 | * env_load() - Load the environment from storage |
| 255 | * |
Heinrich Schuchardt | 185f812 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 256 | * Return: 0 if OK, -ve on error |
Simon Glass | 4be490a | 2019-08-01 09:46:57 -0600 | [diff] [blame] | 257 | */ |
| 258 | int env_load(void); |
| 259 | |
| 260 | /** |
Patrick Delaunay | 0115dd3 | 2020-07-28 11:51:20 +0200 | [diff] [blame] | 261 | * env_reload() - Re-Load the environment from current storage |
| 262 | * |
Heinrich Schuchardt | 185f812 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 263 | * Return: 0 if OK, -ve on error |
Patrick Delaunay | 0115dd3 | 2020-07-28 11:51:20 +0200 | [diff] [blame] | 264 | */ |
| 265 | int env_reload(void); |
| 266 | |
| 267 | /** |
Simon Glass | 4be490a | 2019-08-01 09:46:57 -0600 | [diff] [blame] | 268 | * env_save() - Save the environment to storage |
| 269 | * |
Heinrich Schuchardt | 185f812 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 270 | * Return: 0 if OK, -ve on error |
Simon Glass | 4be490a | 2019-08-01 09:46:57 -0600 | [diff] [blame] | 271 | */ |
| 272 | int env_save(void); |
| 273 | |
| 274 | /** |
| 275 | * env_erase() - Erase the environment on storage |
| 276 | * |
Heinrich Schuchardt | 185f812 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 277 | * Return: 0 if OK, -ve on error |
Simon Glass | 4be490a | 2019-08-01 09:46:57 -0600 | [diff] [blame] | 278 | */ |
| 279 | int env_erase(void); |
| 280 | |
Simon Glass | 4e9ce8a | 2019-08-01 09:46:58 -0600 | [diff] [blame] | 281 | /** |
Patrick Delaunay | a97d22e | 2020-07-28 11:51:21 +0200 | [diff] [blame] | 282 | * env_select() - Select the environment storage |
| 283 | * |
Heinrich Schuchardt | 185f812 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 284 | * Return: 0 if OK, -ve on error |
Patrick Delaunay | a97d22e | 2020-07-28 11:51:21 +0200 | [diff] [blame] | 285 | */ |
| 286 | int env_select(const char *name); |
| 287 | |
| 288 | /** |
Simon Glass | 4e9ce8a | 2019-08-01 09:46:58 -0600 | [diff] [blame] | 289 | * env_import() - Import from a binary representation into hash table |
| 290 | * |
| 291 | * This imports the environment from a buffer. The format for each variable is |
| 292 | * var=value\0 with a double \0 at the end of the buffer. |
| 293 | * |
| 294 | * @buf: Buffer containing the environment (struct environemnt_s *) |
| 295 | * @check: non-zero to check the CRC at the start of the environment, 0 to |
| 296 | * ignore it |
Marek Vasut | 890feec | 2020-07-07 20:51:35 +0200 | [diff] [blame] | 297 | * @flags: Flags controlling matching (H_... - see search.h) |
Heinrich Schuchardt | 185f812 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 298 | * Return: 0 if imported successfully, -ENOMSG if the CRC was bad, -EIO if |
Simon Glass | 4e9ce8a | 2019-08-01 09:46:58 -0600 | [diff] [blame] | 299 | * something else went wrong |
| 300 | */ |
Marek Vasut | 890feec | 2020-07-07 20:51:35 +0200 | [diff] [blame] | 301 | int env_import(const char *buf, int check, int flags); |
Simon Glass | 4e9ce8a | 2019-08-01 09:46:58 -0600 | [diff] [blame] | 302 | |
| 303 | /** |
| 304 | * env_export() - Export the environment to a buffer |
| 305 | * |
| 306 | * Export from hash table into binary representation |
| 307 | * |
| 308 | * @env_out: Buffer to contain the environment (must be large enough!) |
Heinrich Schuchardt | 185f812 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 309 | * Return: 0 if OK, 1 on error |
Simon Glass | 4e9ce8a | 2019-08-01 09:46:58 -0600 | [diff] [blame] | 310 | */ |
| 311 | int env_export(struct environment_s *env_out); |
| 312 | |
| 313 | /** |
Heiko Schocher | 1229533 | 2020-10-10 10:28:04 +0200 | [diff] [blame] | 314 | * env_check_redund() - check the two redundant environments |
| 315 | * and find out, which is the valid one. |
| 316 | * |
| 317 | * @buf1: First environment (struct environemnt_s *) |
| 318 | * @buf1_read_fail: 0 if buf1 is valid, non-zero if invalid |
| 319 | * @buf2: Second environment (struct environemnt_s *) |
| 320 | * @buf2_read_fail: 0 if buf2 is valid, non-zero if invalid |
Heinrich Schuchardt | 185f812 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 321 | * Return: 0 if OK, |
Heiko Schocher | 1229533 | 2020-10-10 10:28:04 +0200 | [diff] [blame] | 322 | * -EIO if no environment is valid, |
Heiko Schocher | 1229533 | 2020-10-10 10:28:04 +0200 | [diff] [blame] | 323 | * -ENOMSG if the CRC was bad |
| 324 | */ |
| 325 | |
| 326 | int env_check_redund(const char *buf1, int buf1_read_fail, |
| 327 | const char *buf2, int buf2_read_fail); |
| 328 | |
| 329 | /** |
Simon Glass | 4e9ce8a | 2019-08-01 09:46:58 -0600 | [diff] [blame] | 330 | * env_import_redund() - Select and import one of two redundant environments |
| 331 | * |
| 332 | * @buf1: First environment (struct environemnt_s *) |
| 333 | * @buf1_read_fail: 0 if buf1 is valid, non-zero if invalid |
| 334 | * @buf2: Second environment (struct environemnt_s *) |
| 335 | * @buf2_read_fail: 0 if buf2 is valid, non-zero if invalid |
Marek Vasut | 890feec | 2020-07-07 20:51:35 +0200 | [diff] [blame] | 336 | * @flags: Flags controlling matching (H_... - see search.h) |
Heinrich Schuchardt | 185f812 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 337 | * Return: 0 if OK, -EIO if no environment is valid, -ENOMSG if the CRC was bad |
Simon Glass | 4e9ce8a | 2019-08-01 09:46:58 -0600 | [diff] [blame] | 338 | */ |
| 339 | int env_import_redund(const char *buf1, int buf1_read_fail, |
Marek Vasut | 890feec | 2020-07-07 20:51:35 +0200 | [diff] [blame] | 340 | const char *buf2, int buf2_read_fail, |
| 341 | int flags); |
Simon Glass | 4e9ce8a | 2019-08-01 09:46:58 -0600 | [diff] [blame] | 342 | |
Simon Glass | 0ac7d72 | 2019-08-01 09:47:00 -0600 | [diff] [blame] | 343 | /** |
| 344 | * env_get_default() - Look up a variable from the default environment |
| 345 | * |
| 346 | * @name: Variable to look up |
Heinrich Schuchardt | 185f812 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 347 | * Return: value if found, NULL if not found in default environment |
Simon Glass | 0ac7d72 | 2019-08-01 09:47:00 -0600 | [diff] [blame] | 348 | */ |
| 349 | char *env_get_default(const char *name); |
| 350 | |
| 351 | /* [re]set to the default environment */ |
| 352 | void env_set_default(const char *s, int flags); |
| 353 | |
Simon Glass | b5f449e | 2019-08-01 09:47:01 -0600 | [diff] [blame] | 354 | /** |
Rasmus Villemoes | 95fd977 | 2021-04-21 11:06:54 +0200 | [diff] [blame] | 355 | * env_import_fdt() - Import environment values from device tree blob |
| 356 | * |
| 357 | * This uses the value of the environment variable "env_fdt_path" as a |
| 358 | * path to an fdt node, whose property/value pairs are added to the |
| 359 | * environment. |
| 360 | */ |
| 361 | #ifdef CONFIG_ENV_IMPORT_FDT |
| 362 | void env_import_fdt(void); |
| 363 | #else |
| 364 | static inline void env_import_fdt(void) {} |
| 365 | #endif |
| 366 | |
Simon Glass | af95f20 | 2019-08-01 09:46:40 -0600 | [diff] [blame] | 367 | #endif |