Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2001 |
| 4 | * Erik Theisen, Wave 7 Optics, etheisen@mindspring.com. |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
York Sun | fe92d67 | 2016-11-15 17:02:31 -0800 | [diff] [blame] | 7 | #include <linux/kconfig.h> |
| 8 | |
Wolfgang Denk | db5f386 | 2005-08-03 22:32:02 +0200 | [diff] [blame] | 9 | #ifndef __ASSEMBLY__ |
Igor Grinberg | 95a4e1d | 2011-11-07 01:14:06 +0000 | [diff] [blame] | 10 | #define __ASSEMBLY__ /* Dirty trick to get only #defines */ |
Wolfgang Denk | db5f386 | 2005-08-03 22:32:02 +0200 | [diff] [blame] | 11 | #endif |
Igor Grinberg | 95a4e1d | 2011-11-07 01:14:06 +0000 | [diff] [blame] | 12 | #define __ASM_STUB_PROCESSOR_H__ /* don't include asm/processor. */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 13 | #include <config.h> |
Wolfgang Denk | db5f386 | 2005-08-03 22:32:02 +0200 | [diff] [blame] | 14 | #undef __ASSEMBLY__ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 15 | #include <environment.h> |
Marek Vasut | 0b3176c | 2012-09-23 17:41:24 +0200 | [diff] [blame] | 16 | #include <linux/stringify.h> |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 17 | |
Igor Grinberg | 95a4e1d | 2011-11-07 01:14:06 +0000 | [diff] [blame] | 18 | /* Handle HOSTS that have prepended crap on symbol names, not TARGETS. */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 19 | #if defined(__APPLE__) |
| 20 | /* Leading underscore on symbols */ |
| 21 | # define SYM_CHAR "_" |
| 22 | #else /* No leading character on symbols */ |
| 23 | # define SYM_CHAR |
| 24 | #endif |
| 25 | |
| 26 | /* |
Wolfgang Denk | 51420fb | 2009-10-27 00:03:32 +0100 | [diff] [blame] | 27 | * Generate embedded environment table |
| 28 | * inside U-Boot image, if needed. |
| 29 | */ |
Mike Frysinger | 63b8f12 | 2011-07-08 10:44:25 +0000 | [diff] [blame] | 30 | #if defined(ENV_IS_EMBEDDED) || defined(CONFIG_BUILD_ENVCRC) |
Wolfgang Denk | 51420fb | 2009-10-27 00:03:32 +0100 | [diff] [blame] | 31 | /* |
Thomas Petazzoni | c3e088d | 2017-07-28 23:46:37 +0200 | [diff] [blame] | 32 | * Put the environment in the .text section when we are building |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 33 | * U-Boot proper. The host based program "tools/envcrc" does not need |
Thomas Petazzoni | c3e088d | 2017-07-28 23:46:37 +0200 | [diff] [blame] | 34 | * a seperate section. |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 35 | */ |
Thomas Petazzoni | c3e088d | 2017-07-28 23:46:37 +0200 | [diff] [blame] | 36 | #if defined(USE_HOSTCC) /* Native for 'tools/envcrc' */ |
Christophe Leroy | 29524f2 | 2018-03-16 17:20:53 +0100 | [diff] [blame] | 37 | # define __UBOOT_ENV_SECTION__(name) /*XXX DO_NOT_DEL_THIS_COMMENT*/ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 38 | |
| 39 | #else /* Environment is embedded in U-Boot's .text section */ |
| 40 | /* XXX - This only works with GNU C */ |
Christophe Leroy | 29524f2 | 2018-03-16 17:20:53 +0100 | [diff] [blame] | 41 | # define __UBOOT_ENV_SECTION__(name) __attribute__ ((section(".text."#name))) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 42 | #endif |
| 43 | |
| 44 | /* |
| 45 | * Macros to generate global absolutes. |
| 46 | */ |
Mike Frysinger | 15c5135 | 2008-02-04 19:26:54 -0500 | [diff] [blame] | 47 | #if defined(__bfin__) |
Igor Grinberg | 95a4e1d | 2011-11-07 01:14:06 +0000 | [diff] [blame] | 48 | # define GEN_SET_VALUE(name, value) \ |
| 49 | asm(".set " GEN_SYMNAME(name) ", " GEN_VALUE(value)) |
Mike Frysinger | 15c5135 | 2008-02-04 19:26:54 -0500 | [diff] [blame] | 50 | #else |
Igor Grinberg | 95a4e1d | 2011-11-07 01:14:06 +0000 | [diff] [blame] | 51 | # define GEN_SET_VALUE(name, value) \ |
| 52 | asm(GEN_SYMNAME(name) " = " GEN_VALUE(value)) |
Mike Frysinger | 15c5135 | 2008-02-04 19:26:54 -0500 | [diff] [blame] | 53 | #endif |
Igor Grinberg | 95a4e1d | 2011-11-07 01:14:06 +0000 | [diff] [blame] | 54 | #define GEN_SYMNAME(str) SYM_CHAR #str |
| 55 | #define GEN_VALUE(str) #str |
| 56 | #define GEN_ABS(name, value) \ |
| 57 | asm(".globl " GEN_SYMNAME(name)); \ |
| 58 | GEN_SET_VALUE(name, value) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 59 | |
| 60 | /* |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 61 | * Check to see if we are building with a |
| 62 | * computed CRC. Otherwise define it as ~0. |
| 63 | */ |
| 64 | #if !defined(ENV_CRC) |
Igor Grinberg | 95a4e1d | 2011-11-07 01:14:06 +0000 | [diff] [blame] | 65 | # define ENV_CRC (~0) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 66 | #endif |
| 67 | |
Joe Hershberger | 8132114 | 2012-10-12 08:48:51 +0000 | [diff] [blame] | 68 | #define DEFAULT_ENV_INSTANCE_EMBEDDED |
| 69 | #include <env_default.h> |
| 70 | |
Jean-Christophe PLAGNIOL-VILLARD | 7e1cda6 | 2008-09-10 22:48:06 +0200 | [diff] [blame] | 71 | #ifdef CONFIG_ENV_ADDR_REDUND |
Christophe Leroy | 29524f2 | 2018-03-16 17:20:53 +0100 | [diff] [blame] | 72 | env_t redundand_environment __UBOOT_ENV_SECTION__(redundand_environment) = { |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 73 | 0, /* CRC Sum: invalid */ |
| 74 | 0, /* Flags: invalid */ |
| 75 | { |
| 76 | "\0" |
| 77 | } |
| 78 | }; |
Jean-Christophe PLAGNIOL-VILLARD | 7e1cda6 | 2008-09-10 22:48:06 +0200 | [diff] [blame] | 79 | #endif /* CONFIG_ENV_ADDR_REDUND */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 80 | |
| 81 | /* |
| 82 | * These will end up in the .text section |
| 83 | * if the environment strings are embedded |
| 84 | * in the image. When this is used for |
| 85 | * tools/envcrc, they are placed in the |
| 86 | * .data/.sdata section. |
| 87 | * |
| 88 | */ |
Christophe Leroy | 29524f2 | 2018-03-16 17:20:53 +0100 | [diff] [blame] | 89 | unsigned long env_size __UBOOT_ENV_SECTION__(env_size) = sizeof(env_t); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 90 | |
| 91 | /* |
| 92 | * Add in absolutes. |
| 93 | */ |
Jean-Christophe PLAGNIOL-VILLARD | 7e1cda6 | 2008-09-10 22:48:06 +0200 | [diff] [blame] | 94 | GEN_ABS(env_offset, CONFIG_ENV_OFFSET); |
Wolfgang Denk | 51420fb | 2009-10-27 00:03:32 +0100 | [diff] [blame] | 95 | |
| 96 | #endif /* ENV_IS_EMBEDDED */ |