embedded.c 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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 <config.h>
  62. #include <env_default.h>
  63. #ifdef CONFIG_ENV_ADDR_REDUND
  64. env_t redundand_environment __UBOOT_ENV_SECTION__(redundand_environment) = {
  65. 0, /* CRC Sum: invalid */
  66. 0, /* Flags: invalid */
  67. {
  68. "\0"
  69. }
  70. };
  71. #endif /* CONFIG_ENV_ADDR_REDUND */
  72. /*
  73. * These will end up in the .text section
  74. * if the environment strings are embedded
  75. * in the image. When this is used for
  76. * tools/envcrc, they are placed in the
  77. * .data/.sdata section.
  78. *
  79. */
  80. unsigned long env_size __UBOOT_ENV_SECTION__(env_size) = sizeof(env_t);
  81. /*
  82. * Add in absolutes.
  83. */
  84. GEN_ABS(env_offset, (CONFIG_ENV_ADDR - CONFIG_SYS_FLASH_BASE));
  85. #endif /* ENV_IS_EMBEDDED */