blob: 56a13cb882d22f0916e8220571abd98eba917bbe [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
Wolfgang Denkdc17fb62005-08-03 22:32:02 +02008#ifndef __ASSEMBLY__
Igor Grinbergbd2a23a2011-11-07 01:14:06 +00009#define __ASSEMBLY__ /* Dirty trick to get only #defines */
Wolfgang Denkdc17fb62005-08-03 22:32:02 +020010#endif
Igor Grinbergbd2a23a2011-11-07 01:14:06 +000011#define __ASM_STUB_PROCESSOR_H__ /* don't include asm/processor. */
wdenkc6097192002-11-03 00:24:07 +000012#include <config.h>
Wolfgang Denkdc17fb62005-08-03 22:32:02 +020013#undef __ASSEMBLY__
wdenkc6097192002-11-03 00:24:07 +000014#include <environment.h>
Marek Vasut5368c552012-09-23 17:41:24 +020015#include <linux/stringify.h>
wdenkc6097192002-11-03 00:24:07 +000016
Igor Grinbergbd2a23a2011-11-07 01:14:06 +000017/* Handle HOSTS that have prepended crap on symbol names, not TARGETS. */
wdenkc6097192002-11-03 00:24:07 +000018#if defined(__APPLE__)
19/* Leading underscore on symbols */
20# define SYM_CHAR "_"
21#else /* No leading character on symbols */
22# define SYM_CHAR
23#endif
24
25/*
Wolfgang Denka747a7f2009-10-27 00:03:32 +010026 * Generate embedded environment table
27 * inside U-Boot image, if needed.
28 */
Mike Frysingerc3eb3fe2011-07-08 10:44:25 +000029#if defined(ENV_IS_EMBEDDED) || defined(CONFIG_BUILD_ENVCRC)
Wolfgang Denka747a7f2009-10-27 00:03:32 +010030/*
wdenkc6097192002-11-03 00:24:07 +000031 * Only put the environment in it's own section when we are building
32 * U-Boot proper. The host based program "tools/envcrc" does not need
33 * a seperate section. Note that ENV_CRC is only defined when building
34 * U-Boot itself.
35 */
Masahiro Yamada66948c22014-06-04 10:26:53 +090036#if defined(CONFIG_SYS_USE_PPCENV) && \
Igor Grinbergbd2a23a2011-11-07 01:14:06 +000037 defined(ENV_CRC) /* Environment embedded in U-Boot .ppcenv section */
wdenkc6097192002-11-03 00:24:07 +000038/* XXX - This only works with GNU C */
Igor Grinbergbd2a23a2011-11-07 01:14:06 +000039# define __PPCENV__ __attribute__ ((section(".ppcenv")))
40# define __PPCTEXT__ __attribute__ ((section(".text")))
wdenkc6097192002-11-03 00:24:07 +000041
42#elif defined(USE_HOSTCC) /* Native for 'tools/envcrc' */
Igor Grinbergbd2a23a2011-11-07 01:14:06 +000043# define __PPCENV__ /*XXX DO_NOT_DEL_THIS_COMMENT*/
44# define __PPCTEXT__ /*XXX DO_NOT_DEL_THIS_COMMENT*/
wdenkc6097192002-11-03 00:24:07 +000045
46#else /* Environment is embedded in U-Boot's .text section */
47/* XXX - This only works with GNU C */
Igor Grinbergbd2a23a2011-11-07 01:14:06 +000048# define __PPCENV__ __attribute__ ((section(".text")))
49# define __PPCTEXT__ __attribute__ ((section(".text")))
wdenkc6097192002-11-03 00:24:07 +000050#endif
51
52/*
53 * Macros to generate global absolutes.
54 */
Mike Frysinger4087bc82008-02-04 19:26:54 -050055#if defined(__bfin__)
Igor Grinbergbd2a23a2011-11-07 01:14:06 +000056# define GEN_SET_VALUE(name, value) \
57 asm(".set " GEN_SYMNAME(name) ", " GEN_VALUE(value))
Mike Frysinger4087bc82008-02-04 19:26:54 -050058#else
Igor Grinbergbd2a23a2011-11-07 01:14:06 +000059# define GEN_SET_VALUE(name, value) \
60 asm(GEN_SYMNAME(name) " = " GEN_VALUE(value))
Mike Frysinger4087bc82008-02-04 19:26:54 -050061#endif
Igor Grinbergbd2a23a2011-11-07 01:14:06 +000062#define GEN_SYMNAME(str) SYM_CHAR #str
63#define GEN_VALUE(str) #str
64#define GEN_ABS(name, value) \
65 asm(".globl " GEN_SYMNAME(name)); \
66 GEN_SET_VALUE(name, value)
wdenkc6097192002-11-03 00:24:07 +000067
68/*
wdenkc6097192002-11-03 00:24:07 +000069 * Check to see if we are building with a
70 * computed CRC. Otherwise define it as ~0.
71 */
72#if !defined(ENV_CRC)
Igor Grinbergbd2a23a2011-11-07 01:14:06 +000073# define ENV_CRC (~0)
wdenkc6097192002-11-03 00:24:07 +000074#endif
75
Joe Hershbergerddd84182012-10-12 08:48:51 +000076#define DEFAULT_ENV_INSTANCE_EMBEDDED
77#include <env_default.h>
78
Jean-Christophe PLAGNIOL-VILLARD0e8d1582008-09-10 22:48:06 +020079#ifdef CONFIG_ENV_ADDR_REDUND
wdenkc6097192002-11-03 00:24:07 +000080env_t redundand_environment __PPCENV__ = {
81 0, /* CRC Sum: invalid */
82 0, /* Flags: invalid */
83 {
84 "\0"
85 }
86};
Jean-Christophe PLAGNIOL-VILLARD0e8d1582008-09-10 22:48:06 +020087#endif /* CONFIG_ENV_ADDR_REDUND */
wdenkc6097192002-11-03 00:24:07 +000088
89/*
90 * These will end up in the .text section
91 * if the environment strings are embedded
92 * in the image. When this is used for
93 * tools/envcrc, they are placed in the
94 * .data/.sdata section.
95 *
96 */
97unsigned long env_size __PPCTEXT__ = sizeof(env_t);
98
99/*
100 * Add in absolutes.
101 */
Jean-Christophe PLAGNIOL-VILLARD0e8d1582008-09-10 22:48:06 +0200102GEN_ABS(env_offset, CONFIG_ENV_OFFSET);
Wolfgang Denka747a7f2009-10-27 00:03:32 +0100103
104#endif /* ENV_IS_EMBEDDED */