blob: 9b0a6a3c3da1310a941f0f057c46315317c9c710 [file] [log] [blame]
wdenkc6097192002-11-03 00:24:07 +00001/*
2 * (C) Copyright 2001
3 * Erik Theisen, Wave 7 Optics, etheisen@mindspring.com.
4 *
Wolfgang Denk3765b3e2013-10-07 13:07:26 +02005 * SPDX-License-Identifier: GPL-2.0+
wdenkc6097192002-11-03 00:24:07 +00006 */
7
York Sunf33f3e02016-11-15 17:02:31 -08008#include <linux/kconfig.h>
9
Wolfgang Denkdc17fb62005-08-03 22:32:02 +020010#ifndef __ASSEMBLY__
Igor Grinbergbd2a23a2011-11-07 01:14:06 +000011#define __ASSEMBLY__ /* Dirty trick to get only #defines */
Wolfgang Denkdc17fb62005-08-03 22:32:02 +020012#endif
Igor Grinbergbd2a23a2011-11-07 01:14:06 +000013#define __ASM_STUB_PROCESSOR_H__ /* don't include asm/processor. */
wdenkc6097192002-11-03 00:24:07 +000014#include <config.h>
Wolfgang Denkdc17fb62005-08-03 22:32:02 +020015#undef __ASSEMBLY__
wdenkc6097192002-11-03 00:24:07 +000016#include <environment.h>
Marek Vasut5368c552012-09-23 17:41:24 +020017#include <linux/stringify.h>
wdenkc6097192002-11-03 00:24:07 +000018
Igor Grinbergbd2a23a2011-11-07 01:14:06 +000019/* Handle HOSTS that have prepended crap on symbol names, not TARGETS. */
wdenkc6097192002-11-03 00:24:07 +000020#if defined(__APPLE__)
21/* Leading underscore on symbols */
22# define SYM_CHAR "_"
23#else /* No leading character on symbols */
24# define SYM_CHAR
25#endif
26
27/*
Wolfgang Denka747a7f2009-10-27 00:03:32 +010028 * Generate embedded environment table
29 * inside U-Boot image, if needed.
30 */
Mike Frysingerc3eb3fe2011-07-08 10:44:25 +000031#if defined(ENV_IS_EMBEDDED) || defined(CONFIG_BUILD_ENVCRC)
Wolfgang Denka747a7f2009-10-27 00:03:32 +010032/*
Thomas Petazzoni76539422017-07-28 23:46:37 +020033 * Put the environment in the .text section when we are building
wdenkc6097192002-11-03 00:24:07 +000034 * U-Boot proper. The host based program "tools/envcrc" does not need
Thomas Petazzoni76539422017-07-28 23:46:37 +020035 * a seperate section.
wdenkc6097192002-11-03 00:24:07 +000036 */
Thomas Petazzoni76539422017-07-28 23:46:37 +020037#if defined(USE_HOSTCC) /* Native for 'tools/envcrc' */
Christophe Leroy23ac79f2018-03-16 17:20:53 +010038# define __UBOOT_ENV_SECTION__(name) /*XXX DO_NOT_DEL_THIS_COMMENT*/
wdenkc6097192002-11-03 00:24:07 +000039
40#else /* Environment is embedded in U-Boot's .text section */
41/* XXX - This only works with GNU C */
Christophe Leroy23ac79f2018-03-16 17:20:53 +010042# define __UBOOT_ENV_SECTION__(name) __attribute__ ((section(".text."#name)))
wdenkc6097192002-11-03 00:24:07 +000043#endif
44
45/*
46 * Macros to generate global absolutes.
47 */
Mike Frysinger4087bc82008-02-04 19:26:54 -050048#if defined(__bfin__)
Igor Grinbergbd2a23a2011-11-07 01:14:06 +000049# define GEN_SET_VALUE(name, value) \
50 asm(".set " GEN_SYMNAME(name) ", " GEN_VALUE(value))
Mike Frysinger4087bc82008-02-04 19:26:54 -050051#else
Igor Grinbergbd2a23a2011-11-07 01:14:06 +000052# define GEN_SET_VALUE(name, value) \
53 asm(GEN_SYMNAME(name) " = " GEN_VALUE(value))
Mike Frysinger4087bc82008-02-04 19:26:54 -050054#endif
Igor Grinbergbd2a23a2011-11-07 01:14:06 +000055#define GEN_SYMNAME(str) SYM_CHAR #str
56#define GEN_VALUE(str) #str
57#define GEN_ABS(name, value) \
58 asm(".globl " GEN_SYMNAME(name)); \
59 GEN_SET_VALUE(name, value)
wdenkc6097192002-11-03 00:24:07 +000060
61/*
wdenkc6097192002-11-03 00:24:07 +000062 * Check to see if we are building with a
63 * computed CRC. Otherwise define it as ~0.
64 */
65#if !defined(ENV_CRC)
Igor Grinbergbd2a23a2011-11-07 01:14:06 +000066# define ENV_CRC (~0)
wdenkc6097192002-11-03 00:24:07 +000067#endif
68
Joe Hershbergerddd84182012-10-12 08:48:51 +000069#define DEFAULT_ENV_INSTANCE_EMBEDDED
70#include <env_default.h>
71
Jean-Christophe PLAGNIOL-VILLARD0e8d1582008-09-10 22:48:06 +020072#ifdef CONFIG_ENV_ADDR_REDUND
Christophe Leroy23ac79f2018-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-VILLARD0e8d1582008-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 Leroy23ac79f2018-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 */
Jean-Christophe PLAGNIOL-VILLARD0e8d1582008-09-10 22:48:06 +020095GEN_ABS(env_offset, CONFIG_ENV_OFFSET);
Wolfgang Denka747a7f2009-10-27 00:03:32 +010096
97#endif /* ENV_IS_EMBEDDED */