blob: 5b488ef818e888b361093e6016bf4092a014965a [file] [log] [blame]
Tom Rini83d290c2018-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 Rinib1069612023-12-14 07:16:54 -05007#ifdef USE_HOSTCC
York Sunf33f3e02016-11-15 17:02:31 -08008#include <linux/kconfig.h>
Tom Rinib1069612023-12-14 07:16:54 -05009#endif
York Sunf33f3e02016-11-15 17:02:31 -080010
Wolfgang Denkdc17fb62005-08-03 22:32:02 +020011#ifndef __ASSEMBLY__
Igor Grinbergbd2a23a2011-11-07 01:14:06 +000012#define __ASSEMBLY__ /* Dirty trick to get only #defines */
Wolfgang Denkdc17fb62005-08-03 22:32:02 +020013#endif
Igor Grinbergbd2a23a2011-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 Denkdc17fb62005-08-03 22:32:02 +020016#undef __ASSEMBLY__
Simon Glassf3998fd2019-08-02 09:44:25 -060017#include <env_internal.h>
Marek Vasut5368c552012-09-23 17:41:24 +020018#include <linux/stringify.h>
wdenkc6097192002-11-03 00:24:07 +000019
Igor Grinbergbd2a23a2011-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 Denka747a7f2009-10-27 00:03:32 +010029 * Generate embedded environment table
30 * inside U-Boot image, if needed.
31 */
Tom Rini6bd23722022-12-02 16:42:17 -050032#if defined(ENV_IS_EMBEDDED)
Wolfgang Denka747a7f2009-10-27 00:03:32 +010033/*
Thomas Petazzoni76539422017-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 Petazzoni76539422017-07-28 23:46:37 +020036 * a seperate section.
wdenkc6097192002-11-03 00:24:07 +000037 */
Thomas Petazzoni76539422017-07-28 23:46:37 +020038#if defined(USE_HOSTCC) /* Native for 'tools/envcrc' */
Christophe Leroy23ac79f2018-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 Leroy23ac79f2018-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 Frysinger4087bc82008-02-04 19:26:54 -050049#if defined(__bfin__)
Igor Grinbergbd2a23a2011-11-07 01:14:06 +000050# define GEN_SET_VALUE(name, value) \
51 asm(".set " GEN_SYMNAME(name) ", " GEN_VALUE(value))
Mike Frysinger4087bc82008-02-04 19:26:54 -050052#else
Igor Grinbergbd2a23a2011-11-07 01:14:06 +000053# define GEN_SET_VALUE(name, value) \
54 asm(GEN_SYMNAME(name) " = " GEN_VALUE(value))
Mike Frysinger4087bc82008-02-04 19:26:54 -050055#endif
Igor Grinbergbd2a23a2011-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 Grinbergbd2a23a2011-11-07 01:14:06 +000067# define ENV_CRC (~0)
wdenkc6097192002-11-03 00:24:07 +000068#endif
69
Joe Hershbergerddd84182012-10-12 08:48:51 +000070#define DEFAULT_ENV_INSTANCE_EMBEDDED
Simon Glass86b9c3e2021-10-21 21:08:46 -060071#include <config.h>
Joe Hershbergerddd84182012-10-12 08:48:51 +000072#include <env_default.h>
73
Jean-Christophe PLAGNIOL-VILLARD0e8d1582008-09-10 22:48:06 +020074#ifdef CONFIG_ENV_ADDR_REDUND
Christophe Leroy23ac79f2018-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-VILLARD0e8d1582008-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 Leroy23ac79f2018-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 Rini65cc0e22022-11-16 13:10:41 -050097GEN_ABS(env_offset, (CONFIG_ENV_ADDR - CFG_SYS_FLASH_BASE));
Wolfgang Denka747a7f2009-10-27 00:03:32 +010098
99#endif /* ENV_IS_EMBEDDED */