env_embedded.c 2.7 KB

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