Tom Rini | 10e4779 | 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 | 460a9ff | 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 | |
| 10 | #include <common.h> |
wdenk | 0bc4a1a | 2002-09-18 11:09:59 +0000 | [diff] [blame] | 11 | #include <command.h> |
Simon Glass | bf86488 | 2019-08-01 09:47:04 -0600 | [diff] [blame] | 12 | #include <env.h> |
Simon Glass | 9d1f619 | 2019-08-02 09:44:25 -0600 | [diff] [blame] | 13 | #include <env_internal.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 14 | #include <asm/global_data.h> |
wdenk | 0bc4a1a | 2002-09-18 11:09:59 +0000 | [diff] [blame] | 15 | #include <linux/stddef.h> |
wdenk | 0bc4a1a | 2002-09-18 11:09:59 +0000 | [diff] [blame] | 16 | |
Wolfgang Denk | 6405a15 | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 17 | DECLARE_GLOBAL_DATA_PTR; |
| 18 | |
Tom Rini | 8a7c44b | 2017-08-19 22:27:57 -0400 | [diff] [blame] | 19 | /* |
| 20 | * Because we only ever have the default environment available we must mark |
| 21 | * it as invalid. |
| 22 | */ |
| 23 | static int env_nowhere_init(void) |
| 24 | { |
| 25 | gd->env_addr = (ulong)&default_environment[0]; |
| 26 | gd->env_valid = ENV_INVALID; |
| 27 | |
| 28 | return 0; |
| 29 | } |
| 30 | |
Patrick Delaunay | 789c3c3 | 2020-07-28 11:51:18 +0200 | [diff] [blame] | 31 | static int env_nowhere_load(void) |
| 32 | { |
| 33 | /* |
Marek BehĂșn | 9a359b5 | 2021-10-17 17:36:30 +0200 | [diff] [blame] | 34 | * For SPL, setting env_valid = ENV_INVALID is enough, as env_get() |
| 35 | * searches default_environment array in that case. |
Patrick Delaunay | 789c3c3 | 2020-07-28 11:51:18 +0200 | [diff] [blame] | 36 | * For U-Boot proper, import the default environment to allow reload. |
| 37 | */ |
| 38 | if (!IS_ENABLED(CONFIG_SPL_BUILD)) |
| 39 | env_set_default(NULL, 0); |
| 40 | |
| 41 | gd->env_valid = ENV_INVALID; |
| 42 | |
| 43 | return 0; |
| 44 | } |
| 45 | |
Simon Glass | c10a88e | 2017-08-03 12:21:58 -0600 | [diff] [blame] | 46 | U_BOOT_ENV_LOCATION(nowhere) = { |
| 47 | .location = ENVL_NOWHERE, |
Tom Rini | 8a7c44b | 2017-08-19 22:27:57 -0400 | [diff] [blame] | 48 | .init = env_nowhere_init, |
Patrick Delaunay | 789c3c3 | 2020-07-28 11:51:18 +0200 | [diff] [blame] | 49 | .load = env_nowhere_load, |
Simon Glass | d8273ed | 2017-08-03 12:22:03 -0600 | [diff] [blame] | 50 | ENV_NAME("nowhere") |
Simon Glass | c10a88e | 2017-08-03 12:21:58 -0600 | [diff] [blame] | 51 | }; |