14f6ad66aSAchin Gupta# 2c9c56f6eSManish V Badarkhe# Copyright (c) 2013-2022, Arm Limited and Contributors. All rights reserved. 34f6ad66aSAchin Gupta# 482cb2c1aSdp-arm# SPDX-License-Identifier: BSD-3-Clause 54f6ad66aSAchin Gupta# 64f6ad66aSAchin Gupta 7e35c4045SJeenu Viswambharan# 8aaa3e722SJuan Castillo# Trusted Firmware Version 9aaa3e722SJuan Castillo# 101a0f1121SSoby MathewVERSION_MAJOR := 2 1124c5d206SJayanth Dodderi ChidanandVERSION_MINOR := 7 12dddf4283Slaurenw-armVERSION := ${VERSION_MAJOR}.${VERSION_MINOR} 13aaa3e722SJuan Castillo 1488154678SJuan Castillo# Default goal is build all images 1588154678SJuan Castillo.DEFAULT_GOAL := all 1688154678SJuan Castillo 1772fc70edSDouglas Raillard# Avoid any implicit propagation of command line variable definitions to 1872fc70edSDouglas Raillard# sub-Makefiles, like CFLAGS that we reserved for the firmware images' 1972fc70edSDouglas Raillard# usage. Other command line options like "-s" are still propagated as usual. 2072fc70edSDouglas RaillardMAKEOVERRIDES = 2172fc70edSDouglas Raillard 22231c1470SEvan LloydMAKE_HELPERS_DIRECTORY := make_helpers/ 23231c1470SEvan Lloydinclude ${MAKE_HELPERS_DIRECTORY}build_macros.mk 24e7f54dbdSEvan Lloydinclude ${MAKE_HELPERS_DIRECTORY}build_env.mk 2573c99d4eSJuan Castillo 2673c99d4eSJuan Castillo################################################################################ 272fae4b1eSJeenu Viswambharan# Default values for build configurations, and their dependencies 2873c99d4eSJuan Castillo################################################################################ 29e35c4045SJeenu Viswambharan 302fae4b1eSJeenu Viswambharaninclude ${MAKE_HELPERS_DIRECTORY}defaults.mk 31872be88aSdp-arm 32cc8b5632SAntonio Nino Diaz# Assertions enabled for DEBUG builds by default 33cc8b5632SAntonio Nino DiazENABLE_ASSERTIONS := ${DEBUG} 342fae4b1eSJeenu ViswambharanENABLE_PMF := ${ENABLE_RUNTIME_INSTRUMENTATION} 352fae4b1eSJeenu ViswambharanPLAT := ${DEFAULT_PLAT} 3673c99d4eSJuan Castillo 3773c99d4eSJuan Castillo################################################################################ 3873c99d4eSJuan Castillo# Checkpatch script options 3973c99d4eSJuan Castillo################################################################################ 4073c99d4eSJuan Castillo 41f607739cSSandrine BailleuxCHECKCODE_ARGS := --no-patch 42f0b489c1SDan Handley# Do not check the coding style on imported library files or documentation files 434501843fSGilad Ben-YossefINC_ARM_DIRS_TO_CHECK := $(sort $(filter-out \ 444501843fSGilad Ben-Yossef include/drivers/arm/cryptocell, \ 454501843fSGilad Ben-Yossef $(wildcard include/drivers/arm/*))) 464501843fSGilad Ben-YossefINC_ARM_DIRS_TO_CHECK += include/drivers/arm/cryptocell/*.h 474501843fSGilad Ben-YossefINC_DRV_DIRS_TO_CHECK := $(sort $(filter-out \ 484501843fSGilad Ben-Yossef include/drivers/arm, \ 494501843fSGilad Ben-Yossef $(wildcard include/drivers/*))) 50f0b489c1SDan HandleyINC_LIB_DIRS_TO_CHECK := $(sort $(filter-out \ 511a41e8c1SDan Handley include/lib/libfdt \ 5261f72a34SRoberto Vargas include/lib/libc, \ 53f0b489c1SDan Handley $(wildcard include/lib/*))) 54f0b489c1SDan HandleyINC_DIRS_TO_CHECK := $(sort $(filter-out \ 554501843fSGilad Ben-Yossef include/lib \ 564501843fSGilad Ben-Yossef include/drivers, \ 57f0b489c1SDan Handley $(wildcard include/*))) 58f0b489c1SDan HandleyLIB_DIRS_TO_CHECK := $(sort $(filter-out \ 59d801fbb0Sdp-arm lib/compiler-rt \ 6055cdcf75SAntonio Nino Diaz lib/libfdt% \ 6161f72a34SRoberto Vargas lib/libc, \ 62f0b489c1SDan Handley $(wildcard lib/*))) 63f0b489c1SDan HandleyROOT_DIRS_TO_CHECK := $(sort $(filter-out \ 64f0b489c1SDan Handley lib \ 65f0b489c1SDan Handley include \ 66f0b489c1SDan Handley docs \ 671ef35512SPaul Beesley %.rst, \ 68f0b489c1SDan Handley $(wildcard *))) 69f0b489c1SDan HandleyCHECK_PATHS := ${ROOT_DIRS_TO_CHECK} \ 70f0b489c1SDan Handley ${INC_DIRS_TO_CHECK} \ 71f0b489c1SDan Handley ${INC_LIB_DIRS_TO_CHECK} \ 724501843fSGilad Ben-Yossef ${LIB_DIRS_TO_CHECK} \ 734501843fSGilad Ben-Yossef ${INC_DRV_DIRS_TO_CHECK} \ 744501843fSGilad Ben-Yossef ${INC_ARM_DIRS_TO_CHECK} 7536eaaf37SIan Spray 7673c99d4eSJuan Castillo 7773c99d4eSJuan Castillo################################################################################ 7873c99d4eSJuan Castillo# Process build options 7973c99d4eSJuan Castillo################################################################################ 8073c99d4eSJuan Castillo 8173c99d4eSJuan Castillo# Verbose flag 82e35c4045SJeenu Viswambharanifeq (${V},0) 83b169f6a9SEvan Lloyd Q:=@ 84ee1ba6d4SAndre Przywara ECHO:=@echo 8536eaaf37SIan Spray CHECKCODE_ARGS += --no-summary --terse 864f6ad66aSAchin Guptaelse 87b169f6a9SEvan Lloyd Q:= 88b5a0f4bdSAntonio Nino Diaz ECHO:=$(ECHO_QUIET) 894f6ad66aSAchin Guptaendif 90ee1ba6d4SAndre Przywara 91ee1ba6d4SAndre Przywaraifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),) 92ee1ba6d4SAndre Przywara Q:=@ 93b5a0f4bdSAntonio Nino Diaz ECHO:=$(ECHO_QUIET) 94ee1ba6d4SAndre Przywaraendif 95ee1ba6d4SAndre Przywara 96ee1ba6d4SAndre Przywaraexport Q ECHO 972f2cef46SJeenu Viswambharan 9873c99d4eSJuan Castillo# The cert_create tool cannot generate certificates individually, so we use the 9973c99d4eSJuan Castillo# target 'certificates' to create them all 10073c99d4eSJuan Castilloifneq (${GENERATE_COT},0) 10173c99d4eSJuan Castillo FIP_DEPS += certificates 1020191262dSYatharth Kochar FWU_FIP_DEPS += fwu_certificates 10373c99d4eSJuan Castilloendif 10473c99d4eSJuan Castillo 1059fc59639SAlexei Fedorov# Process BRANCH_PROTECTION value and set 1069fc59639SAlexei Fedorov# Pointer Authentication and Branch Target Identification flags 1079fc59639SAlexei Fedorovifeq (${BRANCH_PROTECTION},0) 1089fc59639SAlexei Fedorov # Default value turns off all types of branch protection 1099fc59639SAlexei Fedorov BP_OPTION := none 1109fc59639SAlexei Fedorovelse ifneq (${ARCH},aarch64) 1119fc59639SAlexei Fedorov $(error BRANCH_PROTECTION requires AArch64) 1129fc59639SAlexei Fedorovelse ifeq (${BRANCH_PROTECTION},1) 1139fc59639SAlexei Fedorov # Enables all types of branch protection features 1149fc59639SAlexei Fedorov BP_OPTION := standard 1159fc59639SAlexei Fedorov ENABLE_BTI := 1 1169fc59639SAlexei Fedorov ENABLE_PAUTH := 1 1179fc59639SAlexei Fedorovelse ifeq (${BRANCH_PROTECTION},2) 1189fc59639SAlexei Fedorov # Return address signing to its standard level 1199fc59639SAlexei Fedorov BP_OPTION := pac-ret 1209fc59639SAlexei Fedorov ENABLE_PAUTH := 1 1219fc59639SAlexei Fedorovelse ifeq (${BRANCH_PROTECTION},3) 1229fc59639SAlexei Fedorov # Extend the signing to include leaf functions 1239fc59639SAlexei Fedorov BP_OPTION := pac-ret+leaf 1249fc59639SAlexei Fedorov ENABLE_PAUTH := 1 1253768fecfSAlexei Fedorovelse ifeq (${BRANCH_PROTECTION},4) 1263768fecfSAlexei Fedorov # Turn on branch target identification mechanism 1273768fecfSAlexei Fedorov BP_OPTION := bti 1283768fecfSAlexei Fedorov ENABLE_BTI := 1 1299fc59639SAlexei Fedorovelse 1309fc59639SAlexei Fedorov $(error Unknown BRANCH_PROTECTION value ${BRANCH_PROTECTION}) 1319fc59639SAlexei Fedorovendif 13273c99d4eSJuan Castillo 1335b18de09SZelalem Aweke# FEAT_RME 1345b18de09SZelalem Awekeifeq (${ENABLE_RME},1) 1355b18de09SZelalem Aweke# RME doesn't support PIE 1365b18de09SZelalem Awekeifneq (${ENABLE_PIE},0) 1375b18de09SZelalem Aweke $(error ENABLE_RME does not support PIE) 1385b18de09SZelalem Awekeendif 139744ad974Sjohpow01# RME doesn't support BRBE 140744ad974Sjohpow01ifneq (${ENABLE_BRBE_FOR_NS},0) 141744ad974Sjohpow01 $(error ENABLE_RME does not support BRBE.) 142744ad974Sjohpow01endif 1435b18de09SZelalem Aweke# RME requires AARCH64 1445b18de09SZelalem Awekeifneq (${ARCH},aarch64) 1455b18de09SZelalem Aweke $(error ENABLE_RME requires AArch64) 1465b18de09SZelalem Awekeendif 1475b18de09SZelalem Aweke# RME requires el2 context to be saved for now. 1485b18de09SZelalem AwekeCTX_INCLUDE_EL2_REGS := 1 1495b18de09SZelalem AwekeCTX_INCLUDE_AARCH32_REGS := 0 1505b18de09SZelalem AwekeARM_ARCH_MAJOR := 8 1515b18de09SZelalem AwekeARM_ARCH_MINOR := 6 1525b18de09SZelalem Awekeendif 1535b18de09SZelalem Aweke 154c97cba4eSSoby Mathew# USE_SPINLOCK_CAS requires AArch64 build 155c97cba4eSSoby Mathewifeq (${USE_SPINLOCK_CAS},1) 156c97cba4eSSoby Mathewifneq (${ARCH},aarch64) 157c97cba4eSSoby Mathew $(error USE_SPINLOCK_CAS requires AArch64) 158c97cba4eSSoby Mathewendif 159c97cba4eSSoby Mathewendif 160c97cba4eSSoby Mathew 1610ca3913dSOlivier Deprez# USE_DEBUGFS experimental feature recommended only in debug builds 1620ca3913dSOlivier Deprezifeq (${USE_DEBUGFS},1) 1630ca3913dSOlivier Deprezifeq (${DEBUG},1) 1640ca3913dSOlivier Deprez $(warning DEBUGFS experimental feature is enabled.) 1650ca3913dSOlivier Deprezelse 1660ca3913dSOlivier Deprez $(warning DEBUGFS experimental, recommended in DEBUG builds ONLY) 1670ca3913dSOlivier Deprezendif 1680ca3913dSOlivier Deprezendif 1690ca3913dSOlivier Deprez 170c6ba9b45SSumit Gargifneq (${DECRYPTION_SUPPORT},none) 171c6ba9b45SSumit GargENC_ARGS += -f ${FW_ENC_STATUS} 172c6ba9b45SSumit GargENC_ARGS += -k ${ENC_KEY} 173c6ba9b45SSumit GargENC_ARGS += -n ${ENC_NONCE} 174c6ba9b45SSumit GargFIP_DEPS += enctool 175c6ba9b45SSumit GargFWU_FIP_DEPS += enctool 176c6ba9b45SSumit Gargendif 177c6ba9b45SSumit Garg 17873c99d4eSJuan Castillo################################################################################ 17973c99d4eSJuan Castillo# Toolchain 18073c99d4eSJuan Castillo################################################################################ 18173c99d4eSJuan Castillo 18272610c41Sdp-armHOSTCC := gcc 18372610c41Sdp-armexport HOSTCC 18472610c41Sdp-arm 18573c99d4eSJuan CastilloCC := ${CROSS_COMPILE}gcc 18673c99d4eSJuan CastilloCPP := ${CROSS_COMPILE}cpp 18773c99d4eSJuan CastilloAS := ${CROSS_COMPILE}gcc 18873c99d4eSJuan CastilloAR := ${CROSS_COMPILE}ar 1892adee763SRoberto VargasLINKER := ${CROSS_COMPILE}ld 19073c99d4eSJuan CastilloOC := ${CROSS_COMPILE}objcopy 19173c99d4eSJuan CastilloOD := ${CROSS_COMPILE}objdump 19273c99d4eSJuan CastilloNM := ${CROSS_COMPILE}nm 19373c99d4eSJuan CastilloPP := ${CROSS_COMPILE}gcc -E 19438c14d88SSoby MathewDTC := dtc 19573c99d4eSJuan Castillo 196b25a577fSJulius Werner# Use ${LD}.bfd instead if it exists (as absolute path or together with $PATH). 197b25a577fSJulius Wernerifneq ($(strip $(wildcard ${LD}.bfd) \ 1982adee763SRoberto Vargas $(foreach dir,$(subst :, ,${PATH}),$(wildcard ${dir}/${LINKER}.bfd))),) 1992adee763SRoberto VargasLINKER := ${LINKER}.bfd 200b25a577fSJulius Wernerendif 201b25a577fSJulius Werner 20226e63c44SEtienne Carriereifeq (${ARM_ARCH_MAJOR},7) 20326e63c44SEtienne Carrieretarget32-directive = -target arm-none-eabi 20426e63c44SEtienne Carriere# Will set march32-directive from platform configuration 20526e63c44SEtienne Carriereelse 20626e63c44SEtienne Carrieretarget32-directive = -target armv8a-none-eabi 207fa6f774bSAlexei Fedorov 208f1821790SAlexei Fedorov# Set the compiler's target architecture profile based on 209f1821790SAlexei Fedorov# ARM_ARCH_MAJOR ARM_ARCH_MINOR options 210fa6f774bSAlexei Fedorovifeq (${ARM_ARCH_MINOR},0) 211f1821790SAlexei Fedorovmarch32-directive = -march=armv${ARM_ARCH_MAJOR}-a 212f1821790SAlexei Fedorovmarch64-directive = -march=armv${ARM_ARCH_MAJOR}-a 213fa6f774bSAlexei Fedorovelse 214f1821790SAlexei Fedorovmarch32-directive = -march=armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a 215f1821790SAlexei Fedorovmarch64-directive = -march=armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a 216fa6f774bSAlexei Fedorovendif 21726e63c44SEtienne Carriereendif 21826e63c44SEtienne Carriere 2197ff088d1SManish V Badarkhe# Memory tagging is supported in architecture Armv8.5-A AArch64 and onwards 2207ff088d1SManish V Badarkheifeq ($(ARCH), aarch64) 2214a565bd8SSami Mujawar# Check if revision is greater than or equal to 8.5 2224a565bd8SSami Mujawarifeq "8.5" "$(word 1, $(sort 8.5 $(ARM_ARCH_MAJOR).$(ARM_ARCH_MINOR)))" 2237ff088d1SManish V Badarkhemem_tag_arch_support = yes 2247ff088d1SManish V Badarkheendif 2257ff088d1SManish V Badarkheendif 2267ff088d1SManish V Badarkhe 227f1821790SAlexei Fedorov# Get architecture feature modifiers 228f1821790SAlexei Fedorovarch-features = ${ARM_ARCH_FEATURE} 229f1821790SAlexei Fedorov 230f1821790SAlexei Fedorov# Enable required options for memory stack tagging. 231f1821790SAlexei Fedorov# Currently, these options are enabled only for clang and armclang compiler. 2327ff088d1SManish V Badarkheifeq (${SUPPORT_STACK_MEMTAG},yes) 2337ff088d1SManish V Badarkheifdef mem_tag_arch_support 234f1821790SAlexei Fedorov# Check for armclang and clang compilers 2357ff088d1SManish V Badarkheifneq ( ,$(filter $(notdir $(CC)),armclang clang)) 236f1821790SAlexei Fedorov# Add "memtag" architecture feature modifier if not specified 237f1821790SAlexei Fedorovifeq ( ,$(findstring memtag,$(arch-features))) 238f1821790SAlexei Fedorovarch-features := $(arch-features)+memtag 239f1821790SAlexei Fedorovendif # memtag 2407ff088d1SManish V Badarkheifeq ($(notdir $(CC)),armclang) 2417ff088d1SManish V BadarkheTF_CFLAGS += -mmemtag-stack 2427ff088d1SManish V Badarkheelse ifeq ($(notdir $(CC)),clang) 2437ff088d1SManish V BadarkheTF_CFLAGS += -fsanitize=memtag 244f1821790SAlexei Fedorovendif # armclang 245f1821790SAlexei Fedorovendif # armclang clang 2467ff088d1SManish V Badarkheelse 2477ff088d1SManish V Badarkhe$(error "Error: stack memory tagging is not supported for architecture \ 2487ff088d1SManish V Badarkhe ${ARCH},armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a") 249f1821790SAlexei Fedorovendif # mem_tag_arch_support 250f1821790SAlexei Fedorovendif # SUPPORT_STACK_MEMTAG 251f1821790SAlexei Fedorov 252f1821790SAlexei Fedorov# Set the compiler's architecture feature modifiers 253f1821790SAlexei Fedorovifneq ($(arch-features), none) 254f1821790SAlexei Fedorov# Strip "none+" from arch-features 255f1821790SAlexei Fedorovarch-features := $(subst none+,,$(arch-features)) 256f1821790SAlexei Fedorovifeq ($(ARCH), aarch32) 257f1821790SAlexei Fedorovmarch32-directive := $(march32-directive)+$(arch-features) 258f1821790SAlexei Fedorovelse 259f1821790SAlexei Fedorovmarch64-directive := $(march64-directive)+$(arch-features) 2607ff088d1SManish V Badarkheendif 261f1821790SAlexei Fedorov# Print features 262f1821790SAlexei Fedorov$(info Arm Architecture Features specified: $(subst +, ,$(arch-features))) 263f1821790SAlexei Fedorovendif # arch-features 2647ff088d1SManish V Badarkhe 26512cd65e0STomas Pilar# Determine if FEAT_RNG is supported 26612cd65e0STomas PilarENABLE_FEAT_RNG = $(if $(findstring rng,${arch-features}),1,0) 26712cd65e0STomas Pilar 2684e04478aSChris Kay# Determine if FEAT_SB is supported 2694e04478aSChris KayENABLE_FEAT_SB = $(if $(findstring sb,${arch-features}),1,0) 2704e04478aSChris Kay 271c8a992fdSoriginifneq ($(findstring clang,$(notdir $(CC))),) 272fd18a8fcSVarun Wadekar ifneq ($(findstring armclang,$(notdir $(CC))),) 273c8a992fdSorigin TF_CFLAGS_aarch32 := -target arm-arm-none-eabi $(march32-directive) 274c8a992fdSorigin TF_CFLAGS_aarch64 := -target aarch64-arm-none-eabi $(march64-directive) 275c8a992fdSorigin LD := $(LINKER) 276c8a992fdSorigin else 277c8a992fdSorigin TF_CFLAGS_aarch32 := $(target32-directive) $(march32-directive) 278c8a992fdSorigin TF_CFLAGS_aarch64 := -target aarch64-elf $(march64-directive) 279c8a992fdSorigin LD := $(shell $(CC) --print-prog-name ld.lld) 280c8a992fdSorigin 281c8a992fdSorigin AR := $(shell $(CC) --print-prog-name llvm-ar) 282c8a992fdSorigin OD := $(shell $(CC) --print-prog-name llvm-objdump) 283c8a992fdSorigin OC := $(shell $(CC) --print-prog-name llvm-objcopy) 284641f16e7SAmbroise Vincent endif 285c8a992fdSorigin 286c8a992fdSorigin CPP := $(CC) -E $(TF_CFLAGS_$(ARCH)) 287c8a992fdSorigin PP := $(CC) -E $(TF_CFLAGS_$(ARCH)) 288c8a992fdSorigin AS := $(CC) -c -x assembler-with-cpp $(TF_CFLAGS_$(ARCH)) 289edbce9aaSzelalem-awekeelse ifneq ($(findstring gcc,$(notdir $(CC))),) 290edbce9aaSzelalem-awekeTF_CFLAGS_aarch32 = $(march32-directive) 291edbce9aaSzelalem-awekeTF_CFLAGS_aarch64 = $(march64-directive) 292edbce9aaSzelalem-awekeifeq ($(ENABLE_LTO),1) 293edbce9aaSzelalem-aweke # Enable LTO only for aarch64 294edbce9aaSzelalem-aweke ifeq (${ARCH},aarch64) 295edbce9aaSzelalem-aweke LTO_CFLAGS = -flto 296edbce9aaSzelalem-aweke # Use gcc as a wrapper for the ld, recommended for LTO 297edbce9aaSzelalem-aweke LINKER := ${CROSS_COMPILE}gcc 298edbce9aaSzelalem-aweke endif 299edbce9aaSzelalem-awekeendif 300edbce9aaSzelalem-awekeLD = $(LINKER) 301d5461857Sdp-armelse 30226e63c44SEtienne CarriereTF_CFLAGS_aarch32 = $(march32-directive) 303fa6f774bSAlexei FedorovTF_CFLAGS_aarch64 = $(march64-directive) 3042adee763SRoberto VargasLD = $(LINKER) 305d5461857Sdp-armendif 306d5461857Sdp-arm 30732b209bfSAhmad Fatoum# Process Debug flag 30832b209bfSAhmad Fatoum$(eval $(call add_define,DEBUG)) 30932b209bfSAhmad Fatoumifneq (${DEBUG}, 0) 31032b209bfSAhmad Fatoum BUILD_TYPE := debug 3114466cf82SDaniel Boulby TF_CFLAGS += -g -gdwarf-4 3124466cf82SDaniel Boulby ASFLAGS += -g -Wa,-gdwarf-4 31332b209bfSAhmad Fatoum 31432b209bfSAhmad Fatoum # Use LOG_LEVEL_INFO by default for debug builds 31532b209bfSAhmad Fatoum LOG_LEVEL := 40 31632b209bfSAhmad Fatoumelse 31732b209bfSAhmad Fatoum BUILD_TYPE := release 31832b209bfSAhmad Fatoum # Use LOG_LEVEL_NOTICE by default for release builds 31932b209bfSAhmad Fatoum LOG_LEVEL := 20 32032b209bfSAhmad Fatoumendif 32132b209bfSAhmad Fatoum 322f1de4c8fSPeiyuan Song# Default build string (git branch and commit) 323f1de4c8fSPeiyuan Songifeq (${BUILD_STRING},) 324f1de4c8fSPeiyuan Song BUILD_STRING := $(shell git describe --always --dirty --tags 2> /dev/null) 325f1de4c8fSPeiyuan Songendif 326dddf4283Slaurenw-armVERSION_STRING := v${VERSION}(${BUILD_TYPE}):${BUILD_STRING} 327f1de4c8fSPeiyuan Song 3288fd9d4d5SAntonio Nino Diazifeq (${AARCH32_INSTRUCTION_SET},A32) 3298fd9d4d5SAntonio Nino DiazTF_CFLAGS_aarch32 += -marm 3308fd9d4d5SAntonio Nino Diazelse ifeq (${AARCH32_INSTRUCTION_SET},T32) 3318fd9d4d5SAntonio Nino DiazTF_CFLAGS_aarch32 += -mthumb 3328fd9d4d5SAntonio Nino Diazelse 3338fd9d4d5SAntonio Nino Diaz$(error Error: Unknown AArch32 instruction set ${AARCH32_INSTRUCTION_SET}) 3348fd9d4d5SAntonio Nino Diazendif 3358fd9d4d5SAntonio Nino Diaz 336a9c4dde3SSandrine BailleuxTF_CFLAGS_aarch32 += -mno-unaligned-access 337d5461857Sdp-armTF_CFLAGS_aarch64 += -mgeneral-regs-only -mstrict-align 3389d29c227SSoby Mathew 3399fc59639SAlexei Fedorovifneq (${BP_OPTION},none) 3409fc59639SAlexei FedorovTF_CFLAGS_aarch64 += -mbranch-protection=${BP_OPTION} 3419fc59639SAlexei Fedorovendif 3429fc59639SAlexei Fedorov 34326e63c44SEtienne CarriereASFLAGS_aarch32 = $(march32-directive) 344fa6f774bSAlexei FedorovASFLAGS_aarch64 = $(march64-directive) 345b86048c4SAntonio Nino Diaz 3469ab81b5eSJustin Chadwell# General warnings 3479ab81b5eSJustin ChadwellWARNINGS := -Wall -Wmissing-include-dirs -Wunused \ 348b7f6525dSJustin Chadwell -Wdisabled-optimization -Wvla -Wshadow \ 349ca661a00SMadhukar Pappireddy -Wno-unused-parameter -Wredundant-decls 3509ab81b5eSJustin Chadwell 3519ab81b5eSJustin Chadwell# Additional warnings 3529ab81b5eSJustin Chadwell# Level 1 353e7c645b5SYann GautierWARNING1 := -Wextra 354e7c645b5SYann GautierWARNING1 += -Wmissing-format-attribute 355e7c645b5SYann GautierWARNING1 += -Wmissing-prototypes 356e7c645b5SYann GautierWARNING1 += -Wold-style-definition 357e7c645b5SYann Gautier 358b7f6525dSJustin Chadwell# Level 2 359e7c645b5SYann GautierWARNING2 := -Waggregate-return 360e7c645b5SYann GautierWARNING2 += -Wcast-align 361e7c645b5SYann GautierWARNING2 += -Wnested-externs 362e7c645b5SYann Gautier 363e7c645b5SYann GautierWARNING3 := -Wbad-function-cast 364e7c645b5SYann GautierWARNING3 += -Wcast-qual 365e7c645b5SYann GautierWARNING3 += -Wconversion 366e7c645b5SYann GautierWARNING3 += -Wpacked 367e7c645b5SYann GautierWARNING3 += -Wpointer-arith 368e7c645b5SYann GautierWARNING3 += -Wswitch-default 369e7c645b5SYann Gautier 370e7c645b5SYann Gautierifeq (${W},1) 3719ab81b5eSJustin ChadwellWARNINGS += $(WARNING1) 372e7c645b5SYann Gautierelse ifeq (${W},2) 3739ab81b5eSJustin ChadwellWARNINGS += $(WARNING1) $(WARNING2) 374e7c645b5SYann Gautierelse ifeq (${W},3) 3759ab81b5eSJustin ChadwellWARNINGS += $(WARNING1) $(WARNING2) $(WARNING3) 376e7c645b5SYann Gautierendif 377e7c645b5SYann Gautier 3789ab81b5eSJustin Chadwell# Compiler specific warnings 37900296576SAmbroise Vincentifeq ($(findstring clang,$(notdir $(CC))),) 38093c690ebSJustin Chadwell# not using clang 381d7b4cd41SJustin ChadwellWARNINGS += -Wunused-but-set-variable -Wmaybe-uninitialized \ 382d7b4cd41SJustin Chadwell -Wpacked-bitfield-compat -Wshift-overflow=2 \ 383d7b4cd41SJustin Chadwell -Wlogical-op 38493c690ebSJustin Chadwellelse 38593c690ebSJustin Chadwell# using clang 386d7b4cd41SJustin ChadwellWARNINGS += -Wshift-overflow -Wshift-sign-overflow \ 387d7b4cd41SJustin Chadwell -Wlogical-op-parentheses 38800296576SAmbroise Vincentendif 38900296576SAmbroise Vincent 3906336b07aSYann Gautierifneq (${E},0) 3916336b07aSYann GautierERRORS := -Werror 3926336b07aSYann Gautierendif 3936336b07aSYann Gautier 394ea7a57a3SRoberto VargasCPPFLAGS = ${DEFINES} ${INCLUDES} ${MBEDTLS_INC} -nostdinc \ 3959ab81b5eSJustin Chadwell $(ERRORS) $(WARNINGS) 39659de5096SMasahiro YamadaASFLAGS += $(CPPFLAGS) $(ASFLAGS_$(ARCH)) \ 397d5dfdeb6SJulius Werner -ffreestanding -Wa,--fatal-warnings 39859de5096SMasahiro YamadaTF_CFLAGS += $(CPPFLAGS) $(TF_CFLAGS_$(ARCH)) \ 399ebd6efaeSSamuel Holland -ffunction-sections -fdata-sections \ 400ebd6efaeSSamuel Holland -ffreestanding -fno-builtin -fno-common \ 401ebd6efaeSSamuel Holland -Os -std=gnu99 40273c99d4eSJuan Castillo 403bebcf27fSMark Brown$(eval $(call add_define,SVE_VECTOR_LEN)) 404bebcf27fSMark Brown 4051f461979SJustin Chadwellifeq (${SANITIZE_UB},on) 4061f461979SJustin ChadwellTF_CFLAGS += -fsanitize=undefined -fno-sanitize-recover 4071f461979SJustin Chadwellendif 4081f461979SJustin Chadwellifeq (${SANITIZE_UB},trap) 4091f461979SJustin ChadwellTF_CFLAGS += -fsanitize=undefined -fno-sanitize-recover \ 4101f461979SJustin Chadwell -fsanitize-undefined-trap-on-error 4111f461979SJustin Chadwellendif 4121f461979SJustin Chadwell 413f7ec31dbSdavid cunadoGCC_V_OUTPUT := $(shell $(CC) -v 2>&1) 414f7ec31dbSdavid cunado 415641f16e7SAmbroise Vincent# LD = armlink 416c2ad38ceSVarun Wadekarifneq ($(findstring armlink,$(notdir $(LD))),) 417c2ad38ceSVarun WadekarTF_LDFLAGS += --diag_error=warning --lto_level=O1 418c2ad38ceSVarun WadekarTF_LDFLAGS += --remove --info=unused,unusedsymbols 419edbce9aaSzelalem-awekeTF_LDFLAGS += $(TF_LDFLAGS_$(ARCH)) 420641f16e7SAmbroise Vincent 421641f16e7SAmbroise Vincent# LD = gcc (used when GCC LTO is enabled) 422edbce9aaSzelalem-awekeelse ifneq ($(findstring gcc,$(notdir $(LD))),) 423edbce9aaSzelalem-aweke# Pass ld options with Wl or Xlinker switches 424edbce9aaSzelalem-awekeTF_LDFLAGS += -Wl,--fatal-warnings -O1 425edbce9aaSzelalem-awekeTF_LDFLAGS += -Wl,--gc-sections 426edbce9aaSzelalem-awekeifeq ($(ENABLE_LTO),1) 427edbce9aaSzelalem-aweke ifeq (${ARCH},aarch64) 428edbce9aaSzelalem-aweke TF_LDFLAGS += -flto -fuse-linker-plugin 429edbce9aaSzelalem-aweke endif 430edbce9aaSzelalem-awekeendif 431edbce9aaSzelalem-aweke# GCC automatically adds fix-cortex-a53-843419 flag when used to link 432edbce9aaSzelalem-aweke# which breaks some builds, so disable if errata fix is not explicitly enabled 433edbce9aaSzelalem-awekeifneq (${ERRATA_A53_843419},1) 434edbce9aaSzelalem-aweke TF_LDFLAGS += -mno-fix-cortex-a53-843419 435edbce9aaSzelalem-awekeendif 436edbce9aaSzelalem-awekeTF_LDFLAGS += -nostdlib 437edbce9aaSzelalem-awekeTF_LDFLAGS += $(subst --,-Xlinker --,$(TF_LDFLAGS_$(ARCH))) 438641f16e7SAmbroise Vincent 439641f16e7SAmbroise Vincent# LD = gcc-ld (ld) or llvm-ld (ld.lld) or other 440c2ad38ceSVarun Wadekarelse 441c2b8806fSDouglas RaillardTF_LDFLAGS += --fatal-warnings -O1 442c2b8806fSDouglas RaillardTF_LDFLAGS += --gc-sections 443641f16e7SAmbroise Vincent# ld.lld doesn't recognize the errata flags, 444641f16e7SAmbroise Vincent# therefore don't add those in that case 445641f16e7SAmbroise Vincentifeq ($(findstring ld.lld,$(notdir $(LD))),) 446c2b8806fSDouglas RaillardTF_LDFLAGS += $(TF_LDFLAGS_$(ARCH)) 447edbce9aaSzelalem-awekeendif 448641f16e7SAmbroise Vincentendif 44973c99d4eSJuan Castillo 45003b397a8SNishanth MenonDTC_FLAGS += -I dts -O dtb 451a6de824fSLouis MayencourtDTC_CPPFLAGS += -P -nostdinc -Iinclude -Ifdts -undef \ 452a6de824fSLouis Mayencourt -x assembler-with-cpp $(DEFINES) 45303b397a8SNishanth Menon 45473c99d4eSJuan Castillo################################################################################ 45573c99d4eSJuan Castillo# Common sources and include directories 45673c99d4eSJuan Castillo################################################################################ 4576a0da736SJayanth Dodderi Chidanandinclude ${MAKE_HELPERS_DIRECTORY}arch_features.mk 458d801fbb0Sdp-arminclude lib/compiler-rt/compiler-rt.mk 45973c99d4eSJuan Castillo 46073c99d4eSJuan CastilloBL_COMMON_SOURCES += common/bl_common.c \ 4617f56e9a3SSoby Mathew common/tf_log.c \ 4629d29c227SSoby Mathew common/${ARCH}/debug.S \ 46391b48c9fSJulius Werner drivers/console/multi_console.c \ 4649d29c227SSoby Mathew lib/${ARCH}/cache_helpers.S \ 4659d29c227SSoby Mathew lib/${ARCH}/misc_helpers.S \ 466566034fcSSoby Mathew plat/common/plat_bl_common.c \ 4677f56e9a3SSoby Mathew plat/common/plat_log_common.c \ 46875311203Sdp-arm plat/common/${ARCH}/plat_common.c \ 4699d29c227SSoby Mathew plat/common/${ARCH}/platform_helpers.S \ 47061f72a34SRoberto Vargas ${COMPILER_RT_SRCS} 471d7a6b0f8SRyan Harkin 4728422a840SAntonio Nino Diazifeq ($(notdir $(CC)),armclang) 4738422a840SAntonio Nino DiazBL_COMMON_SOURCES += lib/${ARCH}/armclang_printf.S 4748422a840SAntonio Nino Diazendif 4758422a840SAntonio Nino Diaz 4761f461979SJustin Chadwellifeq (${SANITIZE_UB},on) 4771f461979SJustin ChadwellBL_COMMON_SOURCES += plat/common/ubsan.c 4781f461979SJustin Chadwellendif 4791f461979SJustin Chadwell 48001d237cbSYann GautierINCLUDES += -Iinclude \ 481f5478dedSAntonio Nino Diaz -Iinclude/arch/${ARCH} \ 48209d40e0eSAntonio Nino Diaz -Iinclude/lib/cpus/${ARCH} \ 48309d40e0eSAntonio Nino Diaz -Iinclude/lib/el3_runtime/${ARCH} \ 48409d40e0eSAntonio Nino Diaz ${PLAT_INCLUDES} \ 48509d40e0eSAntonio Nino Diaz ${SPD_INCLUDES} 48609d40e0eSAntonio Nino Diaz 4879c6d1c50SAntonio Nino Diazinclude common/backtrace/backtrace.mk 4889c6d1c50SAntonio Nino Diaz 48973c99d4eSJuan Castillo################################################################################ 49073c99d4eSJuan Castillo# Generic definitions 49173c99d4eSJuan Castillo################################################################################ 49273c99d4eSJuan Castillo 493231c1470SEvan Lloydinclude ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk 494231c1470SEvan Lloyd 49529214e95SGrant Likelyifeq (${BUILD_BASE},) 49673c99d4eSJuan Castillo BUILD_BASE := ./build 49729214e95SGrant Likelyendif 49829214e95SGrant LikelyBUILD_PLAT := $(abspath ${BUILD_BASE})/${PLAT}/${BUILD_TYPE} 49973c99d4eSJuan Castillo 500231c1470SEvan LloydSPDS := $(sort $(filter-out none, $(patsubst services/spd/%,%,$(wildcard services/spd/*)))) 50173c99d4eSJuan Castillo 50273c99d4eSJuan Castillo# Platforms providing their own TBB makefile may override this value 50373c99d4eSJuan CastilloINCLUDE_TBBR_MK := 1 50473c99d4eSJuan Castillo 50573c99d4eSJuan Castillo 50673c99d4eSJuan Castillo################################################################################ 50773c99d4eSJuan Castillo# Include SPD Makefile if one has been specified 50873c99d4eSJuan Castillo################################################################################ 50973c99d4eSJuan Castillo 51073c99d4eSJuan Castilloifneq (${SPD},none) 5119d29c227SSoby Mathew ifeq (${ARCH},aarch32) 5129d29c227SSoby Mathew $(error "Error: SPD is incompatible with AArch32.") 5139d29c227SSoby Mathew endif 51428f39f02SMax Shvetsov 5154c117f6cSSandrine Bailleux ifdef EL3_PAYLOAD_BASE 5164c117f6cSSandrine Bailleux $(warning "SPD and EL3_PAYLOAD_BASE are incompatible build options.") 5174c117f6cSSandrine Bailleux $(warning "The SPD and its BL32 companion will be present but ignored.") 5184c117f6cSSandrine Bailleux endif 51928f39f02SMax Shvetsov 520c3fb00d9SAchin Gupta ifeq (${SPD},spmd) 521c3fb00d9SAchin Gupta # SPMD is located in std_svc directory 522c3fb00d9SAchin Gupta SPD_DIR := std_svc 52328f39f02SMax Shvetsov 524033039f8SMax Shvetsov ifeq ($(SPMD_SPM_AT_SEL2),1) 52528f39f02SMax Shvetsov ifeq ($(CTX_INCLUDE_EL2_REGS),0) 526033039f8SMax Shvetsov $(error SPMD with SPM at S-EL2 requires CTX_INCLUDE_EL2_REGS option) 527033039f8SMax Shvetsov endif 5281d63ae4dSMarc Bonnici ifeq ($(SPMC_AT_EL3),1) 5291d63ae4dSMarc Bonnici $(error SPM cannot be enabled in both S-EL2 and EL3.) 5301d63ae4dSMarc Bonnici endif 53128f39f02SMax Shvetsov endif 532db1ef41aSOlivier Deprez 533db1ef41aSOlivier Deprez ifeq ($(findstring optee_sp,$(ARM_SPMC_MANIFEST_DTS)),optee_sp) 534db1ef41aSOlivier Deprez DTC_CPPFLAGS += -DOPTEE_SP_FW_CONFIG 535db1ef41aSOlivier Deprez endif 536ca932481SDavidson K 537ca932481SDavidson K ifeq ($(TS_SP_FW_CONFIG),1) 538ca932481SDavidson K DTC_CPPFLAGS += -DTS_SP_FW_CONFIG 539ca932481SDavidson K endif 54033993a37SBalint Dobszay 54133993a37SBalint Dobszay ifneq ($(ARM_BL2_SP_LIST_DTS),) 54233993a37SBalint Dobszay DTC_CPPFLAGS += -DARM_BL2_SP_LIST_DTS=$(ARM_BL2_SP_LIST_DTS) 54333993a37SBalint Dobszay endif 54446789a7cSBalint Dobszay 54546789a7cSBalint Dobszay ifneq ($(SP_LAYOUT_FILE),) 54646789a7cSBalint Dobszay BL2_ENABLE_SP_LOAD := 1 54746789a7cSBalint Dobszay endif 548c3fb00d9SAchin Gupta else 549c3fb00d9SAchin Gupta # All other SPDs in spd directory 550c3fb00d9SAchin Gupta SPD_DIR := spd 551c3fb00d9SAchin Gupta endif 552c3fb00d9SAchin Gupta 55373c99d4eSJuan Castillo # We expect to locate an spd.mk under the specified SPD directory 554c3fb00d9SAchin Gupta SPD_MAKE := $(wildcard services/${SPD_DIR}/${SPD}/${SPD}.mk) 555c3fb00d9SAchin Gupta 55673c99d4eSJuan Castillo ifeq (${SPD_MAKE},) 557c3fb00d9SAchin Gupta $(error Error: No services/${SPD_DIR}/${SPD}/${SPD}.mk located) 55873c99d4eSJuan Castillo endif 55973c99d4eSJuan Castillo $(info Including ${SPD_MAKE}) 56073c99d4eSJuan Castillo include ${SPD_MAKE} 56173c99d4eSJuan Castillo 56270d1fc53SJuan Castillo # If there's BL32 companion for the chosen SPD, we expect that the SPD's 56370d1fc53SJuan Castillo # Makefile would set NEED_BL32 to "yes". In this case, the build system 56470d1fc53SJuan Castillo # supports two mutually exclusive options: 56570d1fc53SJuan Castillo # * BL32 is built from source: then BL32_SOURCES must contain the list 56670d1fc53SJuan Castillo # of source files to build BL32 56770d1fc53SJuan Castillo # * BL32 is a prebuilt binary: then BL32 must point to the image file 56870d1fc53SJuan Castillo # that will be included in the FIP 56970d1fc53SJuan Castillo # If both BL32_SOURCES and BL32 are defined, the binary takes precedence 57070d1fc53SJuan Castillo # over the sources. 571e35c4045SJeenu Viswambharanendif 572e35c4045SJeenu Viswambharan 57351faada7SDouglas Raillard################################################################################ 5745b18de09SZelalem Aweke# Include rmmd Makefile if RME is enabled 5755b18de09SZelalem Aweke################################################################################ 5765b18de09SZelalem Aweke 5775b18de09SZelalem Awekeifneq (${ENABLE_RME},0) 5785b18de09SZelalem Awekeifneq (${ARCH},aarch64) 5795b18de09SZelalem Aweke $(error ENABLE_RME requires AArch64) 5805b18de09SZelalem Awekeendif 5811d63ae4dSMarc Bonniciifeq ($(SPMC_AT_EL3),1) 5821d63ae4dSMarc Bonnici $(error SPMC_AT_EL3 and ENABLE_RME cannot both be enabled.) 5831d63ae4dSMarc Bonniciendif 5845b18de09SZelalem Awekeinclude services/std_svc/rmmd/rmmd.mk 5855b18de09SZelalem Aweke$(warning "RME is an experimental feature") 5865b18de09SZelalem Awekeendif 5875b18de09SZelalem Aweke 5885b18de09SZelalem Aweke################################################################################ 58973c99d4eSJuan Castillo# Include the platform specific Makefile after the SPD Makefile (the platform 59073c99d4eSJuan Castillo# makefile may use all previous definitions in this file) 59173c99d4eSJuan Castillo################################################################################ 5922da8d8bfSJeenu Viswambharan 59373c99d4eSJuan Castilloinclude ${PLAT_MAKEFILE_FULL} 5940f21c547SJuan Castillo 5958012cc5cSMasahiro Yamada$(eval $(call MAKE_PREREQ_DIR,${BUILD_PLAT})) 5968012cc5cSMasahiro Yamada 59726e63c44SEtienne Carriereifeq (${ARM_ARCH_MAJOR},7) 59826e63c44SEtienne Carriereinclude make_helpers/armv7-a-cpus.mk 59926e63c44SEtienne Carriereendif 60026e63c44SEtienne Carriere 6013bd17c0fSSoby MathewPIE_FOUND := $(findstring --enable-default-pie,${GCC_V_OUTPUT}) 6023bd17c0fSSoby Mathewifneq ($(PIE_FOUND),) 6033bd17c0fSSoby Mathew TF_CFLAGS += -fno-PIE 6047b592418SSamuel Hollandifneq ($(findstring gcc,$(notdir $(LD))),) 6057b592418SSamuel Holland TF_LDFLAGS += -no-pie 6067b592418SSamuel Hollandendif 6073bd17c0fSSoby Mathewendif 608320920c1SMasahiro Yamada 609320920c1SMasahiro Yamadaifneq ($(findstring gcc,$(notdir $(LD))),) 610320920c1SMasahiro Yamada PIE_LDFLAGS += -Wl,-pie -Wl,--no-dynamic-linker 611320920c1SMasahiro Yamadaelse 612320920c1SMasahiro Yamada PIE_LDFLAGS += -pie --no-dynamic-linker 613320920c1SMasahiro Yamadaendif 614320920c1SMasahiro Yamada 615320920c1SMasahiro Yamadaifeq ($(ENABLE_PIE),1) 61669af7fcfSMasahiro Yamadaifeq ($(BL2_AT_EL3),1) 61769af7fcfSMasahiro Yamadaifneq ($(BL2_IN_XIP_MEM),1) 61869af7fcfSMasahiro Yamada BL2_CFLAGS += -fpie 61969af7fcfSMasahiro Yamada BL2_LDFLAGS += $(PIE_LDFLAGS) 62069af7fcfSMasahiro Yamadaendif 62169af7fcfSMasahiro Yamadaendif 622320920c1SMasahiro Yamada BL31_CFLAGS += -fpie 623320920c1SMasahiro Yamada BL31_LDFLAGS += $(PIE_LDFLAGS) 624d974301dSMasahiro Yamada BL32_CFLAGS += -fpie 625d974301dSMasahiro Yamada BL32_LDFLAGS += $(PIE_LDFLAGS) 626d974301dSMasahiro Yamadaendif 6273bd17c0fSSoby Mathew 628d5e97a1dSMasahiro Yamadaifeq (${ARCH},aarch64) 6299cefb4b1SMasahiro YamadaBL1_CPPFLAGS += -DIMAGE_AT_EL3 630d5e97a1dSMasahiro Yamadaifeq ($(BL2_AT_EL3),1) 6319cefb4b1SMasahiro YamadaBL2_CPPFLAGS += -DIMAGE_AT_EL3 632d5e97a1dSMasahiro Yamadaelse 6339cefb4b1SMasahiro YamadaBL2_CPPFLAGS += -DIMAGE_AT_EL1 634d5e97a1dSMasahiro Yamadaendif 6359cefb4b1SMasahiro YamadaBL2U_CPPFLAGS += -DIMAGE_AT_EL1 6369cefb4b1SMasahiro YamadaBL31_CPPFLAGS += -DIMAGE_AT_EL3 6379cefb4b1SMasahiro YamadaBL32_CPPFLAGS += -DIMAGE_AT_EL1 638d5e97a1dSMasahiro Yamadaendif 639d5e97a1dSMasahiro Yamada 64054035fc4SSandrine Bailleux# Include the CPU specific operations makefile, which provides default 64154035fc4SSandrine Bailleux# values for all CPU errata workarounds and CPU specific optimisations. 64254035fc4SSandrine Bailleux# This can be overridden by the platform. 64373c99d4eSJuan Castilloinclude lib/cpus/cpu-ops.mk 6444f6ad66aSAchin Gupta 645a4409008Sdp-armifeq (${ARCH},aarch32) 646a4409008Sdp-armNEED_BL32 := yes 647a4409008Sdp-arm 648a4409008Sdp-arm################################################################################ 649a4409008Sdp-arm# Build `AARCH32_SP` as BL32 image for AArch32 650a4409008Sdp-arm################################################################################ 651a4409008Sdp-armifneq (${AARCH32_SP},none) 652a4409008Sdp-arm# We expect to locate an sp.mk under the specified AARCH32_SP directory 653a4409008Sdp-armAARCH32_SP_MAKE := $(wildcard bl32/${AARCH32_SP}/${AARCH32_SP}.mk) 654a4409008Sdp-arm 655a4409008Sdp-armifeq (${AARCH32_SP_MAKE},) 656a4409008Sdp-arm $(error Error: No bl32/${AARCH32_SP}/${AARCH32_SP}.mk located) 657a4409008Sdp-armendif 658a4409008Sdp-arm 659a4409008Sdp-arm$(info Including ${AARCH32_SP_MAKE}) 660a4409008Sdp-arminclude ${AARCH32_SP_MAKE} 661a4409008Sdp-armendif 662a4409008Sdp-arm 663a4409008Sdp-armendif 6644f6ad66aSAchin Gupta 66573c99d4eSJuan Castillo################################################################################ 66677f1f7a1SVarun Wadekar# Include libc if not overridden 66777f1f7a1SVarun Wadekar################################################################################ 66877f1f7a1SVarun Wadekarifeq (${OVERRIDE_LIBC},0) 66977f1f7a1SVarun Wadekarinclude lib/libc/libc.mk 67077f1f7a1SVarun Wadekarendif 67177f1f7a1SVarun Wadekar 67277f1f7a1SVarun Wadekar################################################################################ 673cf2c8a33SAntonio Nino Diaz# Check incompatible options 674cf2c8a33SAntonio Nino Diaz################################################################################ 675cf2c8a33SAntonio Nino Diaz 676cf2c8a33SAntonio Nino Diazifdef EL3_PAYLOAD_BASE 67768450a6dSAntonio Nino Diaz ifdef PRELOADED_BL33_BASE 67868450a6dSAntonio Nino Diaz $(warning "PRELOADED_BL33_BASE and EL3_PAYLOAD_BASE are \ 67968450a6dSAntonio Nino Diaz incompatible build options. EL3_PAYLOAD_BASE has priority.") 680cf2c8a33SAntonio Nino Diaz endif 68176580f3dSQixiang Xu ifneq (${GENERATE_COT},0) 68276580f3dSQixiang Xu $(error "GENERATE_COT and EL3_PAYLOAD_BASE are incompatible build options.") 68376580f3dSQixiang Xu endif 68476580f3dSQixiang Xu ifneq (${TRUSTED_BOARD_BOOT},0) 68576580f3dSQixiang Xu $(error "TRUSTED_BOARD_BOOT and EL3_PAYLOAD_BASE are incompatible build options.") 68676580f3dSQixiang Xu endif 687cf2c8a33SAntonio Nino Diazendif 688cf2c8a33SAntonio Nino Diaz 689cf2c8a33SAntonio Nino Diazifeq (${NEED_BL33},yes) 690cf2c8a33SAntonio Nino Diaz ifdef EL3_PAYLOAD_BASE 691cf2c8a33SAntonio Nino Diaz $(warning "BL33 image is not needed when option \ 692cf2c8a33SAntonio Nino Diaz BL33_PAYLOAD_BASE is used and won't be added to the FIP file.") 693cf2c8a33SAntonio Nino Diaz endif 69468450a6dSAntonio Nino Diaz ifdef PRELOADED_BL33_BASE 69568450a6dSAntonio Nino Diaz $(warning "BL33 image is not needed when option \ 69668450a6dSAntonio Nino Diaz PRELOADED_BL33_BASE is used and won't be added to the FIP \ 69768450a6dSAntonio Nino Diaz file.") 698cf2c8a33SAntonio Nino Diaz endif 699cf2c8a33SAntonio Nino Diazendif 700cf2c8a33SAntonio Nino Diaz 701d4593e47SJeenu Viswambharan# When building for systems with hardware-assisted coherency, there's no need to 702d4593e47SJeenu Viswambharan# use USE_COHERENT_MEM. Require that USE_COHERENT_MEM must be set to 0 too. 703d4593e47SJeenu Viswambharanifeq ($(HW_ASSISTED_COHERENCY)-$(USE_COHERENT_MEM),1-1) 704d4593e47SJeenu Viswambharan$(error USE_COHERENT_MEM cannot be enabled with HW_ASSISTED_COHERENCY) 705d4593e47SJeenu Viswambharanendif 7061a0a3f06SYatharth Kochar 7077d173fc5SJiafei Pan#For now, BL2_IN_XIP_MEM is only supported when BL2_AT_EL3 is 1. 7087d173fc5SJiafei Panifeq ($(BL2_AT_EL3)-$(BL2_IN_XIP_MEM),0-1) 7097d173fc5SJiafei Pan$(error "BL2_IN_XIP_MEM is only supported when BL2_AT_EL3 is enabled") 7107d173fc5SJiafei Panendif 7117d173fc5SJiafei Pan 71214c6016aSJeenu Viswambharan# For RAS_EXTENSION, require that EAs are handled in EL3 first 71314c6016aSJeenu Viswambharanifeq ($(RAS_EXTENSION),1) 71414c6016aSJeenu Viswambharan ifneq ($(HANDLE_EA_EL3_FIRST),1) 71514c6016aSJeenu Viswambharan $(error For RAS_EXTENSION, HANDLE_EA_EL3_FIRST must also be 1) 71614c6016aSJeenu Viswambharan endif 71714c6016aSJeenu Viswambharanendif 71814c6016aSJeenu Viswambharan 7191a7c1cfeSJeenu Viswambharan# When FAULT_INJECTION_SUPPORT is used, require that RAS_EXTENSION is enabled 7201a7c1cfeSJeenu Viswambharanifeq ($(FAULT_INJECTION_SUPPORT),1) 7211a7c1cfeSJeenu Viswambharan ifneq ($(RAS_EXTENSION),1) 7221a7c1cfeSJeenu Viswambharan $(error For FAULT_INJECTION_SUPPORT, RAS_EXTENSION must also be 1) 7231a7c1cfeSJeenu Viswambharan endif 7241a7c1cfeSJeenu Viswambharanendif 7251a7c1cfeSJeenu Viswambharan 726ed51b51fSRoberto Vargas# DYN_DISABLE_AUTH can be set only when TRUSTED_BOARD_BOOT=1 727209a60ccSSoby Mathewifeq ($(DYN_DISABLE_AUTH), 1) 728209a60ccSSoby Mathew ifeq (${TRUSTED_BOARD_BOOT}, 0) 729209a60ccSSoby Mathew $(error "TRUSTED_BOARD_BOOT must be enabled for DYN_DISABLE_AUTH to be set.") 730209a60ccSSoby Mathew endif 731209a60ccSSoby Mathewendif 732209a60ccSSoby Mathew 733*2bf4f27fSManish V Badarkheifeq ($(MEASURED_BOOT)-$(TRUSTED_BOARD_BOOT),1-1) 734*2bf4f27fSManish V Badarkhe# Support authentication verification and hash calculation 735*2bf4f27fSManish V Badarkhe CRYPTO_SUPPORT := 3 736*2bf4f27fSManish V Badarkheelse ifeq ($(DRTM_SUPPORT)-$(TRUSTED_BOARD_BOOT),1-1) 737*2bf4f27fSManish V Badarkhe# Support authentication verification and hash calculation 738*2bf4f27fSManish V Badarkhe CRYPTO_SUPPORT := 3 739*2bf4f27fSManish V Badarkheelse ifneq ($(filter 1,${MEASURED_BOOT} ${DRTM_SUPPORT}),) 740*2bf4f27fSManish V Badarkhe# Support hash calculation only 741*2bf4f27fSManish V Badarkhe CRYPTO_SUPPORT := 2 742*2bf4f27fSManish V Badarkheelse ifeq (${TRUSTED_BOARD_BOOT},1) 743*2bf4f27fSManish V Badarkhe# Support authentication verification only 744c9c56f6eSManish V Badarkhe CRYPTO_SUPPORT := 1 745c9c56f6eSManish V Badarkheelse 746c9c56f6eSManish V Badarkhe CRYPTO_SUPPORT := 0 747c9c56f6eSManish V Badarkheendif 748c9c56f6eSManish V Badarkhe 749cbf9e84aSBalint Dobszay# SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled. 750cbf9e84aSBalint Dobszayifeq ($(SDEI_SUPPORT)-$(SDEI_IN_FCONF),0-1) 751700e7685SManish Pandey$(error "SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled") 75284ef9cd8SManish V Badarkheendif 75384ef9cd8SManish V Badarkhe 754b86048c4SAntonio Nino Diaz# If pointer authentication is used in the firmware, make sure that all the 7559fc59639SAlexei Fedorov# registers associated to it are also saved and restored. 7569fc59639SAlexei Fedorov# Not doing it would leak the value of the keys used by EL3 to EL1 and S-EL1. 757b86048c4SAntonio Nino Diazifeq ($(ENABLE_PAUTH),1) 7589fc59639SAlexei Fedorov ifeq ($(CTX_INCLUDE_PAUTH_REGS),0) 7599fc59639SAlexei Fedorov $(error Pointer Authentication requires CTX_INCLUDE_PAUTH_REGS=1) 76006715f85SAlexei Fedorov endif 7619fc59639SAlexei Fedorovendif 7629fc59639SAlexei Fedorov 76306715f85SAlexei Fedorovifeq ($(CTX_INCLUDE_PAUTH_REGS),1) 7649fc59639SAlexei Fedorov ifneq (${ARCH},aarch64) 7659fc59639SAlexei Fedorov $(error CTX_INCLUDE_PAUTH_REGS requires AArch64) 766b86048c4SAntonio Nino Diaz endif 767b86048c4SAntonio Nino Diazendif 7689fc59639SAlexei Fedorov 7699dd94382SJustin Chadwellifeq ($(CTX_INCLUDE_MTE_REGS),1) 7709dd94382SJustin Chadwell ifneq (${ARCH},aarch64) 7719dd94382SJustin Chadwell $(error CTX_INCLUDE_MTE_REGS requires AArch64) 7729dd94382SJustin Chadwell endif 7739dd94382SJustin Chadwellendif 7749dd94382SJustin Chadwell 775396b339dSManish V Badarkheifeq ($(PSA_FWU_SUPPORT),1) 776396b339dSManish V Badarkhe $(info PSA_FWU_SUPPORT is an experimental feature) 777396b339dSManish V Badarkheendif 778396b339dSManish V Badarkhe 7796a0da736SJayanth Dodderi Chidanandifeq ($(FEATURE_DETECTION),1) 7806a0da736SJayanth Dodderi Chidanand $(info FEATURE_DETECTION is an experimental feature) 7816a0da736SJayanth Dodderi Chidanandendif 7826a0da736SJayanth Dodderi Chidanand 78360e8f3cfSPetre-Ionut Tudorifeq (${ARM_XLAT_TABLES_LIB_V1}, 1) 78460e8f3cfSPetre-Ionut Tudor ifeq (${ALLOW_RO_XLAT_TABLES}, 1) 78560e8f3cfSPetre-Ionut Tudor $(error "ALLOW_RO_XLAT_TABLES requires translation tables library v2") 78660e8f3cfSPetre-Ionut Tudor endif 78760e8f3cfSPetre-Ionut Tudorendif 78860e8f3cfSPetre-Ionut Tudor 7897cda17bbSSumit Gargifneq (${DECRYPTION_SUPPORT},none) 7907cda17bbSSumit Garg ifeq (${TRUSTED_BOARD_BOOT}, 0) 7917cda17bbSSumit Garg $(error TRUSTED_BOARD_BOOT must be enabled for DECRYPTION_SUPPORT to be set) 7927cda17bbSSumit Garg endif 7937cda17bbSSumit Gargendif 7947cda17bbSSumit Garg 795744ad974Sjohpow01# Ensure that no Aarch64-only features are enabled in Aarch32 build 796dc78e62dSjohpow01ifeq (${ARCH},aarch32) 797744ad974Sjohpow01 798744ad974Sjohpow01 # SME/SVE only supported on AArch64 799dc78e62dSjohpow01 ifeq (${ENABLE_SME_FOR_NS},1) 800dc78e62dSjohpow01 $(error "ENABLE_SME_FOR_NS cannot be used with ARCH=aarch32") 801dc78e62dSjohpow01 endif 802dc78e62dSjohpow01 ifeq (${ENABLE_SVE_FOR_NS},1) 803dc78e62dSjohpow01 # Warning instead of error due to CI dependency on this 80424ab2c0aSYann Gautier $(error "ENABLE_SVE_FOR_NS cannot be used with ARCH=aarch32") 805dc78e62dSjohpow01 endif 806744ad974Sjohpow01 807ff86e0b4SJuan Pablo Conde # BRBE is not supported in AArch32 808744ad974Sjohpow01 ifeq (${ENABLE_BRBE_FOR_NS},1) 809744ad974Sjohpow01 $(error "ENABLE_BRBE_FOR_NS cannot be used with ARCH=aarch32") 810744ad974Sjohpow01 endif 811744ad974Sjohpow01 812ff86e0b4SJuan Pablo Conde # FEAT_RNG_TRAP is not supported in AArch32 813ff86e0b4SJuan Pablo Conde ifeq (${ENABLE_FEAT_RNG_TRAP},1) 814ff86e0b4SJuan Pablo Conde $(error "ENABLE_FEAT_RNG_TRAP cannot be used with ARCH=aarch32") 815ff86e0b4SJuan Pablo Conde endif 816dc78e62dSjohpow01endif 817dc78e62dSjohpow01 818dc78e62dSjohpow01# Ensure ENABLE_RME is not used with SME 819dc78e62dSjohpow01ifeq (${ENABLE_RME},1) 820dc78e62dSjohpow01 ifeq (${ENABLE_SME_FOR_NS},1) 821dc78e62dSjohpow01 $(error "ENABLE_SME_FOR_NS cannot be used with ENABLE_RME") 822dc78e62dSjohpow01 endif 823dc78e62dSjohpow01endif 824dc78e62dSjohpow01 825dc78e62dSjohpow01# Secure SME/SVE requires the non-secure component as well 826dc78e62dSjohpow01ifeq (${ENABLE_SME_FOR_SWD},1) 827dc78e62dSjohpow01 ifeq (${ENABLE_SME_FOR_NS},0) 828dc78e62dSjohpow01 $(error "ENABLE_SME_FOR_SWD requires ENABLE_SME_FOR_NS") 829dc78e62dSjohpow01 endif 830dc78e62dSjohpow01endif 831dc78e62dSjohpow01ifeq (${ENABLE_SVE_FOR_SWD},1) 832dc78e62dSjohpow01 ifeq (${ENABLE_SVE_FOR_NS},0) 833dc78e62dSjohpow01 $(error "ENABLE_SVE_FOR_SWD requires ENABLE_SVE_FOR_NS") 834dc78e62dSjohpow01 endif 835dc78e62dSjohpow01endif 836dc78e62dSjohpow01 837dc78e62dSjohpow01# SVE and SME cannot be used with CTX_INCLUDE_FPREGS since secure manager does 838dc78e62dSjohpow01# its own context management including FPU registers. 839dc78e62dSjohpow01ifeq (${CTX_INCLUDE_FPREGS},1) 840dc78e62dSjohpow01 ifeq (${ENABLE_SME_FOR_NS},1) 841dc78e62dSjohpow01 $(error "ENABLE_SME_FOR_NS cannot be used with CTX_INCLUDE_FPREGS") 842dc78e62dSjohpow01 endif 843dc78e62dSjohpow01 ifeq (${ENABLE_SVE_FOR_NS},1) 844dc78e62dSjohpow01 # Warning instead of error due to CI dependency on this 845dc78e62dSjohpow01 $(warning "ENABLE_SVE_FOR_NS cannot be used with CTX_INCLUDE_FPREGS") 846dc78e62dSjohpow01 $(warning "Forced ENABLE_SVE_FOR_NS=0") 847dc78e62dSjohpow01 override ENABLE_SVE_FOR_NS := 0 848dc78e62dSjohpow01 endif 849dc78e62dSjohpow01endif 850dc78e62dSjohpow01 85100e28874SManish V Badarkheifeq ($(DRTM_SUPPORT),1) 85200e28874SManish V Badarkhe $(info DRTM_SUPPORT is an experimental feature) 85300e28874SManish V Badarkheendif 85400e28874SManish V Badarkhe 855cf2c8a33SAntonio Nino Diaz################################################################################ 85673c99d4eSJuan Castillo# Process platform overrideable behaviour 85773c99d4eSJuan Castillo################################################################################ 8584f6ad66aSAchin Gupta 8595f24ce96SManish Pandeyifdef BL1_SOURCES 8605f24ce96SManish PandeyNEED_BL1 := yes 8615f24ce96SManish Pandeyendif 8625f24ce96SManish Pandey 8635f24ce96SManish Pandeyifdef BL2_SOURCES 8645f24ce96SManish Pandey NEED_BL2 := yes 8655f24ce96SManish Pandey 866bd97f83aSJohn Tsichritzis # Using BL2 implies that a BL33 image also needs to be supplied for the FIP and 867bd97f83aSJohn Tsichritzis # Certificate generation tools. This flag can be overridden by the platform. 868cf2c8a33SAntonio Nino Diaz ifdef EL3_PAYLOAD_BASE 869cf2c8a33SAntonio Nino Diaz # If booting an EL3 payload there is no need for a BL33 image 870cf2c8a33SAntonio Nino Diaz # in the FIP file. 8714c117f6cSSandrine Bailleux NEED_BL33 := no 872cf2c8a33SAntonio Nino Diaz else 87368450a6dSAntonio Nino Diaz ifdef PRELOADED_BL33_BASE 874cf2c8a33SAntonio Nino Diaz # If booting a BL33 preloaded image there is no need of 875cf2c8a33SAntonio Nino Diaz # another one in the FIP file. 876cf2c8a33SAntonio Nino Diaz NEED_BL33 := no 877cf2c8a33SAntonio Nino Diaz else 878cf2c8a33SAntonio Nino Diaz NEED_BL33 ?= yes 879cf2c8a33SAntonio Nino Diaz endif 8804c117f6cSSandrine Bailleux endif 88173c99d4eSJuan Castilloendif 8826f971622SJuan Castillo 8835f24ce96SManish Pandeyifdef BL2U_SOURCES 8845f24ce96SManish PandeyNEED_BL2U := yes 8855f24ce96SManish Pandeyendif 8865f24ce96SManish Pandey 8874d045d0eSMasahiro Yamada# If SCP_BL2 is given, we always want FIP to include it. 8884d045d0eSMasahiro Yamadaifdef SCP_BL2 8894d045d0eSMasahiro Yamada NEED_SCP_BL2 := yes 8904d045d0eSMasahiro Yamadaendif 8914d045d0eSMasahiro Yamada 8925744e874SSoby Mathew# For AArch32, BL31 is not currently supported. 8935744e874SSoby Mathewifneq (${ARCH},aarch32) 8945744e874SSoby Mathew ifdef BL31_SOURCES 8955744e874SSoby Mathew # When booting an EL3 payload, there is no need to compile the BL31 image nor 8965744e874SSoby Mathew # put it in the FIP. 8975744e874SSoby Mathew ifndef EL3_PAYLOAD_BASE 8985744e874SSoby Mathew NEED_BL31 := yes 8995744e874SSoby Mathew endif 9005744e874SSoby Mathew endif 9015744e874SSoby Mathewendif 9025744e874SSoby Mathew 90373c99d4eSJuan Castillo# Process TBB related flags 9046f971622SJuan Castilloifneq (${GENERATE_COT},0) 90573c99d4eSJuan Castillo # Common cert_create options 9066f971622SJuan Castillo ifneq (${CREATE_KEYS},0) 9076f971622SJuan Castillo $(eval CRT_ARGS += -n) 9080191262dSYatharth Kochar $(eval FWU_CRT_ARGS += -n) 909fd34e7baSJuan Castillo ifneq (${SAVE_KEYS},0) 910fd34e7baSJuan Castillo $(eval CRT_ARGS += -k) 9110191262dSYatharth Kochar $(eval FWU_CRT_ARGS += -k) 912fd34e7baSJuan Castillo endif 9136f971622SJuan Castillo endif 91473c99d4eSJuan Castillo # Include TBBR makefile (unless the platform indicates otherwise) 91573c99d4eSJuan Castillo ifeq (${INCLUDE_TBBR_MK},1) 91673c99d4eSJuan Castillo include make_helpers/tbbr/tbbr_tools.mk 91773c99d4eSJuan Castillo endif 9186f971622SJuan Castilloendif 9196f971622SJuan Castillo 9201c75d5dfSMasahiro Yamadaifneq (${FIP_ALIGN},0) 9211c75d5dfSMasahiro YamadaFIP_ARGS += --align ${FIP_ALIGN} 9221c75d5dfSMasahiro Yamadaendif 9231c75d5dfSMasahiro Yamada 9245f24ce96SManish Pandeyifdef FDT_SOURCES 9255f24ce96SManish PandeyNEED_FDT := yes 9265f24ce96SManish Pandeyendif 9275f24ce96SManish Pandey 92873c99d4eSJuan Castillo################################################################################ 92946e5e035SMichalis Pappas# Include libraries' Makefile that are used in all BL 93046e5e035SMichalis Pappas################################################################################ 93146e5e035SMichalis Pappas 93246e5e035SMichalis Pappasinclude lib/stack_protector/stack_protector.mk 93346e5e035SMichalis Pappas 93446e5e035SMichalis Pappas################################################################################ 935819281eeSdp-arm# Auxiliary tools (fiptool, cert_create, etc) 93673c99d4eSJuan Castillo################################################################################ 93773c99d4eSJuan Castillo 93873c99d4eSJuan Castillo# Variables for use with Certificate Generation Tool 93973c99d4eSJuan CastilloCRTTOOLPATH ?= tools/cert_create 94042a45b51SEvan LloydCRTTOOL ?= ${CRTTOOLPATH}/cert_create${BIN_EXT} 94173c99d4eSJuan Castillo 94290aa901fSSumit Garg# Variables for use with Firmware Encryption Tool 94390aa901fSSumit GargENCTOOLPATH ?= tools/encrypt_fw 94490aa901fSSumit GargENCTOOL ?= ${ENCTOOLPATH}/encrypt_fw${BIN_EXT} 94590aa901fSSumit Garg 94673c99d4eSJuan Castillo# Variables for use with Firmware Image Package 947819281eeSdp-armFIPTOOLPATH ?= tools/fiptool 948819281eeSdp-armFIPTOOL ?= ${FIPTOOLPATH}/fiptool${BIN_EXT} 94973c99d4eSJuan Castillo 95026010da1SAntonio Nino Diaz# Variables for use with sptool 95126010da1SAntonio Nino DiazSPTOOLPATH ?= tools/sptool 952822c7279SJ-AlvesSPTOOL ?= ${SPTOOLPATH}/sptool.py 953ce2b1ec6SManish PandeySP_MK_GEN ?= ${SPTOOLPATH}/sp_mk_generator.py 95426010da1SAntonio Nino Diaz 9555accce5bSRoberto Vargas# Variables for use with ROMLIB 9565accce5bSRoberto VargasROMLIBPATH ?= lib/romlib 9575accce5bSRoberto Vargas 958cfe83910SLouis Mayencourt# Variable for use with Python 959cfe83910SLouis MayencourtPYTHON ?= python3 960cfe83910SLouis Mayencourt 961cfe83910SLouis Mayencourt# Variables for use with PRINT_MEMORY_MAP 962cfe83910SLouis MayencourtPRINT_MEMORY_MAP_PATH ?= tools/memory 963cfe83910SLouis MayencourtPRINT_MEMORY_MAP ?= ${PRINT_MEMORY_MAP_PATH}/print_memory_map.py 964cfe83910SLouis Mayencourt 9656de32378SMadhukar Pappireddy# Variables for use with documentation build using Sphinx tool 9666de32378SMadhukar PappireddyDOCS_PATH ?= docs 9676de32378SMadhukar Pappireddy 9681f1c0206SAbdul Halim, Muhammad Hadi Asyrafi# Defination of SIMICS flag 9691f1c0206SAbdul Halim, Muhammad Hadi AsyrafiSIMICS_BUILD ?= 0 9701f1c0206SAbdul Halim, Muhammad Hadi Asyrafi 9718a86052dSSoby Mathew################################################################################ 9728a86052dSSoby Mathew# Include BL specific makefiles 9738a86052dSSoby Mathew################################################################################ 9745f24ce96SManish Pandey 9755f24ce96SManish Pandeyifeq (${NEED_BL1},yes) 9768a86052dSSoby Mathewinclude bl1/bl1.mk 9778a86052dSSoby Mathewendif 9788a86052dSSoby Mathew 9795f24ce96SManish Pandeyifeq (${NEED_BL2},yes) 9808a86052dSSoby Mathewinclude bl2/bl2.mk 9818a86052dSSoby Mathewendif 9828a86052dSSoby Mathew 9835f24ce96SManish Pandeyifeq (${NEED_BL2U},yes) 9848a86052dSSoby Mathewinclude bl2u/bl2u.mk 9858a86052dSSoby Mathewendif 9868a86052dSSoby Mathew 9875744e874SSoby Mathewifeq (${NEED_BL31},yes) 9888a86052dSSoby Mathewinclude bl31/bl31.mk 9898a86052dSSoby Mathewendif 99003b397a8SNishanth Menon 99173c99d4eSJuan Castillo################################################################################ 99273c99d4eSJuan Castillo# Build options checks 99373c99d4eSJuan Castillo################################################################################ 99473c99d4eSJuan Castillo 995327131c4SLeonardo Sandoval$(eval $(call assert_booleans,\ 996327131c4SLeonardo Sandoval $(sort \ 997327131c4SLeonardo Sandoval ALLOW_RO_XLAT_TABLES \ 99846789a7cSBalint Dobszay BL2_ENABLE_SP_LOAD \ 999327131c4SLeonardo Sandoval COLD_BOOT_SINGLE_CPU \ 1000327131c4SLeonardo Sandoval CREATE_KEYS \ 1001327131c4SLeonardo Sandoval CTX_INCLUDE_AARCH32_REGS \ 1002327131c4SLeonardo Sandoval CTX_INCLUDE_FPREGS \ 1003327131c4SLeonardo Sandoval CTX_INCLUDE_EL2_REGS \ 1004327131c4SLeonardo Sandoval DEBUG \ 10050063dd17SJavier Almansa Sobrino DISABLE_MTPMU \ 1006327131c4SLeonardo Sandoval DYN_DISABLE_AUTH \ 1007327131c4SLeonardo Sandoval EL3_EXCEPTION_HANDLING \ 1008327131c4SLeonardo Sandoval ENABLE_AMU \ 10091fd685a7SChris Kay ENABLE_AMU_AUXILIARY_COUNTERS \ 1010742ca230SChris Kay ENABLE_AMU_FCONF \ 1011873d4241Sjohpow01 AMU_RESTRICT_COUNTERS \ 1012327131c4SLeonardo Sandoval ENABLE_ASSERTIONS \ 1013327131c4SLeonardo Sandoval ENABLE_PIE \ 1014327131c4SLeonardo Sandoval ENABLE_PMF \ 1015327131c4SLeonardo Sandoval ENABLE_PSCI_STAT \ 1016327131c4SLeonardo Sandoval ENABLE_RUNTIME_INSTRUMENTATION \ 1017dc78e62dSjohpow01 ENABLE_SME_FOR_NS \ 1018dc78e62dSjohpow01 ENABLE_SME_FOR_SWD \ 1019327131c4SLeonardo Sandoval ENABLE_SPE_FOR_LOWER_ELS \ 1020327131c4SLeonardo Sandoval ENABLE_SVE_FOR_NS \ 10210c5e7d1cSMax Shvetsov ENABLE_SVE_FOR_SWD \ 1022327131c4SLeonardo Sandoval ERROR_DEPRECATED \ 1023327131c4SLeonardo Sandoval FAULT_INJECTION_SUPPORT \ 1024327131c4SLeonardo Sandoval GENERATE_COT \ 1025327131c4SLeonardo Sandoval GICV2_G0_FOR_EL3 \ 1026327131c4SLeonardo Sandoval HANDLE_EA_EL3_FIRST \ 1027327131c4SLeonardo Sandoval HW_ASSISTED_COHERENCY \ 1028327131c4SLeonardo Sandoval INVERTED_MEMMAP \ 1029327131c4SLeonardo Sandoval MEASURED_BOOT \ 103000e28874SManish V Badarkhe DRTM_SUPPORT \ 1031327131c4SLeonardo Sandoval NS_TIMER_SWITCH \ 1032327131c4SLeonardo Sandoval OVERRIDE_LIBC \ 1033327131c4SLeonardo Sandoval PL011_GENERIC_UART \ 10340ce2072dSTamas Ban PLAT_RSS_NOT_SUPPORTED \ 1035327131c4SLeonardo Sandoval PROGRAMMABLE_RESET_ADDRESS \ 1036327131c4SLeonardo Sandoval PSCI_EXTENDED_STATE_ID \ 1037327131c4SLeonardo Sandoval RESET_TO_BL31 \ 103825844ff7SJorge Ramirez-Ortiz RESET_TO_BL31_WITH_PARAMS \ 1039327131c4SLeonardo Sandoval SAVE_KEYS \ 1040327131c4SLeonardo Sandoval SEPARATE_CODE_AND_RODATA \ 104196a8ed14SJiafei Pan SEPARATE_BL2_NOLOAD_REGION \ 1042327131c4SLeonardo Sandoval SEPARATE_NOBITS_REGION \ 1043327131c4SLeonardo Sandoval SPIN_ON_BL1_EXIT \ 1044327131c4SLeonardo Sandoval SPM_MM \ 10451d63ae4dSMarc Bonnici SPMC_AT_EL3 \ 1046327131c4SLeonardo Sandoval SPMD_SPM_AT_SEL2 \ 1047327131c4SLeonardo Sandoval TRUSTED_BOARD_BOOT \ 1048327131c4SLeonardo Sandoval USE_COHERENT_MEM \ 1049327131c4SLeonardo Sandoval USE_DEBUGFS \ 1050327131c4SLeonardo Sandoval ARM_IO_IN_DTB \ 1051327131c4SLeonardo Sandoval SDEI_IN_FCONF \ 1052327131c4SLeonardo Sandoval SEC_INT_DESC_IN_FCONF \ 1053327131c4SLeonardo Sandoval USE_ROMLIB \ 1054327131c4SLeonardo Sandoval USE_TBBR_DEFS \ 1055327131c4SLeonardo Sandoval WARMBOOT_ENABLE_DCACHE_EARLY \ 1056327131c4SLeonardo Sandoval BL2_AT_EL3 \ 1057327131c4SLeonardo Sandoval BL2_IN_XIP_MEM \ 1058327131c4SLeonardo Sandoval BL2_INV_DCACHE \ 1059327131c4SLeonardo Sandoval USE_SPINLOCK_CAS \ 1060327131c4SLeonardo Sandoval ENCRYPT_BL31 \ 1061327131c4SLeonardo Sandoval ENCRYPT_BL32 \ 1062327131c4SLeonardo Sandoval ERRATA_SPECULATIVE_AT \ 106300e8f79cSManish Pandey RAS_TRAP_NS_ERR_REC_ACCESS \ 1064327131c4SLeonardo Sandoval COT_DESC_IN_DTB \ 1065327131c4SLeonardo Sandoval USE_SP804_TIMER \ 1066396b339dSManish V Badarkhe PSA_FWU_SUPPORT \ 1067d4582d30SManish V Badarkhe ENABLE_SYS_REG_TRACE_FOR_NS \ 106868120783SChris Kay ENABLE_MPMM \ 106968120783SChris Kay ENABLE_MPMM_FCONF \ 10701f1c0206SAbdul Halim, Muhammad Hadi Asyrafi SIMICS_BUILD \ 10716a0da736SJayanth Dodderi Chidanand FEATURE_DETECTION \ 1072327131c4SLeonardo Sandoval))) 107373c99d4eSJuan Castillo 1074327131c4SLeonardo Sandoval$(eval $(call assert_numerics,\ 1075327131c4SLeonardo Sandoval $(sort \ 1076327131c4SLeonardo Sandoval ARM_ARCH_MAJOR \ 1077327131c4SLeonardo Sandoval ARM_ARCH_MINOR \ 1078327131c4SLeonardo Sandoval BRANCH_PROTECTION \ 10796a0da736SJayanth Dodderi Chidanand CTX_INCLUDE_PAUTH_REGS \ 10806a0da736SJayanth Dodderi Chidanand CTX_INCLUDE_MTE_REGS \ 10816a0da736SJayanth Dodderi Chidanand CTX_INCLUDE_NEVE_REGS \ 1082*2bf4f27fSManish V Badarkhe CRYPTO_SUPPORT \ 10831298f2f1SJayanth Dodderi Chidanand ENABLE_BRBE_FOR_NS \ 108447c681b7SJayanth Dodderi Chidanand ENABLE_TRBE_FOR_NS \ 10856a0da736SJayanth Dodderi Chidanand ENABLE_BTI \ 10866a0da736SJayanth Dodderi Chidanand ENABLE_PAUTH \ 10876a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_AMUv1 \ 10886a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_AMUv1p1 \ 10896a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_CSV2_2 \ 10906a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_DIT \ 10916a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_ECV \ 10926a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_FGT \ 10936a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_HCX \ 10946a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_PAN \ 10956a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_RNG \ 1096ff86e0b4SJuan Pablo Conde ENABLE_FEAT_RNG_TRAP \ 10976a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_SB \ 10986a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_SEL2 \ 10996a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_VHE \ 11006a0da736SJayanth Dodderi Chidanand ENABLE_MPAM_FOR_LOWER_ELS \ 11016a0da736SJayanth Dodderi Chidanand ENABLE_RME \ 11026a0da736SJayanth Dodderi Chidanand ENABLE_TRF_FOR_NS \ 1103327131c4SLeonardo Sandoval FW_ENC_STATUS \ 11045357f83dSManish V Badarkhe NR_OF_FW_BANKS \ 11055357f83dSManish V Badarkhe NR_OF_IMAGES_IN_FW_BANK \ 11066a0da736SJayanth Dodderi Chidanand RAS_EXTENSION \ 1107781d07a4SJayanth Dodderi Chidanand TWED_DELAY \ 1108781d07a4SJayanth Dodderi Chidanand ENABLE_FEAT_TWED \ 1109bebcf27fSMark Brown SVE_VECTOR_LEN \ 1110327131c4SLeonardo Sandoval))) 1111c877b414SJeenu Viswambharan 1112aacff749SJustin Chadwellifdef KEY_SIZE 1113aacff749SJustin Chadwell $(eval $(call assert_numeric,KEY_SIZE)) 1114aacff749SJustin Chadwellendif 1115aacff749SJustin Chadwell 11161f461979SJustin Chadwellifeq ($(filter $(SANITIZE_UB), on off trap),) 11171f461979SJustin Chadwell $(error "Invalid value for SANITIZE_UB: can be one of on, off, trap") 11181f461979SJustin Chadwellendif 11191f461979SJustin Chadwell 112073c99d4eSJuan Castillo################################################################################ 112173c99d4eSJuan Castillo# Add definitions to the cpp preprocessor based on the current build options. 112273c99d4eSJuan Castillo# This is done after including the platform specific makefile to allow the 112373c99d4eSJuan Castillo# platform to overwrite the default options 112473c99d4eSJuan Castillo################################################################################ 112573c99d4eSJuan Castillo 1126327131c4SLeonardo Sandoval$(eval $(call add_defines,\ 1127327131c4SLeonardo Sandoval $(sort \ 1128327131c4SLeonardo Sandoval ALLOW_RO_XLAT_TABLES \ 1129327131c4SLeonardo Sandoval ARM_ARCH_MAJOR \ 1130327131c4SLeonardo Sandoval ARM_ARCH_MINOR \ 113146789a7cSBalint Dobszay BL2_ENABLE_SP_LOAD \ 1132327131c4SLeonardo Sandoval COLD_BOOT_SINGLE_CPU \ 1133327131c4SLeonardo Sandoval CTX_INCLUDE_AARCH32_REGS \ 1134327131c4SLeonardo Sandoval CTX_INCLUDE_FPREGS \ 1135327131c4SLeonardo Sandoval CTX_INCLUDE_PAUTH_REGS \ 1136327131c4SLeonardo Sandoval EL3_EXCEPTION_HANDLING \ 1137327131c4SLeonardo Sandoval CTX_INCLUDE_MTE_REGS \ 1138327131c4SLeonardo Sandoval CTX_INCLUDE_EL2_REGS \ 1139062f8aafSArunachalam Ganapathy CTX_INCLUDE_NEVE_REGS \ 1140327131c4SLeonardo Sandoval DECRYPTION_SUPPORT_${DECRYPTION_SUPPORT} \ 11410063dd17SJavier Almansa Sobrino DISABLE_MTPMU \ 1142327131c4SLeonardo Sandoval ENABLE_AMU \ 11431fd685a7SChris Kay ENABLE_AMU_AUXILIARY_COUNTERS \ 1144742ca230SChris Kay ENABLE_AMU_FCONF \ 1145873d4241Sjohpow01 AMU_RESTRICT_COUNTERS \ 1146327131c4SLeonardo Sandoval ENABLE_ASSERTIONS \ 1147327131c4SLeonardo Sandoval ENABLE_BTI \ 1148327131c4SLeonardo Sandoval ENABLE_MPAM_FOR_LOWER_ELS \ 1149327131c4SLeonardo Sandoval ENABLE_PAUTH \ 1150327131c4SLeonardo Sandoval ENABLE_PIE \ 1151327131c4SLeonardo Sandoval ENABLE_PMF \ 1152327131c4SLeonardo Sandoval ENABLE_PSCI_STAT \ 11535b18de09SZelalem Aweke ENABLE_RME \ 1154327131c4SLeonardo Sandoval ENABLE_RUNTIME_INSTRUMENTATION \ 1155dc78e62dSjohpow01 ENABLE_SME_FOR_NS \ 1156dc78e62dSjohpow01 ENABLE_SME_FOR_SWD \ 1157327131c4SLeonardo Sandoval ENABLE_SPE_FOR_LOWER_ELS \ 1158327131c4SLeonardo Sandoval ENABLE_SVE_FOR_NS \ 11590c5e7d1cSMax Shvetsov ENABLE_SVE_FOR_SWD \ 1160327131c4SLeonardo Sandoval ENCRYPT_BL31 \ 1161327131c4SLeonardo Sandoval ENCRYPT_BL32 \ 1162327131c4SLeonardo Sandoval ERROR_DEPRECATED \ 1163327131c4SLeonardo Sandoval FAULT_INJECTION_SUPPORT \ 1164327131c4SLeonardo Sandoval GICV2_G0_FOR_EL3 \ 1165327131c4SLeonardo Sandoval HANDLE_EA_EL3_FIRST \ 1166327131c4SLeonardo Sandoval HW_ASSISTED_COHERENCY \ 1167327131c4SLeonardo Sandoval LOG_LEVEL \ 1168327131c4SLeonardo Sandoval MEASURED_BOOT \ 116900e28874SManish V Badarkhe DRTM_SUPPORT \ 1170327131c4SLeonardo Sandoval NS_TIMER_SWITCH \ 1171327131c4SLeonardo Sandoval PL011_GENERIC_UART \ 1172327131c4SLeonardo Sandoval PLAT_${PLAT} \ 11730ce2072dSTamas Ban PLAT_RSS_NOT_SUPPORTED \ 1174327131c4SLeonardo Sandoval PROGRAMMABLE_RESET_ADDRESS \ 1175327131c4SLeonardo Sandoval PSCI_EXTENDED_STATE_ID \ 1176327131c4SLeonardo Sandoval RAS_EXTENSION \ 1177327131c4SLeonardo Sandoval RESET_TO_BL31 \ 117825844ff7SJorge Ramirez-Ortiz RESET_TO_BL31_WITH_PARAMS \ 1179327131c4SLeonardo Sandoval SEPARATE_CODE_AND_RODATA \ 118096a8ed14SJiafei Pan SEPARATE_BL2_NOLOAD_REGION \ 1181327131c4SLeonardo Sandoval SEPARATE_NOBITS_REGION \ 1182327131c4SLeonardo Sandoval RECLAIM_INIT_CODE \ 1183327131c4SLeonardo Sandoval SPD_${SPD} \ 1184327131c4SLeonardo Sandoval SPIN_ON_BL1_EXIT \ 1185327131c4SLeonardo Sandoval SPM_MM \ 11861d63ae4dSMarc Bonnici SPMC_AT_EL3 \ 1187327131c4SLeonardo Sandoval SPMD_SPM_AT_SEL2 \ 1188327131c4SLeonardo Sandoval TRUSTED_BOARD_BOOT \ 1189c9c56f6eSManish V Badarkhe CRYPTO_SUPPORT \ 11907dfb9911SJimmy Brisson TRNG_SUPPORT \ 1191327131c4SLeonardo Sandoval USE_COHERENT_MEM \ 1192327131c4SLeonardo Sandoval USE_DEBUGFS \ 1193327131c4SLeonardo Sandoval ARM_IO_IN_DTB \ 1194327131c4SLeonardo Sandoval SDEI_IN_FCONF \ 1195327131c4SLeonardo Sandoval SEC_INT_DESC_IN_FCONF \ 1196327131c4SLeonardo Sandoval USE_ROMLIB \ 1197327131c4SLeonardo Sandoval USE_TBBR_DEFS \ 1198327131c4SLeonardo Sandoval WARMBOOT_ENABLE_DCACHE_EARLY \ 1199327131c4SLeonardo Sandoval BL2_AT_EL3 \ 1200327131c4SLeonardo Sandoval BL2_IN_XIP_MEM \ 1201327131c4SLeonardo Sandoval BL2_INV_DCACHE \ 1202327131c4SLeonardo Sandoval USE_SPINLOCK_CAS \ 1203327131c4SLeonardo Sandoval ERRATA_SPECULATIVE_AT \ 120400e8f79cSManish Pandey RAS_TRAP_NS_ERR_REC_ACCESS \ 1205327131c4SLeonardo Sandoval COT_DESC_IN_DTB \ 1206327131c4SLeonardo Sandoval USE_SP804_TIMER \ 120712cd65e0STomas Pilar ENABLE_FEAT_RNG \ 1208ff86e0b4SJuan Pablo Conde ENABLE_FEAT_RNG_TRAP \ 12094e04478aSChris Kay ENABLE_FEAT_SB \ 12107d33ffe4SDaniel Boulby ENABLE_FEAT_DIT \ 12115357f83dSManish V Badarkhe NR_OF_FW_BANKS \ 12125357f83dSManish V Badarkhe NR_OF_IMAGES_IN_FW_BANK \ 1213396b339dSManish V Badarkhe PSA_FWU_SUPPORT \ 1214744ad974Sjohpow01 ENABLE_BRBE_FOR_NS \ 1215813524eaSManish V Badarkhe ENABLE_TRBE_FOR_NS \ 1216d4582d30SManish V Badarkhe ENABLE_SYS_REG_TRACE_FOR_NS \ 12178fcd3d96SManish V Badarkhe ENABLE_TRF_FOR_NS \ 1218cb4ec47bSjohpow01 ENABLE_FEAT_HCX \ 121968120783SChris Kay ENABLE_MPMM \ 122068120783SChris Kay ENABLE_MPMM_FCONF \ 1221f74cb0beSJayanth Dodderi Chidanand ENABLE_FEAT_FGT \ 1222f74cb0beSJayanth Dodderi Chidanand ENABLE_FEAT_AMUv1 \ 1223f74cb0beSJayanth Dodderi Chidanand ENABLE_FEAT_ECV \ 12241f1c0206SAbdul Halim, Muhammad Hadi Asyrafi SIMICS_BUILD \ 12256a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_AMUv1p1 \ 12266a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_SEL2 \ 12276a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_VHE \ 12286a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_CSV2_2 \ 12296a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_PAN \ 12306a0da736SJayanth Dodderi Chidanand FEATURE_DETECTION \ 1231781d07a4SJayanth Dodderi Chidanand TWED_DELAY \ 1232781d07a4SJayanth Dodderi Chidanand ENABLE_FEAT_TWED \ 1233327131c4SLeonardo Sandoval))) 12342fae4b1eSJeenu Viswambharan 12351f461979SJustin Chadwellifeq (${SANITIZE_UB},trap) 12361f461979SJustin Chadwell $(eval $(call add_define,MONITOR_TRAPS)) 12371f461979SJustin Chadwellendif 12381f461979SJustin Chadwell 12394c117f6cSSandrine Bailleux# Define the EL3_PAYLOAD_BASE flag only if it is provided. 12404c117f6cSSandrine Bailleuxifdef EL3_PAYLOAD_BASE 12414c117f6cSSandrine Bailleux $(eval $(call add_define,EL3_PAYLOAD_BASE)) 1242cf2c8a33SAntonio Nino Diazelse 124368450a6dSAntonio Nino Diaz # Define the PRELOADED_BL33_BASE flag only if it is provided and 124468450a6dSAntonio Nino Diaz # EL3_PAYLOAD_BASE is not defined, as it has priority. 124568450a6dSAntonio Nino Diaz ifdef PRELOADED_BL33_BASE 124668450a6dSAntonio Nino Diaz $(eval $(call add_define,PRELOADED_BL33_BASE)) 12474c117f6cSSandrine Bailleux endif 1248cf2c8a33SAntonio Nino Diazendif 124973c99d4eSJuan Castillo 1250209a60ccSSoby Mathew# Define the DYN_DISABLE_AUTH flag only if set. 1251209a60ccSSoby Mathewifeq (${DYN_DISABLE_AUTH},1) 1252209a60ccSSoby Mathew$(eval $(call add_define,DYN_DISABLE_AUTH)) 1253209a60ccSSoby Mathewendif 1254209a60ccSSoby Mathew 1255c2ad38ceSVarun Wadekarifneq ($(findstring armlink,$(notdir $(LD))),) 1256c2ad38ceSVarun Wadekar$(eval $(call add_define,USE_ARM_LINK)) 1257c2ad38ceSVarun Wadekarendif 1258c2ad38ceSVarun Wadekar 1259ce2b1ec6SManish Pandey# Generate and include sp_gen.mk if SPD is spmd and SP_LAYOUT_FILE is defined 1260ce2b1ec6SManish Pandeyifeq (${SPD},spmd) 1261c33ff198SOlivier Deprezifdef SP_LAYOUT_FILE 1262ce2b1ec6SManish Pandey -include $(BUILD_PLAT)/sp_gen.mk 1263ce2b1ec6SManish Pandey FIP_DEPS += sp 126407c44475SManish Pandey CRT_DEPS += sp 1265ce2b1ec6SManish Pandey NEED_SP_PKG := yes 1266ce2b1ec6SManish Pandeyelse 1267c33ff198SOlivier Deprez ifeq (${SPMD_SPM_AT_SEL2},1) 1268c33ff198SOlivier Deprez $(error "SPMD with SPM at S-EL2 require SP_LAYOUT_FILE") 1269c33ff198SOlivier Deprez endif 1270ce2b1ec6SManish Pandeyendif 1271ce2b1ec6SManish Pandeyendif 1272ce2b1ec6SManish Pandey 127373c99d4eSJuan Castillo################################################################################ 127473c99d4eSJuan Castillo# Build targets 127573c99d4eSJuan Castillo################################################################################ 127673c99d4eSJuan Castillo 127790aa901fSSumit Garg.PHONY: all msg_start clean realclean distclean cscope locate-checkpatch checkcodebase checkpatch fiptool sptool fip sp fwu_fip certtool dtbs memmap doc enctool 127873c99d4eSJuan Castillo.SUFFIXES: 127973c99d4eSJuan Castillo 128073c99d4eSJuan Castilloall: msg_start 128173c99d4eSJuan Castillo 128273c99d4eSJuan Castillomsg_start: 128373c99d4eSJuan Castillo @echo "Building ${PLAT}" 128473c99d4eSJuan Castillo 12857a24cba5SSoby Mathewifeq (${ERROR_DEPRECATED},0) 1286d5dfdeb6SJulius Werner# Check if deprecated declarations and cpp warnings should be treated as error or not. 1287c2ad38ceSVarun Wadekarifneq ($(findstring clang,$(notdir $(CC))),) 1288c2ad38ceSVarun Wadekar CPPFLAGS += -Wno-error=deprecated-declarations 1289c2ad38ceSVarun Wadekarelse 1290bc1a03c7SDan Handley CPPFLAGS += -Wno-error=deprecated-declarations -Wno-error=cpp 12917a24cba5SSoby Mathewendif 1292d5dfdeb6SJulius Wernerendif # !ERROR_DEPRECATED 12937a24cba5SSoby Mathew 12945accce5bSRoberto Vargas$(eval $(call MAKE_LIB_DIRS)) 129561f72a34SRoberto Vargas$(eval $(call MAKE_LIB,c)) 12965fee0287SRoberto Vargas 129773c99d4eSJuan Castillo# Expand build macros for the different images 129873c99d4eSJuan Castilloifeq (${NEED_BL1},yes) 1299b34635a0SChris KayBL1_SOURCES := $(sort ${BL1_SOURCES}) 1300b34635a0SChris Kay 1301434d0491SZelalem Aweke$(eval $(call MAKE_BL,bl1)) 130273c99d4eSJuan Castilloendif 130373c99d4eSJuan Castillo 130473c99d4eSJuan Castilloifeq (${NEED_BL2},yes) 1305c9b31ae8SRoberto Vargasifeq (${BL2_AT_EL3}, 0) 1306c9b31ae8SRoberto VargasFIP_BL2_ARGS := tb-fw 1307c9b31ae8SRoberto Vargasendif 1308c9b31ae8SRoberto Vargas 1309eb1acfb6SChris KayBL2_SOURCES := $(sort ${BL2_SOURCES}) 1310eb1acfb6SChris Kay 131133950dd8SMasahiro Yamada$(if ${BL2}, $(eval $(call TOOL_ADD_IMG,bl2,--${FIP_BL2_ARGS})),\ 1312434d0491SZelalem Aweke $(eval $(call MAKE_BL,bl2,${FIP_BL2_ARGS}))) 131373c99d4eSJuan Castilloendif 131473c99d4eSJuan Castillo 13154d045d0eSMasahiro Yamadaifeq (${NEED_SCP_BL2},yes) 131633950dd8SMasahiro Yamada$(eval $(call TOOL_ADD_IMG,scp_bl2,--scp-fw)) 13174d045d0eSMasahiro Yamadaendif 13184d045d0eSMasahiro Yamada 131973c99d4eSJuan Castilloifeq (${NEED_BL31},yes) 132073c99d4eSJuan CastilloBL31_SOURCES += ${SPD_SOURCES} 132126d1e0c3SMadhukar Pappireddy# Sort BL31 source files to remove duplicates 132226d1e0c3SMadhukar PappireddyBL31_SOURCES := $(sort ${BL31_SOURCES}) 1323c6ba9b45SSumit Gargifneq (${DECRYPTION_SUPPORT},none) 1324c6ba9b45SSumit Garg$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw,,$(ENCRYPT_BL31))),\ 1325434d0491SZelalem Aweke $(eval $(call MAKE_BL,bl31,soc-fw,,$(ENCRYPT_BL31)))) 1326c6ba9b45SSumit Gargelse 132733950dd8SMasahiro Yamada$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw)),\ 1328434d0491SZelalem Aweke $(eval $(call MAKE_BL,bl31,soc-fw))) 132973c99d4eSJuan Castilloendif 1330c6ba9b45SSumit Gargendif 133173c99d4eSJuan Castillo 133270d1fc53SJuan Castillo# If a BL32 image is needed but neither BL32 nor BL32_SOURCES is defined, the 1333c939d13aSMasahiro Yamada# build system will call TOOL_ADD_IMG to print a warning message and abort the 133470d1fc53SJuan Castillo# process. Note that the dependency on BL32 applies to the FIP only. 133573c99d4eSJuan Castilloifeq (${NEED_BL32},yes) 133626d1e0c3SMadhukar Pappireddy# Sort BL32 source files to remove duplicates 133726d1e0c3SMadhukar PappireddyBL32_SOURCES := $(sort ${BL32_SOURCES}) 13389cd15239SMasahiro YamadaBUILD_BL32 := $(if $(BL32),,$(if $(BL32_SOURCES),1)) 13399cd15239SMasahiro Yamada 1340c6ba9b45SSumit Gargifneq (${DECRYPTION_SUPPORT},none) 1341434d0491SZelalem Aweke$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw,,$(ENCRYPT_BL32))),\ 1342c6ba9b45SSumit Garg $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw,,$(ENCRYPT_BL32)))) 1343c6ba9b45SSumit Gargelse 1344434d0491SZelalem Aweke$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw)),\ 134533950dd8SMasahiro Yamada $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw))) 134673c99d4eSJuan Castilloendif 1347c6ba9b45SSumit Gargendif 134873c99d4eSJuan Castillo 13495b18de09SZelalem Aweke# If RMM image is needed but RMM is not defined, Test Realm Payload (TRP) 13505b18de09SZelalem Aweke# needs to be built from RMM_SOURCES. 13515b18de09SZelalem Awekeifeq (${NEED_RMM},yes) 13525b18de09SZelalem Aweke# Sort RMM source files to remove duplicates 13535b18de09SZelalem AwekeRMM_SOURCES := $(sort ${RMM_SOURCES}) 13545b18de09SZelalem AwekeBUILD_RMM := $(if $(RMM),,$(if $(RMM_SOURCES),1)) 13555b18de09SZelalem Aweke 13565b18de09SZelalem Aweke$(if ${BUILD_RMM}, $(eval $(call MAKE_BL,rmm,rmm-fw)),\ 13575b18de09SZelalem Aweke $(eval $(call TOOL_ADD_IMG,rmm,--rmm-fw))) 13585b18de09SZelalem Awekeendif 13595b18de09SZelalem Aweke 136073c99d4eSJuan Castillo# Add the BL33 image if required by the platform 136173c99d4eSJuan Castilloifeq (${NEED_BL33},yes) 136233950dd8SMasahiro Yamada$(eval $(call TOOL_ADD_IMG,bl33,--nt-fw)) 1363db6071c9SJuan Castilloendif 1364db6071c9SJuan Castillo 13659003fa0bSYatharth Kocharifeq (${NEED_BL2U},yes) 136633950dd8SMasahiro Yamada$(if ${BL2U}, $(eval $(call TOOL_ADD_IMG,bl2u,--ap-fwu-cfg,FWU_)),\ 1367434d0491SZelalem Aweke $(eval $(call MAKE_BL,bl2u,ap-fwu-cfg,FWU_))) 13689003fa0bSYatharth Kocharendif 13699003fa0bSYatharth Kochar 137003b397a8SNishanth Menon# Expand build macros for the different images 137103b397a8SNishanth Menonifeq (${NEED_FDT},yes) 137203b397a8SNishanth Menon $(eval $(call MAKE_DTBS,$(BUILD_PLAT)/fdts,$(FDT_SOURCES))) 137303b397a8SNishanth Menonendif 137403b397a8SNishanth Menon 1375ce2b1ec6SManish Pandey# Add Secure Partition packages 1376ce2b1ec6SManish Pandeyifeq (${NEED_SP_PKG},yes) 1377ce2b1ec6SManish Pandey$(BUILD_PLAT)/sp_gen.mk: ${SP_MK_GEN} ${SP_LAYOUT_FILE} | ${BUILD_PLAT} 13781e7528ecSRuari Phipps ${Q}${PYTHON} "$<" "$@" $(filter-out $<,$^) $(BUILD_PLAT) ${COT} 1379822c7279SJ-Alvessp: $(DTBS) $(BUILD_PLAT)/sp_gen.mk $(SP_PKGS) 1380ce2b1ec6SManish Pandey @${ECHO_BLANK_LINE} 1381ce2b1ec6SManish Pandey @echo "Built SP Images successfully" 1382ce2b1ec6SManish Pandey @${ECHO_BLANK_LINE} 1383ce2b1ec6SManish Pandeyendif 1384ce2b1ec6SManish Pandey 138536eaaf37SIan Spraylocate-checkpatch: 138636eaaf37SIan Sprayifndef CHECKPATCH 138766079b04SEtienne Carriere $(error "Please set CHECKPATCH to point to the Linux checkpatch.pl file, eg: CHECKPATCH=../linux/scripts/checkpatch.pl") 138836eaaf37SIan Sprayelse 138936eaaf37SIan Sprayifeq (,$(wildcard ${CHECKPATCH})) 139066079b04SEtienne Carriere $(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/scripts/checkpatch.pl") 139136eaaf37SIan Sprayendif 139236eaaf37SIan Sprayendif 139336eaaf37SIan Spray 13944f6ad66aSAchin Guptaclean: 13954f6ad66aSAchin Gupta @echo " CLEAN" 1396f1477d4aSEvan Lloyd $(call SHELL_REMOVE_DIR,${BUILD_PLAT}) 139788a1cf1eSSami Mujawarifdef UNIX_MK 13982f2cef46SJeenu Viswambharan ${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean 139988a1cf1eSSami Mujawarelse 140088a1cf1eSSami Mujawar# Clear the MAKEFLAGS as we do not want 140188a1cf1eSSami Mujawar# to pass the gnumake flags to nmake. 140288a1cf1eSSami Mujawar ${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) clean 140388a1cf1eSSami Mujawarendif 14046f971622SJuan Castillo ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean 140590aa901fSSumit Garg ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} clean 14065accce5bSRoberto Vargas ${Q}${MAKE} --no-print-directory -C ${ROMLIBPATH} clean 14074f6ad66aSAchin Gupta 1408eaaeece2SJames Morrisseyrealclean distclean: 1409eaaeece2SJames Morrissey @echo " REALCLEAN" 1410f1477d4aSEvan Lloyd $(call SHELL_REMOVE_DIR,${BUILD_BASE}) 1411f1477d4aSEvan Lloyd $(call SHELL_DELETE_ALL, ${CURDIR}/cscope.*) 141288a1cf1eSSami Mujawarifdef UNIX_MK 14132f2cef46SJeenu Viswambharan ${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean 141488a1cf1eSSami Mujawarelse 141588a1cf1eSSami Mujawar# Clear the MAKEFLAGS as we do not want 141688a1cf1eSSami Mujawar# to pass the gnumake flags to nmake. 141788a1cf1eSSami Mujawar ${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) realclean 141888a1cf1eSSami Mujawarendif 1419e15591aaSNicolas Boulenguez ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} realclean 142090aa901fSSumit Garg ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} realclean 14215accce5bSRoberto Vargas ${Q}${MAKE} --no-print-directory -C ${ROMLIBPATH} clean 14224f6ad66aSAchin Gupta 142336eaaf37SIan Spraycheckcodebase: locate-checkpatch 142436eaaf37SIan Spray @echo " CHECKING STYLE" 142536eaaf37SIan Spray @if test -d .git ; then \ 14261ef35512SPaul Beesley git ls-files | grep -E -v 'libfdt|libc|docs|\.rst' | \ 14271a41e8c1SDan Handley while read GIT_FILE ; \ 14281a41e8c1SDan Handley do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ; \ 14291a41e8c1SDan Handley done ; \ 143036eaaf37SIan Spray else \ 14311a41e8c1SDan Handley find . -type f -not -iwholename "*.git*" \ 14321a41e8c1SDan Handley -not -iwholename "*build*" \ 14331a41e8c1SDan Handley -not -iwholename "*libfdt*" \ 143461f72a34SRoberto Vargas -not -iwholename "*libc*" \ 14351a41e8c1SDan Handley -not -iwholename "*docs*" \ 14361ef35512SPaul Beesley -not -iwholename "*.rst" \ 14371a41e8c1SDan Handley -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ; \ 143836eaaf37SIan Spray fi 143936eaaf37SIan Spray 144036eaaf37SIan Spraycheckpatch: locate-checkpatch 144136eaaf37SIan Spray @echo " CHECKING STYLE" 144202a76d5fSYann Gautier @if test -n "${CHECKPATCH_OPTS}"; then \ 144302a76d5fSYann Gautier echo " with ${CHECKPATCH_OPTS} option(s)"; \ 144402a76d5fSYann Gautier fi 144551d28937SAntonio Nino Diaz ${Q}COMMON_COMMIT=$$(git merge-base HEAD ${BASE_COMMIT}); \ 144677a0a7f1SYann Gautier for commit in `git rev-list --no-merges $$COMMON_COMMIT..HEAD`; \ 144777a0a7f1SYann Gautier do \ 144851d28937SAntonio Nino Diaz printf "\n[*] Checking style of '$$commit'\n\n"; \ 144951d28937SAntonio Nino Diaz git log --format=email "$$commit~..$$commit" \ 145002a76d5fSYann Gautier -- ${CHECK_PATHS} | \ 145102a76d5fSYann Gautier ${CHECKPATCH} ${CHECKPATCH_OPTS} - || true; \ 145251d28937SAntonio Nino Diaz git diff --format=email "$$commit~..$$commit" \ 145302a76d5fSYann Gautier -- ${CHECK_PATHS} | \ 145402a76d5fSYann Gautier ${CHECKPATCH} ${CHECKPATCH_OPTS} - || true; \ 145551d28937SAntonio Nino Diaz done 145636eaaf37SIan Spray 145773c99d4eSJuan Castillocerttool: ${CRTTOOL} 145873c99d4eSJuan Castillo 1459a9812206SPali Rohár${CRTTOOL}: FORCE 1460fafd3ec9SManish V Badarkhe ${Q}${MAKE} PLAT=${PLAT} USE_TBBR_DEFS=${USE_TBBR_DEFS} COT=${COT} OPENSSL_DIR=${OPENSSL_DIR} CRTTOOL=${CRTTOOL} --no-print-directory -C ${CRTTOOLPATH} 1461f1477d4aSEvan Lloyd @${ECHO_BLANK_LINE} 14626f971622SJuan Castillo @echo "Built $@ successfully" 1463f1477d4aSEvan Lloyd @${ECHO_BLANK_LINE} 14646f971622SJuan Castillo 14656f971622SJuan Castilloifneq (${GENERATE_COT},0) 146673c99d4eSJuan Castillocertificates: ${CRT_DEPS} ${CRTTOOL} 14676f971622SJuan Castillo ${Q}${CRTTOOL} ${CRT_ARGS} 1468f1477d4aSEvan Lloyd @${ECHO_BLANK_LINE} 14696f971622SJuan Castillo @echo "Built $@ successfully" 14706f971622SJuan Castillo @echo "Certificates can be found in ${BUILD_PLAT}" 1471f1477d4aSEvan Lloyd @${ECHO_BLANK_LINE} 147273c99d4eSJuan Castilloendif 147327713fb4SSoby Mathew 147473c99d4eSJuan Castillo${BUILD_PLAT}/${FIP_NAME}: ${FIP_DEPS} ${FIPTOOL} 14754727fd13SPali Rohár $(eval ${CHECK_FIP_CMD}) 1476819281eeSdp-arm ${Q}${FIPTOOL} create ${FIP_ARGS} $@ 1477819281eeSdp-arm ${Q}${FIPTOOL} info $@ 1478f1477d4aSEvan Lloyd @${ECHO_BLANK_LINE} 14792f2cef46SJeenu Viswambharan @echo "Built $@ successfully" 1480f1477d4aSEvan Lloyd @${ECHO_BLANK_LINE} 1481f58ad36fSHarry Liebel 14820191262dSYatharth Kocharifneq (${GENERATE_COT},0) 14830191262dSYatharth Kocharfwu_certificates: ${FWU_CRT_DEPS} ${CRTTOOL} 14840191262dSYatharth Kochar ${Q}${CRTTOOL} ${FWU_CRT_ARGS} 1485052ab529SEvan Lloyd @${ECHO_BLANK_LINE} 14860191262dSYatharth Kochar @echo "Built $@ successfully" 14870191262dSYatharth Kochar @echo "FWU certificates can be found in ${BUILD_PLAT}" 1488052ab529SEvan Lloyd @${ECHO_BLANK_LINE} 14890191262dSYatharth Kocharendif 14900191262dSYatharth Kochar 14910191262dSYatharth Kochar${BUILD_PLAT}/${FWU_FIP_NAME}: ${FWU_FIP_DEPS} ${FIPTOOL} 14924727fd13SPali Rohár $(eval ${CHECK_FWU_FIP_CMD}) 1493819281eeSdp-arm ${Q}${FIPTOOL} create ${FWU_FIP_ARGS} $@ 1494819281eeSdp-arm ${Q}${FIPTOOL} info $@ 1495052ab529SEvan Lloyd @${ECHO_BLANK_LINE} 14960191262dSYatharth Kochar @echo "Built $@ successfully" 1497052ab529SEvan Lloyd @${ECHO_BLANK_LINE} 14980191262dSYatharth Kochar 149973c99d4eSJuan Castillofiptool: ${FIPTOOL} 150073c99d4eSJuan Castillofip: ${BUILD_PLAT}/${FIP_NAME} 15010191262dSYatharth Kocharfwu_fip: ${BUILD_PLAT}/${FWU_FIP_NAME} 150273c99d4eSJuan Castillo 1503a9812206SPali Rohár${FIPTOOL}: FORCE 150488a1cf1eSSami Mujawarifdef UNIX_MK 15050a956f81SRoss Burton ${Q}${MAKE} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" FIPTOOL=${FIPTOOL} OPENSSL_DIR=${OPENSSL_DIR} --no-print-directory -C ${FIPTOOLPATH} 150688a1cf1eSSami Mujawarelse 150788a1cf1eSSami Mujawar# Clear the MAKEFLAGS as we do not want 150888a1cf1eSSami Mujawar# to pass the gnumake flags to nmake. 150988a1cf1eSSami Mujawar ${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) 151088a1cf1eSSami Mujawarendif 1511f58ad36fSHarry Liebel 1512a9812206SPali Rohárromlib.bin: libraries FORCE 1513bbb24f61SJohn Tsichritzis ${Q}${MAKE} PLAT_DIR=${PLAT_DIR} BUILD_PLAT=${BUILD_PLAT} ENABLE_BTI=${ENABLE_BTI} ARM_ARCH_MINOR=${ARM_ARCH_MINOR} INCLUDES='${INCLUDES}' DEFINES='${DEFINES}' --no-print-directory -C ${ROMLIBPATH} all 15145accce5bSRoberto Vargas 1515cfe83910SLouis Mayencourt# Call print_memory_map tool 1516cfe83910SLouis Mayencourtmemmap: all 1517b890b36dSLouis Mayencourt ${Q}${PYTHON} ${PRINT_MEMORY_MAP} ${BUILD_PLAT} ${INVERTED_MEMMAP} 1518cfe83910SLouis Mayencourt 15196de32378SMadhukar Pappireddydoc: 15206de32378SMadhukar Pappireddy @echo " BUILD DOCUMENTATION" 15216de32378SMadhukar Pappireddy ${Q}${MAKE} --no-print-directory -C ${DOCS_PATH} html 15226de32378SMadhukar Pappireddy 152390aa901fSSumit Gargenctool: ${ENCTOOL} 152490aa901fSSumit Garg 1525a9812206SPali Rohár${ENCTOOL}: FORCE 1526fafd3ec9SManish V Badarkhe ${Q}${MAKE} PLAT=${PLAT} BUILD_INFO=0 OPENSSL_DIR=${OPENSSL_DIR} ENCTOOL=${ENCTOOL} --no-print-directory -C ${ENCTOOLPATH} 152790aa901fSSumit Garg @${ECHO_BLANK_LINE} 152890aa901fSSumit Garg @echo "Built $@ successfully" 152990aa901fSSumit Garg @${ECHO_BLANK_LINE} 153090aa901fSSumit Garg 153135fab8c9SJoakim Bechcscope: 153235fab8c9SJoakim Bech @echo " CSCOPE" 153335fab8c9SJoakim Bech ${Q}find ${CURDIR} -name "*.[chsS]" > cscope.files 153435fab8c9SJoakim Bech ${Q}cscope -b -q -k 153535fab8c9SJoakim Bech 153672ee3314SRyan Harkinhelp: 15377c23126cSJohn Tsichritzis @echo "usage: ${MAKE} [PLAT=<platform>] [OPTIONS] [TARGET]" 153872ee3314SRyan Harkin @echo "" 153972ee3314SRyan Harkin @echo "PLAT is used to specify which platform you wish to build." 154008c7ed0fSSandrine Bailleux @echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}" 154172ee3314SRyan Harkin @echo "" 15427c23126cSJohn Tsichritzis @echo "platform = ${PLATFORM_LIST}" 15437c23126cSJohn Tsichritzis @echo "" 15441b578596SSandrine Bailleux @echo "Please refer to the User Guide for a list of all supported options." 15451b578596SSandrine Bailleux @echo "Note that the build system doesn't track dependencies for build " 15461b578596SSandrine Bailleux @echo "options. Therefore, if any of the build options are changed " 15471b578596SSandrine Bailleux @echo "from a previous build, a clean build must be performed." 15481b578596SSandrine Bailleux @echo "" 154972ee3314SRyan Harkin @echo "Supported Targets:" 15501b578596SSandrine Bailleux @echo " all Build all individual bootloader binaries" 155136eaaf37SIan Spray @echo " bl1 Build the BL1 binary" 15528aa559c0SJeenu Viswambharan @echo " bl2 Build the BL2 binary" 15539003fa0bSYatharth Kochar @echo " bl2u Build the BL2U binary" 1554d178637dSJuan Castillo @echo " bl31 Build the BL31 binary" 15559d29c227SSoby Mathew @echo " bl32 Build the BL32 binary. If ARCH=aarch32, then " 15569d29c227SSoby Mathew @echo " this builds secure payload specified by AARCH32_SP" 155773c99d4eSJuan Castillo @echo " certificates Build the certificates (requires 'GENERATE_COT=1')" 15581b578596SSandrine Bailleux @echo " fip Build the Firmware Image Package (FIP)" 15590191262dSYatharth Kochar @echo " fwu_fip Build the FWU Firmware Image Package (FIP)" 156036eaaf37SIan Spray @echo " checkcodebase Check the coding style of the entire source tree" 156136eaaf37SIan Spray @echo " checkpatch Check the coding style on changes in the current" 156236eaaf37SIan Spray @echo " branch against BASE_COMMIT (default origin/master)" 156372ee3314SRyan Harkin @echo " clean Clean the build for the selected platform" 156435fab8c9SJoakim Bech @echo " cscope Generate cscope index" 156572ee3314SRyan Harkin @echo " distclean Remove all build artifacts for all platforms" 15666f971622SJuan Castillo @echo " certtool Build the Certificate generation tool" 156790aa901fSSumit Garg @echo " enctool Build the Firmware encryption tool" 1568f58ad36fSHarry Liebel @echo " fiptool Build the Firmware Image Package (FIP) creation tool" 1569ce2b1ec6SManish Pandey @echo " sp Build the Secure Partition Packages" 157026010da1SAntonio Nino Diaz @echo " sptool Build the Secure Partition Package creation tool" 157138c14d88SSoby Mathew @echo " dtbs Build the Device Tree Blobs (if required for the platform)" 1572cfe83910SLouis Mayencourt @echo " memmap Print the memory map of the built binaries" 15736de32378SMadhukar Pappireddy @echo " doc Build html based documentation using Sphinx tool" 157472ee3314SRyan Harkin @echo "" 15751b578596SSandrine Bailleux @echo "Note: most build targets require PLAT to be set to a specific platform." 157672ee3314SRyan Harkin @echo "" 157772ee3314SRyan Harkin @echo "example: build all targets for the FVP platform:" 157872ee3314SRyan Harkin @echo " CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all" 1579a9812206SPali Rohár 1580a9812206SPali Rohár.PHONY: FORCE 1581a9812206SPali RohárFORCE:; 1582