platform.mk 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  1. #
  2. # Copyright (c) 2015-2023, Arm Limited and Contributors. All rights reserved.
  3. #
  4. # Copyright (c) 2017-2023 Nuvoton Ltd.
  5. #
  6. # SPDX-License-Identifier: BSD-3-Clause
  7. #
  8. # This is a debug flag for bring-up. It allows reducing CPU numbers
  9. # SECONDARY_BRINGUP := 1
  10. RESET_TO_BL31 := 1
  11. SPMD_SPM_AT_SEL2 := 0
  12. #temporary until the RAM size is reduced
  13. USE_COHERENT_MEM := 1
  14. INIT_UNUSED_NS_EL2 := 1
  15. $(eval $(call add_define,RESET_TO_BL31))
  16. ifeq (${ARCH}, aarch64)
  17. # On ARM standard platorms, the TSP can execute from Trusted SRAM,
  18. # Trusted DRAM (if available) or the TZC secured area of DRAM.
  19. # TZC secured DRAM is the default.
  20. ARM_TSP_RAM_LOCATION ?= dram
  21. ifeq (${ARM_TSP_RAM_LOCATION}, tsram)
  22. ARM_TSP_RAM_LOCATION_ID = ARM_TRUSTED_SRAM_ID
  23. else ifeq (${ARM_TSP_RAM_LOCATION}, tdram)
  24. ARM_TSP_RAM_LOCATION_ID = ARM_TRUSTED_DRAM_ID
  25. else ifeq (${ARM_TSP_RAM_LOCATION}, dram)
  26. ARM_TSP_RAM_LOCATION_ID = ARM_DRAM_ID
  27. else
  28. $(error "Unsupported ARM_TSP_RAM_LOCATION value")
  29. endif
  30. # Process flags
  31. # Process ARM_BL31_IN_DRAM flag
  32. ARM_BL31_IN_DRAM := 0
  33. $(eval $(call assert_boolean,ARM_BL31_IN_DRAM))
  34. $(eval $(call add_define,ARM_BL31_IN_DRAM))
  35. else
  36. ARM_TSP_RAM_LOCATION_ID = ARM_TRUSTED_SRAM_ID
  37. endif
  38. $(eval $(call add_define,ARM_TSP_RAM_LOCATION_ID))
  39. # For the original power-state parameter format, the State-ID can be encoded
  40. # according to the recommended encoding or zero. This flag determines which
  41. # State-ID encoding to be parsed.
  42. ARM_RECOM_STATE_ID_ENC := 0
  43. # If the PSCI_EXTENDED_STATE_ID is set, then ARM_RECOM_STATE_ID_ENC
  44. # need to be set. Else throw a build error.
  45. ifeq (${PSCI_EXTENDED_STATE_ID}, 1)
  46. ifeq (${ARM_RECOM_STATE_ID_ENC}, 0)
  47. $(error Build option ARM_RECOM_STATE_ID_ENC needs to be set if \
  48. PSCI_EXTENDED_STATE_ID is set for ARM platforms)
  49. endif
  50. endif
  51. # Process ARM_RECOM_STATE_ID_ENC flag
  52. $(eval $(call assert_boolean,ARM_RECOM_STATE_ID_ENC))
  53. $(eval $(call add_define,ARM_RECOM_STATE_ID_ENC))
  54. # Process ARM_DISABLE_TRUSTED_WDOG flag
  55. # By default, Trusted Watchdog is always enabled unless SPIN_ON_BL1_EXIT is set
  56. ARM_DISABLE_TRUSTED_WDOG := 0
  57. ifeq (${SPIN_ON_BL1_EXIT}, 1)
  58. ARM_DISABLE_TRUSTED_WDOG := 1
  59. endif
  60. $(eval $(call assert_boolean,ARM_DISABLE_TRUSTED_WDOG))
  61. $(eval $(call add_define,ARM_DISABLE_TRUSTED_WDOG))
  62. # Process ARM_CONFIG_CNTACR
  63. ARM_CONFIG_CNTACR := 1
  64. $(eval $(call assert_boolean,ARM_CONFIG_CNTACR))
  65. $(eval $(call add_define,ARM_CONFIG_CNTACR))
  66. # Process ARM_BL31_IN_DRAM flag
  67. ARM_BL31_IN_DRAM := 0
  68. $(eval $(call assert_boolean,ARM_BL31_IN_DRAM))
  69. $(eval $(call add_define,ARM_BL31_IN_DRAM))
  70. # Process ARM_PLAT_MT flag
  71. ARM_PLAT_MT := 0
  72. $(eval $(call assert_boolean,ARM_PLAT_MT))
  73. $(eval $(call add_define,ARM_PLAT_MT))
  74. # Use translation tables library v2 by default
  75. ARM_XLAT_TABLES_LIB_V1 := 0
  76. $(eval $(call assert_boolean,ARM_XLAT_TABLES_LIB_V1))
  77. $(eval $(call add_define,ARM_XLAT_TABLES_LIB_V1))
  78. # Don't have the Linux kernel as a BL33 image by default
  79. ARM_LINUX_KERNEL_AS_BL33 := 0
  80. $(eval $(call assert_boolean,ARM_LINUX_KERNEL_AS_BL33))
  81. $(eval $(call add_define,ARM_LINUX_KERNEL_AS_BL33))
  82. ifeq (${ARM_LINUX_KERNEL_AS_BL33},1)
  83. ifeq (${ARCH},aarch64)
  84. ifneq (${RESET_TO_BL31},1)
  85. $(error "ARM_LINUX_KERNEL_AS_BL33 is only available if RESET_TO_BL31=1.")
  86. endif
  87. else
  88. ifneq (${RESET_TO_SP_MIN},1)
  89. $(error "ARM_LINUX_KERNEL_AS_BL33 is only available if RESET_TO_SP_MIN=1.")
  90. endif
  91. endif
  92. ifndef PRELOADED_BL33_BASE
  93. $(error "PRELOADED_BL33_BASE must be set if ARM_LINUX_KERNEL_AS_BL33 is used.")
  94. endif
  95. ifndef ARM_PRELOADED_DTB_BASE
  96. $(error "ARM_PRELOADED_DTB_BASE must be set if ARM_LINUX_KERNEL_AS_BL33 is used.")
  97. endif
  98. $(eval $(call add_define,ARM_PRELOADED_DTB_BASE))
  99. endif
  100. # Use an implementation of SHA-256 with a smaller memory footprint
  101. # but reduced speed.
  102. $(eval $(call add_define,MBEDTLS_SHA256_SMALLER))
  103. # Add the build options to pack Trusted OS Extra1 and Trusted OS Extra2 images
  104. # in the FIP if the platform requires.
  105. ifneq ($(BL32_EXTRA1),)
  106. $(eval $(call TOOL_ADD_IMG,bl32_extra1,--tos-fw-extra1))
  107. endif
  108. ifneq ($(BL32_EXTRA2),)
  109. $(eval $(call TOOL_ADD_IMG,bl32_extra2,--tos-fw-extra2))
  110. endif
  111. # Enable PSCI_STAT_COUNT/RESIDENCY APIs on ARM platforms
  112. ENABLE_PSCI_STAT := 1
  113. ENABLE_PMF := 1
  114. # On ARM platforms, separate the code and read-only data sections to allow
  115. # mapping the former as executable and the latter as execute-never.
  116. SEPARATE_CODE_AND_RODATA := 1
  117. # On ARM platforms, disable SEPARATE_NOBITS_REGION by default. Both PROGBITS
  118. # and NOBITS sections of BL31 image are adjacent to each other and loaded
  119. # into Trusted SRAM.
  120. SEPARATE_NOBITS_REGION := 0
  121. # In order to support SEPARATE_NOBITS_REGION for Arm platforms, we need to load
  122. # BL31 PROGBITS into secure DRAM space and BL31 NOBITS into SRAM. Hence mandate
  123. # the build to require that ARM_BL31_IN_DRAM is enabled as well.
  124. ifeq ($(SEPARATE_NOBITS_REGION),1)
  125. ifneq ($(ARM_BL31_IN_DRAM),1)
  126. $(error For SEPARATE_NOBITS_REGION, ARM_BL31_IN_DRAM must be enabled)
  127. endif
  128. ifneq ($(RECLAIM_INIT_CODE),0)
  129. $(error For SEPARATE_NOBITS_REGION, RECLAIM_INIT_CODE cannot be supported)
  130. endif
  131. endif
  132. # Disable ARM Cryptocell by default
  133. ARM_CRYPTOCELL_INTEG := 0
  134. $(eval $(call assert_boolean,ARM_CRYPTOCELL_INTEG))
  135. $(eval $(call add_define,ARM_CRYPTOCELL_INTEG))
  136. # Enable PIE support for RESET_TO_BL31 case
  137. ifeq (${RESET_TO_BL31},1)
  138. ENABLE_PIE := 1
  139. endif
  140. # CryptoCell integration relies on coherent buffers for passing data from
  141. # the AP CPU to the CryptoCell
  142. ifeq (${ARM_CRYPTOCELL_INTEG},1)
  143. ifeq (${USE_COHERENT_MEM},0)
  144. $(error "ARM_CRYPTOCELL_INTEG needs USE_COHERENT_MEM to be set.")
  145. endif
  146. endif
  147. PLAT_INCLUDES := -Iinclude/plat/nuvoton/npcm845x \
  148. -Iinclude/plat/nuvoton/common \
  149. -Iinclude/drivers/nuvoton/npcm845x \
  150. ifeq (${ARCH}, aarch64)
  151. PLAT_INCLUDES += -Iinclude/plat/arm/common/aarch64
  152. endif
  153. # Include GICv3 driver files
  154. include drivers/arm/gic/v2/gicv2.mk
  155. NPCM850_GIC_SOURCES := ${GICV2_SOURCES}
  156. BL31_SOURCES +=lib/cpus/aarch64/cortex_a35.S \
  157. plat/common/plat_psci_common.c \
  158. drivers/ti/uart/aarch64/16550_console.S \
  159. plat/nuvoton/npcm845x/npcm845x_psci.c \
  160. plat/nuvoton/npcm845x/npcm845x_serial_port.c \
  161. plat/nuvoton/common/nuvoton_topology.c \
  162. plat/nuvoton/npcm845x/npcm845x_bl31_setup.c
  163. PLAT_BL_COMMON_SOURCES := drivers/delay_timer/delay_timer.c \
  164. drivers/delay_timer/generic_delay_timer.c \
  165. plat/common/plat_gicv2.c \
  166. plat/arm/common/arm_gicv2.c \
  167. plat/nuvoton/common/plat_nuvoton_gic.c \
  168. ${NPCM850_GIC_SOURCES} \
  169. plat/nuvoton/npcm845x/npcm845x_common.c \
  170. plat/nuvoton/common/nuvoton_helpers.S \
  171. lib/semihosting/semihosting.c \
  172. lib/semihosting/${ARCH}/semihosting_call.S \
  173. plat/arm/common/arm_common.c \
  174. plat/arm/common/arm_console.c
  175. ifeq (${ARM_XLAT_TABLES_LIB_V1}, 1)
  176. PLAT_BL_COMMON_SOURCES += lib/xlat_tables/xlat_tables_common.c \
  177. lib/xlat_tables/${ARCH}/xlat_tables.c
  178. else
  179. include lib/xlat_tables_v2/xlat_tables.mk
  180. PLAT_BL_COMMON_SOURCES += ${XLAT_TABLES_LIB_SRCS}
  181. endif
  182. ARM_IO_SOURCES += plat/arm/common/arm_io_storage.c \
  183. plat/arm/common/fconf/arm_fconf_io.c
  184. ifeq (${SPD},spmd)
  185. ifeq (${SPMD_SPM_AT_SEL2},1)
  186. ARM_IO_SOURCES += plat/arm/common/fconf/arm_fconf_sp.c
  187. endif
  188. endif
  189. BL1_SOURCES += drivers/io/io_fip.c \
  190. drivers/io/io_memmap.c \
  191. drivers/io/io_storage.c \
  192. plat/arm/common/arm_bl1_setup.c \
  193. plat/arm/common/arm_err.c \
  194. ${ARM_IO_SOURCES}
  195. ifdef EL3_PAYLOAD_BASE
  196. # Need the plat_arm_program_trusted_mailbox() function to release secondary CPUs
  197. # from their holding pen
  198. BL1_SOURCES += plat/arm/common/arm_pm.c
  199. endif
  200. BL2_SOURCES += drivers/delay_timer/delay_timer.c \
  201. drivers/delay_timer/generic_delay_timer.c \
  202. drivers/io/io_fip.c \
  203. drivers/io/io_memmap.c \
  204. drivers/io/io_storage.c \
  205. plat/arm/common/arm_bl2_setup.c \
  206. plat/arm/common/arm_err.c \
  207. ${ARM_IO_SOURCES}
  208. # Firmware Configuration Framework sources
  209. include lib/fconf/fconf.mk
  210. # Add `libfdt` and Arm common helpers required for Dynamic Config
  211. include lib/libfdt/libfdt.mk
  212. DYN_CFG_SOURCES += plat/arm/common/arm_dyn_cfg.c \
  213. plat/arm/common/arm_dyn_cfg_helpers.c \
  214. common/fdt_wrappers.c
  215. BL1_SOURCES += ${DYN_CFG_SOURCES}
  216. BL2_SOURCES += ${DYN_CFG_SOURCES}
  217. ifeq (${BL2_AT_EL3},1)
  218. BL2_SOURCES += plat/arm/common/arm_bl2_el3_setup.c
  219. endif
  220. # Because BL1/BL2 execute in AArch64 mode but BL32 in AArch32 we need to use
  221. # the AArch32 descriptors.
  222. BL2_SOURCES += plat/arm/common/${ARCH}/arm_bl2_mem_params_desc.c
  223. BL2_SOURCES += plat/arm/common/arm_image_load.c \
  224. common/desc_image_load.c
  225. ifeq (${SPD},opteed)
  226. BL2_SOURCES += lib/optee/optee_utils.c
  227. endif
  228. BL2U_SOURCES += drivers/delay_timer/delay_timer.c \
  229. drivers/delay_timer/generic_delay_timer.c \
  230. plat/arm/common/arm_bl2u_setup.c
  231. BL31_SOURCES += plat/arm/common/arm_bl31_setup.c \
  232. plat/nuvoton/common/nuvoton_pm.c \
  233. plat/nuvoton/common/nuvoton_topology.c \
  234. plat/common/plat_psci_common.c
  235. ifeq (${ENABLE_PMF}, 1)
  236. ifeq (${ARCH}, aarch64)
  237. BL31_SOURCES += plat/arm/common/aarch64/execution_state_switch.c \
  238. plat/arm/common/arm_sip_svc.c \
  239. plat/arm/common/plat_arm_sip_svc.c \
  240. lib/pmf/pmf_smc.c
  241. else
  242. BL32_SOURCES += plat/arm/common/arm_sip_svc.c \
  243. plat/arm/common/plat_arm_sip_svc.c \
  244. lib/pmf/pmf_smc.c
  245. endif
  246. endif
  247. ifeq (${EL3_EXCEPTION_HANDLING},1)
  248. BL31_SOURCES += plat/arm/common/aarch64/arm_ehf.c
  249. endif
  250. ifeq (${SDEI_SUPPORT},1)
  251. BL31_SOURCES += plat/arm/common/aarch64/arm_sdei.c
  252. ifeq (${SDEI_IN_FCONF},1)
  253. BL31_SOURCES += plat/arm/common/fconf/fconf_sdei_getter.c
  254. endif
  255. endif
  256. # RAS sources
  257. ifeq (${RAS_EXTENSION},1)
  258. BL31_SOURCES += lib/extensions/ras/std_err_record.c \
  259. lib/extensions/ras/ras_common.c
  260. endif
  261. # Pointer Authentication sources
  262. ifeq (${ENABLE_PAUTH}, 1)
  263. PLAT_BL_COMMON_SOURCES += plat/arm/common/aarch64/arm_pauth.c \
  264. lib/extensions/pauth/pauth_helpers.S
  265. endif
  266. ifeq (${SPD},spmd)
  267. BL31_SOURCES += plat/common/plat_spmd_manifest.c \
  268. common/fdt_wrappers.c \
  269. ${LIBFDT_SRCS}
  270. endif
  271. ifneq (${TRUSTED_BOARD_BOOT},0)
  272. # Include common TBB sources
  273. AUTH_SOURCES := drivers/auth/auth_mod.c \
  274. drivers/auth/crypto_mod.c \
  275. drivers/auth/img_parser_mod.c \
  276. lib/fconf/fconf_tbbr_getter.c
  277. # Include the selected chain of trust sources.
  278. ifeq (${COT},tbbr)
  279. AUTH_SOURCES += drivers/auth/tbbr/tbbr_cot_common.c
  280. BL1_SOURCES += drivers/auth/tbbr/tbbr_cot_bl1.c
  281. BL2_SOURCES += drivers/auth/tbbr/tbbr_cot_bl2.c
  282. else ifeq (${COT},dualroot)
  283. AUTH_SOURCES += drivers/auth/dualroot/cot.c
  284. else
  285. $(error Unknown chain of trust ${COT})
  286. endif
  287. BL1_SOURCES += ${AUTH_SOURCES} \
  288. bl1/tbbr/tbbr_img_desc.c \
  289. plat/arm/common/arm_bl1_fwu.c \
  290. plat/common/tbbr/plat_tbbr.c
  291. BL2_SOURCES += ${AUTH_SOURCES} \
  292. plat/common/tbbr/plat_tbbr.c
  293. $(eval $(call TOOL_ADD_IMG,ns_bl2u,--fwu,FWU_))
  294. # We expect to locate the *.mk files under the directories specified below
  295. ifeq (${ARM_CRYPTOCELL_INTEG},0)
  296. CRYPTO_LIB_MK := drivers/auth/mbedtls/mbedtls_crypto.mk
  297. else
  298. CRYPTO_LIB_MK := drivers/auth/cryptocell/cryptocell_crypto.mk
  299. endif
  300. IMG_PARSER_LIB_MK := drivers/auth/mbedtls/mbedtls_x509.mk
  301. $(info Including ${CRYPTO_LIB_MK})
  302. include ${CRYPTO_LIB_MK}
  303. $(info Including ${IMG_PARSER_LIB_MK})
  304. include ${IMG_PARSER_LIB_MK}
  305. endif
  306. ifeq (${RECLAIM_INIT_CODE}, 1)
  307. ifeq (${ARM_XLAT_TABLES_LIB_V1}, 1)
  308. $(error "To reclaim init code xlat tables v2 must be used")
  309. endif
  310. endif
  311. ifeq (${MEASURED_BOOT},1)
  312. MEASURED_BOOT_MK := drivers/measured_boot/measured_boot.mk
  313. $(info Including ${MEASURED_BOOT_MK})
  314. include ${MEASURED_BOOT_MK}
  315. endif
  316. ifeq (${EL3_EXCEPTION_HANDLING},1)
  317. BL31_SOURCES += plat/arm/common/aarch64/arm_ehf.c
  318. endif
  319. BL1_SOURCES :=
  320. BL2_SOURCES :=
  321. BL2U_SOURCES :=
  322. DEBUG_CONSOLE ?= 0
  323. $(eval $(call add_define,DEBUG_CONSOLE))
  324. $(eval $(call add_define,ARM_TSP_RAM_LOCATION_ID))