blob: 9ebc357dbd785e7b9390e315f0d21319a7b0d92d [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
wdenk0bc4a1a2002-09-18 11:09:59 +00002/*
Wolfgang Denkea882ba2010-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
10#include <common.h>
wdenk0bc4a1a2002-09-18 11:09:59 +000011#include <command.h>
Simon Glassdb197012019-08-01 09:47:04 -060012#include <env.h>
Simon Glassf3998fd2019-08-02 09:44:25 -060013#include <env_internal.h>
Simon Glass401d1c42020-10-30 21:38:53 -060014#include <asm/global_data.h>
wdenk0bc4a1a2002-09-18 11:09:59 +000015#include <linux/stddef.h>
wdenk0bc4a1a2002-09-18 11:09:59 +000016
Wolfgang Denkd87080b2006-03-31 18:32:53 +020017DECLARE_GLOBAL_DATA_PTR;
18
Tom Rinieeba55c2017-08-19 22:27:57 -040019/*
20 * Because we only ever have the default environment available we must mark
21 * it as invalid.
22 */
23static int env_nowhere_init(void)
24{
Marek Behún9fc31062021-10-22 15:47:19 +020025 gd->env_valid = ENV_INVALID;
Tom Rinieeba55c2017-08-19 22:27:57 -040026
27 return 0;
28}
29
Patrick Delaunayad3fec22020-07-28 11:51:18 +020030static int env_nowhere_load(void)
31{
32 /*
Marek Behún52f9ed32021-10-17 17:36:30 +020033 * For SPL, setting env_valid = ENV_INVALID is enough, as env_get()
34 * searches default_environment array in that case.
Patrick Delaunayad3fec22020-07-28 11:51:18 +020035 * For U-Boot proper, import the default environment to allow reload.
36 */
37 if (!IS_ENABLED(CONFIG_SPL_BUILD))
38 env_set_default(NULL, 0);
39
Marek Behún9fc31062021-10-22 15:47:19 +020040 gd->env_valid = ENV_INVALID;
Patrick Delaunayad3fec22020-07-28 11:51:18 +020041
42 return 0;
43}
44
Simon Glass4415f1d2017-08-03 12:21:58 -060045U_BOOT_ENV_LOCATION(nowhere) = {
46 .location = ENVL_NOWHERE,
Tom Rinieeba55c2017-08-19 22:27:57 -040047 .init = env_nowhere_init,
Patrick Delaunayad3fec22020-07-28 11:51:18 +020048 .load = env_nowhere_load,
Simon Glassac358be2017-08-03 12:22:03 -060049 ENV_NAME("nowhere")
Simon Glass4415f1d2017-08-03 12:21:58 -060050};