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