wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2001 |
| 3 | * Erik Theisen, Wave 7 Optics, etheisen@mindspring.com. |
| 4 | * |
Wolfgang Denk | 3765b3e | 2013-10-07 13:07:26 +0200 | [diff] [blame] | 5 | * SPDX-License-Identifier: GPL-2.0+ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
York Sun | f33f3e0 | 2016-11-15 17:02:31 -0800 | [diff] [blame] | 8 | #include <linux/kconfig.h> |
| 9 | |
Wolfgang Denk | dc17fb6 | 2005-08-03 22:32:02 +0200 | [diff] [blame] | 10 | #ifndef __ASSEMBLY__ |
Igor Grinberg | bd2a23a | 2011-11-07 01:14:06 +0000 | [diff] [blame] | 11 | #define __ASSEMBLY__ /* Dirty trick to get only #defines */ |
Wolfgang Denk | dc17fb6 | 2005-08-03 22:32:02 +0200 | [diff] [blame] | 12 | #endif |
Igor Grinberg | bd2a23a | 2011-11-07 01:14:06 +0000 | [diff] [blame] | 13 | #define __ASM_STUB_PROCESSOR_H__ /* don't include asm/processor. */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 14 | #include <config.h> |
Wolfgang Denk | dc17fb6 | 2005-08-03 22:32:02 +0200 | [diff] [blame] | 15 | #undef __ASSEMBLY__ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 16 | #include <environment.h> |
Marek Vasut | 5368c55 | 2012-09-23 17:41:24 +0200 | [diff] [blame] | 17 | #include <linux/stringify.h> |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 18 | |
Igor Grinberg | bd2a23a | 2011-11-07 01:14:06 +0000 | [diff] [blame] | 19 | /* Handle HOSTS that have prepended crap on symbol names, not TARGETS. */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 20 | #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 Denk | a747a7f | 2009-10-27 00:03:32 +0100 | [diff] [blame] | 28 | * Generate embedded environment table |
| 29 | * inside U-Boot image, if needed. |
| 30 | */ |
Mike Frysinger | c3eb3fe | 2011-07-08 10:44:25 +0000 | [diff] [blame] | 31 | #if defined(ENV_IS_EMBEDDED) || defined(CONFIG_BUILD_ENVCRC) |
Wolfgang Denk | a747a7f | 2009-10-27 00:03:32 +0100 | [diff] [blame] | 32 | /* |
Thomas Petazzoni | 7653942 | 2017-07-28 23:46:37 +0200 | [diff] [blame] | 33 | * Put the environment in the .text section when we are building |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 34 | * U-Boot proper. The host based program "tools/envcrc" does not need |
Thomas Petazzoni | 7653942 | 2017-07-28 23:46:37 +0200 | [diff] [blame] | 35 | * a seperate section. |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 36 | */ |
Thomas Petazzoni | 7653942 | 2017-07-28 23:46:37 +0200 | [diff] [blame] | 37 | #if defined(USE_HOSTCC) /* Native for 'tools/envcrc' */ |
Thomas Petazzoni | eaa90e5 | 2017-07-28 23:46:38 +0200 | [diff] [blame^] | 38 | # define __UBOOT_ENV_SECTION__ /*XXX DO_NOT_DEL_THIS_COMMENT*/ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 39 | |
| 40 | #else /* Environment is embedded in U-Boot's .text section */ |
| 41 | /* XXX - This only works with GNU C */ |
Thomas Petazzoni | eaa90e5 | 2017-07-28 23:46:38 +0200 | [diff] [blame^] | 42 | # define __UBOOT_ENV_SECTION__ __attribute__ ((section(".text"))) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 43 | #endif |
| 44 | |
| 45 | /* |
| 46 | * Macros to generate global absolutes. |
| 47 | */ |
Mike Frysinger | 4087bc8 | 2008-02-04 19:26:54 -0500 | [diff] [blame] | 48 | #if defined(__bfin__) |
Igor Grinberg | bd2a23a | 2011-11-07 01:14:06 +0000 | [diff] [blame] | 49 | # define GEN_SET_VALUE(name, value) \ |
| 50 | asm(".set " GEN_SYMNAME(name) ", " GEN_VALUE(value)) |
Mike Frysinger | 4087bc8 | 2008-02-04 19:26:54 -0500 | [diff] [blame] | 51 | #else |
Igor Grinberg | bd2a23a | 2011-11-07 01:14:06 +0000 | [diff] [blame] | 52 | # define GEN_SET_VALUE(name, value) \ |
| 53 | asm(GEN_SYMNAME(name) " = " GEN_VALUE(value)) |
Mike Frysinger | 4087bc8 | 2008-02-04 19:26:54 -0500 | [diff] [blame] | 54 | #endif |
Igor Grinberg | bd2a23a | 2011-11-07 01:14:06 +0000 | [diff] [blame] | 55 | #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) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 60 | |
| 61 | /* |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 62 | * Check to see if we are building with a |
| 63 | * computed CRC. Otherwise define it as ~0. |
| 64 | */ |
| 65 | #if !defined(ENV_CRC) |
Igor Grinberg | bd2a23a | 2011-11-07 01:14:06 +0000 | [diff] [blame] | 66 | # define ENV_CRC (~0) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 67 | #endif |
| 68 | |
Joe Hershberger | ddd8418 | 2012-10-12 08:48:51 +0000 | [diff] [blame] | 69 | #define DEFAULT_ENV_INSTANCE_EMBEDDED |
| 70 | #include <env_default.h> |
| 71 | |
Jean-Christophe PLAGNIOL-VILLARD | 0e8d158 | 2008-09-10 22:48:06 +0200 | [diff] [blame] | 72 | #ifdef CONFIG_ENV_ADDR_REDUND |
Thomas Petazzoni | eaa90e5 | 2017-07-28 23:46:38 +0200 | [diff] [blame^] | 73 | env_t redundand_environment __UBOOT_ENV_SECTION__ = { |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 74 | 0, /* CRC Sum: invalid */ |
| 75 | 0, /* Flags: invalid */ |
| 76 | { |
| 77 | "\0" |
| 78 | } |
| 79 | }; |
Jean-Christophe PLAGNIOL-VILLARD | 0e8d158 | 2008-09-10 22:48:06 +0200 | [diff] [blame] | 80 | #endif /* CONFIG_ENV_ADDR_REDUND */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 81 | |
| 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 | */ |
Thomas Petazzoni | eaa90e5 | 2017-07-28 23:46:38 +0200 | [diff] [blame^] | 90 | unsigned long env_size __UBOOT_ENV_SECTION__ = sizeof(env_t); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 91 | |
| 92 | /* |
| 93 | * Add in absolutes. |
| 94 | */ |
Jean-Christophe PLAGNIOL-VILLARD | 0e8d158 | 2008-09-10 22:48:06 +0200 | [diff] [blame] | 95 | GEN_ABS(env_offset, CONFIG_ENV_OFFSET); |
Wolfgang Denk | a747a7f | 2009-10-27 00:03:32 +0100 | [diff] [blame] | 96 | |
| 97 | #endif /* ENV_IS_EMBEDDED */ |