embedded.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2001
  4. * Erik Theisen, Wave 7 Optics, etheisen@mindspring.com.
  5. */
  6. #include <linux/kconfig.h>
  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 <env_internal.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. * Put the environment in the .text section when we are building
  29. * U-Boot proper. The host based program "tools/envcrc" does not need
  30. * a seperate section.
  31. */
  32. #if defined(USE_HOSTCC) /* Native for 'tools/envcrc' */
  33. # define __UBOOT_ENV_SECTION__(name) /*XXX DO_NOT_DEL_THIS_COMMENT*/
  34. #else /* Environment is embedded in U-Boot's .text section */
  35. /* XXX - This only works with GNU C */
  36. # define __UBOOT_ENV_SECTION__(name) __attribute__ ((section(".text."#name)))
  37. #endif
  38. /*
  39. * Macros to generate global absolutes.
  40. */
  41. #if defined(__bfin__)
  42. # define GEN_SET_VALUE(name, value) \
  43. asm(".set " GEN_SYMNAME(name) ", " GEN_VALUE(value))
  44. #else
  45. # define GEN_SET_VALUE(name, value) \
  46. asm(GEN_SYMNAME(name) " = " GEN_VALUE(value))
  47. #endif
  48. #define GEN_SYMNAME(str) SYM_CHAR #str
  49. #define GEN_VALUE(str) #str
  50. #define GEN_ABS(name, value) \
  51. asm(".globl " GEN_SYMNAME(name)); \
  52. GEN_SET_VALUE(name, value)
  53. /*
  54. * Check to see if we are building with a
  55. * computed CRC. Otherwise define it as ~0.
  56. */
  57. #if !defined(ENV_CRC)
  58. # define ENV_CRC (~0)
  59. #endif
  60. #define DEFAULT_ENV_INSTANCE_EMBEDDED
  61. #include <env_default.h>
  62. #ifdef CONFIG_ENV_ADDR_REDUND
  63. env_t redundand_environment __UBOOT_ENV_SECTION__(redundand_environment) = {
  64. 0, /* CRC Sum: invalid */
  65. 0, /* Flags: invalid */
  66. {
  67. "\0"
  68. }
  69. };
  70. #endif /* CONFIG_ENV_ADDR_REDUND */
  71. /*
  72. * These will end up in the .text section
  73. * if the environment strings are embedded
  74. * in the image. When this is used for
  75. * tools/envcrc, they are placed in the
  76. * .data/.sdata section.
  77. *
  78. */
  79. unsigned long env_size __UBOOT_ENV_SECTION__(env_size) = sizeof(env_t);
  80. /*
  81. * Add in absolutes.
  82. */
  83. GEN_ABS(env_offset, (CONFIG_ENV_ADDR - CONFIG_SYS_FLASH_BASE));
  84. #endif /* ENV_IS_EMBEDDED */