blob: 41557f5ce44f44adcb03054c36f51b7905657127 [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
10#include <common.h>
wdenk0bc4a1a2002-09-18 11:09:59 +000011#include <command.h>
Simon Glassbf864882019-08-01 09:47:04 -060012#include <env.h>
Simon Glass9d1f6192019-08-02 09:44:25 -060013#include <env_internal.h>
Simon Glass3ba929a2020-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 Denk6405a152006-03-31 18:32:53 +020017DECLARE_GLOBAL_DATA_PTR;
18
Tom Rini8a7c44b2017-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{
25 gd->env_addr = (ulong)&default_environment[0];
26 gd->env_valid = ENV_INVALID;
27
28 return 0;
29}
30
Patrick Delaunay789c3c32020-07-28 11:51:18 +020031static int env_nowhere_load(void)
32{
33 /*
Heinrich Schuchardt7076d6d2020-10-30 06:11:12 +010034 * for SPL, set env_valid = ENV_INVALID is enough as env_get_char()
Patrick Delaunay789c3c32020-07-28 11:51:18 +020035 * return the default env if env_get is used
36 * and SPL don't used env_import to reduce its size
37 * For U-Boot proper, import the default environment to allow reload.
38 */
39 if (!IS_ENABLED(CONFIG_SPL_BUILD))
40 env_set_default(NULL, 0);
41
42 gd->env_valid = ENV_INVALID;
43
44 return 0;
45}
46
Simon Glassc10a88e2017-08-03 12:21:58 -060047U_BOOT_ENV_LOCATION(nowhere) = {
48 .location = ENVL_NOWHERE,
Tom Rini8a7c44b2017-08-19 22:27:57 -040049 .init = env_nowhere_init,
Patrick Delaunay789c3c32020-07-28 11:51:18 +020050 .load = env_nowhere_load,
Simon Glassd8273ed2017-08-03 12:22:03 -060051 ENV_NAME("nowhere")
Simon Glassc10a88e2017-08-03 12:21:58 -060052};