embedded.c 2.5 KB

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