1// SPDX-License-Identifier: GPL-2.0+
2/*
3 * (C) Copyright 2001
4 * Erik Theisen,  Wave 7 Optics, etheisen@mindspring.com.
5 */
6
7#ifdef USE_HOSTCC
8#include <linux/kconfig.h>
9#endif
10
11#ifndef __ASSEMBLY__
12#define	__ASSEMBLY__			/* Dirty trick to get only #defines */
13#endif
14#define	__ASM_STUB_PROCESSOR_H__	/* don't include asm/processor. */
15#include <config.h>
16#undef	__ASSEMBLY__
17#include <env_internal.h>
18#include <linux/stringify.h>
19
20/* Handle HOSTS that have prepended crap on symbol names, not TARGETS. */
21#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/*
29 * Generate embedded environment table
30 * inside U-Boot image, if needed.
31 */
32#if defined(ENV_IS_EMBEDDED)
33/*
34 * Put the environment in the .text section when we are building
35 * U-Boot proper.  The host based program "tools/envcrc" does not need
36 * a seperate section.
37 */
38#if defined(USE_HOSTCC) /* Native for 'tools/envcrc' */
39#  define __UBOOT_ENV_SECTION__(name)	/*XXX DO_NOT_DEL_THIS_COMMENT*/
40
41#else /* Environment is embedded in U-Boot's .text section */
42/* XXX - This only works with GNU C */
43#  define __UBOOT_ENV_SECTION__(name)	__attribute__ ((section(".text."#name)))
44#endif
45
46/*
47 * Macros to generate global absolutes.
48 */
49#if defined(__bfin__)
50# define GEN_SET_VALUE(name, value)	\
51	asm(".set " GEN_SYMNAME(name) ", " GEN_VALUE(value))
52#else
53# define GEN_SET_VALUE(name, value)	\
54	asm(GEN_SYMNAME(name) " = " GEN_VALUE(value))
55#endif
56#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)
61
62/*
63 * Check to see if we are building with a
64 * computed CRC.  Otherwise define it as ~0.
65 */
66#if !defined(ENV_CRC)
67#  define ENV_CRC	(~0)
68#endif
69
70#define DEFAULT_ENV_INSTANCE_EMBEDDED
71#include <config.h>
72#include <env_default.h>
73
74#ifdef CONFIG_ENV_ADDR_REDUND
75env_t redundand_environment __UBOOT_ENV_SECTION__(redundand_environment) = {
76	0,		/* CRC Sum: invalid */
77	0,		/* Flags:   invalid */
78	{
79	"\0"
80	}
81};
82#endif	/* CONFIG_ENV_ADDR_REDUND */
83
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 */
92unsigned long env_size __UBOOT_ENV_SECTION__(env_size) = sizeof(env_t);
93
94/*
95 * Add in absolutes.
96 */
97GEN_ABS(env_offset, (CONFIG_ENV_ADDR - CFG_SYS_FLASH_BASE));
98
99#endif /* ENV_IS_EMBEDDED */
100