Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
wdenk | 0bc4a1a | 2002-09-18 11:09:59 +0000 | [diff] [blame] | 2 | /* |
Wolfgang Denk | ea882ba | 2010-06-20 23:33:59 +0200 | [diff] [blame] | 3 | * (C) Copyright 2000-2010 |
wdenk | 0bc4a1a | 2002-09-18 11:09:59 +0000 | [diff] [blame] | 4 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 5 | * |
| 6 | * (C) Copyright 2001 Sysgo Real-Time Solutions, GmbH <www.elinos.com> |
| 7 | * Andreas Heppel <aheppel@sysgo.de> |
wdenk | 0bc4a1a | 2002-09-18 11:09:59 +0000 | [diff] [blame] | 8 | */ |
| 9 | |
wdenk | 0bc4a1a | 2002-09-18 11:09:59 +0000 | [diff] [blame] | 10 | #include <command.h> |
Simon Glass | db19701 | 2019-08-01 09:47:04 -0600 | [diff] [blame] | 11 | #include <env.h> |
Simon Glass | f3998fd | 2019-08-02 09:44:25 -0600 | [diff] [blame] | 12 | #include <env_internal.h> |
Simon Glass | 401d1c4 | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 13 | #include <asm/global_data.h> |
wdenk | 0bc4a1a | 2002-09-18 11:09:59 +0000 | [diff] [blame] | 14 | #include <linux/stddef.h> |
wdenk | 0bc4a1a | 2002-09-18 11:09:59 +0000 | [diff] [blame] | 15 | |
Wolfgang Denk | d87080b | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 16 | DECLARE_GLOBAL_DATA_PTR; |
| 17 | |
Tom Rini | eeba55c | 2017-08-19 22:27:57 -0400 | [diff] [blame] | 18 | /* |
| 19 | * Because we only ever have the default environment available we must mark |
| 20 | * it as invalid. |
| 21 | */ |
| 22 | static int env_nowhere_init(void) |
| 23 | { |
Marek Behún | 9fc3106 | 2021-10-22 15:47:19 +0200 | [diff] [blame] | 24 | gd->env_valid = ENV_INVALID; |
Tom Rini | eeba55c | 2017-08-19 22:27:57 -0400 | [diff] [blame] | 25 | |
| 26 | return 0; |
| 27 | } |
| 28 | |
Patrick Delaunay | ad3fec2 | 2020-07-28 11:51:18 +0200 | [diff] [blame] | 29 | static int env_nowhere_load(void) |
| 30 | { |
| 31 | /* |
Marek Behún | 52f9ed3 | 2021-10-17 17:36:30 +0200 | [diff] [blame] | 32 | * For SPL, setting env_valid = ENV_INVALID is enough, as env_get() |
| 33 | * searches default_environment array in that case. |
Patrick Delaunay | ad3fec2 | 2020-07-28 11:51:18 +0200 | [diff] [blame] | 34 | * For U-Boot proper, import the default environment to allow reload. |
| 35 | */ |
Simon Glass | 1d6132e | 2024-09-29 19:49:50 -0600 | [diff] [blame] | 36 | if (!IS_ENABLED(CONFIG_XPL_BUILD)) |
Patrick Delaunay | ad3fec2 | 2020-07-28 11:51:18 +0200 | [diff] [blame] | 37 | env_set_default(NULL, 0); |
| 38 | |
Marek Behún | 9fc3106 | 2021-10-22 15:47:19 +0200 | [diff] [blame] | 39 | gd->env_valid = ENV_INVALID; |
Patrick Delaunay | ad3fec2 | 2020-07-28 11:51:18 +0200 | [diff] [blame] | 40 | |
| 41 | return 0; |
| 42 | } |
| 43 | |
Simon Glass | 4415f1d | 2017-08-03 12:21:58 -0600 | [diff] [blame] | 44 | U_BOOT_ENV_LOCATION(nowhere) = { |
| 45 | .location = ENVL_NOWHERE, |
Tom Rini | eeba55c | 2017-08-19 22:27:57 -0400 | [diff] [blame] | 46 | .init = env_nowhere_init, |
Patrick Delaunay | ad3fec2 | 2020-07-28 11:51:18 +0200 | [diff] [blame] | 47 | .load = env_nowhere_load, |
Simon Glass | ac358be | 2017-08-03 12:22:03 -0600 | [diff] [blame] | 48 | ENV_NAME("nowhere") |
Simon Glass | 4415f1d | 2017-08-03 12:21:58 -0600 | [diff] [blame] | 49 | }; |