env_embedded.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. * (C) Copyright 2001
  3. * Erik Theisen, Wave 7 Optics, etheisen@mindspring.com.
  4. *
  5. * SPDX-License-Identifier: GPL-2.0+
  6. */
  7. #include <linux/kconfig.h>
  8. #ifndef __ASSEMBLY__
  9. #define __ASSEMBLY__ /* Dirty trick to get only #defines */
  10. #endif
  11. #define __ASM_STUB_PROCESSOR_H__ /* don't include asm/processor. */
  12. #include <config.h>
  13. #undef __ASSEMBLY__
  14. #include <environment.h>
  15. #include <linux/stringify.h>
  16. /* Handle HOSTS that have prepended crap on symbol names, not TARGETS. */
  17. #if defined(__APPLE__)
  18. /* Leading underscore on symbols */
  19. # define SYM_CHAR "_"
  20. #else /* No leading character on symbols */
  21. # define SYM_CHAR
  22. #endif
  23. /*
  24. * Generate embedded environment table
  25. * inside U-Boot image, if needed.
  26. */
  27. #if defined(ENV_IS_EMBEDDED) || defined(CONFIG_BUILD_ENVCRC)
  28. /*
  29. * Only put the environment in it's own section when we are building
  30. * U-Boot proper. The host based program "tools/envcrc" does not need
  31. * a seperate section. Note that ENV_CRC is only defined when building
  32. * U-Boot itself.
  33. */
  34. #if defined(CONFIG_SYS_USE_PPCENV) && \
  35. defined(ENV_CRC) /* Environment embedded in U-Boot .ppcenv section */
  36. /* XXX - This only works with GNU C */
  37. # define __PPCENV__ __attribute__ ((section(".ppcenv")))
  38. # define __PPCTEXT__ __attribute__ ((section(".text")))
  39. #elif defined(USE_HOSTCC) /* Native for 'tools/envcrc' */
  40. # define __PPCENV__ /*XXX DO_NOT_DEL_THIS_COMMENT*/
  41. # define __PPCTEXT__ /*XXX DO_NOT_DEL_THIS_COMMENT*/
  42. #else /* Environment is embedded in U-Boot's .text section */
  43. /* XXX - This only works with GNU C */
  44. # define __PPCENV__ __attribute__ ((section(".text")))
  45. # define __PPCTEXT__ __attribute__ ((section(".text")))
  46. #endif
  47. /*
  48. * Macros to generate global absolutes.
  49. */
  50. #if defined(__bfin__)
  51. # define GEN_SET_VALUE(name, value) \
  52. asm(".set " GEN_SYMNAME(name) ", " GEN_VALUE(value))
  53. #else
  54. # define GEN_SET_VALUE(name, value) \
  55. asm(GEN_SYMNAME(name) " = " GEN_VALUE(value))
  56. #endif
  57. #define GEN_SYMNAME(str) SYM_CHAR #str
  58. #define GEN_VALUE(str) #str
  59. #define GEN_ABS(name, value) \
  60. asm(".globl " GEN_SYMNAME(name)); \
  61. GEN_SET_VALUE(name, value)
  62. /*
  63. * Check to see if we are building with a
  64. * computed CRC. Otherwise define it as ~0.
  65. */
  66. #if !defined(ENV_CRC)
  67. # define ENV_CRC (~0)
  68. #endif
  69. #define DEFAULT_ENV_INSTANCE_EMBEDDED
  70. #include <env_default.h>
  71. #ifdef CONFIG_ENV_ADDR_REDUND
  72. env_t redundand_environment __PPCENV__ = {
  73. 0, /* CRC Sum: invalid */
  74. 0, /* Flags: invalid */
  75. {
  76. "\0"
  77. }
  78. };
  79. #endif /* CONFIG_ENV_ADDR_REDUND */
  80. /*
  81. * These will end up in the .text section
  82. * if the environment strings are embedded
  83. * in the image. When this is used for
  84. * tools/envcrc, they are placed in the
  85. * .data/.sdata section.
  86. *
  87. */
  88. unsigned long env_size __PPCTEXT__ = sizeof(env_t);
  89. /*
  90. * Add in absolutes.
  91. */
  92. GEN_ABS(env_offset, CONFIG_ENV_OFFSET);
  93. #endif /* ENV_IS_EMBEDDED */