common_def.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. /*
  2. * Copyright (c) 2015-2024, Arm Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #ifndef COMMON_DEF_H
  7. #define COMMON_DEF_H
  8. #include <common/bl_common.h>
  9. #include <lib/utils_def.h>
  10. #include <lib/xlat_tables/xlat_tables_defs.h>
  11. #include <platform_def.h>
  12. #ifdef __aarch64__
  13. #define SZ_32 UL(0x00000020)
  14. #define SZ_64 UL(0x00000040)
  15. #define SZ_128 UL(0x00000080)
  16. #define SZ_256 UL(0x00000100)
  17. #define SZ_512 UL(0x00000200)
  18. #define SZ_1K UL(0x00000400)
  19. #define SZ_2K UL(0x00000800)
  20. #define SZ_4K UL(0x00001000)
  21. #define SZ_8K UL(0x00002000)
  22. #define SZ_16K UL(0x00004000)
  23. #define SZ_32K UL(0x00008000)
  24. #define SZ_64K UL(0x00010000)
  25. #define SZ_128K UL(0x00020000)
  26. #define SZ_256K UL(0x00040000)
  27. #define SZ_512K UL(0x00080000)
  28. #define SZ_1M UL(0x00100000)
  29. #define SZ_2M UL(0x00200000)
  30. #define SZ_4M UL(0x00400000)
  31. #define SZ_8M UL(0x00800000)
  32. #define SZ_16M UL(0x01000000)
  33. #define SZ_32M UL(0x02000000)
  34. #define SZ_64M UL(0x04000000)
  35. #define SZ_128M UL(0x08000000)
  36. #define SZ_256M UL(0x10000000)
  37. #define SZ_512M UL(0x20000000)
  38. #define SZ_1G UL(0x40000000)
  39. #define SZ_2G UL(0x80000000)
  40. #else /* !__aarch64__ */
  41. #define SZ_32 U(0x00000020)
  42. #define SZ_64 U(0x00000040)
  43. #define SZ_128 U(0x00000080)
  44. #define SZ_256 U(0x00000100)
  45. #define SZ_512 U(0x00000200)
  46. #define SZ_1K U(0x00000400)
  47. #define SZ_2K U(0x00000800)
  48. #define SZ_4K U(0x00001000)
  49. #define SZ_8K U(0x00002000)
  50. #define SZ_16K U(0x00004000)
  51. #define SZ_32K U(0x00008000)
  52. #define SZ_64K U(0x00010000)
  53. #define SZ_128K U(0x00020000)
  54. #define SZ_256K U(0x00040000)
  55. #define SZ_512K U(0x00080000)
  56. #define SZ_1M U(0x00100000)
  57. #define SZ_2M U(0x00200000)
  58. #define SZ_4M U(0x00400000)
  59. #define SZ_8M U(0x00800000)
  60. #define SZ_16M U(0x01000000)
  61. #define SZ_32M U(0x02000000)
  62. #define SZ_64M U(0x04000000)
  63. #define SZ_128M U(0x08000000)
  64. #define SZ_256M U(0x10000000)
  65. #define SZ_512M U(0x20000000)
  66. #define SZ_1G U(0x40000000)
  67. #define SZ_2G U(0x80000000)
  68. #endif /* __aarch64__ */
  69. /******************************************************************************
  70. * Required platform porting definitions that are expected to be common to
  71. * all platforms
  72. *****************************************************************************/
  73. /*
  74. * Platform binary types for linking
  75. */
  76. #ifdef __aarch64__
  77. #define PLATFORM_LINKER_FORMAT "elf64-littleaarch64"
  78. #define PLATFORM_LINKER_ARCH aarch64
  79. #else
  80. #define PLATFORM_LINKER_FORMAT "elf32-littlearm"
  81. #define PLATFORM_LINKER_ARCH arm
  82. #endif /* __aarch64__ */
  83. /*
  84. * Generic platform constants
  85. */
  86. #define FIRMWARE_WELCOME_STR "Booting Trusted Firmware\n"
  87. #define BL2_IMAGE_DESC { \
  88. .image_id = BL2_IMAGE_ID, \
  89. SET_STATIC_PARAM_HEAD(image_info, PARAM_EP, \
  90. VERSION_2, image_info_t, 0), \
  91. .image_info.image_base = BL2_BASE, \
  92. .image_info.image_max_size = BL2_LIMIT - BL2_BASE,\
  93. SET_STATIC_PARAM_HEAD(ep_info, PARAM_EP, \
  94. VERSION_2, entry_point_info_t, SECURE | EXECUTABLE),\
  95. .ep_info.pc = BL2_BASE, \
  96. }
  97. /*
  98. * The following constants identify the extents of the code & read-only data
  99. * regions. These addresses are used by the MMU setup code and therefore they
  100. * must be page-aligned.
  101. *
  102. * When the code and read-only data are mapped as a single atomic section
  103. * (i.e. when SEPARATE_CODE_AND_RODATA=0) then we treat the whole section as
  104. * code by specifying the read-only data section as empty.
  105. *
  106. * BL1 is different than the other images in the sense that its read-write data
  107. * originally lives in Trusted ROM and needs to be relocated in Trusted SRAM at
  108. * run-time. Therefore, the read-write data in ROM can be mapped with the same
  109. * memory attributes as the read-only data region. For this reason, BL1 uses
  110. * different macros.
  111. *
  112. * Note that BL1_ROM_END is not necessarily aligned on a page boundary as it
  113. * just points to the end of BL1's actual content in Trusted ROM. Therefore it
  114. * needs to be rounded up to the next page size in order to map the whole last
  115. * page of it with the right memory attributes.
  116. */
  117. #if SEPARATE_CODE_AND_RODATA
  118. #define BL1_CODE_END BL_CODE_END
  119. #define BL1_RO_DATA_BASE BL_RO_DATA_BASE
  120. #define BL1_RO_DATA_END round_up(BL1_ROM_END, PAGE_SIZE)
  121. #if BL2_IN_XIP_MEM
  122. #define BL2_CODE_END BL_CODE_END
  123. #define BL2_RO_DATA_BASE BL_RO_DATA_BASE
  124. #define BL2_RO_DATA_END round_up(BL2_ROM_END, PAGE_SIZE)
  125. #endif /* BL2_IN_XIP_MEM */
  126. #else
  127. #define BL_RO_DATA_BASE UL(0)
  128. #define BL_RO_DATA_END UL(0)
  129. #define BL1_CODE_END round_up(BL1_ROM_END, PAGE_SIZE)
  130. #if BL2_IN_XIP_MEM
  131. #define BL2_RO_DATA_BASE UL(0)
  132. #define BL2_RO_DATA_END UL(0)
  133. #define BL2_CODE_END round_up(BL2_ROM_END, PAGE_SIZE)
  134. #endif /* BL2_IN_XIP_MEM */
  135. #endif /* SEPARATE_CODE_AND_RODATA */
  136. #if MEASURED_BOOT
  137. /*
  138. * Start critical data Ids from 2^32/2 reserving Ids from 0 to (2^32/2 - 1)
  139. * for Images, It is a critical data Id base for all platforms.
  140. */
  141. #define CRITICAL_DATA_ID_BASE U(0x80000000)
  142. #endif /* MEASURED_BOOT */
  143. #endif /* COMMON_DEF_H */