1*83d290c5STom Rini // SPDX-License-Identifier: GPL-2.0+ 20649cd0dSSimon Glass /* 30649cd0dSSimon Glass * (C) Copyright 2001 40649cd0dSSimon Glass * Erik Theisen, Wave 7 Optics, etheisen@mindspring.com. 50649cd0dSSimon Glass */ 60649cd0dSSimon Glass 70649cd0dSSimon Glass #include <linux/kconfig.h> 80649cd0dSSimon Glass 90649cd0dSSimon Glass #ifndef __ASSEMBLY__ 100649cd0dSSimon Glass #define __ASSEMBLY__ /* Dirty trick to get only #defines */ 110649cd0dSSimon Glass #endif 120649cd0dSSimon Glass #define __ASM_STUB_PROCESSOR_H__ /* don't include asm/processor. */ 130649cd0dSSimon Glass #include <config.h> 140649cd0dSSimon Glass #undef __ASSEMBLY__ 150649cd0dSSimon Glass #include <environment.h> 160649cd0dSSimon Glass #include <linux/stringify.h> 170649cd0dSSimon Glass 180649cd0dSSimon Glass /* Handle HOSTS that have prepended crap on symbol names, not TARGETS. */ 190649cd0dSSimon Glass #if defined(__APPLE__) 200649cd0dSSimon Glass /* Leading underscore on symbols */ 210649cd0dSSimon Glass # define SYM_CHAR "_" 220649cd0dSSimon Glass #else /* No leading character on symbols */ 230649cd0dSSimon Glass # define SYM_CHAR 240649cd0dSSimon Glass #endif 250649cd0dSSimon Glass 260649cd0dSSimon Glass /* 270649cd0dSSimon Glass * Generate embedded environment table 280649cd0dSSimon Glass * inside U-Boot image, if needed. 290649cd0dSSimon Glass */ 300649cd0dSSimon Glass #if defined(ENV_IS_EMBEDDED) || defined(CONFIG_BUILD_ENVCRC) 310649cd0dSSimon Glass /* 320649cd0dSSimon Glass * Put the environment in the .text section when we are building 330649cd0dSSimon Glass * U-Boot proper. The host based program "tools/envcrc" does not need 340649cd0dSSimon Glass * a seperate section. 350649cd0dSSimon Glass */ 360649cd0dSSimon Glass #if defined(USE_HOSTCC) /* Native for 'tools/envcrc' */ 3723ac79ffSChristophe Leroy # define __UBOOT_ENV_SECTION__(name) /*XXX DO_NOT_DEL_THIS_COMMENT*/ 380649cd0dSSimon Glass 390649cd0dSSimon Glass #else /* Environment is embedded in U-Boot's .text section */ 400649cd0dSSimon Glass /* XXX - This only works with GNU C */ 4123ac79ffSChristophe Leroy # define __UBOOT_ENV_SECTION__(name) __attribute__ ((section(".text."#name))) 420649cd0dSSimon Glass #endif 430649cd0dSSimon Glass 440649cd0dSSimon Glass /* 450649cd0dSSimon Glass * Macros to generate global absolutes. 460649cd0dSSimon Glass */ 470649cd0dSSimon Glass #if defined(__bfin__) 480649cd0dSSimon Glass # define GEN_SET_VALUE(name, value) \ 490649cd0dSSimon Glass asm(".set " GEN_SYMNAME(name) ", " GEN_VALUE(value)) 500649cd0dSSimon Glass #else 510649cd0dSSimon Glass # define GEN_SET_VALUE(name, value) \ 520649cd0dSSimon Glass asm(GEN_SYMNAME(name) " = " GEN_VALUE(value)) 530649cd0dSSimon Glass #endif 540649cd0dSSimon Glass #define GEN_SYMNAME(str) SYM_CHAR #str 550649cd0dSSimon Glass #define GEN_VALUE(str) #str 560649cd0dSSimon Glass #define GEN_ABS(name, value) \ 570649cd0dSSimon Glass asm(".globl " GEN_SYMNAME(name)); \ 580649cd0dSSimon Glass GEN_SET_VALUE(name, value) 590649cd0dSSimon Glass 600649cd0dSSimon Glass /* 610649cd0dSSimon Glass * Check to see if we are building with a 620649cd0dSSimon Glass * computed CRC. Otherwise define it as ~0. 630649cd0dSSimon Glass */ 640649cd0dSSimon Glass #if !defined(ENV_CRC) 650649cd0dSSimon Glass # define ENV_CRC (~0) 660649cd0dSSimon Glass #endif 670649cd0dSSimon Glass 680649cd0dSSimon Glass #define DEFAULT_ENV_INSTANCE_EMBEDDED 690649cd0dSSimon Glass #include <env_default.h> 700649cd0dSSimon Glass 710649cd0dSSimon Glass #ifdef CONFIG_ENV_ADDR_REDUND 7223ac79ffSChristophe Leroy env_t redundand_environment __UBOOT_ENV_SECTION__(redundand_environment) = { 730649cd0dSSimon Glass 0, /* CRC Sum: invalid */ 740649cd0dSSimon Glass 0, /* Flags: invalid */ 750649cd0dSSimon Glass { 760649cd0dSSimon Glass "\0" 770649cd0dSSimon Glass } 780649cd0dSSimon Glass }; 790649cd0dSSimon Glass #endif /* CONFIG_ENV_ADDR_REDUND */ 800649cd0dSSimon Glass 810649cd0dSSimon Glass /* 820649cd0dSSimon Glass * These will end up in the .text section 830649cd0dSSimon Glass * if the environment strings are embedded 840649cd0dSSimon Glass * in the image. When this is used for 850649cd0dSSimon Glass * tools/envcrc, they are placed in the 860649cd0dSSimon Glass * .data/.sdata section. 870649cd0dSSimon Glass * 880649cd0dSSimon Glass */ 8923ac79ffSChristophe Leroy unsigned long env_size __UBOOT_ENV_SECTION__(env_size) = sizeof(env_t); 900649cd0dSSimon Glass 910649cd0dSSimon Glass /* 920649cd0dSSimon Glass * Add in absolutes. 930649cd0dSSimon Glass */ 940649cd0dSSimon Glass GEN_ABS(env_offset, CONFIG_ENV_OFFSET); 950649cd0dSSimon Glass 960649cd0dSSimon Glass #endif /* ENV_IS_EMBEDDED */ 97