blob: 5b488ef818e888b361093e6016bf4092a014965a [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
Tom Rini8fac3d42023-12-14 07:16:54 -05007#ifdef USE_HOSTCC
York Sunfe92d672016-11-15 17:02:31 -08008#include <linux/kconfig.h>
Tom Rini8fac3d42023-12-14 07:16:54 -05009#endif
York Sunfe92d672016-11-15 17:02:31 -080010
Wolfgang Denkdb5f3862005-08-03 22:32:02 +020011#ifndef __ASSEMBLY__
Igor Grinberg95a4e1d2011-11-07 01:14:06 +000012#define __ASSEMBLY__ /* Dirty trick to get only #defines */
Wolfgang Denkdb5f3862005-08-03 22:32:02 +020013#endif
Igor Grinberg95a4e1d2011-11-07 01:14:06 +000014#define __ASM_STUB_PROCESSOR_H__ /* don't include asm/processor. */
wdenkc6097192002-11-03 00:24:07 +000015#include <config.h>
Wolfgang Denkdb5f3862005-08-03 22:32:02 +020016#undef __ASSEMBLY__
Simon Glass9d1f6192019-08-02 09:44:25 -060017#include <env_internal.h>
Marek Vasut0b3176c2012-09-23 17:41:24 +020018#include <linux/stringify.h>
wdenkc6097192002-11-03 00:24:07 +000019
Igor Grinberg95a4e1d2011-11-07 01:14:06 +000020/* Handle HOSTS that have prepended crap on symbol names, not TARGETS. */
wdenkc6097192002-11-03 00:24:07 +000021#if defined(__APPLE__)
22/* Leading underscore on symbols */
23# define SYM_CHAR "_"
24#else /* No leading character on symbols */
25# define SYM_CHAR
26#endif
27
28/*
Wolfgang Denk51420fb2009-10-27 00:03:32 +010029 * Generate embedded environment table
30 * inside U-Boot image, if needed.
31 */
Tom Rini4714ab22022-12-02 16:42:17 -050032#if defined(ENV_IS_EMBEDDED)
Wolfgang Denk51420fb2009-10-27 00:03:32 +010033/*
Thomas Petazzonic3e088d2017-07-28 23:46:37 +020034 * Put the environment in the .text section when we are building
wdenkc6097192002-11-03 00:24:07 +000035 * U-Boot proper. The host based program "tools/envcrc" does not need
Thomas Petazzonic3e088d2017-07-28 23:46:37 +020036 * a seperate section.
wdenkc6097192002-11-03 00:24:07 +000037 */
Thomas Petazzonic3e088d2017-07-28 23:46:37 +020038#if defined(USE_HOSTCC) /* Native for 'tools/envcrc' */
Christophe Leroy29524f22018-03-16 17:20:53 +010039# define __UBOOT_ENV_SECTION__(name) /*XXX DO_NOT_DEL_THIS_COMMENT*/
wdenkc6097192002-11-03 00:24:07 +000040
41#else /* Environment is embedded in U-Boot's .text section */
42/* XXX - This only works with GNU C */
Christophe Leroy29524f22018-03-16 17:20:53 +010043# define __UBOOT_ENV_SECTION__(name) __attribute__ ((section(".text."#name)))
wdenkc6097192002-11-03 00:24:07 +000044#endif
45
46/*
47 * Macros to generate global absolutes.
48 */
Mike Frysinger15c51352008-02-04 19:26:54 -050049#if defined(__bfin__)
Igor Grinberg95a4e1d2011-11-07 01:14:06 +000050# define GEN_SET_VALUE(name, value) \
51 asm(".set " GEN_SYMNAME(name) ", " GEN_VALUE(value))
Mike Frysinger15c51352008-02-04 19:26:54 -050052#else
Igor Grinberg95a4e1d2011-11-07 01:14:06 +000053# define GEN_SET_VALUE(name, value) \
54 asm(GEN_SYMNAME(name) " = " GEN_VALUE(value))
Mike Frysinger15c51352008-02-04 19:26:54 -050055#endif
Igor Grinberg95a4e1d2011-11-07 01:14:06 +000056#define GEN_SYMNAME(str) SYM_CHAR #str
57#define GEN_VALUE(str) #str
58#define GEN_ABS(name, value) \
59 asm(".globl " GEN_SYMNAME(name)); \
60 GEN_SET_VALUE(name, value)
wdenkc6097192002-11-03 00:24:07 +000061
62/*
wdenkc6097192002-11-03 00:24:07 +000063 * Check to see if we are building with a
64 * computed CRC. Otherwise define it as ~0.
65 */
66#if !defined(ENV_CRC)
Igor Grinberg95a4e1d2011-11-07 01:14:06 +000067# define ENV_CRC (~0)
wdenkc6097192002-11-03 00:24:07 +000068#endif
69
Joe Hershberger81321142012-10-12 08:48:51 +000070#define DEFAULT_ENV_INSTANCE_EMBEDDED
Simon Glass7327fe72021-10-21 21:08:46 -060071#include <config.h>
Joe Hershberger81321142012-10-12 08:48:51 +000072#include <env_default.h>
73
Jean-Christophe PLAGNIOL-VILLARD7e1cda62008-09-10 22:48:06 +020074#ifdef CONFIG_ENV_ADDR_REDUND
Christophe Leroy29524f22018-03-16 17:20:53 +010075env_t redundand_environment __UBOOT_ENV_SECTION__(redundand_environment) = {
wdenkc6097192002-11-03 00:24:07 +000076 0, /* CRC Sum: invalid */
77 0, /* Flags: invalid */
78 {
79 "\0"
80 }
81};
Jean-Christophe PLAGNIOL-VILLARD7e1cda62008-09-10 22:48:06 +020082#endif /* CONFIG_ENV_ADDR_REDUND */
wdenkc6097192002-11-03 00:24:07 +000083
84/*
85 * These will end up in the .text section
86 * if the environment strings are embedded
87 * in the image. When this is used for
88 * tools/envcrc, they are placed in the
89 * .data/.sdata section.
90 *
91 */
Christophe Leroy29524f22018-03-16 17:20:53 +010092unsigned long env_size __UBOOT_ENV_SECTION__(env_size) = sizeof(env_t);
wdenkc6097192002-11-03 00:24:07 +000093
94/*
95 * Add in absolutes.
96 */
Tom Rini6a5dccc2022-11-16 13:10:41 -050097GEN_ABS(env_offset, (CONFIG_ENV_ADDR - CFG_SYS_FLASH_BASE));
Wolfgang Denk51420fb2009-10-27 00:03:32 +010098
99#endif /* ENV_IS_EMBEDDED */