embedded.c 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. * Put the environment in the .text section when we are building
  30. * U-Boot proper. The host based program "tools/envcrc" does not need
  31. * a seperate section.
  32. */
  33. #if defined(USE_HOSTCC) /* Native for 'tools/envcrc' */
  34. # define __UBOOT_ENV_SECTION__ /*XXX DO_NOT_DEL_THIS_COMMENT*/
  35. #else /* Environment is embedded in U-Boot's .text section */
  36. /* XXX - This only works with GNU C */
  37. # define __UBOOT_ENV_SECTION__ __attribute__ ((section(".text")))
  38. #endif
  39. /*
  40. * Macros to generate global absolutes.
  41. */
  42. #if defined(__bfin__)
  43. # define GEN_SET_VALUE(name, value) \
  44. asm(".set " GEN_SYMNAME(name) ", " GEN_VALUE(value))
  45. #else
  46. # define GEN_SET_VALUE(name, value) \
  47. asm(GEN_SYMNAME(name) " = " GEN_VALUE(value))
  48. #endif
  49. #define GEN_SYMNAME(str) SYM_CHAR #str
  50. #define GEN_VALUE(str) #str
  51. #define GEN_ABS(name, value) \
  52. asm(".globl " GEN_SYMNAME(name)); \
  53. GEN_SET_VALUE(name, value)
  54. /*
  55. * Check to see if we are building with a
  56. * computed CRC. Otherwise define it as ~0.
  57. */
  58. #if !defined(ENV_CRC)
  59. # define ENV_CRC (~0)
  60. #endif
  61. #define DEFAULT_ENV_INSTANCE_EMBEDDED
  62. #include <env_default.h>
  63. #ifdef CONFIG_ENV_ADDR_REDUND
  64. env_t redundand_environment __UBOOT_ENV_SECTION__ = {
  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__ = sizeof(env_t);
  81. /*
  82. * Add in absolutes.
  83. */
  84. GEN_ABS(env_offset, CONFIG_ENV_OFFSET);
  85. #endif /* ENV_IS_EMBEDDED */