blob: 7cbe54c56e001db6e92a1f9a7c27e13988e223bc [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
wdenkc6097192002-11-03 00:24:07 +00002/*
3 * (C) Copyright 2001
4 * Erik Theisen, Wave 7 Optics, etheisen@mindspring.com.
wdenkc6097192002-11-03 00:24:07 +00005 */
6
York Sunfe92d672016-11-15 17:02:31 -08007#include <linux/kconfig.h>
8
Wolfgang Denkdb5f3862005-08-03 22:32:02 +02009#ifndef __ASSEMBLY__
Igor Grinberg95a4e1d2011-11-07 01:14:06 +000010#define __ASSEMBLY__ /* Dirty trick to get only #defines */
Wolfgang Denkdb5f3862005-08-03 22:32:02 +020011#endif
Igor Grinberg95a4e1d2011-11-07 01:14:06 +000012#define __ASM_STUB_PROCESSOR_H__ /* don't include asm/processor. */
wdenkc6097192002-11-03 00:24:07 +000013#include <config.h>
Wolfgang Denkdb5f3862005-08-03 22:32:02 +020014#undef __ASSEMBLY__
Simon Glass9d1f6192019-08-02 09:44:25 -060015#include <env_internal.h>
Marek Vasut0b3176c2012-09-23 17:41:24 +020016#include <linux/stringify.h>
wdenkc6097192002-11-03 00:24:07 +000017
Igor Grinberg95a4e1d2011-11-07 01:14:06 +000018/* Handle HOSTS that have prepended crap on symbol names, not TARGETS. */
wdenkc6097192002-11-03 00:24:07 +000019#if defined(__APPLE__)
20/* Leading underscore on symbols */
21# define SYM_CHAR "_"
22#else /* No leading character on symbols */
23# define SYM_CHAR
24#endif
25
26/*
Wolfgang Denk51420fb2009-10-27 00:03:32 +010027 * Generate embedded environment table
28 * inside U-Boot image, if needed.
29 */
Tom Rini4714ab22022-12-02 16:42:17 -050030#if defined(ENV_IS_EMBEDDED)
Wolfgang Denk51420fb2009-10-27 00:03:32 +010031/*
Thomas Petazzonic3e088d2017-07-28 23:46:37 +020032 * Put the environment in the .text section when we are building
wdenkc6097192002-11-03 00:24:07 +000033 * U-Boot proper. The host based program "tools/envcrc" does not need
Thomas Petazzonic3e088d2017-07-28 23:46:37 +020034 * a seperate section.
wdenkc6097192002-11-03 00:24:07 +000035 */
Thomas Petazzonic3e088d2017-07-28 23:46:37 +020036#if defined(USE_HOSTCC) /* Native for 'tools/envcrc' */
Christophe Leroy29524f22018-03-16 17:20:53 +010037# define __UBOOT_ENV_SECTION__(name) /*XXX DO_NOT_DEL_THIS_COMMENT*/
wdenkc6097192002-11-03 00:24:07 +000038
39#else /* Environment is embedded in U-Boot's .text section */
40/* XXX - This only works with GNU C */
Christophe Leroy29524f22018-03-16 17:20:53 +010041# define __UBOOT_ENV_SECTION__(name) __attribute__ ((section(".text."#name)))
wdenkc6097192002-11-03 00:24:07 +000042#endif
43
44/*
45 * Macros to generate global absolutes.
46 */
Mike Frysinger15c51352008-02-04 19:26:54 -050047#if defined(__bfin__)
Igor Grinberg95a4e1d2011-11-07 01:14:06 +000048# define GEN_SET_VALUE(name, value) \
49 asm(".set " GEN_SYMNAME(name) ", " GEN_VALUE(value))
Mike Frysinger15c51352008-02-04 19:26:54 -050050#else
Igor Grinberg95a4e1d2011-11-07 01:14:06 +000051# define GEN_SET_VALUE(name, value) \
52 asm(GEN_SYMNAME(name) " = " GEN_VALUE(value))
Mike Frysinger15c51352008-02-04 19:26:54 -050053#endif
Igor Grinberg95a4e1d2011-11-07 01:14:06 +000054#define GEN_SYMNAME(str) SYM_CHAR #str
55#define GEN_VALUE(str) #str
56#define GEN_ABS(name, value) \
57 asm(".globl " GEN_SYMNAME(name)); \
58 GEN_SET_VALUE(name, value)
wdenkc6097192002-11-03 00:24:07 +000059
60/*
wdenkc6097192002-11-03 00:24:07 +000061 * Check to see if we are building with a
62 * computed CRC. Otherwise define it as ~0.
63 */
64#if !defined(ENV_CRC)
Igor Grinberg95a4e1d2011-11-07 01:14:06 +000065# define ENV_CRC (~0)
wdenkc6097192002-11-03 00:24:07 +000066#endif
67
Joe Hershberger81321142012-10-12 08:48:51 +000068#define DEFAULT_ENV_INSTANCE_EMBEDDED
Simon Glass7327fe72021-10-21 21:08:46 -060069#include <config.h>
Joe Hershberger81321142012-10-12 08:48:51 +000070#include <env_default.h>
71
Jean-Christophe PLAGNIOL-VILLARD7e1cda62008-09-10 22:48:06 +020072#ifdef CONFIG_ENV_ADDR_REDUND
Christophe Leroy29524f22018-03-16 17:20:53 +010073env_t redundand_environment __UBOOT_ENV_SECTION__(redundand_environment) = {
wdenkc6097192002-11-03 00:24:07 +000074 0, /* CRC Sum: invalid */
75 0, /* Flags: invalid */
76 {
77 "\0"
78 }
79};
Jean-Christophe PLAGNIOL-VILLARD7e1cda62008-09-10 22:48:06 +020080#endif /* CONFIG_ENV_ADDR_REDUND */
wdenkc6097192002-11-03 00:24:07 +000081
82/*
83 * These will end up in the .text section
84 * if the environment strings are embedded
85 * in the image. When this is used for
86 * tools/envcrc, they are placed in the
87 * .data/.sdata section.
88 *
89 */
Christophe Leroy29524f22018-03-16 17:20:53 +010090unsigned long env_size __UBOOT_ENV_SECTION__(env_size) = sizeof(env_t);
wdenkc6097192002-11-03 00:24:07 +000091
92/*
93 * Add in absolutes.
94 */
Tom Rini6a5dccc2022-11-16 13:10:41 -050095GEN_ABS(env_offset, (CONFIG_ENV_ADDR - CFG_SYS_FLASH_BASE));
Wolfgang Denk51420fb2009-10-27 00:03:32 +010096
97#endif /* ENV_IS_EMBEDDED */