Commit c1a4b6b4 authored by Olivier Deprez's avatar Olivier Deprez Committed by TrustedFirmware Code Review
Browse files

Merge "build_macros.mk: include assert and define loop macros" into integration

parents 8c00bcce 327131c4
...@@ -855,71 +855,77 @@ endif ...@@ -855,71 +855,77 @@ endif
# Build options checks # Build options checks
################################################################################ ################################################################################
$(eval $(call assert_boolean,ALLOW_RO_XLAT_TABLES)) $(eval $(call assert_booleans,\
$(eval $(call assert_boolean,COLD_BOOT_SINGLE_CPU)) $(sort \
$(eval $(call assert_boolean,CREATE_KEYS)) ALLOW_RO_XLAT_TABLES \
$(eval $(call assert_boolean,CTX_INCLUDE_AARCH32_REGS)) COLD_BOOT_SINGLE_CPU \
$(eval $(call assert_boolean,CTX_INCLUDE_FPREGS)) CREATE_KEYS \
$(eval $(call assert_boolean,CTX_INCLUDE_PAUTH_REGS)) CTX_INCLUDE_AARCH32_REGS \
$(eval $(call assert_boolean,CTX_INCLUDE_MTE_REGS)) CTX_INCLUDE_FPREGS \
$(eval $(call assert_boolean,CTX_INCLUDE_EL2_REGS)) CTX_INCLUDE_PAUTH_REGS \
$(eval $(call assert_boolean,DEBUG)) CTX_INCLUDE_MTE_REGS \
$(eval $(call assert_boolean,DYN_DISABLE_AUTH)) CTX_INCLUDE_EL2_REGS \
$(eval $(call assert_boolean,EL3_EXCEPTION_HANDLING)) DEBUG \
$(eval $(call assert_boolean,ENABLE_AMU)) DYN_DISABLE_AUTH \
$(eval $(call assert_boolean,ENABLE_ASSERTIONS)) EL3_EXCEPTION_HANDLING \
$(eval $(call assert_boolean,ENABLE_MPAM_FOR_LOWER_ELS)) ENABLE_AMU \
$(eval $(call assert_boolean,ENABLE_PIE)) ENABLE_ASSERTIONS \
$(eval $(call assert_boolean,ENABLE_PMF)) ENABLE_MPAM_FOR_LOWER_ELS \
$(eval $(call assert_boolean,ENABLE_PSCI_STAT)) ENABLE_PIE \
$(eval $(call assert_boolean,ENABLE_RUNTIME_INSTRUMENTATION)) ENABLE_PMF \
$(eval $(call assert_boolean,ENABLE_SPE_FOR_LOWER_ELS)) ENABLE_PSCI_STAT \
$(eval $(call assert_boolean,ENABLE_SVE_FOR_NS)) ENABLE_RUNTIME_INSTRUMENTATION \
$(eval $(call assert_boolean,ERROR_DEPRECATED)) ENABLE_SPE_FOR_LOWER_ELS \
$(eval $(call assert_boolean,FAULT_INJECTION_SUPPORT)) ENABLE_SVE_FOR_NS \
$(eval $(call assert_boolean,GENERATE_COT)) ERROR_DEPRECATED \
$(eval $(call assert_boolean,GICV2_G0_FOR_EL3)) FAULT_INJECTION_SUPPORT \
$(eval $(call assert_boolean,HANDLE_EA_EL3_FIRST)) GENERATE_COT \
$(eval $(call assert_boolean,HW_ASSISTED_COHERENCY)) GICV2_G0_FOR_EL3 \
$(eval $(call assert_boolean,INVERTED_MEMMAP)) HANDLE_EA_EL3_FIRST \
$(eval $(call assert_boolean,MEASURED_BOOT)) HW_ASSISTED_COHERENCY \
$(eval $(call assert_boolean,NS_TIMER_SWITCH)) INVERTED_MEMMAP \
$(eval $(call assert_boolean,OVERRIDE_LIBC)) MEASURED_BOOT \
$(eval $(call assert_boolean,PL011_GENERIC_UART)) NS_TIMER_SWITCH \
$(eval $(call assert_boolean,PROGRAMMABLE_RESET_ADDRESS)) OVERRIDE_LIBC \
$(eval $(call assert_boolean,PSCI_EXTENDED_STATE_ID)) PL011_GENERIC_UART \
$(eval $(call assert_boolean,RAS_EXTENSION)) PROGRAMMABLE_RESET_ADDRESS \
$(eval $(call assert_boolean,RESET_TO_BL31)) PSCI_EXTENDED_STATE_ID \
$(eval $(call assert_boolean,SAVE_KEYS)) RAS_EXTENSION \
$(eval $(call assert_boolean,SEPARATE_CODE_AND_RODATA)) RESET_TO_BL31 \
$(eval $(call assert_boolean,SEPARATE_NOBITS_REGION)) SAVE_KEYS \
$(eval $(call assert_boolean,SPIN_ON_BL1_EXIT)) SEPARATE_CODE_AND_RODATA \
$(eval $(call assert_boolean,SPM_MM)) SEPARATE_NOBITS_REGION \
$(eval $(call assert_boolean,SPMD_SPM_AT_SEL2)) SPIN_ON_BL1_EXIT \
$(eval $(call assert_boolean,TRUSTED_BOARD_BOOT)) SPM_MM \
$(eval $(call assert_boolean,USE_COHERENT_MEM)) SPMD_SPM_AT_SEL2 \
$(eval $(call assert_boolean,USE_DEBUGFS)) TRUSTED_BOARD_BOOT \
$(eval $(call assert_boolean,ARM_IO_IN_DTB)) USE_COHERENT_MEM \
$(eval $(call assert_boolean,SDEI_IN_FCONF)) USE_DEBUGFS \
$(eval $(call assert_boolean,SEC_INT_DESC_IN_FCONF)) ARM_IO_IN_DTB \
$(eval $(call assert_boolean,USE_ROMLIB)) SDEI_IN_FCONF \
$(eval $(call assert_boolean,USE_TBBR_DEFS)) SEC_INT_DESC_IN_FCONF \
$(eval $(call assert_boolean,WARMBOOT_ENABLE_DCACHE_EARLY)) USE_ROMLIB \
$(eval $(call assert_boolean,BL2_AT_EL3)) USE_TBBR_DEFS \
$(eval $(call assert_boolean,BL2_IN_XIP_MEM)) WARMBOOT_ENABLE_DCACHE_EARLY \
$(eval $(call assert_boolean,BL2_INV_DCACHE)) BL2_AT_EL3 \
$(eval $(call assert_boolean,USE_SPINLOCK_CAS)) BL2_IN_XIP_MEM \
$(eval $(call assert_boolean,ENCRYPT_BL31)) BL2_INV_DCACHE \
$(eval $(call assert_boolean,ENCRYPT_BL32)) USE_SPINLOCK_CAS \
$(eval $(call assert_boolean,ERRATA_SPECULATIVE_AT)) ENCRYPT_BL31 \
$(eval $(call assert_boolean,RAS_TRAP_LOWER_EL_ERR_ACCESS)) ENCRYPT_BL32 \
$(eval $(call assert_boolean,COT_DESC_IN_DTB)) ERRATA_SPECULATIVE_AT \
$(eval $(call assert_boolean,USE_SP804_TIMER)) RAS_TRAP_LOWER_EL_ERR_ACCESS \
COT_DESC_IN_DTB \
$(eval $(call assert_numeric,ARM_ARCH_MAJOR)) USE_SP804_TIMER \
$(eval $(call assert_numeric,ARM_ARCH_MINOR)) )))
$(eval $(call assert_numeric,BRANCH_PROTECTION))
$(eval $(call assert_numeric,FW_ENC_STATUS)) $(eval $(call assert_numerics,\
$(sort \
ARM_ARCH_MAJOR \
ARM_ARCH_MINOR \
BRANCH_PROTECTION \
FW_ENC_STATUS \
)))
ifdef KEY_SIZE ifdef KEY_SIZE
$(eval $(call assert_numeric,KEY_SIZE)) $(eval $(call assert_numeric,KEY_SIZE))
...@@ -935,68 +941,71 @@ endif ...@@ -935,68 +941,71 @@ endif
# platform to overwrite the default options # platform to overwrite the default options
################################################################################ ################################################################################
$(eval $(call add_define,ALLOW_RO_XLAT_TABLES)) $(eval $(call add_defines,\
$(eval $(call add_define,ARM_ARCH_MAJOR)) $(sort \
$(eval $(call add_define,ARM_ARCH_MINOR)) ALLOW_RO_XLAT_TABLES \
$(eval $(call add_define,COLD_BOOT_SINGLE_CPU)) ARM_ARCH_MAJOR \
$(eval $(call add_define,CTX_INCLUDE_AARCH32_REGS)) ARM_ARCH_MINOR \
$(eval $(call add_define,CTX_INCLUDE_FPREGS)) COLD_BOOT_SINGLE_CPU \
$(eval $(call add_define,CTX_INCLUDE_PAUTH_REGS)) CTX_INCLUDE_AARCH32_REGS \
$(eval $(call add_define,EL3_EXCEPTION_HANDLING)) CTX_INCLUDE_FPREGS \
$(eval $(call add_define,CTX_INCLUDE_MTE_REGS)) CTX_INCLUDE_PAUTH_REGS \
$(eval $(call add_define,CTX_INCLUDE_EL2_REGS)) EL3_EXCEPTION_HANDLING \
$(eval $(call add_define,DECRYPTION_SUPPORT_${DECRYPTION_SUPPORT})) CTX_INCLUDE_MTE_REGS \
$(eval $(call add_define,ENABLE_AMU)) CTX_INCLUDE_EL2_REGS \
$(eval $(call add_define,ENABLE_ASSERTIONS)) DECRYPTION_SUPPORT_${DECRYPTION_SUPPORT} \
$(eval $(call add_define,ENABLE_BTI)) ENABLE_AMU \
$(eval $(call add_define,ENABLE_MPAM_FOR_LOWER_ELS)) ENABLE_ASSERTIONS \
$(eval $(call add_define,ENABLE_PAUTH)) ENABLE_BTI \
$(eval $(call add_define,ENABLE_PIE)) ENABLE_MPAM_FOR_LOWER_ELS \
$(eval $(call add_define,ENABLE_PMF)) ENABLE_PAUTH \
$(eval $(call add_define,ENABLE_PSCI_STAT)) ENABLE_PIE \
$(eval $(call add_define,ENABLE_RUNTIME_INSTRUMENTATION)) ENABLE_PMF \
$(eval $(call add_define,ENABLE_SPE_FOR_LOWER_ELS)) ENABLE_PSCI_STAT \
$(eval $(call add_define,ENABLE_SVE_FOR_NS)) ENABLE_RUNTIME_INSTRUMENTATION \
$(eval $(call add_define,ENCRYPT_BL31)) ENABLE_SPE_FOR_LOWER_ELS \
$(eval $(call add_define,ENCRYPT_BL32)) ENABLE_SVE_FOR_NS \
$(eval $(call add_define,ERROR_DEPRECATED)) ENCRYPT_BL31 \
$(eval $(call add_define,FAULT_INJECTION_SUPPORT)) ENCRYPT_BL32 \
$(eval $(call add_define,GICV2_G0_FOR_EL3)) ERROR_DEPRECATED \
$(eval $(call add_define,HANDLE_EA_EL3_FIRST)) FAULT_INJECTION_SUPPORT \
$(eval $(call add_define,HW_ASSISTED_COHERENCY)) GICV2_G0_FOR_EL3 \
$(eval $(call add_define,LOG_LEVEL)) HANDLE_EA_EL3_FIRST \
$(eval $(call add_define,MEASURED_BOOT)) HW_ASSISTED_COHERENCY \
$(eval $(call add_define,NS_TIMER_SWITCH)) LOG_LEVEL \
$(eval $(call add_define,PL011_GENERIC_UART)) MEASURED_BOOT \
$(eval $(call add_define,PLAT_${PLAT})) NS_TIMER_SWITCH \
$(eval $(call add_define,PROGRAMMABLE_RESET_ADDRESS)) PL011_GENERIC_UART \
$(eval $(call add_define,PSCI_EXTENDED_STATE_ID)) PLAT_${PLAT} \
$(eval $(call add_define,RAS_EXTENSION)) PROGRAMMABLE_RESET_ADDRESS \
$(eval $(call add_define,RESET_TO_BL31)) PSCI_EXTENDED_STATE_ID \
$(eval $(call add_define,SEPARATE_CODE_AND_RODATA)) RAS_EXTENSION \
$(eval $(call add_define,SEPARATE_NOBITS_REGION)) RESET_TO_BL31 \
$(eval $(call add_define,RECLAIM_INIT_CODE)) SEPARATE_CODE_AND_RODATA \
$(eval $(call add_define,SPD_${SPD})) SEPARATE_NOBITS_REGION \
$(eval $(call add_define,SPIN_ON_BL1_EXIT)) RECLAIM_INIT_CODE \
$(eval $(call add_define,SPM_MM)) SPD_${SPD} \
$(eval $(call add_define,SPMD_SPM_AT_SEL2)) SPIN_ON_BL1_EXIT \
$(eval $(call add_define,TRUSTED_BOARD_BOOT)) SPM_MM \
$(eval $(call add_define,USE_COHERENT_MEM)) SPMD_SPM_AT_SEL2 \
$(eval $(call add_define,USE_DEBUGFS)) TRUSTED_BOARD_BOOT \
$(eval $(call add_define,ARM_IO_IN_DTB)) USE_COHERENT_MEM \
$(eval $(call add_define,SDEI_IN_FCONF)) USE_DEBUGFS \
$(eval $(call add_define,SEC_INT_DESC_IN_FCONF)) ARM_IO_IN_DTB \
$(eval $(call add_define,USE_ROMLIB)) SDEI_IN_FCONF \
$(eval $(call add_define,USE_TBBR_DEFS)) SEC_INT_DESC_IN_FCONF \
$(eval $(call add_define,WARMBOOT_ENABLE_DCACHE_EARLY)) USE_ROMLIB \
$(eval $(call add_define,BL2_AT_EL3)) USE_TBBR_DEFS \
$(eval $(call add_define,BL2_IN_XIP_MEM)) WARMBOOT_ENABLE_DCACHE_EARLY \
$(eval $(call add_define,BL2_INV_DCACHE)) BL2_AT_EL3 \
$(eval $(call add_define,USE_SPINLOCK_CAS)) BL2_IN_XIP_MEM \
$(eval $(call add_define,ERRATA_SPECULATIVE_AT)) BL2_INV_DCACHE \
$(eval $(call add_define,RAS_TRAP_LOWER_EL_ERR_ACCESS)) USE_SPINLOCK_CAS \
$(eval $(call add_define,COT_DESC_IN_DTB)) ERRATA_SPECULATIVE_AT \
$(eval $(call add_define,USE_SP804_TIMER)) RAS_TRAP_LOWER_EL_ERR_ACCESS \
COT_DESC_IN_DTB \
USE_SP804_TIMER \
)))
ifeq (${SANITIZE_UB},trap) ifeq (${SANITIZE_UB},trap)
$(eval $(call add_define,MONITOR_TRAPS)) $(eval $(call add_define,MONITOR_TRAPS))
......
...@@ -89,10 +89,16 @@ ifndef CRASH_REPORTING ...@@ -89,10 +89,16 @@ ifndef CRASH_REPORTING
CRASH_REPORTING := $(DEBUG) CRASH_REPORTING := $(DEBUG)
endif endif
$(eval $(call assert_boolean,CRASH_REPORTING)) $(eval $(call assert_booleans,\
$(eval $(call assert_boolean,EL3_EXCEPTION_HANDLING)) $(sort \
$(eval $(call assert_boolean,SDEI_SUPPORT)) CRASH_REPORTING \
EL3_EXCEPTION_HANDLING \
$(eval $(call add_define,CRASH_REPORTING)) SDEI_SUPPORT \
$(eval $(call add_define,EL3_EXCEPTION_HANDLING)) )))
$(eval $(call add_define,SDEI_SUPPORT))
$(eval $(call add_defines,\
$(sort \
CRASH_REPORTING \
EL3_EXCEPTION_HANDLING \
SDEI_SUPPORT \
)))
...@@ -98,10 +98,13 @@ else ...@@ -98,10 +98,13 @@ else
endif endif
# Needs to be set to drive mbed TLS configuration correctly # Needs to be set to drive mbed TLS configuration correctly
$(eval $(call add_define,TF_MBEDTLS_KEY_ALG_ID)) $(eval $(call add_defines,\
$(eval $(call add_define,TF_MBEDTLS_KEY_SIZE)) $(sort \
$(eval $(call add_define,TF_MBEDTLS_HASH_ALG_ID)) TF_MBEDTLS_KEY_ALG_ID \
$(eval $(call add_define,TF_MBEDTLS_USE_AES_GCM)) TF_MBEDTLS_KEY_SIZE \
TF_MBEDTLS_HASH_ALG_ID \
TF_MBEDTLS_USE_AES_GCM \
)))
$(eval $(call MAKE_LIB,mbedtls)) $(eval $(call MAKE_LIB,mbedtls))
......
...@@ -25,10 +25,13 @@ endif ...@@ -25,10 +25,13 @@ endif
EVENT_LOG_SIZE := 1024 EVENT_LOG_SIZE := 1024
# Set definitions for mbed TLS library and Measured Boot driver # Set definitions for mbed TLS library and Measured Boot driver
$(eval $(call add_define,MBEDTLS_MD_ID)) $(eval $(call add_defines,\
$(eval $(call add_define,TPM_ALG_ID)) $(sort \
$(eval $(call add_define,TCG_DIGEST_SIZE)) MBEDTLS_MD_ID \
$(eval $(call add_define,EVENT_LOG_SIZE)) TPM_ALG_ID \
TCG_DIGEST_SIZE \
EVENT_LOG_SIZE \
)))
ifeq (${HASH_ALG}, sha256) ifeq (${HASH_ALG}, sha256)
ifneq (${TPM_HASH_ALG}, sha256) ifneq (${TPM_HASH_ALG}, sha256)
......
...@@ -44,10 +44,13 @@ endif ...@@ -44,10 +44,13 @@ endif
# Defined if ARMv7 core supports the Generic Timer extension. # Defined if ARMv7 core supports the Generic Timer extension.
ifeq ($(filter yes,$(ARM_CORTEX_A7) $(ARM_CORTEX_A12) $(ARM_CORTEX_A15) $(ARM_CORTEX_A17)),yes) ifeq ($(filter yes,$(ARM_CORTEX_A7) $(ARM_CORTEX_A12) $(ARM_CORTEX_A15) $(ARM_CORTEX_A17)),yes)
$(eval $(call add_define,ARMV7_SUPPORTS_LARGE_PAGE_ADDRESSING)) $(eval $(call add_defines,\
$(eval $(call add_define,ARMV7_SUPPORTS_VIRTUALIZATION)) $(sort \
$(eval $(call add_define,ARMV7_SUPPORTS_GENERIC_TIMER)) ARMV7_SUPPORTS_LARGE_PAGE_ADDRESSING \
$(eval $(call add_define,ARMV7_SUPPORTS_VFP)) ARMV7_SUPPORTS_VIRTUALIZATION \
ARMV7_SUPPORTS_GENERIC_TIMER \
ARMV7_SUPPORTS_VFP \
)))
endif endif
ifeq ($(ARM_CORTEX_A5),yes) ifeq ($(ARM_CORTEX_A5),yes)
......
...@@ -44,6 +44,13 @@ define add_define ...@@ -44,6 +44,13 @@ define add_define
DEFINES += -D$(1)$(if $(value $(1)),=$(value $(1)),) DEFINES += -D$(1)$(if $(value $(1)),=$(value $(1)),)
endef endef
# Convenience function for addding multiple build definitions
# $(eval $(call add_defines,FOO BOO))
define add_defines
$(foreach def,$1,$(eval $(call add_define,$(def))))
endef
# Convenience function for adding build definitions # Convenience function for adding build definitions
# $(eval $(call add_define_val,FOO,BAR)) will have: # $(eval $(call add_define_val,FOO,BAR)) will have:
# -DFOO=BAR # -DFOO=BAR
...@@ -57,6 +64,12 @@ define assert_boolean ...@@ -57,6 +64,12 @@ define assert_boolean
$(if $(filter-out 0 1,$($1)),$(error $1 must be boolean)) $(if $(filter-out 0 1,$($1)),$(error $1 must be boolean))
endef endef
# Convenience function for verifying options have boolean values
# $(eval $(call assert_booleans,FOO BOO)) will assert FOO and BOO for 0 or 1 values
define assert_booleans
$(foreach bool,$1,$(eval $(call assert_boolean,$(bool))))
endef
0-9 := 0 1 2 3 4 5 6 7 8 9 0-9 := 0 1 2 3 4 5 6 7 8 9
# Function to verify that a given option $(1) contains a numeric value # Function to verify that a given option $(1) contains a numeric value
...@@ -67,6 +80,12 @@ $(foreach d,$(0-9),$(eval __numeric := $(subst $(d),,$(__numeric)))) ...@@ -67,6 +80,12 @@ $(foreach d,$(0-9),$(eval __numeric := $(subst $(d),,$(__numeric))))
$(if $(__numeric),$(error $(1) must be numeric)) $(if $(__numeric),$(error $(1) must be numeric))
endef endef
# Convenience function for verifying options have numeric values
# $(eval $(call assert_numerics,FOO BOO)) will assert FOO and BOO contain numeric values
define assert_numerics
$(foreach num,$1,$(eval $(call assert_numeric,$(num))))
endef
# CREATE_SEQ is a recursive function to create sequence of numbers from 1 to # CREATE_SEQ is a recursive function to create sequence of numbers from 1 to
# $(2) and assign the sequence to $(1) # $(2) and assign the sequence to $(1)
define CREATE_SEQ define CREATE_SEQ
......
...@@ -46,16 +46,23 @@ ifeq ($(filter 1,${STM32MP_EMMC} ${STM32MP_SDMMC} ${STM32MP_RAW_NAND} \ ...@@ -46,16 +46,23 @@ ifeq ($(filter 1,${STM32MP_EMMC} ${STM32MP_SDMMC} ${STM32MP_RAW_NAND} \
$(error "No boot device driver is enabled") $(error "No boot device driver is enabled")
endif endif
$(eval $(call assert_boolean,STM32MP_EMMC)) $(eval $(call assert_booleans,\
$(eval $(call assert_boolean,STM32MP_SDMMC)) $(sort \
$(eval $(call assert_boolean,STM32MP_RAW_NAND)) STM32MP_EMMC \
$(eval $(call assert_boolean,STM32MP_SPI_NAND)) STM32MP_SDMMC \
$(eval $(call assert_boolean,STM32MP_SPI_NOR)) STM32MP_RAW_NAND \
$(eval $(call add_define,STM32MP_EMMC)) STM32MP_SPI_NAND \
$(eval $(call add_define,STM32MP_SDMMC)) STM32MP_SPI_NOR \
$(eval $(call add_define,STM32MP_RAW_NAND)) )))
$(eval $(call add_define,STM32MP_SPI_NAND))
$(eval $(call add_define,STM32MP_SPI_NOR)) $(eval $(call add_defines,\
$(sort \
STM32MP_EMMC \
STM32MP_SDMMC \
STM32MP_RAW_NAND \
STM32MP_SPI_NAND \
STM32MP_SPI_NOR \
)))
PLAT_INCLUDES := -Iplat/st/common/include/ PLAT_INCLUDES := -Iplat/st/common/include/
PLAT_INCLUDES += -Iplat/st/stm32mp1/include/ PLAT_INCLUDES += -Iplat/st/stm32mp1/include/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment