blob: 326f27db2e9c5ddb64de637cbfb00ef1771942c5 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
wdenk0bc4a1a2002-09-18 11:09:59 +00002/*
Wolfgang Denk460a9ff2010-06-20 23:33:59 +02003 * (C) Copyright 2000-2010
wdenk0bc4a1a2002-09-18 11:09:59 +00004 * 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>
wdenk0bc4a1a2002-09-18 11:09:59 +00008 */
9
wdenk0bc4a1a2002-09-18 11:09:59 +000010#include <command.h>
Simon Glassbf864882019-08-01 09:47:04 -060011#include <env.h>
Simon Glass9d1f6192019-08-02 09:44:25 -060012#include <env_internal.h>
Simon Glass3ba929a2020-10-30 21:38:53 -060013#include <asm/global_data.h>
wdenk0bc4a1a2002-09-18 11:09:59 +000014#include <linux/stddef.h>
wdenk0bc4a1a2002-09-18 11:09:59 +000015
Wolfgang Denk6405a152006-03-31 18:32:53 +020016DECLARE_GLOBAL_DATA_PTR;
17
Tom Rini8a7c44b2017-08-19 22:27:57 -040018/*
19 * Because we only ever have the default environment available we must mark
20 * it as invalid.
21 */
22static int env_nowhere_init(void)
23{
Marek Behún6da2fbf2021-10-22 15:47:19 +020024 gd->env_valid = ENV_INVALID;
Tom Rini8a7c44b2017-08-19 22:27:57 -040025
26 return 0;
27}
28
Patrick Delaunay789c3c32020-07-28 11:51:18 +020029static int env_nowhere_load(void)
30{
31 /*
Marek Behún9a359b52021-10-17 17:36:30 +020032 * For SPL, setting env_valid = ENV_INVALID is enough, as env_get()
33 * searches default_environment array in that case.
Patrick Delaunay789c3c32020-07-28 11:51:18 +020034 * For U-Boot proper, import the default environment to allow reload.
35 */
36 if (!IS_ENABLED(CONFIG_SPL_BUILD))
37 env_set_default(NULL, 0);
38
Marek Behún6da2fbf2021-10-22 15:47:19 +020039 gd->env_valid = ENV_INVALID;
Patrick Delaunay789c3c32020-07-28 11:51:18 +020040
41 return 0;
42}
43
Simon Glassc10a88e2017-08-03 12:21:58 -060044U_BOOT_ENV_LOCATION(nowhere) = {
45 .location = ENVL_NOWHERE,
Tom Rini8a7c44b2017-08-19 22:27:57 -040046 .init = env_nowhere_init,
Patrick Delaunay789c3c32020-07-28 11:51:18 +020047 .load = env_nowhere_load,
Simon Glassd8273ed2017-08-03 12:22:03 -060048 ENV_NAME("nowhere")
Simon Glassc10a88e2017-08-03 12:21:58 -060049};