embedded.c 2.42 KB
Newer Older
1
// SPDX-License-Identifier: GPL-2.0+
wdenk's avatar
wdenk committed
2 3 4 5 6
/*
 * (C) Copyright 2001
 * Erik Theisen,  Wave 7 Optics, etheisen@mindspring.com.
 */

York Sun's avatar
York Sun committed
7 8
#include <linux/kconfig.h>

9
#ifndef __ASSEMBLY__
10
#define	__ASSEMBLY__			/* Dirty trick to get only #defines */
11
#endif
12
#define	__ASM_STUB_PROCESSOR_H__	/* don't include asm/processor. */
wdenk's avatar
wdenk committed
13
#include <config.h>
14
#undef	__ASSEMBLY__
wdenk's avatar
wdenk committed
15
#include <environment.h>
16
#include <linux/stringify.h>
wdenk's avatar
wdenk committed
17

18
/* Handle HOSTS that have prepended crap on symbol names, not TARGETS. */
wdenk's avatar
wdenk committed
19 20 21 22 23 24 25
#if defined(__APPLE__)
/* Leading underscore on symbols */
#  define SYM_CHAR "_"
#else /* No leading character on symbols */
#  define SYM_CHAR
#endif

26 27 28 29
/*
 * Generate embedded environment table
 * inside U-Boot image, if needed.
 */
30
#if defined(ENV_IS_EMBEDDED) || defined(CONFIG_BUILD_ENVCRC)
wdenk's avatar
wdenk committed
31
/*
32
 * Put the environment in the .text section when we are building
wdenk's avatar
wdenk committed
33
 * U-Boot proper.  The host based program "tools/envcrc" does not need
34
 * a seperate section.
wdenk's avatar
wdenk committed
35
 */
36
#if defined(USE_HOSTCC) /* Native for 'tools/envcrc' */
37
#  define __UBOOT_ENV_SECTION__(name)	/*XXX DO_NOT_DEL_THIS_COMMENT*/
wdenk's avatar
wdenk committed
38 39 40

#else /* Environment is embedded in U-Boot's .text section */
/* XXX - This only works with GNU C */
41
#  define __UBOOT_ENV_SECTION__(name)	__attribute__ ((section(".text."#name)))
wdenk's avatar
wdenk committed
42 43 44 45 46
#endif

/*
 * Macros to generate global absolutes.
 */
47
#if defined(__bfin__)
48 49
# define GEN_SET_VALUE(name, value)	\
	asm(".set " GEN_SYMNAME(name) ", " GEN_VALUE(value))
50
#else
51 52 53 54 55 56 57 58
# define GEN_SET_VALUE(name, value)	\
	asm(GEN_SYMNAME(name) " = " GEN_VALUE(value))
#endif
#define GEN_SYMNAME(str)	SYM_CHAR #str
#define GEN_VALUE(str)		#str
#define GEN_ABS(name, value)			\
	asm(".globl " GEN_SYMNAME(name));	\
	GEN_SET_VALUE(name, value)
wdenk's avatar
wdenk committed
59 60 61 62 63 64

/*
 * Check to see if we are building with a
 * computed CRC.  Otherwise define it as ~0.
 */
#if !defined(ENV_CRC)
65
#  define ENV_CRC	(~0)
wdenk's avatar
wdenk committed
66 67
#endif

68 69 70
#define DEFAULT_ENV_INSTANCE_EMBEDDED
#include <env_default.h>

71
#ifdef CONFIG_ENV_ADDR_REDUND
72
env_t redundand_environment __UBOOT_ENV_SECTION__(redundand_environment) = {
wdenk's avatar
wdenk committed
73 74 75 76 77 78
	0,		/* CRC Sum: invalid */
	0,		/* Flags:   invalid */
	{
	"\0"
	}
};
79
#endif	/* CONFIG_ENV_ADDR_REDUND */
wdenk's avatar
wdenk committed
80 81 82 83 84 85 86 87 88

/*
 * These will end up in the .text section
 * if the environment strings are embedded
 * in the image.  When this is used for
 * tools/envcrc, they are placed in the
 * .data/.sdata section.
 *
 */
89
unsigned long env_size __UBOOT_ENV_SECTION__(env_size) = sizeof(env_t);
wdenk's avatar
wdenk committed
90 91 92 93

/*
 * Add in absolutes.
 */
94
GEN_ABS(env_offset, CONFIG_ENV_OFFSET);
95 96

#endif /* ENV_IS_EMBEDDED */