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