14f6ad66aSAchin Gupta# 201cf14ddSMaksims Svecovs# Copyright (c) 2013-2023, 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 11b78ad00eSJuan Pablo CondeVERSION_MINOR := 9 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, \ 62a194255dSDaniel Boulby lib/zlib \ 63f0b489c1SDan Handley $(wildcard lib/*))) 64f0b489c1SDan HandleyROOT_DIRS_TO_CHECK := $(sort $(filter-out \ 65f0b489c1SDan Handley lib \ 66f0b489c1SDan Handley include \ 67f0b489c1SDan Handley docs \ 681ef35512SPaul Beesley %.rst, \ 69f0b489c1SDan Handley $(wildcard *))) 70f0b489c1SDan HandleyCHECK_PATHS := ${ROOT_DIRS_TO_CHECK} \ 71f0b489c1SDan Handley ${INC_DIRS_TO_CHECK} \ 72f0b489c1SDan Handley ${INC_LIB_DIRS_TO_CHECK} \ 734501843fSGilad Ben-Yossef ${LIB_DIRS_TO_CHECK} \ 744501843fSGilad Ben-Yossef ${INC_DRV_DIRS_TO_CHECK} \ 754501843fSGilad Ben-Yossef ${INC_ARM_DIRS_TO_CHECK} 7636eaaf37SIan Spray 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################################################################################ 9973c99d4eSJuan Castillo# Toolchain 10073c99d4eSJuan Castillo################################################################################ 10173c99d4eSJuan Castillo 10272610c41Sdp-armHOSTCC := gcc 10372610c41Sdp-armexport HOSTCC 10472610c41Sdp-arm 10573c99d4eSJuan CastilloCC := ${CROSS_COMPILE}gcc 10673c99d4eSJuan CastilloCPP := ${CROSS_COMPILE}cpp 10773c99d4eSJuan CastilloAS := ${CROSS_COMPILE}gcc 10873c99d4eSJuan CastilloAR := ${CROSS_COMPILE}ar 1092adee763SRoberto VargasLINKER := ${CROSS_COMPILE}ld 11073c99d4eSJuan CastilloOC := ${CROSS_COMPILE}objcopy 11173c99d4eSJuan CastilloOD := ${CROSS_COMPILE}objdump 11273c99d4eSJuan CastilloNM := ${CROSS_COMPILE}nm 11373c99d4eSJuan CastilloPP := ${CROSS_COMPILE}gcc -E 11438c14d88SSoby MathewDTC := dtc 11573c99d4eSJuan Castillo 116b25a577fSJulius Werner# Use ${LD}.bfd instead if it exists (as absolute path or together with $PATH). 117b25a577fSJulius Wernerifneq ($(strip $(wildcard ${LD}.bfd) \ 1182adee763SRoberto Vargas $(foreach dir,$(subst :, ,${PATH}),$(wildcard ${dir}/${LINKER}.bfd))),) 1192adee763SRoberto VargasLINKER := ${LINKER}.bfd 120b25a577fSJulius Wernerendif 121b25a577fSJulius Werner 122c5e1da83SJayanth Dodderi Chidanand################################################################################ 123c5e1da83SJayanth Dodderi Chidanand# Auxiliary tools (fiptool, cert_create, etc) 124c5e1da83SJayanth Dodderi Chidanand################################################################################ 125c5e1da83SJayanth Dodderi Chidanand 126c5e1da83SJayanth Dodderi Chidanand# Variables for use with Certificate Generation Tool 127c5e1da83SJayanth Dodderi ChidanandCRTTOOLPATH ?= tools/cert_create 128c5e1da83SJayanth Dodderi ChidanandCRTTOOL ?= ${CRTTOOLPATH}/cert_create${BIN_EXT} 129c5e1da83SJayanth Dodderi Chidanand 130c5e1da83SJayanth Dodderi Chidanand# Variables for use with Firmware Encryption Tool 131c5e1da83SJayanth Dodderi ChidanandENCTOOLPATH ?= tools/encrypt_fw 132c5e1da83SJayanth Dodderi ChidanandENCTOOL ?= ${ENCTOOLPATH}/encrypt_fw${BIN_EXT} 133c5e1da83SJayanth Dodderi Chidanand 134c5e1da83SJayanth Dodderi Chidanand# Variables for use with Firmware Image Package 135c5e1da83SJayanth Dodderi ChidanandFIPTOOLPATH ?= tools/fiptool 136c5e1da83SJayanth Dodderi ChidanandFIPTOOL ?= ${FIPTOOLPATH}/fiptool${BIN_EXT} 137c5e1da83SJayanth Dodderi Chidanand 138c5e1da83SJayanth Dodderi Chidanand# Variables for use with sptool 139c5e1da83SJayanth Dodderi ChidanandSPTOOLPATH ?= tools/sptool 140c5e1da83SJayanth Dodderi ChidanandSPTOOL ?= ${SPTOOLPATH}/sptool.py 141c5e1da83SJayanth Dodderi ChidanandSP_MK_GEN ?= ${SPTOOLPATH}/sp_mk_generator.py 142c5e1da83SJayanth Dodderi Chidanand 143c5e1da83SJayanth Dodderi Chidanand# Variables for use with ROMLIB 144c5e1da83SJayanth Dodderi ChidanandROMLIBPATH ?= lib/romlib 145c5e1da83SJayanth Dodderi Chidanand 146c5e1da83SJayanth Dodderi Chidanand# Variable for use with Python 147c5e1da83SJayanth Dodderi ChidanandPYTHON ?= python3 148c5e1da83SJayanth Dodderi Chidanand 149c5e1da83SJayanth Dodderi Chidanand# Variables for use with documentation build using Sphinx tool 150c5e1da83SJayanth Dodderi ChidanandDOCS_PATH ?= docs 151c5e1da83SJayanth Dodderi Chidanand 152c5e1da83SJayanth Dodderi Chidanand################################################################################ 153c5e1da83SJayanth Dodderi Chidanand# Process BRANCH_PROTECTION value and set 154c5e1da83SJayanth Dodderi Chidanand# Pointer Authentication and Branch Target Identification flags 155c5e1da83SJayanth Dodderi Chidanand################################################################################ 156c5e1da83SJayanth Dodderi Chidanandifeq (${BRANCH_PROTECTION},0) 157c5e1da83SJayanth Dodderi Chidanand # Default value turns off all types of branch protection 158c5e1da83SJayanth Dodderi Chidanand BP_OPTION := none 159c5e1da83SJayanth Dodderi Chidanandelse ifneq (${ARCH},aarch64) 160c5e1da83SJayanth Dodderi Chidanand $(error BRANCH_PROTECTION requires AArch64) 161c5e1da83SJayanth Dodderi Chidanandelse ifeq (${BRANCH_PROTECTION},1) 162c5e1da83SJayanth Dodderi Chidanand # Enables all types of branch protection features 163c5e1da83SJayanth Dodderi Chidanand BP_OPTION := standard 164c5e1da83SJayanth Dodderi Chidanand ENABLE_BTI := 1 165c5e1da83SJayanth Dodderi Chidanand ENABLE_PAUTH := 1 166c5e1da83SJayanth Dodderi Chidanandelse ifeq (${BRANCH_PROTECTION},2) 167c5e1da83SJayanth Dodderi Chidanand # Return address signing to its standard level 168c5e1da83SJayanth Dodderi Chidanand BP_OPTION := pac-ret 169c5e1da83SJayanth Dodderi Chidanand ENABLE_PAUTH := 1 170c5e1da83SJayanth Dodderi Chidanandelse ifeq (${BRANCH_PROTECTION},3) 171c5e1da83SJayanth Dodderi Chidanand # Extend the signing to include leaf functions 172c5e1da83SJayanth Dodderi Chidanand BP_OPTION := pac-ret+leaf 173c5e1da83SJayanth Dodderi Chidanand ENABLE_PAUTH := 1 174c5e1da83SJayanth Dodderi Chidanandelse ifeq (${BRANCH_PROTECTION},4) 175c5e1da83SJayanth Dodderi Chidanand # Turn on branch target identification mechanism 176c5e1da83SJayanth Dodderi Chidanand BP_OPTION := bti 177c5e1da83SJayanth Dodderi Chidanand ENABLE_BTI := 1 178c5e1da83SJayanth Dodderi Chidanandelse 179c5e1da83SJayanth Dodderi Chidanand $(error Unknown BRANCH_PROTECTION value ${BRANCH_PROTECTION}) 180c5e1da83SJayanth Dodderi Chidanandendif #(BRANCH_PROTECTION) 181c5e1da83SJayanth Dodderi Chidanand 182c5e1da83SJayanth Dodderi Chidanand################################################################################ 183c5e1da83SJayanth Dodderi Chidanand# RME dependent flags configuration 184c5e1da83SJayanth Dodderi Chidanand################################################################################ 185c5e1da83SJayanth Dodderi Chidanand# FEAT_RME 186c5e1da83SJayanth Dodderi Chidanandifeq (${ENABLE_RME},1) 187c5e1da83SJayanth Dodderi Chidanand # RME doesn't support PIE 188c5e1da83SJayanth Dodderi Chidanand ifneq (${ENABLE_PIE},0) 189c5e1da83SJayanth Dodderi Chidanand $(error ENABLE_RME does not support PIE) 190c5e1da83SJayanth Dodderi Chidanand endif 191c5e1da83SJayanth Dodderi Chidanand 192c5e1da83SJayanth Dodderi Chidanand # RME doesn't support BRBE 193c5e1da83SJayanth Dodderi Chidanand ifneq (${ENABLE_BRBE_FOR_NS},0) 194c5e1da83SJayanth Dodderi Chidanand $(error ENABLE_RME does not support BRBE.) 195c5e1da83SJayanth Dodderi Chidanand endif 196c5e1da83SJayanth Dodderi Chidanand 197c5e1da83SJayanth Dodderi Chidanand # RME requires AARCH64 198c5e1da83SJayanth Dodderi Chidanand ifneq (${ARCH},aarch64) 199c5e1da83SJayanth Dodderi Chidanand $(error ENABLE_RME requires AArch64) 200c5e1da83SJayanth Dodderi Chidanand endif 201c5e1da83SJayanth Dodderi Chidanand 202c5e1da83SJayanth Dodderi Chidanand # RME requires el2 context to be saved for now. 203c5e1da83SJayanth Dodderi Chidanand CTX_INCLUDE_EL2_REGS := 1 204c5e1da83SJayanth Dodderi Chidanand CTX_INCLUDE_AARCH32_REGS := 0 205c5e1da83SJayanth Dodderi Chidanand ARM_ARCH_MAJOR := 8 206c5e1da83SJayanth Dodderi Chidanand ARM_ARCH_MINOR := 5 207c5e1da83SJayanth Dodderi Chidanand ENABLE_FEAT_ECV = 1 208c5e1da83SJayanth Dodderi Chidanand ENABLE_FEAT_FGT = 1 209c5e1da83SJayanth Dodderi Chidanand CTX_INCLUDE_PAUTH_REGS := 1 210c5e1da83SJayanth Dodderi Chidanand 211c5e1da83SJayanth Dodderi Chidanand # RME enables CSV2_2 extension by default. 212c5e1da83SJayanth Dodderi Chidanand ENABLE_FEAT_CSV2_2 = 1 213c5e1da83SJayanth Dodderi Chidanandendif #(FEAT_RME) 214c5e1da83SJayanth Dodderi Chidanand 215c5e1da83SJayanth Dodderi Chidanand################################################################################ 216c5e1da83SJayanth Dodderi Chidanand# Compiler Configuration based on ARCH_MAJOR and ARCH_MINOR flags 217c5e1da83SJayanth Dodderi Chidanand################################################################################ 21826e63c44SEtienne Carriereifeq (${ARM_ARCH_MAJOR},7) 21926e63c44SEtienne Carriere target32-directive = -target arm-none-eabi 220d4089fb8SGovindraj Raja# Will set march-directive from platform configuration 22126e63c44SEtienne Carriereelse 22226e63c44SEtienne Carriere target32-directive = -target armv8a-none-eabi 223c5e1da83SJayanth Dodderi Chidanandendif #(ARM_ARCH_MAJOR) 224c5e1da83SJayanth Dodderi Chidanand 225c5e1da83SJayanth Dodderi Chidanand################################################################################ 226c5e1da83SJayanth Dodderi Chidanand# Get Architecture Feature Modifiers 227c5e1da83SJayanth Dodderi Chidanand################################################################################ 228c5e1da83SJayanth Dodderi Chidanandarch-features = ${ARM_ARCH_FEATURE} 229c5e1da83SJayanth Dodderi Chidanand 230c5e1da83SJayanth Dodderi Chidanand#################################################### 231c5e1da83SJayanth Dodderi Chidanand# Enable required options for Memory Stack Tagging. 232c5e1da83SJayanth Dodderi Chidanand#################################################### 23326e63c44SEtienne Carriere 2347ff088d1SManish V Badarkhe# Memory tagging is supported in architecture Armv8.5-A AArch64 and onwards 2357ff088d1SManish V Badarkheifeq ($(ARCH), aarch64) 2364a565bd8SSami Mujawar # Check if revision is greater than or equal to 8.5 2374a565bd8SSami Mujawar ifeq "8.5" "$(word 1, $(sort 8.5 $(ARM_ARCH_MAJOR).$(ARM_ARCH_MINOR)))" 2387ff088d1SManish V Badarkhe mem_tag_arch_support = yes 2397ff088d1SManish V Badarkhe endif 240c5e1da83SJayanth Dodderi Chidanandendif #(ARCH=aarch64) 2417ff088d1SManish V Badarkhe 242f1821790SAlexei Fedorov# Currently, these options are enabled only for clang and armclang compiler. 2437ff088d1SManish V Badarkheifeq (${SUPPORT_STACK_MEMTAG},yes) 2447ff088d1SManish V Badarkhe ifdef mem_tag_arch_support 245f1821790SAlexei Fedorov # Check for armclang and clang compilers 2467ff088d1SManish V Badarkhe ifneq ( ,$(filter $(notdir $(CC)),armclang clang)) 247f1821790SAlexei Fedorov # Add "memtag" architecture feature modifier if not specified 248f1821790SAlexei Fedorov ifeq ( ,$(findstring memtag,$(arch-features))) 249f1821790SAlexei Fedorov arch-features := $(arch-features)+memtag 250f1821790SAlexei Fedorov endif # memtag 2517ff088d1SManish V Badarkhe ifeq ($(notdir $(CC)),armclang) 2527ff088d1SManish V Badarkhe TF_CFLAGS += -mmemtag-stack 2537ff088d1SManish V Badarkhe else ifeq ($(notdir $(CC)),clang) 2547ff088d1SManish V Badarkhe TF_CFLAGS += -fsanitize=memtag 255f1821790SAlexei Fedorov endif # armclang 256c5e1da83SJayanth Dodderi Chidanand endif 2577ff088d1SManish V Badarkhe else 258c5e1da83SJayanth Dodderi Chidanand $(error "Error: stack memory tagging is not supported for \ 259c5e1da83SJayanth Dodderi Chidanand architecture ${ARCH},armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a") 260c5e1da83SJayanth Dodderi Chidanand endif #(mem_tag_arch_support) 261c5e1da83SJayanth Dodderi Chidanandendif #(SUPPORT_STACK_MEMTAG) 262f1821790SAlexei Fedorov 263f1821790SAlexei Fedorov# Set the compiler's architecture feature modifiers 264f1821790SAlexei Fedorovifneq ($(arch-features), none) 265f1821790SAlexei Fedorov # Strip "none+" from arch-features 266f1821790SAlexei Fedorov arch-features := $(subst none+,,$(arch-features)) 267d4089fb8SGovindraj Raja march-directive := $(march-directive)+$(arch-features) 268f1821790SAlexei Fedorov# Print features 269f1821790SAlexei Fedorov $(info Arm Architecture Features specified: $(subst +, ,$(arch-features))) 270c5e1da83SJayanth Dodderi Chidanandendif #(arch-features) 2714e04478aSChris Kay 272c8a992fdSoriginifneq ($(findstring clang,$(notdir $(CC))),) 273fd18a8fcSVarun Wadekar ifneq ($(findstring armclang,$(notdir $(CC))),) 274*7794d6c8SGovindraj Raja TF_CFLAGS_aarch32 := -target arm-arm-none-eabi 275*7794d6c8SGovindraj Raja TF_CFLAGS_aarch64 := -target aarch64-arm-none-eabi 276c8a992fdSorigin LD := $(LINKER) 277c8a992fdSorigin else 278*7794d6c8SGovindraj Raja TF_CFLAGS_aarch32 = $(target32-directive) 279*7794d6c8SGovindraj Raja TF_CFLAGS_aarch64 := -target aarch64-elf 280c8a992fdSorigin LD := $(shell $(CC) --print-prog-name ld.lld) 281c8a992fdSorigin 282c8a992fdSorigin AR := $(shell $(CC) --print-prog-name llvm-ar) 283c8a992fdSorigin OD := $(shell $(CC) --print-prog-name llvm-objdump) 284c8a992fdSorigin OC := $(shell $(CC) --print-prog-name llvm-objcopy) 285641f16e7SAmbroise Vincent endif 286c8a992fdSorigin 287c8a992fdSorigin CPP := $(CC) -E $(TF_CFLAGS_$(ARCH)) 288c8a992fdSorigin PP := $(CC) -E $(TF_CFLAGS_$(ARCH)) 289c8a992fdSorigin AS := $(CC) -c -x assembler-with-cpp $(TF_CFLAGS_$(ARCH)) 290edbce9aaSzelalem-awekeelse ifneq ($(findstring gcc,$(notdir $(CC))),) 291edbce9aaSzelalem-aweke ifeq ($(ENABLE_LTO),1) 292edbce9aaSzelalem-aweke # Enable LTO only for aarch64 293edbce9aaSzelalem-aweke ifeq (${ARCH},aarch64) 294edbce9aaSzelalem-aweke LTO_CFLAGS = -flto 295edbce9aaSzelalem-aweke # Use gcc as a wrapper for the ld, recommended for LTO 296edbce9aaSzelalem-aweke LINKER := ${CROSS_COMPILE}gcc 297edbce9aaSzelalem-aweke endif 298edbce9aaSzelalem-aweke endif 299edbce9aaSzelalem-aweke LD = $(LINKER) 300d5461857Sdp-armelse 3012adee763SRoberto Vargas LD = $(LINKER) 302c5e1da83SJayanth Dodderi Chidanandendif #(clang) 303d5461857Sdp-arm 30432b209bfSAhmad Fatoum# Process Debug flag 30532b209bfSAhmad Fatoum$(eval $(call add_define,DEBUG)) 30632b209bfSAhmad Fatoumifneq (${DEBUG}, 0) 30732b209bfSAhmad Fatoum BUILD_TYPE := debug 3084466cf82SDaniel Boulby TF_CFLAGS += -g -gdwarf-4 3094466cf82SDaniel Boulby ASFLAGS += -g -Wa,-gdwarf-4 31032b209bfSAhmad Fatoum 31132b209bfSAhmad Fatoum # Use LOG_LEVEL_INFO by default for debug builds 31232b209bfSAhmad Fatoum LOG_LEVEL := 40 31332b209bfSAhmad Fatoumelse 31432b209bfSAhmad Fatoum BUILD_TYPE := release 31532b209bfSAhmad Fatoum # Use LOG_LEVEL_NOTICE by default for release builds 31632b209bfSAhmad Fatoum LOG_LEVEL := 20 317c5e1da83SJayanth Dodderi Chidanandendif #(Debug) 31832b209bfSAhmad Fatoum 319f1de4c8fSPeiyuan Song# Default build string (git branch and commit) 320f1de4c8fSPeiyuan Songifeq (${BUILD_STRING},) 321f1de4c8fSPeiyuan Song BUILD_STRING := $(shell git describe --always --dirty --tags 2> /dev/null) 322f1de4c8fSPeiyuan Songendif 323dddf4283Slaurenw-armVERSION_STRING := v${VERSION}(${BUILD_TYPE}):${BUILD_STRING} 324f1de4c8fSPeiyuan Song 3258fd9d4d5SAntonio Nino Diazifeq (${AARCH32_INSTRUCTION_SET},A32) 3268fd9d4d5SAntonio Nino Diaz TF_CFLAGS_aarch32 += -marm 3278fd9d4d5SAntonio Nino Diazelse ifeq (${AARCH32_INSTRUCTION_SET},T32) 3288fd9d4d5SAntonio Nino Diaz TF_CFLAGS_aarch32 += -mthumb 3298fd9d4d5SAntonio Nino Diazelse 3308fd9d4d5SAntonio Nino Diaz $(error Error: Unknown AArch32 instruction set ${AARCH32_INSTRUCTION_SET}) 331c5e1da83SJayanth Dodderi Chidanandendif #(AARCH32_INSTRUCTION_SET) 3328fd9d4d5SAntonio Nino Diaz 333a9c4dde3SSandrine BailleuxTF_CFLAGS_aarch32 += -mno-unaligned-access 334d5461857Sdp-armTF_CFLAGS_aarch64 += -mgeneral-regs-only -mstrict-align 3359d29c227SSoby Mathew 3369fc59639SAlexei Fedorovifneq (${BP_OPTION},none) 3379fc59639SAlexei Fedorov TF_CFLAGS_aarch64 += -mbranch-protection=${BP_OPTION} 338c5e1da83SJayanth Dodderi Chidanandendif #(BP_OPTION) 3399fc59639SAlexei Fedorov 340d4089fb8SGovindraj RajaASFLAGS += $(march-directive) 341b86048c4SAntonio Nino Diaz 342c5e1da83SJayanth Dodderi Chidanand############################################################################## 343c5e1da83SJayanth Dodderi Chidanand# WARNINGS Configuration 344c5e1da83SJayanth Dodderi Chidanand############################################################################### 3459ab81b5eSJustin Chadwell# General warnings 3469ab81b5eSJustin ChadwellWARNINGS := -Wall -Wmissing-include-dirs -Wunused \ 347b7f6525dSJustin Chadwell -Wdisabled-optimization -Wvla -Wshadow \ 348d75a9ecdSBoyan Karatotev -Wredundant-decls 349d75a9ecdSBoyan Karatotev# stricter warnings 350d75a9ecdSBoyan KaratotevWARNINGS += -Wextra -Wno-trigraphs 351d75a9ecdSBoyan Karatotev# too verbose for generic build 352d75a9ecdSBoyan KaratotevWARNINGS += -Wno-missing-field-initializers \ 353d75a9ecdSBoyan Karatotev -Wno-type-limits -Wno-sign-compare \ 354d75a9ecdSBoyan Karatotev# on clang this flag gets reset if -Wextra is set after it. No difference on gcc 355d75a9ecdSBoyan KaratotevWARNINGS += -Wno-unused-parameter 3569ab81b5eSJustin Chadwell 3579ab81b5eSJustin Chadwell# Additional warnings 358d75a9ecdSBoyan Karatotev# Level 1 - infrequent warnings we should have none of 359d75a9ecdSBoyan Karatotev# full -Wextra 360d75a9ecdSBoyan KaratotevWARNING1 += -Wsign-compare 361d75a9ecdSBoyan KaratotevWARNING1 += -Wtype-limits 362d75a9ecdSBoyan KaratotevWARNING1 += -Wmissing-field-initializers 363e7c645b5SYann Gautier 364d75a9ecdSBoyan Karatotev# Level 2 - problematic warnings that we want 365d75a9ecdSBoyan Karatotev# zlib, compiler-rt, coreboot, and mbdedtls blow up with these 366d75a9ecdSBoyan Karatotev# TODO: disable just for them and move into default build 367d75a9ecdSBoyan KaratotevWARNING2 += -Wold-style-definition 368d75a9ecdSBoyan KaratotevWARNING2 += -Wmissing-prototypes 369d75a9ecdSBoyan KaratotevWARNING2 += -Wmissing-format-attribute 370d75a9ecdSBoyan Karatotev# TF-A aims to comply with this eventually. Effort too large at present 371d75a9ecdSBoyan KaratotevWARNING2 += -Wundef 372d141e638SBoyan Karatotev# currently very involved and many platforms set this off 373d141e638SBoyan KaratotevWARNING2 += -Wunused-const-variable=2 374e7c645b5SYann Gautier 375d75a9ecdSBoyan Karatotev# Level 3 - very pedantic, frequently ignored 376e7c645b5SYann GautierWARNING3 := -Wbad-function-cast 377d75a9ecdSBoyan KaratotevWARNING3 += -Waggregate-return 378d75a9ecdSBoyan KaratotevWARNING3 += -Wnested-externs 379d75a9ecdSBoyan KaratotevWARNING3 += -Wcast-align 380e7c645b5SYann GautierWARNING3 += -Wcast-qual 381e7c645b5SYann GautierWARNING3 += -Wconversion 382e7c645b5SYann GautierWARNING3 += -Wpacked 383e7c645b5SYann GautierWARNING3 += -Wpointer-arith 384e7c645b5SYann GautierWARNING3 += -Wswitch-default 385e7c645b5SYann Gautier 386d75a9ecdSBoyan Karatotev# Setting W is quite verbose and most warnings will be pre-existing issues 387d75a9ecdSBoyan Karatotev# outside of the contributor's control. Don't fail the build on them so warnings 388d75a9ecdSBoyan Karatotev# can be seen and hopefully addressed 389d75a9ecdSBoyan Karatotevifdef W 390d75a9ecdSBoyan Karatotev ifneq (${W},0) 391d75a9ecdSBoyan Karatotev E ?= 0 392d75a9ecdSBoyan Karatotev endif 393d75a9ecdSBoyan Karatotevendif 394d75a9ecdSBoyan Karatotev 395e7c645b5SYann Gautierifeq (${W},1) 3969ab81b5eSJustin Chadwell WARNINGS += $(WARNING1) 397e7c645b5SYann Gautierelse ifeq (${W},2) 3989ab81b5eSJustin Chadwell WARNINGS += $(WARNING1) $(WARNING2) 399e7c645b5SYann Gautierelse ifeq (${W},3) 4009ab81b5eSJustin Chadwell WARNINGS += $(WARNING1) $(WARNING2) $(WARNING3) 401c5e1da83SJayanth Dodderi Chidanandendif #(W) 402e7c645b5SYann Gautier 4039ab81b5eSJustin Chadwell# Compiler specific warnings 40400296576SAmbroise Vincentifeq ($(findstring clang,$(notdir $(CC))),) 40593c690ebSJustin Chadwell# not using clang 406d7b4cd41SJustin ChadwellWARNINGS += -Wunused-but-set-variable -Wmaybe-uninitialized \ 407d7b4cd41SJustin Chadwell -Wpacked-bitfield-compat -Wshift-overflow=2 \ 408d7b4cd41SJustin Chadwell -Wlogical-op 409dea23e24SGovindraj Raja 410dea23e24SGovindraj Raja# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105523 411dea23e24SGovindraj RajaTF_CFLAGS += $(call cc_option, --param=min-pagesize=0) 412dea23e24SGovindraj Raja 41393c690ebSJustin Chadwellelse 41493c690ebSJustin Chadwell# using clang 415d7b4cd41SJustin ChadwellWARNINGS += -Wshift-overflow -Wshift-sign-overflow \ 416d7b4cd41SJustin Chadwell -Wlogical-op-parentheses 417c5e1da83SJayanth Dodderi Chidanandendif #(Clang Warning) 41800296576SAmbroise Vincent 4196336b07aSYann Gautierifneq (${E},0) 4206336b07aSYann Gautier ERRORS := -Werror 421c5e1da83SJayanth Dodderi Chidanandendif #(E) 4226336b07aSYann Gautier 423c5e1da83SJayanth Dodderi Chidanand################################################################################ 424c5e1da83SJayanth Dodderi Chidanand# Compiler and Linker Directives 425c5e1da83SJayanth Dodderi Chidanand################################################################################ 426ea7a57a3SRoberto VargasCPPFLAGS = ${DEFINES} ${INCLUDES} ${MBEDTLS_INC} -nostdinc \ 4279ab81b5eSJustin Chadwell $(ERRORS) $(WARNINGS) 428d4089fb8SGovindraj RajaASFLAGS += $(CPPFLAGS) \ 429d5dfdeb6SJulius Werner -ffreestanding -Wa,--fatal-warnings 43059de5096SMasahiro YamadaTF_CFLAGS += $(CPPFLAGS) $(TF_CFLAGS_$(ARCH)) \ 431ebd6efaeSSamuel Holland -ffunction-sections -fdata-sections \ 432ebd6efaeSSamuel Holland -ffreestanding -fno-builtin -fno-common \ 433ebd6efaeSSamuel Holland -Os -std=gnu99 43473c99d4eSJuan Castillo 4351f461979SJustin Chadwellifeq (${SANITIZE_UB},on) 4361f461979SJustin Chadwell TF_CFLAGS += -fsanitize=undefined -fno-sanitize-recover 437c5e1da83SJayanth Dodderi Chidanandendif #(${SANITIZE_UB},on) 438c5e1da83SJayanth Dodderi Chidanand 4391f461979SJustin Chadwellifeq (${SANITIZE_UB},trap) 4401f461979SJustin Chadwell TF_CFLAGS += -fsanitize=undefined -fno-sanitize-recover \ 4411f461979SJustin Chadwell -fsanitize-undefined-trap-on-error 442c5e1da83SJayanth Dodderi Chidanandendif #(${SANITIZE_UB},trap) 4431f461979SJustin Chadwell 444f7ec31dbSdavid cunadoGCC_V_OUTPUT := $(shell $(CC) -v 2>&1) 445f7ec31dbSdavid cunado 4461f49db5fSMarco FelschTF_LDFLAGS += -z noexecstack 4471f49db5fSMarco Felsch 448641f16e7SAmbroise Vincent# LD = armlink 449c2ad38ceSVarun Wadekarifneq ($(findstring armlink,$(notdir $(LD))),) 450c2ad38ceSVarun Wadekar TF_LDFLAGS += --diag_error=warning --lto_level=O1 451c2ad38ceSVarun Wadekar TF_LDFLAGS += --remove --info=unused,unusedsymbols 452edbce9aaSzelalem-aweke TF_LDFLAGS += $(TF_LDFLAGS_$(ARCH)) 453641f16e7SAmbroise Vincent 454641f16e7SAmbroise Vincent# LD = gcc (used when GCC LTO is enabled) 455edbce9aaSzelalem-awekeelse ifneq ($(findstring gcc,$(notdir $(LD))),) 456edbce9aaSzelalem-aweke # Pass ld options with Wl or Xlinker switches 457edbce9aaSzelalem-aweke TF_LDFLAGS += -Wl,--fatal-warnings -O1 458edbce9aaSzelalem-aweke TF_LDFLAGS += -Wl,--gc-sections 459ac98b82aSChris Kay 460ac98b82aSChris Kay TF_LDFLAGS += -Wl,-z,common-page-size=4096 #Configure page size constants 461ac98b82aSChris Kay TF_LDFLAGS += -Wl,-z,max-page-size=4096 462ac98b82aSChris Kay 463edbce9aaSzelalem-aweke ifeq ($(ENABLE_LTO),1) 464edbce9aaSzelalem-aweke ifeq (${ARCH},aarch64) 465edbce9aaSzelalem-aweke TF_LDFLAGS += -flto -fuse-linker-plugin 466edbce9aaSzelalem-aweke endif 467c5e1da83SJayanth Dodderi Chidanand endif #(ENABLE_LTO) 468c5e1da83SJayanth Dodderi Chidanand 469edbce9aaSzelalem-aweke# GCC automatically adds fix-cortex-a53-843419 flag when used to link 470edbce9aaSzelalem-aweke# which breaks some builds, so disable if errata fix is not explicitly enabled 471edbce9aaSzelalem-aweke ifneq (${ERRATA_A53_843419},1) 472edbce9aaSzelalem-aweke TF_LDFLAGS += -mno-fix-cortex-a53-843419 473edbce9aaSzelalem-aweke endif 474edbce9aaSzelalem-aweke TF_LDFLAGS += -nostdlib 475edbce9aaSzelalem-aweke TF_LDFLAGS += $(subst --,-Xlinker --,$(TF_LDFLAGS_$(ARCH))) 476641f16e7SAmbroise Vincent 477641f16e7SAmbroise Vincent# LD = gcc-ld (ld) or llvm-ld (ld.lld) or other 478c2ad38ceSVarun Wadekarelse 4791f49db5fSMarco Felsch# With ld.bfd version 2.39 and newer new warnings are added. Skip those since we 4801f49db5fSMarco Felsch# are not loaded by a elf loader. 4811f49db5fSMarco Felsch TF_LDFLAGS += $(call ld_option, --no-warn-rwx-segments) 482ebac6922SYabin Cui TF_LDFLAGS += -O1 483c2b8806fSDouglas Raillard TF_LDFLAGS += --gc-sections 484ac98b82aSChris Kay 485ac98b82aSChris Kay TF_LDFLAGS += -z common-page-size=4096 # Configure page size constants 486ac98b82aSChris Kay TF_LDFLAGS += -z max-page-size=4096 487ac98b82aSChris Kay 488641f16e7SAmbroise Vincent# ld.lld doesn't recognize the errata flags, 489ebac6922SYabin Cui# therefore don't add those in that case. 490ebac6922SYabin Cui# ld.lld reports section type mismatch warnings, 491ebac6922SYabin Cui# therefore don't add --fatal-warnings to it. 492641f16e7SAmbroise Vincent ifeq ($(findstring ld.lld,$(notdir $(LD))),) 493ebac6922SYabin Cui TF_LDFLAGS += $(TF_LDFLAGS_$(ARCH)) --fatal-warnings 494edbce9aaSzelalem-aweke endif 495c5e1da83SJayanth Dodderi Chidanand 496c5e1da83SJayanth Dodderi Chidanandendif #(LD = armlink) 49773c99d4eSJuan Castillo 49803b397a8SNishanth MenonDTC_FLAGS += -I dts -O dtb 499a6de824fSLouis MayencourtDTC_CPPFLAGS += -P -nostdinc -Iinclude -Ifdts -undef \ 500a6de824fSLouis Mayencourt -x assembler-with-cpp $(DEFINES) 50103b397a8SNishanth Menon 50273c99d4eSJuan Castillo################################################################################ 50373c99d4eSJuan Castillo# Common sources and include directories 50473c99d4eSJuan Castillo################################################################################ 5056a0da736SJayanth Dodderi Chidanandinclude ${MAKE_HELPERS_DIRECTORY}arch_features.mk 506d801fbb0Sdp-arminclude lib/compiler-rt/compiler-rt.mk 50773c99d4eSJuan Castillo 50873c99d4eSJuan CastilloBL_COMMON_SOURCES += common/bl_common.c \ 5097f56e9a3SSoby Mathew common/tf_log.c \ 5109d29c227SSoby Mathew common/${ARCH}/debug.S \ 51191b48c9fSJulius Werner drivers/console/multi_console.c \ 5129d29c227SSoby Mathew lib/${ARCH}/cache_helpers.S \ 5139d29c227SSoby Mathew lib/${ARCH}/misc_helpers.S \ 514c73686a1SBoyan Karatotev lib/extensions/pmuv3/${ARCH}/pmuv3.c \ 515566034fcSSoby Mathew plat/common/plat_bl_common.c \ 5167f56e9a3SSoby Mathew plat/common/plat_log_common.c \ 51775311203Sdp-arm plat/common/${ARCH}/plat_common.c \ 5189d29c227SSoby Mathew plat/common/${ARCH}/platform_helpers.S \ 51961f72a34SRoberto Vargas ${COMPILER_RT_SRCS} 520d7a6b0f8SRyan Harkin 52190ce8b87SBoyan Karatotev# Pointer Authentication sources 52290ce8b87SBoyan Karatotevifeq (${ENABLE_PAUTH}, 1) 52390ce8b87SBoyan Karatotev# arm/common/aarch64/arm_pauth.c contains a sample platform hook to complete the 52490ce8b87SBoyan Karatotev# Pauth support. As it's not secure, it must be reimplemented for real platforms 52590ce8b87SBoyan Karatotev BL_COMMON_SOURCES += lib/extensions/pauth/pauth_helpers.S 52690ce8b87SBoyan Karatotevendif 52790ce8b87SBoyan Karatotev 5288422a840SAntonio Nino Diazifeq ($(notdir $(CC)),armclang) 5298422a840SAntonio Nino Diaz BL_COMMON_SOURCES += lib/${ARCH}/armclang_printf.S 5308422a840SAntonio Nino Diazendif 5318422a840SAntonio Nino Diaz 5321f461979SJustin Chadwellifeq (${SANITIZE_UB},on) 5331f461979SJustin Chadwell BL_COMMON_SOURCES += plat/common/ubsan.c 5341f461979SJustin Chadwellendif 5351f461979SJustin Chadwell 53601d237cbSYann GautierINCLUDES += -Iinclude \ 537f5478dedSAntonio Nino Diaz -Iinclude/arch/${ARCH} \ 53809d40e0eSAntonio Nino Diaz -Iinclude/lib/cpus/${ARCH} \ 53909d40e0eSAntonio Nino Diaz -Iinclude/lib/el3_runtime/${ARCH} \ 54009d40e0eSAntonio Nino Diaz ${PLAT_INCLUDES} \ 54109d40e0eSAntonio Nino Diaz ${SPD_INCLUDES} 54209d40e0eSAntonio Nino Diaz 5439c6d1c50SAntonio Nino Diazinclude common/backtrace/backtrace.mk 5449c6d1c50SAntonio Nino Diaz 54573c99d4eSJuan Castillo################################################################################ 54673c99d4eSJuan Castillo# Generic definitions 54773c99d4eSJuan Castillo################################################################################ 548231c1470SEvan Lloydinclude ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk 549231c1470SEvan Lloyd 55029214e95SGrant Likelyifeq (${BUILD_BASE},) 55173c99d4eSJuan Castillo BUILD_BASE := ./build 55229214e95SGrant Likelyendif 55329214e95SGrant LikelyBUILD_PLAT := $(abspath ${BUILD_BASE})/${PLAT}/${BUILD_TYPE} 55473c99d4eSJuan Castillo 555231c1470SEvan LloydSPDS := $(sort $(filter-out none, $(patsubst services/spd/%,%,$(wildcard services/spd/*)))) 55673c99d4eSJuan Castillo 55773c99d4eSJuan Castillo# Platforms providing their own TBB makefile may override this value 55873c99d4eSJuan CastilloINCLUDE_TBBR_MK := 1 55973c99d4eSJuan Castillo 56073c99d4eSJuan Castillo################################################################################ 56173c99d4eSJuan Castillo# Include SPD Makefile if one has been specified 56273c99d4eSJuan Castillo################################################################################ 56373c99d4eSJuan Castillo 56473c99d4eSJuan Castilloifneq (${SPD},none) 5659d29c227SSoby Mathew ifeq (${ARCH},aarch32) 5669d29c227SSoby Mathew $(error "Error: SPD is incompatible with AArch32.") 5679d29c227SSoby Mathew endif 56828f39f02SMax Shvetsov 5694c117f6cSSandrine Bailleux ifdef EL3_PAYLOAD_BASE 5704c117f6cSSandrine Bailleux $(warning "SPD and EL3_PAYLOAD_BASE are incompatible build options.") 571c5e1da83SJayanth Dodderi Chidanand $(warning "The SPD and its BL32 companion will be present but \ 572c5e1da83SJayanth Dodderi Chidanand ignored.") 5734c117f6cSSandrine Bailleux endif 57428f39f02SMax Shvetsov 575c3fb00d9SAchin Gupta ifeq (${SPD},spmd) 576c3fb00d9SAchin Gupta # SPMD is located in std_svc directory 577c3fb00d9SAchin Gupta SPD_DIR := std_svc 57828f39f02SMax Shvetsov 579033039f8SMax Shvetsov ifeq ($(SPMD_SPM_AT_SEL2),1) 580f1910cc1SGovindraj Raja CTX_INCLUDE_EL2_REGS := 1 5811d63ae4dSMarc Bonnici ifeq ($(SPMC_AT_EL3),1) 5821d63ae4dSMarc Bonnici $(error SPM cannot be enabled in both S-EL2 and EL3.) 5831d63ae4dSMarc Bonnici endif 58428f39f02SMax Shvetsov endif 585db1ef41aSOlivier Deprez 586db1ef41aSOlivier Deprez ifeq ($(findstring optee_sp,$(ARM_SPMC_MANIFEST_DTS)),optee_sp) 587db1ef41aSOlivier Deprez DTC_CPPFLAGS += -DOPTEE_SP_FW_CONFIG 588db1ef41aSOlivier Deprez endif 589ca932481SDavidson K 590ca932481SDavidson K ifeq ($(TS_SP_FW_CONFIG),1) 591ca932481SDavidson K DTC_CPPFLAGS += -DTS_SP_FW_CONFIG 592ca932481SDavidson K endif 59333993a37SBalint Dobszay 59433993a37SBalint Dobszay ifneq ($(ARM_BL2_SP_LIST_DTS),) 59533993a37SBalint Dobszay DTC_CPPFLAGS += -DARM_BL2_SP_LIST_DTS=$(ARM_BL2_SP_LIST_DTS) 59633993a37SBalint Dobszay endif 59746789a7cSBalint Dobszay 59846789a7cSBalint Dobszay ifneq ($(SP_LAYOUT_FILE),) 59946789a7cSBalint Dobszay BL2_ENABLE_SP_LOAD := 1 60046789a7cSBalint Dobszay endif 601c3fb00d9SAchin Gupta else 602c3fb00d9SAchin Gupta # All other SPDs in spd directory 603c3fb00d9SAchin Gupta SPD_DIR := spd 604c5e1da83SJayanth Dodderi Chidanand endif #(SPD) 605c3fb00d9SAchin Gupta 60673c99d4eSJuan Castillo # We expect to locate an spd.mk under the specified SPD directory 607c3fb00d9SAchin Gupta SPD_MAKE := $(wildcard services/${SPD_DIR}/${SPD}/${SPD}.mk) 608c3fb00d9SAchin Gupta 60973c99d4eSJuan Castillo ifeq (${SPD_MAKE},) 610c3fb00d9SAchin Gupta $(error Error: No services/${SPD_DIR}/${SPD}/${SPD}.mk located) 61173c99d4eSJuan Castillo endif 61273c99d4eSJuan Castillo $(info Including ${SPD_MAKE}) 61373c99d4eSJuan Castillo include ${SPD_MAKE} 61473c99d4eSJuan Castillo 61570d1fc53SJuan Castillo # If there's BL32 companion for the chosen SPD, we expect that the SPD's 61670d1fc53SJuan Castillo # Makefile would set NEED_BL32 to "yes". In this case, the build system 61770d1fc53SJuan Castillo # supports two mutually exclusive options: 61870d1fc53SJuan Castillo # * BL32 is built from source: then BL32_SOURCES must contain the list 61970d1fc53SJuan Castillo # of source files to build BL32 62070d1fc53SJuan Castillo # * BL32 is a prebuilt binary: then BL32 must point to the image file 62170d1fc53SJuan Castillo # that will be included in the FIP 62270d1fc53SJuan Castillo # If both BL32_SOURCES and BL32 are defined, the binary takes precedence 62370d1fc53SJuan Castillo # over the sources. 624c5e1da83SJayanth Dodderi Chidanandendif #(SPD=none) 625e35c4045SJeenu Viswambharan 626f1910cc1SGovindraj Rajaifeq (${CTX_INCLUDE_EL2_REGS}, 1) 627f1910cc1SGovindraj Raja ifeq (${SPD},none) 628f1910cc1SGovindraj Raja ifeq (${ENABLE_RME},0) 629c5e1da83SJayanth Dodderi Chidanand $(error CTX_INCLUDE_EL2_REGS is available only when SPD \ 630c5e1da83SJayanth Dodderi Chidanand or RME is enabled) 631f1910cc1SGovindraj Raja endif 632f1910cc1SGovindraj Raja endif 633f1910cc1SGovindraj Rajaendif 634f1910cc1SGovindraj Raja 63551faada7SDouglas Raillard################################################################################ 6365b18de09SZelalem Aweke# Include rmmd Makefile if RME is enabled 6375b18de09SZelalem Aweke################################################################################ 6385b18de09SZelalem Awekeifneq (${ENABLE_RME},0) 6395b18de09SZelalem Aweke ifneq (${ARCH},aarch64) 6405b18de09SZelalem Aweke $(error ENABLE_RME requires AArch64) 6415b18de09SZelalem Aweke endif 6421d63ae4dSMarc Bonnici ifeq ($(SPMC_AT_EL3),1) 6431d63ae4dSMarc Bonnici $(error SPMC_AT_EL3 and ENABLE_RME cannot both be enabled.) 6441d63ae4dSMarc Bonnici endif 645c5e1da83SJayanth Dodderi Chidanand 6464fba2e1fSBoyan Karatotev ifneq (${SPD}, none) 6474fba2e1fSBoyan Karatotev ifneq (${SPD}, spmd) 6484fba2e1fSBoyan Karatotev $(error ENABLE_RME is incompatible with SPD=${SPD}. Use SPD=spmd) 6494fba2e1fSBoyan Karatotev endif 6504fba2e1fSBoyan Karatotev endif 6515b18de09SZelalem Awekeinclude services/std_svc/rmmd/rmmd.mk 6525b18de09SZelalem Aweke$(warning "RME is an experimental feature") 6535b18de09SZelalem Awekeendif 6545b18de09SZelalem Aweke 6555b18de09SZelalem Aweke################################################################################ 65673c99d4eSJuan Castillo# Include the platform specific Makefile after the SPD Makefile (the platform 65773c99d4eSJuan Castillo# makefile may use all previous definitions in this file) 65873c99d4eSJuan Castillo################################################################################ 6592da8d8bfSJeenu Viswambharan 66073c99d4eSJuan Castilloinclude ${PLAT_MAKEFILE_FULL} 6610f21c547SJuan Castillo 662*7794d6c8SGovindraj Raja################################################################################ 663*7794d6c8SGovindraj Raja# Platform specific Makefile might provide us ARCH_MAJOR/MINOR use that to come 664*7794d6c8SGovindraj Raja# up with appropriate march values for compiler. 665*7794d6c8SGovindraj Raja################################################################################ 666*7794d6c8SGovindraj Rajainclude ${MAKE_HELPERS_DIRECTORY}march.mk 667*7794d6c8SGovindraj Raja 668*7794d6c8SGovindraj RajaTF_CFLAGS += $(march-directive) 669*7794d6c8SGovindraj Raja 67042d4d3baSArvind Ram Prakash# This internal flag is common option which is set to 1 for scenarios 67142d4d3baSArvind Ram Prakash# when the BL2 is running in EL3 level. This occurs in two scenarios - 67242d4d3baSArvind Ram Prakash# 4 world system running BL2 at EL3 and two world system without BL1 running 67342d4d3baSArvind Ram Prakash# BL2 in EL3 67442d4d3baSArvind Ram Prakash 67542d4d3baSArvind Ram Prakashifeq (${RESET_TO_BL2},1) 67642d4d3baSArvind Ram Prakash BL2_RUNS_AT_EL3 := 1 67742d4d3baSArvind Ram Prakash ifeq (${ENABLE_RME},1) 678c5e1da83SJayanth Dodderi Chidanand $(error RESET_TO_BL2=1 and ENABLE_RME=1 configuration is not \ 679c5e1da83SJayanth Dodderi Chidanand supported at the moment.) 68042d4d3baSArvind Ram Prakash endif 68142d4d3baSArvind Ram Prakashelse ifeq (${ENABLE_RME},1) 68242d4d3baSArvind Ram Prakash BL2_RUNS_AT_EL3 := 1 68342d4d3baSArvind Ram Prakashelse 68442d4d3baSArvind Ram Prakash BL2_RUNS_AT_EL3 := 0 68542d4d3baSArvind Ram Prakashendif 68642d4d3baSArvind Ram Prakash 6878012cc5cSMasahiro Yamada$(eval $(call MAKE_PREREQ_DIR,${BUILD_PLAT})) 6888012cc5cSMasahiro Yamada 68926e63c44SEtienne Carriereifeq (${ARM_ARCH_MAJOR},7) 69026e63c44SEtienne Carriereinclude make_helpers/armv7-a-cpus.mk 69126e63c44SEtienne Carriereendif 69226e63c44SEtienne Carriere 6933bd17c0fSSoby MathewPIE_FOUND := $(findstring --enable-default-pie,${GCC_V_OUTPUT}) 6943bd17c0fSSoby Mathewifneq ($(PIE_FOUND),) 6953bd17c0fSSoby Mathew TF_CFLAGS += -fno-PIE 6967b592418SSamuel Hollandifneq ($(findstring gcc,$(notdir $(LD))),) 6977b592418SSamuel Holland TF_LDFLAGS += -no-pie 6987b592418SSamuel Hollandendif 699c5e1da83SJayanth Dodderi Chidanandendif #(PIE_FOUND) 700320920c1SMasahiro Yamada 701320920c1SMasahiro Yamadaifneq ($(findstring gcc,$(notdir $(LD))),) 702320920c1SMasahiro Yamada PIE_LDFLAGS += -Wl,-pie -Wl,--no-dynamic-linker 703320920c1SMasahiro Yamadaelse 704320920c1SMasahiro Yamada PIE_LDFLAGS += -pie --no-dynamic-linker 705320920c1SMasahiro Yamadaendif 706320920c1SMasahiro Yamada 707320920c1SMasahiro Yamadaifeq ($(ENABLE_PIE),1) 70842d4d3baSArvind Ram Prakash ifeq ($(RESET_TO_BL2),1) 70969af7fcfSMasahiro Yamada ifneq ($(BL2_IN_XIP_MEM),1) 710966660ecSChris Kay BL2_CPPFLAGS += -fpie 71169af7fcfSMasahiro Yamada BL2_CFLAGS += -fpie 71269af7fcfSMasahiro Yamada BL2_LDFLAGS += $(PIE_LDFLAGS) 713c5e1da83SJayanth Dodderi Chidanand endif #(BL2_IN_XIP_MEM) 714c5e1da83SJayanth Dodderi Chidanand endif #(RESET_TO_BL2) 715966660ecSChris Kay BL31_CPPFLAGS += -fpie 716320920c1SMasahiro Yamada BL31_CFLAGS += -fpie 717320920c1SMasahiro Yamada BL31_LDFLAGS += $(PIE_LDFLAGS) 718966660ecSChris Kay 719966660ecSChris Kay BL32_CPPFLAGS += -fpie 720d974301dSMasahiro Yamada BL32_CFLAGS += -fpie 721d974301dSMasahiro Yamada BL32_LDFLAGS += $(PIE_LDFLAGS) 722c5e1da83SJayanth Dodderi Chidanandendif #(ENABLE_PIE) 7233bd17c0fSSoby Mathew 724007433d8SBoyan KaratotevBL1_CPPFLAGS += -DREPORT_ERRATA=${DEBUG} 725007433d8SBoyan KaratotevBL31_CPPFLAGS += -DREPORT_ERRATA=${DEBUG} 726007433d8SBoyan KaratotevBL32_CPPFLAGS += -DREPORT_ERRATA=${DEBUG} 727007433d8SBoyan Karatotev 7289cefb4b1SMasahiro YamadaBL1_CPPFLAGS += -DIMAGE_AT_EL3 72942d4d3baSArvind Ram Prakashifeq ($(RESET_TO_BL2),1) 7309cefb4b1SMasahiro Yamada BL2_CPPFLAGS += -DIMAGE_AT_EL3 731d5e97a1dSMasahiro Yamadaelse 7329cefb4b1SMasahiro Yamada BL2_CPPFLAGS += -DIMAGE_AT_EL1 733c5e1da83SJayanth Dodderi Chidanandendif #(RESET_TO_BL2) 734007433d8SBoyan Karatotev 735007433d8SBoyan Karatotevifeq (${ARCH},aarch64) 7369cefb4b1SMasahiro Yamada BL2U_CPPFLAGS += -DIMAGE_AT_EL1 7379cefb4b1SMasahiro Yamada BL31_CPPFLAGS += -DIMAGE_AT_EL3 7389cefb4b1SMasahiro Yamada BL32_CPPFLAGS += -DIMAGE_AT_EL1 739007433d8SBoyan Karatotevelse 740007433d8SBoyan Karatotev BL32_CPPFLAGS += -DIMAGE_AT_EL3 741d5e97a1dSMasahiro Yamadaendif 742d5e97a1dSMasahiro Yamada 74354035fc4SSandrine Bailleux# Include the CPU specific operations makefile, which provides default 74454035fc4SSandrine Bailleux# values for all CPU errata workarounds and CPU specific optimisations. 74554035fc4SSandrine Bailleux# This can be overridden by the platform. 74673c99d4eSJuan Castilloinclude lib/cpus/cpu-ops.mk 7474f6ad66aSAchin Gupta 748a4409008Sdp-arm################################################################################ 749a4409008Sdp-arm# Build `AARCH32_SP` as BL32 image for AArch32 750a4409008Sdp-arm################################################################################ 751c5e1da83SJayanth Dodderi Chidanandifeq (${ARCH},aarch32) 752c5e1da83SJayanth Dodderi Chidanand NEED_BL32 := yes 753c5e1da83SJayanth Dodderi Chidanand 754a4409008Sdp-arm ifneq (${AARCH32_SP},none) 755a4409008Sdp-arm # We expect to locate an sp.mk under the specified AARCH32_SP directory 756a4409008Sdp-arm AARCH32_SP_MAKE := $(wildcard bl32/${AARCH32_SP}/${AARCH32_SP}.mk) 757a4409008Sdp-arm 758a4409008Sdp-arm ifeq (${AARCH32_SP_MAKE},) 759a4409008Sdp-arm $(error Error: No bl32/${AARCH32_SP}/${AARCH32_SP}.mk located) 760a4409008Sdp-arm endif 761a4409008Sdp-arm $(info Including ${AARCH32_SP_MAKE}) 762a4409008Sdp-arm include ${AARCH32_SP_MAKE} 763a4409008Sdp-arm endif 764c5e1da83SJayanth Dodderi Chidanandendif #(ARCH=aarch32) 7654f6ad66aSAchin Gupta 76673c99d4eSJuan Castillo################################################################################ 76777f1f7a1SVarun Wadekar# Include libc if not overridden 76877f1f7a1SVarun Wadekar################################################################################ 76977f1f7a1SVarun Wadekarifeq (${OVERRIDE_LIBC},0) 77077f1f7a1SVarun Wadekarinclude lib/libc/libc.mk 77177f1f7a1SVarun Wadekarendif 77277f1f7a1SVarun Wadekar 77377f1f7a1SVarun Wadekar################################################################################ 774c5e1da83SJayanth Dodderi Chidanand# Check incompatible options and dependencies 775cf2c8a33SAntonio Nino Diaz################################################################################ 776cf2c8a33SAntonio Nino Diaz 777c5e1da83SJayanth Dodderi Chidanand# USE_DEBUGFS experimental feature recommended only in debug builds 778c5e1da83SJayanth Dodderi Chidanandifeq (${USE_DEBUGFS},1) 779c5e1da83SJayanth Dodderi Chidanand ifeq (${DEBUG},1) 780c5e1da83SJayanth Dodderi Chidanand $(warning DEBUGFS experimental feature is enabled.) 781c5e1da83SJayanth Dodderi Chidanand else 782c5e1da83SJayanth Dodderi Chidanand $(warning DEBUGFS experimental, recommended in DEBUG builds ONLY) 783c5e1da83SJayanth Dodderi Chidanand endif 784c5e1da83SJayanth Dodderi Chidanandendif #(USE_DEBUGFS) 785c5e1da83SJayanth Dodderi Chidanand 786c5e1da83SJayanth Dodderi Chidanand# USE_SPINLOCK_CAS requires AArch64 build 787c5e1da83SJayanth Dodderi Chidanandifeq (${USE_SPINLOCK_CAS},1) 788c5e1da83SJayanth Dodderi Chidanand ifneq (${ARCH},aarch64) 789c5e1da83SJayanth Dodderi Chidanand $(error USE_SPINLOCK_CAS requires AArch64) 790c5e1da83SJayanth Dodderi Chidanand endif 791c5e1da83SJayanth Dodderi Chidanandendif #(USE_SPINLOCK_CAS) 792c5e1da83SJayanth Dodderi Chidanand 793c5e1da83SJayanth Dodderi Chidanand# The cert_create tool cannot generate certificates individually, so we use the 794c5e1da83SJayanth Dodderi Chidanand# target 'certificates' to create them all 795c5e1da83SJayanth Dodderi Chidanandifneq (${GENERATE_COT},0) 796c5e1da83SJayanth Dodderi Chidanand FIP_DEPS += certificates 797c5e1da83SJayanth Dodderi Chidanand FWU_FIP_DEPS += fwu_certificates 798c5e1da83SJayanth Dodderi Chidanandendif 799c5e1da83SJayanth Dodderi Chidanand 800c5e1da83SJayanth Dodderi Chidanandifneq (${DECRYPTION_SUPPORT},none) 801c5e1da83SJayanth Dodderi Chidanand ENC_ARGS += -f ${FW_ENC_STATUS} 802c5e1da83SJayanth Dodderi Chidanand ENC_ARGS += -k ${ENC_KEY} 803c5e1da83SJayanth Dodderi Chidanand ENC_ARGS += -n ${ENC_NONCE} 804c5e1da83SJayanth Dodderi Chidanand FIP_DEPS += enctool 805c5e1da83SJayanth Dodderi Chidanand FWU_FIP_DEPS += enctool 806c5e1da83SJayanth Dodderi Chidanandendif #(DECRYPTION_SUPPORT) 807c5e1da83SJayanth Dodderi Chidanand 808cf2c8a33SAntonio Nino Diazifdef EL3_PAYLOAD_BASE 80968450a6dSAntonio Nino Diaz ifdef PRELOADED_BL33_BASE 81068450a6dSAntonio Nino Diaz $(warning "PRELOADED_BL33_BASE and EL3_PAYLOAD_BASE are \ 81168450a6dSAntonio Nino Diaz incompatible build options. EL3_PAYLOAD_BASE has priority.") 812cf2c8a33SAntonio Nino Diaz endif 81376580f3dSQixiang Xu ifneq (${GENERATE_COT},0) 814c5e1da83SJayanth Dodderi Chidanand $(error "GENERATE_COT and EL3_PAYLOAD_BASE are incompatible \ 815c5e1da83SJayanth Dodderi Chidanand build options.") 81676580f3dSQixiang Xu endif 81776580f3dSQixiang Xu ifneq (${TRUSTED_BOARD_BOOT},0) 818c5e1da83SJayanth Dodderi Chidanand $(error "TRUSTED_BOARD_BOOT and EL3_PAYLOAD_BASE are \ 819c5e1da83SJayanth Dodderi Chidanand incompatible \ build options.") 82076580f3dSQixiang Xu endif 821c5e1da83SJayanth Dodderi Chidanandendif #(EL3_PAYLOAD_BASE) 822cf2c8a33SAntonio Nino Diaz 823cf2c8a33SAntonio Nino Diazifeq (${NEED_BL33},yes) 824cf2c8a33SAntonio Nino Diaz ifdef EL3_PAYLOAD_BASE 825cf2c8a33SAntonio Nino Diaz $(warning "BL33 image is not needed when option \ 826cf2c8a33SAntonio Nino Diaz BL33_PAYLOAD_BASE is used and won't be added to the FIP file.") 827cf2c8a33SAntonio Nino Diaz endif 82868450a6dSAntonio Nino Diaz ifdef PRELOADED_BL33_BASE 82968450a6dSAntonio Nino Diaz $(warning "BL33 image is not needed when option \ 830c5e1da83SJayanth Dodderi Chidanand PRELOADED_BL33_BASE is used and won't be added to the FIP file.") 831cf2c8a33SAntonio Nino Diaz endif 832c5e1da83SJayanth Dodderi Chidanandendif #(NEED_BL33) 833cf2c8a33SAntonio Nino Diaz 834d4593e47SJeenu Viswambharan# When building for systems with hardware-assisted coherency, there's no need to 835d4593e47SJeenu Viswambharan# use USE_COHERENT_MEM. Require that USE_COHERENT_MEM must be set to 0 too. 836d4593e47SJeenu Viswambharanifeq ($(HW_ASSISTED_COHERENCY)-$(USE_COHERENT_MEM),1-1) 837d4593e47SJeenu Viswambharan $(error USE_COHERENT_MEM cannot be enabled with HW_ASSISTED_COHERENCY) 838d4593e47SJeenu Viswambharanendif 8391a0a3f06SYatharth Kochar 84042d4d3baSArvind Ram Prakash#For now, BL2_IN_XIP_MEM is only supported when RESET_TO_BL2 is 1. 84142d4d3baSArvind Ram Prakashifeq ($(RESET_TO_BL2)-$(BL2_IN_XIP_MEM),0-1) 84242d4d3baSArvind Ram Prakash $(error "BL2_IN_XIP_MEM is only supported when RESET_TO_BL2 is enabled") 8437d173fc5SJiafei Panendif 8447d173fc5SJiafei Pan 8459202d519SManish Pandey# RAS_EXTENSION is deprecated, provide alternate build options 84614c6016aSJeenu Viswambharanifeq ($(RAS_EXTENSION),1) 847c5e1da83SJayanth Dodderi Chidanand $(error "RAS_EXTENSION is now deprecated, please use ENABLE_FEAT_RAS \ 848c5e1da83SJayanth Dodderi Chidanand and RAS_FFH_SUPPORT instead") 8499202d519SManish Pandeyendif 850c5e1da83SJayanth Dodderi Chidanand 8519202d519SManish Pandey# RAS firmware first handling requires that EAs are handled in EL3 first 8529202d519SManish Pandeyifeq ($(RAS_FFH_SUPPORT),1) 8539202d519SManish Pandey ifneq ($(ENABLE_FEAT_RAS),1) 8549202d519SManish Pandey $(error For RAS_FFH_SUPPORT, ENABLE_FEAT_RAS must also be 1) 8559202d519SManish Pandey endif 85646cc41d5SManish Pandey ifneq ($(HANDLE_EA_EL3_FIRST_NS),1) 8579202d519SManish Pandey $(error For RAS_FFH_SUPPORT, HANDLE_EA_EL3_FIRST_NS must also be 1) 85814c6016aSJeenu Viswambharan endif 859c5e1da83SJayanth Dodderi Chidanandendif #(RAS_FFH_SUPPORT) 860c5e1da83SJayanth Dodderi Chidanand 8619202d519SManish Pandey# When FAULT_INJECTION_SUPPORT is used, require that FEAT_RAS is enabled 8621a7c1cfeSJeenu Viswambharanifeq ($(FAULT_INJECTION_SUPPORT),1) 8636503ff29SAndre Przywara ifeq ($(ENABLE_FEAT_RAS),0) 8646503ff29SAndre Przywara $(error For FAULT_INJECTION_SUPPORT, ENABLE_FEAT_RAS must not be 0) 8651a7c1cfeSJeenu Viswambharan endif 866c5e1da83SJayanth Dodderi Chidanandendif #(FAULT_INJECTION_SUPPORT) 8671a7c1cfeSJeenu Viswambharan 868ed51b51fSRoberto Vargas# DYN_DISABLE_AUTH can be set only when TRUSTED_BOARD_BOOT=1 869209a60ccSSoby Mathewifeq ($(DYN_DISABLE_AUTH), 1) 870209a60ccSSoby Mathew ifeq (${TRUSTED_BOARD_BOOT}, 0) 871c5e1da83SJayanth Dodderi Chidanand $(error "TRUSTED_BOARD_BOOT must be enabled for DYN_DISABLE_AUTH \ 872c5e1da83SJayanth Dodderi Chidanand to be set.") 873209a60ccSSoby Mathew endif 874c5e1da83SJayanth Dodderi Chidanandendif #(DYN_DISABLE_AUTH) 875209a60ccSSoby Mathew 8762bf4f27fSManish V Badarkheifeq ($(MEASURED_BOOT)-$(TRUSTED_BOARD_BOOT),1-1) 8772bf4f27fSManish V Badarkhe# Support authentication verification and hash calculation 8782bf4f27fSManish V Badarkhe CRYPTO_SUPPORT := 3 8792bf4f27fSManish V Badarkheelse ifeq ($(DRTM_SUPPORT)-$(TRUSTED_BOARD_BOOT),1-1) 8802bf4f27fSManish V Badarkhe# Support authentication verification and hash calculation 8812bf4f27fSManish V Badarkhe CRYPTO_SUPPORT := 3 8822bf4f27fSManish V Badarkheelse ifneq ($(filter 1,${MEASURED_BOOT} ${DRTM_SUPPORT}),) 8832bf4f27fSManish V Badarkhe# Support hash calculation only 8842bf4f27fSManish V Badarkhe CRYPTO_SUPPORT := 2 8852bf4f27fSManish V Badarkheelse ifeq (${TRUSTED_BOARD_BOOT},1) 8862bf4f27fSManish V Badarkhe# Support authentication verification only 887c9c56f6eSManish V Badarkhe CRYPTO_SUPPORT := 1 888c9c56f6eSManish V Badarkheelse 889c9c56f6eSManish V Badarkhe CRYPTO_SUPPORT := 0 890c5e1da83SJayanth Dodderi Chidanandendif #($(MEASURED_BOOT)-$(TRUSTED_BOARD_BOOT)) 891c9c56f6eSManish V Badarkhe 892cbf9e84aSBalint Dobszay# SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled. 893cbf9e84aSBalint Dobszayifeq ($(SDEI_SUPPORT)-$(SDEI_IN_FCONF),0-1) 894700e7685SManish Pandey $(error "SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled") 89584ef9cd8SManish V Badarkheendif 89684ef9cd8SManish V Badarkhe 897b86048c4SAntonio Nino Diaz# If pointer authentication is used in the firmware, make sure that all the 8989fc59639SAlexei Fedorov# registers associated to it are also saved and restored. 8999fc59639SAlexei Fedorov# Not doing it would leak the value of the keys used by EL3 to EL1 and S-EL1. 900b86048c4SAntonio Nino Diazifeq ($(ENABLE_PAUTH),1) 9019fc59639SAlexei Fedorov ifeq ($(CTX_INCLUDE_PAUTH_REGS),0) 9029fc59639SAlexei Fedorov $(error Pointer Authentication requires CTX_INCLUDE_PAUTH_REGS=1) 90306715f85SAlexei Fedorov endif 904c5e1da83SJayanth Dodderi Chidanandendif #(ENABLE_PAUTH) 9059fc59639SAlexei Fedorov 90606715f85SAlexei Fedorovifeq ($(CTX_INCLUDE_PAUTH_REGS),1) 9079fc59639SAlexei Fedorov ifneq (${ARCH},aarch64) 9089fc59639SAlexei Fedorov $(error CTX_INCLUDE_PAUTH_REGS requires AArch64) 909b86048c4SAntonio Nino Diaz endif 910c5e1da83SJayanth Dodderi Chidanandendif #(CTX_INCLUDE_PAUTH_REGS) 9119fc59639SAlexei Fedorov 9129dd94382SJustin Chadwellifeq ($(CTX_INCLUDE_MTE_REGS),1) 9139dd94382SJustin Chadwell ifneq (${ARCH},aarch64) 9149dd94382SJustin Chadwell $(error CTX_INCLUDE_MTE_REGS requires AArch64) 9159dd94382SJustin Chadwell endif 916c5e1da83SJayanth Dodderi Chidanandendif #(CTX_INCLUDE_MTE_REGS) 9179dd94382SJustin Chadwell 918396b339dSManish V Badarkheifeq ($(PSA_FWU_SUPPORT),1) 919396b339dSManish V Badarkhe $(info PSA_FWU_SUPPORT is an experimental feature) 920c5e1da83SJayanth Dodderi Chidanandendif #(PSA_FWU_SUPPORT) 921396b339dSManish V Badarkhe 9226a0da736SJayanth Dodderi Chidanandifeq ($(FEATURE_DETECTION),1) 9236a0da736SJayanth Dodderi Chidanand $(info FEATURE_DETECTION is an experimental feature) 924c5e1da83SJayanth Dodderi Chidanandendif #(FEATURE_DETECTION) 9256a0da736SJayanth Dodderi Chidanand 92603d3c0d7SJayanth Dodderi Chidanandifneq ($(ENABLE_SME2_FOR_NS), 0) 92703d3c0d7SJayanth Dodderi Chidanand ifeq (${ENABLE_SME_FOR_NS}, 0) 928c5e1da83SJayanth Dodderi Chidanand $(warning "ENABLE_SME2_FOR_NS requires ENABLE_SME_FOR_NS also \ 929c5e1da83SJayanth Dodderi Chidanand to be set") 93003d3c0d7SJayanth Dodderi Chidanand $(warning "Forced ENABLE_SME_FOR_NS=1") 93103d3c0d7SJayanth Dodderi Chidanand override ENABLE_SME_FOR_NS := 1 93203d3c0d7SJayanth Dodderi Chidanand endif 933c5e1da83SJayanth Dodderi Chidanandendif #(ENABLE_SME2_FOR_NS) 93445007acdSJayanth Dodderi Chidanand 93560e8f3cfSPetre-Ionut Tudorifeq (${ARM_XLAT_TABLES_LIB_V1}, 1) 93660e8f3cfSPetre-Ionut Tudor ifeq (${ALLOW_RO_XLAT_TABLES}, 1) 937c5e1da83SJayanth Dodderi Chidanand $(error "ALLOW_RO_XLAT_TABLES requires translation tables \ 938c5e1da83SJayanth Dodderi Chidanand library v2") 93960e8f3cfSPetre-Ionut Tudor endif 940c5e1da83SJayanth Dodderi Chidanandendif #(ARM_XLAT_TABLES_LIB_V1) 94160e8f3cfSPetre-Ionut Tudor 9427cda17bbSSumit Gargifneq (${DECRYPTION_SUPPORT},none) 9437cda17bbSSumit Garg ifeq (${TRUSTED_BOARD_BOOT}, 0) 944c5e1da83SJayanth Dodderi Chidanand $(error TRUSTED_BOARD_BOOT must be enabled for DECRYPTION_SUPPORT \ 945c5e1da83SJayanth Dodderi Chidanand to be set) 9467cda17bbSSumit Garg endif 947c5e1da83SJayanth Dodderi Chidanandendif #(DECRYPTION_SUPPORT) 9487cda17bbSSumit Garg 949744ad974Sjohpow01# Ensure that no Aarch64-only features are enabled in Aarch32 build 950dc78e62dSjohpow01ifeq (${ARCH},aarch32) 951744ad974Sjohpow01 952744ad974Sjohpow01 # SME/SVE only supported on AArch64 95345007acdSJayanth Dodderi Chidanand ifneq (${ENABLE_SME_FOR_NS},0) 954dc78e62dSjohpow01 $(error "ENABLE_SME_FOR_NS cannot be used with ARCH=aarch32") 955dc78e62dSjohpow01 endif 95603d3c0d7SJayanth Dodderi Chidanand 957dc78e62dSjohpow01 ifeq (${ENABLE_SVE_FOR_NS},1) 958dc78e62dSjohpow01 # Warning instead of error due to CI dependency on this 95924ab2c0aSYann Gautier $(error "ENABLE_SVE_FOR_NS cannot be used with ARCH=aarch32") 960dc78e62dSjohpow01 endif 961744ad974Sjohpow01 962ff86e0b4SJuan Pablo Conde # BRBE is not supported in AArch32 963744ad974Sjohpow01 ifeq (${ENABLE_BRBE_FOR_NS},1) 964744ad974Sjohpow01 $(error "ENABLE_BRBE_FOR_NS cannot be used with ARCH=aarch32") 965744ad974Sjohpow01 endif 966744ad974Sjohpow01 967ff86e0b4SJuan Pablo Conde # FEAT_RNG_TRAP is not supported in AArch32 968ff86e0b4SJuan Pablo Conde ifeq (${ENABLE_FEAT_RNG_TRAP},1) 969ff86e0b4SJuan Pablo Conde $(error "ENABLE_FEAT_RNG_TRAP cannot be used with ARCH=aarch32") 970ff86e0b4SJuan Pablo Conde endif 971c5e1da83SJayanth Dodderi Chidanandendif #(ARCH=aarch32) 972dc78e62dSjohpow01 973dc78e62dSjohpow01# Ensure ENABLE_RME is not used with SME 974dc78e62dSjohpow01ifeq (${ENABLE_RME},1) 97545007acdSJayanth Dodderi Chidanand ifneq (${ENABLE_SME_FOR_NS},0) 976dc78e62dSjohpow01 $(error "ENABLE_SME_FOR_NS cannot be used with ENABLE_RME") 977dc78e62dSjohpow01 endif 978dc78e62dSjohpow01endif 979dc78e62dSjohpow01 9800d122947SBoyan Karatotevifneq (${ENABLE_SME_FOR_NS},0) 9810d122947SBoyan Karatotev ifeq (${ENABLE_SVE_FOR_NS},0) 9820d122947SBoyan Karatotev $(error "ENABLE_SME_FOR_NS requires ENABLE_SVE_FOR_NS") 9830d122947SBoyan Karatotev endif 984c5e1da83SJayanth Dodderi Chidanandendif #(ENABLE_SME_FOR_NS) 9850d122947SBoyan Karatotev 986dc78e62dSjohpow01# Secure SME/SVE requires the non-secure component as well 987dc78e62dSjohpow01ifeq (${ENABLE_SME_FOR_SWD},1) 988dc78e62dSjohpow01 ifeq (${ENABLE_SME_FOR_NS},0) 989dc78e62dSjohpow01 $(error "ENABLE_SME_FOR_SWD requires ENABLE_SME_FOR_NS") 990dc78e62dSjohpow01 endif 9910d122947SBoyan Karatotev ifeq (${ENABLE_SVE_FOR_SWD},0) 9920d122947SBoyan Karatotev $(error "ENABLE_SME_FOR_SWD requires ENABLE_SVE_FOR_SWD") 9930d122947SBoyan Karatotev endif 994c5e1da83SJayanth Dodderi Chidanandendif #(ENABLE_SME_FOR_SWD) 995c5e1da83SJayanth Dodderi Chidanand 996dc78e62dSjohpow01ifeq (${ENABLE_SVE_FOR_SWD},1) 997dc78e62dSjohpow01 ifeq (${ENABLE_SVE_FOR_NS},0) 998dc78e62dSjohpow01 $(error "ENABLE_SVE_FOR_SWD requires ENABLE_SVE_FOR_NS") 999dc78e62dSjohpow01 endif 1000c5e1da83SJayanth Dodderi Chidanandendif #(ENABLE_SVE_FOR_SWD) 1001dc78e62dSjohpow01 1002dc78e62dSjohpow01# SVE and SME cannot be used with CTX_INCLUDE_FPREGS since secure manager does 1003dc78e62dSjohpow01# its own context management including FPU registers. 1004dc78e62dSjohpow01ifeq (${CTX_INCLUDE_FPREGS},1) 100545007acdSJayanth Dodderi Chidanand ifneq (${ENABLE_SME_FOR_NS},0) 1006dc78e62dSjohpow01 $(error "ENABLE_SME_FOR_NS cannot be used with CTX_INCLUDE_FPREGS") 1007dc78e62dSjohpow01 endif 100803d3c0d7SJayanth Dodderi Chidanand 1009dc78e62dSjohpow01 ifeq (${ENABLE_SVE_FOR_NS},1) 1010dc78e62dSjohpow01 # Warning instead of error due to CI dependency on this 1011dc78e62dSjohpow01 $(warning "ENABLE_SVE_FOR_NS cannot be used with CTX_INCLUDE_FPREGS") 1012dc78e62dSjohpow01 $(warning "Forced ENABLE_SVE_FOR_NS=0") 1013dc78e62dSjohpow01 override ENABLE_SVE_FOR_NS := 0 1014dc78e62dSjohpow01 endif 1015c5e1da83SJayanth Dodderi Chidanandendif #(CTX_INCLUDE_FPREGS) 1016dc78e62dSjohpow01 101700e28874SManish V Badarkheifeq ($(DRTM_SUPPORT),1) 101800e28874SManish V Badarkhe $(info DRTM_SUPPORT is an experimental feature) 101900e28874SManish V Badarkheendif 102000e28874SManish V Badarkhe 1021274a69e7SChris Kayifeq (${ENABLE_RME},1) 1022274a69e7SChris Kay ifneq (${SEPARATE_CODE_AND_RODATA},1) 1023274a69e7SChris Kay $(error `ENABLE_RME=1` requires `SEPARATE_CODE_AND_RODATA=1`) 1024274a69e7SChris Kay endif 1025274a69e7SChris Kayendif 1026274a69e7SChris Kay 1027c5e1da83SJayanth Dodderi Chidanand# Determine if FEAT_RNG is supported 1028c5e1da83SJayanth Dodderi ChidanandENABLE_FEAT_RNG = $(if $(findstring rng,${arch-features}),1,0) 1029c5e1da83SJayanth Dodderi Chidanand 1030c5e1da83SJayanth Dodderi Chidanand# Determine if FEAT_SB is supported 1031c5e1da83SJayanth Dodderi ChidanandENABLE_FEAT_SB = $(if $(findstring sb,${arch-features}),1,0) 1032c5e1da83SJayanth Dodderi Chidanand 1033cf2c8a33SAntonio Nino Diaz################################################################################ 103473c99d4eSJuan Castillo# Process platform overrideable behaviour 103573c99d4eSJuan Castillo################################################################################ 10364f6ad66aSAchin Gupta 10375f24ce96SManish Pandeyifdef BL1_SOURCES 10385f24ce96SManish Pandey NEED_BL1 := yes 1039c5e1da83SJayanth Dodderi Chidanandendif #(BL1_SOURCES) 10405f24ce96SManish Pandey 10415f24ce96SManish Pandeyifdef BL2_SOURCES 10425f24ce96SManish Pandey NEED_BL2 := yes 10435f24ce96SManish Pandey 1044bd97f83aSJohn Tsichritzis # Using BL2 implies that a BL33 image also needs to be supplied for the FIP and 1045bd97f83aSJohn Tsichritzis # Certificate generation tools. This flag can be overridden by the platform. 1046cf2c8a33SAntonio Nino Diaz ifdef EL3_PAYLOAD_BASE 1047cf2c8a33SAntonio Nino Diaz # If booting an EL3 payload there is no need for a BL33 image 1048cf2c8a33SAntonio Nino Diaz # in the FIP file. 10494c117f6cSSandrine Bailleux NEED_BL33 := no 1050cf2c8a33SAntonio Nino Diaz else 105168450a6dSAntonio Nino Diaz ifdef PRELOADED_BL33_BASE 1052cf2c8a33SAntonio Nino Diaz # If booting a BL33 preloaded image there is no need of 1053cf2c8a33SAntonio Nino Diaz # another one in the FIP file. 1054cf2c8a33SAntonio Nino Diaz NEED_BL33 := no 1055cf2c8a33SAntonio Nino Diaz else 1056cf2c8a33SAntonio Nino Diaz NEED_BL33 ?= yes 1057cf2c8a33SAntonio Nino Diaz endif 10584c117f6cSSandrine Bailleux endif 1059c5e1da83SJayanth Dodderi Chidanandendif #(BL2_SOURCES) 10606f971622SJuan Castillo 10615f24ce96SManish Pandeyifdef BL2U_SOURCES 10625f24ce96SManish Pandey NEED_BL2U := yes 1063c5e1da83SJayanth Dodderi Chidanandendif #(BL2U_SOURCES) 10645f24ce96SManish Pandey 10654d045d0eSMasahiro Yamada# If SCP_BL2 is given, we always want FIP to include it. 10664d045d0eSMasahiro Yamadaifdef SCP_BL2 10674d045d0eSMasahiro Yamada NEED_SCP_BL2 := yes 1068c5e1da83SJayanth Dodderi Chidanandendif #(SCP_BL2) 10694d045d0eSMasahiro Yamada 10705744e874SSoby Mathew# For AArch32, BL31 is not currently supported. 10715744e874SSoby Mathewifneq (${ARCH},aarch32) 10725744e874SSoby Mathew ifdef BL31_SOURCES 1073c5e1da83SJayanth Dodderi Chidanand # When booting an EL3 payload, there is no need to compile the BL31 1074c5e1da83SJayanth Dodderi Chidanand # image nor put it in the FIP. 10755744e874SSoby Mathew ifndef EL3_PAYLOAD_BASE 10765744e874SSoby Mathew NEED_BL31 := yes 10775744e874SSoby Mathew endif 10785744e874SSoby Mathew endif 1079c5e1da83SJayanth Dodderi Chidanandendif #(ARCH=aarch64) 10805744e874SSoby Mathew 108173c99d4eSJuan Castillo# Process TBB related flags 10826f971622SJuan Castilloifneq (${GENERATE_COT},0) 108373c99d4eSJuan Castillo # Common cert_create options 10846f971622SJuan Castillo ifneq (${CREATE_KEYS},0) 10856f971622SJuan Castillo $(eval CRT_ARGS += -n) 10860191262dSYatharth Kochar $(eval FWU_CRT_ARGS += -n) 1087fd34e7baSJuan Castillo ifneq (${SAVE_KEYS},0) 1088fd34e7baSJuan Castillo $(eval CRT_ARGS += -k) 10890191262dSYatharth Kochar $(eval FWU_CRT_ARGS += -k) 1090fd34e7baSJuan Castillo endif 10916f971622SJuan Castillo endif 109273c99d4eSJuan Castillo # Include TBBR makefile (unless the platform indicates otherwise) 109373c99d4eSJuan Castillo ifeq (${INCLUDE_TBBR_MK},1) 109473c99d4eSJuan Castillo include make_helpers/tbbr/tbbr_tools.mk 109573c99d4eSJuan Castillo endif 1096c5e1da83SJayanth Dodderi Chidanandendif #(GENERATE_COT) 10976f971622SJuan Castillo 10981c75d5dfSMasahiro Yamadaifneq (${FIP_ALIGN},0) 10991c75d5dfSMasahiro Yamada FIP_ARGS += --align ${FIP_ALIGN} 1100c5e1da83SJayanth Dodderi Chidanandendif #(FIP_ALIGN) 11011c75d5dfSMasahiro Yamada 11025f24ce96SManish Pandeyifdef FDT_SOURCES 11035f24ce96SManish Pandey NEED_FDT := yes 1104c5e1da83SJayanth Dodderi Chidanandendif #(FDT_SOURCES) 11055f24ce96SManish Pandey 110673c99d4eSJuan Castillo################################################################################ 110746e5e035SMichalis Pappas# Include libraries' Makefile that are used in all BL 110846e5e035SMichalis Pappas################################################################################ 110946e5e035SMichalis Pappas 111046e5e035SMichalis Pappasinclude lib/stack_protector/stack_protector.mk 111146e5e035SMichalis Pappas 111246e5e035SMichalis Pappas################################################################################ 11138a86052dSSoby Mathew# Include BL specific makefiles 11148a86052dSSoby Mathew################################################################################ 11155f24ce96SManish Pandey 11165f24ce96SManish Pandeyifeq (${NEED_BL1},yes) 11178a86052dSSoby Mathewinclude bl1/bl1.mk 11188a86052dSSoby Mathewendif 11198a86052dSSoby Mathew 11205f24ce96SManish Pandeyifeq (${NEED_BL2},yes) 11218a86052dSSoby Mathewinclude bl2/bl2.mk 11228a86052dSSoby Mathewendif 11238a86052dSSoby Mathew 11245f24ce96SManish Pandeyifeq (${NEED_BL2U},yes) 11258a86052dSSoby Mathewinclude bl2u/bl2u.mk 11268a86052dSSoby Mathewendif 11278a86052dSSoby Mathew 11285744e874SSoby Mathewifeq (${NEED_BL31},yes) 11298a86052dSSoby Mathewinclude bl31/bl31.mk 11308a86052dSSoby Mathewendif 113103b397a8SNishanth Menon 113273c99d4eSJuan Castillo################################################################################ 113373c99d4eSJuan Castillo# Build options checks 113473c99d4eSJuan Castillo################################################################################ 113573c99d4eSJuan Castillo 1136c5e1da83SJayanth Dodderi Chidanand# Boolean_Flags 1137327131c4SLeonardo Sandoval$(eval $(call assert_booleans,\ 1138327131c4SLeonardo Sandoval $(sort \ 1139327131c4SLeonardo Sandoval ALLOW_RO_XLAT_TABLES \ 114046789a7cSBalint Dobszay BL2_ENABLE_SP_LOAD \ 1141327131c4SLeonardo Sandoval COLD_BOOT_SINGLE_CPU \ 1142327131c4SLeonardo Sandoval CREATE_KEYS \ 1143327131c4SLeonardo Sandoval CTX_INCLUDE_AARCH32_REGS \ 1144327131c4SLeonardo Sandoval CTX_INCLUDE_FPREGS \ 1145327131c4SLeonardo Sandoval CTX_INCLUDE_EL2_REGS \ 1146327131c4SLeonardo Sandoval DEBUG \ 1147327131c4SLeonardo Sandoval DYN_DISABLE_AUTH \ 1148327131c4SLeonardo Sandoval EL3_EXCEPTION_HANDLING \ 11491fd685a7SChris Kay ENABLE_AMU_AUXILIARY_COUNTERS \ 1150742ca230SChris Kay ENABLE_AMU_FCONF \ 1151873d4241Sjohpow01 AMU_RESTRICT_COUNTERS \ 1152327131c4SLeonardo Sandoval ENABLE_ASSERTIONS \ 115324077098SAndre Przywara ENABLE_FEAT_SB \ 1154327131c4SLeonardo Sandoval ENABLE_PIE \ 1155327131c4SLeonardo Sandoval ENABLE_PMF \ 1156327131c4SLeonardo Sandoval ENABLE_PSCI_STAT \ 1157327131c4SLeonardo Sandoval ENABLE_RUNTIME_INSTRUMENTATION \ 1158dc78e62dSjohpow01 ENABLE_SME_FOR_SWD \ 11590c5e7d1cSMax Shvetsov ENABLE_SVE_FOR_SWD \ 1160327131c4SLeonardo Sandoval ERROR_DEPRECATED \ 1161327131c4SLeonardo Sandoval FAULT_INJECTION_SUPPORT \ 1162327131c4SLeonardo Sandoval GENERATE_COT \ 1163327131c4SLeonardo Sandoval GICV2_G0_FOR_EL3 \ 116446cc41d5SManish Pandey HANDLE_EA_EL3_FIRST_NS \ 1165327131c4SLeonardo Sandoval HW_ASSISTED_COHERENCY \ 1166327131c4SLeonardo Sandoval MEASURED_BOOT \ 116700e28874SManish V Badarkhe DRTM_SUPPORT \ 1168327131c4SLeonardo Sandoval NS_TIMER_SWITCH \ 1169327131c4SLeonardo Sandoval OVERRIDE_LIBC \ 1170327131c4SLeonardo Sandoval PL011_GENERIC_UART \ 11710ce2072dSTamas Ban PLAT_RSS_NOT_SUPPORTED \ 1172327131c4SLeonardo Sandoval PROGRAMMABLE_RESET_ADDRESS \ 1173327131c4SLeonardo Sandoval PSCI_EXTENDED_STATE_ID \ 117464b4710bSWing Li PSCI_OS_INIT_MODE \ 1175327131c4SLeonardo Sandoval RESET_TO_BL31 \ 1176327131c4SLeonardo Sandoval SAVE_KEYS \ 1177327131c4SLeonardo Sandoval SEPARATE_CODE_AND_RODATA \ 117896a8ed14SJiafei Pan SEPARATE_BL2_NOLOAD_REGION \ 1179327131c4SLeonardo Sandoval SEPARATE_NOBITS_REGION \ 1180327131c4SLeonardo Sandoval SPIN_ON_BL1_EXIT \ 1181327131c4SLeonardo Sandoval SPM_MM \ 11821d63ae4dSMarc Bonnici SPMC_AT_EL3 \ 1183327131c4SLeonardo Sandoval SPMD_SPM_AT_SEL2 \ 1184327131c4SLeonardo Sandoval TRUSTED_BOARD_BOOT \ 1185327131c4SLeonardo Sandoval USE_COHERENT_MEM \ 1186327131c4SLeonardo Sandoval USE_DEBUGFS \ 1187327131c4SLeonardo Sandoval ARM_IO_IN_DTB \ 1188327131c4SLeonardo Sandoval SDEI_IN_FCONF \ 1189327131c4SLeonardo Sandoval SEC_INT_DESC_IN_FCONF \ 1190327131c4SLeonardo Sandoval USE_ROMLIB \ 1191327131c4SLeonardo Sandoval USE_TBBR_DEFS \ 1192327131c4SLeonardo Sandoval WARMBOOT_ENABLE_DCACHE_EARLY \ 119342d4d3baSArvind Ram Prakash RESET_TO_BL2 \ 1194327131c4SLeonardo Sandoval BL2_IN_XIP_MEM \ 1195327131c4SLeonardo Sandoval BL2_INV_DCACHE \ 1196327131c4SLeonardo Sandoval USE_SPINLOCK_CAS \ 1197327131c4SLeonardo Sandoval ENCRYPT_BL31 \ 1198327131c4SLeonardo Sandoval ENCRYPT_BL32 \ 1199327131c4SLeonardo Sandoval ERRATA_SPECULATIVE_AT \ 120000e8f79cSManish Pandey RAS_TRAP_NS_ERR_REC_ACCESS \ 1201327131c4SLeonardo Sandoval COT_DESC_IN_DTB \ 1202327131c4SLeonardo Sandoval USE_SP804_TIMER \ 1203396b339dSManish V Badarkhe PSA_FWU_SUPPORT \ 120468120783SChris Kay ENABLE_MPMM \ 120568120783SChris Kay ENABLE_MPMM_FCONF \ 12066a0da736SJayanth Dodderi Chidanand FEATURE_DETECTION \ 12070b22e591SJayanth Dodderi Chidanand TRNG_SUPPORT \ 1208ffea3844SSona Mathew ERRATA_ABI_SUPPORT \ 1209ef63f5beSSona Mathew ERRATA_NON_ARM_INTERCONNECT \ 121004c7303bSOkash Khawaja CONDITIONAL_CMO \ 12119202d519SManish Pandey RAS_FFH_SUPPORT \ 1212327131c4SLeonardo Sandoval))) 121373c99d4eSJuan Castillo 1214c5e1da83SJayanth Dodderi Chidanand# Numeric_Flags 1215327131c4SLeonardo Sandoval$(eval $(call assert_numerics,\ 1216327131c4SLeonardo Sandoval $(sort \ 1217327131c4SLeonardo Sandoval ARM_ARCH_MAJOR \ 1218327131c4SLeonardo Sandoval ARM_ARCH_MINOR \ 1219327131c4SLeonardo Sandoval BRANCH_PROTECTION \ 12206a0da736SJayanth Dodderi Chidanand CTX_INCLUDE_PAUTH_REGS \ 12216a0da736SJayanth Dodderi Chidanand CTX_INCLUDE_MTE_REGS \ 12226a0da736SJayanth Dodderi Chidanand CTX_INCLUDE_NEVE_REGS \ 12232bf4f27fSManish V Badarkhe CRYPTO_SUPPORT \ 122483a4dae1SBoyan Karatotev DISABLE_MTPMU \ 12251298f2f1SJayanth Dodderi Chidanand ENABLE_BRBE_FOR_NS \ 122647c681b7SJayanth Dodderi Chidanand ENABLE_TRBE_FOR_NS \ 12276a0da736SJayanth Dodderi Chidanand ENABLE_BTI \ 12286a0da736SJayanth Dodderi Chidanand ENABLE_PAUTH \ 1229d23acc9eSAndre Przywara ENABLE_FEAT_AMU \ 12306a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_AMUv1p1 \ 12316a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_CSV2_2 \ 12329202d519SManish Pandey ENABLE_FEAT_RAS \ 12336a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_DIT \ 12346a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_ECV \ 12356a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_FGT \ 12366a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_HCX \ 12376a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_PAN \ 12386a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_RNG \ 1239ff86e0b4SJuan Pablo Conde ENABLE_FEAT_RNG_TRAP \ 12406a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_SEL2 \ 1241d3331603SMark Brown ENABLE_FEAT_TCR2 \ 1242062b6c6bSMark Brown ENABLE_FEAT_S2PIE \ 1243062b6c6bSMark Brown ENABLE_FEAT_S1PIE \ 1244062b6c6bSMark Brown ENABLE_FEAT_S2POE \ 1245062b6c6bSMark Brown ENABLE_FEAT_S1POE \ 1246688ab57bSMark Brown ENABLE_FEAT_GCS \ 12476a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_VHE \ 12486a0da736SJayanth Dodderi Chidanand ENABLE_MPAM_FOR_LOWER_ELS \ 12496a0da736SJayanth Dodderi Chidanand ENABLE_RME \ 12506437a09aSAndre Przywara ENABLE_SPE_FOR_NS \ 1251603a0c6fSAndre Przywara ENABLE_SYS_REG_TRACE_FOR_NS \ 125245007acdSJayanth Dodderi Chidanand ENABLE_SME_FOR_NS \ 125303d3c0d7SJayanth Dodderi Chidanand ENABLE_SME2_FOR_NS \ 12542b0bc4e0SJayanth Dodderi Chidanand ENABLE_SVE_FOR_NS \ 12556a0da736SJayanth Dodderi Chidanand ENABLE_TRF_FOR_NS \ 1256327131c4SLeonardo Sandoval FW_ENC_STATUS \ 12575357f83dSManish V Badarkhe NR_OF_FW_BANKS \ 12585357f83dSManish V Badarkhe NR_OF_IMAGES_IN_FW_BANK \ 1259781d07a4SJayanth Dodderi Chidanand TWED_DELAY \ 1260781d07a4SJayanth Dodderi Chidanand ENABLE_FEAT_TWED \ 1261bebcf27fSMark Brown SVE_VECTOR_LEN \ 12620ed3be6fSVarun Wadekar IMPDEF_SYSREG_TRAP \ 1263327131c4SLeonardo Sandoval))) 1264c877b414SJeenu Viswambharan 1265aacff749SJustin Chadwellifdef KEY_SIZE 1266aacff749SJustin Chadwell $(eval $(call assert_numeric,KEY_SIZE)) 1267aacff749SJustin Chadwellendif 1268aacff749SJustin Chadwell 12691f461979SJustin Chadwellifeq ($(filter $(SANITIZE_UB), on off trap),) 12701f461979SJustin Chadwell $(error "Invalid value for SANITIZE_UB: can be one of on, off, trap") 12711f461979SJustin Chadwellendif 12721f461979SJustin Chadwell 127373c99d4eSJuan Castillo################################################################################ 127473c99d4eSJuan Castillo# Add definitions to the cpp preprocessor based on the current build options. 127573c99d4eSJuan Castillo# This is done after including the platform specific makefile to allow the 127673c99d4eSJuan Castillo# platform to overwrite the default options 127773c99d4eSJuan Castillo################################################################################ 127873c99d4eSJuan Castillo 1279327131c4SLeonardo Sandoval$(eval $(call add_defines,\ 1280327131c4SLeonardo Sandoval $(sort \ 1281327131c4SLeonardo Sandoval ALLOW_RO_XLAT_TABLES \ 1282327131c4SLeonardo Sandoval ARM_ARCH_MAJOR \ 1283327131c4SLeonardo Sandoval ARM_ARCH_MINOR \ 128446789a7cSBalint Dobszay BL2_ENABLE_SP_LOAD \ 1285327131c4SLeonardo Sandoval COLD_BOOT_SINGLE_CPU \ 1286327131c4SLeonardo Sandoval CTX_INCLUDE_AARCH32_REGS \ 1287327131c4SLeonardo Sandoval CTX_INCLUDE_FPREGS \ 1288327131c4SLeonardo Sandoval CTX_INCLUDE_PAUTH_REGS \ 1289327131c4SLeonardo Sandoval EL3_EXCEPTION_HANDLING \ 1290327131c4SLeonardo Sandoval CTX_INCLUDE_MTE_REGS \ 1291327131c4SLeonardo Sandoval CTX_INCLUDE_EL2_REGS \ 1292062f8aafSArunachalam Ganapathy CTX_INCLUDE_NEVE_REGS \ 1293327131c4SLeonardo Sandoval DECRYPTION_SUPPORT_${DECRYPTION_SUPPORT} \ 12940063dd17SJavier Almansa Sobrino DISABLE_MTPMU \ 1295d23acc9eSAndre Przywara ENABLE_FEAT_AMU \ 12961fd685a7SChris Kay ENABLE_AMU_AUXILIARY_COUNTERS \ 1297742ca230SChris Kay ENABLE_AMU_FCONF \ 1298873d4241Sjohpow01 AMU_RESTRICT_COUNTERS \ 1299327131c4SLeonardo Sandoval ENABLE_ASSERTIONS \ 1300327131c4SLeonardo Sandoval ENABLE_BTI \ 1301327131c4SLeonardo Sandoval ENABLE_MPAM_FOR_LOWER_ELS \ 1302327131c4SLeonardo Sandoval ENABLE_PAUTH \ 1303327131c4SLeonardo Sandoval ENABLE_PIE \ 1304327131c4SLeonardo Sandoval ENABLE_PMF \ 1305327131c4SLeonardo Sandoval ENABLE_PSCI_STAT \ 13065b18de09SZelalem Aweke ENABLE_RME \ 1307327131c4SLeonardo Sandoval ENABLE_RUNTIME_INSTRUMENTATION \ 1308dc78e62dSjohpow01 ENABLE_SME_FOR_NS \ 130903d3c0d7SJayanth Dodderi Chidanand ENABLE_SME2_FOR_NS \ 1310dc78e62dSjohpow01 ENABLE_SME_FOR_SWD \ 131190118bb5SAndre Przywara ENABLE_SPE_FOR_NS \ 1312327131c4SLeonardo Sandoval ENABLE_SVE_FOR_NS \ 13130c5e7d1cSMax Shvetsov ENABLE_SVE_FOR_SWD \ 1314327131c4SLeonardo Sandoval ENCRYPT_BL31 \ 1315327131c4SLeonardo Sandoval ENCRYPT_BL32 \ 1316327131c4SLeonardo Sandoval ERROR_DEPRECATED \ 1317327131c4SLeonardo Sandoval FAULT_INJECTION_SUPPORT \ 1318327131c4SLeonardo Sandoval GICV2_G0_FOR_EL3 \ 131946cc41d5SManish Pandey HANDLE_EA_EL3_FIRST_NS \ 1320327131c4SLeonardo Sandoval HW_ASSISTED_COHERENCY \ 1321327131c4SLeonardo Sandoval LOG_LEVEL \ 1322327131c4SLeonardo Sandoval MEASURED_BOOT \ 132300e28874SManish V Badarkhe DRTM_SUPPORT \ 1324327131c4SLeonardo Sandoval NS_TIMER_SWITCH \ 1325327131c4SLeonardo Sandoval PL011_GENERIC_UART \ 1326327131c4SLeonardo Sandoval PLAT_${PLAT} \ 13270ce2072dSTamas Ban PLAT_RSS_NOT_SUPPORTED \ 1328327131c4SLeonardo Sandoval PROGRAMMABLE_RESET_ADDRESS \ 1329327131c4SLeonardo Sandoval PSCI_EXTENDED_STATE_ID \ 133064b4710bSWing Li PSCI_OS_INIT_MODE \ 13319202d519SManish Pandey ENABLE_FEAT_RAS \ 13329202d519SManish Pandey RAS_FFH_SUPPORT \ 1333327131c4SLeonardo Sandoval RESET_TO_BL31 \ 1334327131c4SLeonardo Sandoval SEPARATE_CODE_AND_RODATA \ 133596a8ed14SJiafei Pan SEPARATE_BL2_NOLOAD_REGION \ 1336327131c4SLeonardo Sandoval SEPARATE_NOBITS_REGION \ 1337327131c4SLeonardo Sandoval RECLAIM_INIT_CODE \ 1338327131c4SLeonardo Sandoval SPD_${SPD} \ 1339327131c4SLeonardo Sandoval SPIN_ON_BL1_EXIT \ 1340327131c4SLeonardo Sandoval SPM_MM \ 13411d63ae4dSMarc Bonnici SPMC_AT_EL3 \ 1342327131c4SLeonardo Sandoval SPMD_SPM_AT_SEL2 \ 1343327131c4SLeonardo Sandoval TRUSTED_BOARD_BOOT \ 1344c9c56f6eSManish V Badarkhe CRYPTO_SUPPORT \ 13457dfb9911SJimmy Brisson TRNG_SUPPORT \ 1346ffea3844SSona Mathew ERRATA_ABI_SUPPORT \ 1347ef63f5beSSona Mathew ERRATA_NON_ARM_INTERCONNECT \ 1348327131c4SLeonardo Sandoval USE_COHERENT_MEM \ 1349327131c4SLeonardo Sandoval USE_DEBUGFS \ 1350327131c4SLeonardo Sandoval ARM_IO_IN_DTB \ 1351327131c4SLeonardo Sandoval SDEI_IN_FCONF \ 1352327131c4SLeonardo Sandoval SEC_INT_DESC_IN_FCONF \ 1353327131c4SLeonardo Sandoval USE_ROMLIB \ 1354327131c4SLeonardo Sandoval USE_TBBR_DEFS \ 1355327131c4SLeonardo Sandoval WARMBOOT_ENABLE_DCACHE_EARLY \ 135642d4d3baSArvind Ram Prakash RESET_TO_BL2 \ 135742d4d3baSArvind Ram Prakash BL2_RUNS_AT_EL3 \ 1358327131c4SLeonardo Sandoval BL2_IN_XIP_MEM \ 1359327131c4SLeonardo Sandoval BL2_INV_DCACHE \ 1360327131c4SLeonardo Sandoval USE_SPINLOCK_CAS \ 1361327131c4SLeonardo Sandoval ERRATA_SPECULATIVE_AT \ 136200e8f79cSManish Pandey RAS_TRAP_NS_ERR_REC_ACCESS \ 1363327131c4SLeonardo Sandoval COT_DESC_IN_DTB \ 1364327131c4SLeonardo Sandoval USE_SP804_TIMER \ 136512cd65e0STomas Pilar ENABLE_FEAT_RNG \ 1366ff86e0b4SJuan Pablo Conde ENABLE_FEAT_RNG_TRAP \ 13674e04478aSChris Kay ENABLE_FEAT_SB \ 13687d33ffe4SDaniel Boulby ENABLE_FEAT_DIT \ 13695357f83dSManish V Badarkhe NR_OF_FW_BANKS \ 13705357f83dSManish V Badarkhe NR_OF_IMAGES_IN_FW_BANK \ 1371396b339dSManish V Badarkhe PSA_FWU_SUPPORT \ 1372744ad974Sjohpow01 ENABLE_BRBE_FOR_NS \ 1373813524eaSManish V Badarkhe ENABLE_TRBE_FOR_NS \ 1374d4582d30SManish V Badarkhe ENABLE_SYS_REG_TRACE_FOR_NS \ 13758fcd3d96SManish V Badarkhe ENABLE_TRF_FOR_NS \ 1376cb4ec47bSjohpow01 ENABLE_FEAT_HCX \ 137768120783SChris Kay ENABLE_MPMM \ 137868120783SChris Kay ENABLE_MPMM_FCONF \ 1379f74cb0beSJayanth Dodderi Chidanand ENABLE_FEAT_FGT \ 1380f74cb0beSJayanth Dodderi Chidanand ENABLE_FEAT_ECV \ 13816a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_AMUv1p1 \ 13826a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_SEL2 \ 13836a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_VHE \ 13846a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_CSV2_2 \ 13856a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_PAN \ 1386d3331603SMark Brown ENABLE_FEAT_TCR2 \ 1387062b6c6bSMark Brown ENABLE_FEAT_S2PIE \ 1388062b6c6bSMark Brown ENABLE_FEAT_S1PIE \ 1389062b6c6bSMark Brown ENABLE_FEAT_S2POE \ 1390062b6c6bSMark Brown ENABLE_FEAT_S1POE \ 1391688ab57bSMark Brown ENABLE_FEAT_GCS \ 13926a0da736SJayanth Dodderi Chidanand FEATURE_DETECTION \ 1393781d07a4SJayanth Dodderi Chidanand TWED_DELAY \ 1394781d07a4SJayanth Dodderi Chidanand ENABLE_FEAT_TWED \ 139504c7303bSOkash Khawaja CONDITIONAL_CMO \ 13960ed3be6fSVarun Wadekar IMPDEF_SYSREG_TRAP \ 1397a8cf6faeSJayanth Dodderi Chidanand SVE_VECTOR_LEN \ 1398327131c4SLeonardo Sandoval))) 13992fae4b1eSJeenu Viswambharan 14001f461979SJustin Chadwellifeq (${SANITIZE_UB},trap) 14011f461979SJustin Chadwell $(eval $(call add_define,MONITOR_TRAPS)) 1402c5e1da83SJayanth Dodderi Chidanandendif #(SANITIZE_UB) 14031f461979SJustin Chadwell 14044c117f6cSSandrine Bailleux# Define the EL3_PAYLOAD_BASE flag only if it is provided. 14054c117f6cSSandrine Bailleuxifdef EL3_PAYLOAD_BASE 14064c117f6cSSandrine Bailleux $(eval $(call add_define,EL3_PAYLOAD_BASE)) 1407cf2c8a33SAntonio Nino Diazelse 140868450a6dSAntonio Nino Diaz# Define the PRELOADED_BL33_BASE flag only if it is provided and 140968450a6dSAntonio Nino Diaz# EL3_PAYLOAD_BASE is not defined, as it has priority. 141068450a6dSAntonio Nino Diaz ifdef PRELOADED_BL33_BASE 141168450a6dSAntonio Nino Diaz $(eval $(call add_define,PRELOADED_BL33_BASE)) 14124c117f6cSSandrine Bailleux endif 1413c5e1da83SJayanth Dodderi Chidanandendif #(EL3_PAYLOAD_BASE) 141473c99d4eSJuan Castillo 1415209a60ccSSoby Mathew# Define the DYN_DISABLE_AUTH flag only if set. 1416209a60ccSSoby Mathewifeq (${DYN_DISABLE_AUTH},1) 1417209a60ccSSoby Mathew $(eval $(call add_define,DYN_DISABLE_AUTH)) 1418209a60ccSSoby Mathewendif 1419209a60ccSSoby Mathew 1420c2ad38ceSVarun Wadekarifneq ($(findstring armlink,$(notdir $(LD))),) 1421c2ad38ceSVarun Wadekar $(eval $(call add_define,USE_ARM_LINK)) 1422c2ad38ceSVarun Wadekarendif 1423c2ad38ceSVarun Wadekar 1424ce2b1ec6SManish Pandey# Generate and include sp_gen.mk if SPD is spmd and SP_LAYOUT_FILE is defined 1425ce2b1ec6SManish Pandeyifeq (${SPD},spmd) 1426c33ff198SOlivier Deprezifdef SP_LAYOUT_FILE 1427ce2b1ec6SManish Pandey -include $(BUILD_PLAT)/sp_gen.mk 1428ce2b1ec6SManish Pandey FIP_DEPS += sp 142907c44475SManish Pandey CRT_DEPS += sp 1430ce2b1ec6SManish Pandey NEED_SP_PKG := yes 1431ce2b1ec6SManish Pandeyelse 1432c33ff198SOlivier Deprez ifeq (${SPMD_SPM_AT_SEL2},1) 1433c33ff198SOlivier Deprez $(error "SPMD with SPM at S-EL2 require SP_LAYOUT_FILE") 1434c33ff198SOlivier Deprez endif 1435c5e1da83SJayanth Dodderi Chidanandendif #(SP_LAYOUT_FILE) 1436c5e1da83SJayanth Dodderi Chidanandendif #(SPD) 1437ce2b1ec6SManish Pandey 143873c99d4eSJuan Castillo################################################################################ 143973c99d4eSJuan Castillo# Build targets 144073c99d4eSJuan Castillo################################################################################ 144173c99d4eSJuan Castillo 144290aa901fSSumit Garg.PHONY: all msg_start clean realclean distclean cscope locate-checkpatch checkcodebase checkpatch fiptool sptool fip sp fwu_fip certtool dtbs memmap doc enctool 144373c99d4eSJuan Castillo.SUFFIXES: 144473c99d4eSJuan Castillo 144573c99d4eSJuan Castilloall: msg_start 144673c99d4eSJuan Castillo 144773c99d4eSJuan Castillomsg_start: 144873c99d4eSJuan Castillo @echo "Building ${PLAT}" 144973c99d4eSJuan Castillo 14507a24cba5SSoby Mathewifeq (${ERROR_DEPRECATED},0) 1451d5dfdeb6SJulius Werner# Check if deprecated declarations and cpp warnings should be treated as error or not. 1452c2ad38ceSVarun Wadekarifneq ($(findstring clang,$(notdir $(CC))),) 1453c2ad38ceSVarun Wadekar CPPFLAGS += -Wno-error=deprecated-declarations 1454c2ad38ceSVarun Wadekarelse 1455bc1a03c7SDan Handley CPPFLAGS += -Wno-error=deprecated-declarations -Wno-error=cpp 14567a24cba5SSoby Mathewendif 1457c5e1da83SJayanth Dodderi Chidanandendif #(!ERROR_DEPRECATED) 14587a24cba5SSoby Mathew 14595accce5bSRoberto Vargas$(eval $(call MAKE_LIB_DIRS)) 146061f72a34SRoberto Vargas$(eval $(call MAKE_LIB,c)) 14615fee0287SRoberto Vargas 146273c99d4eSJuan Castillo# Expand build macros for the different images 146373c99d4eSJuan Castilloifeq (${NEED_BL1},yes) 1464b34635a0SChris KayBL1_SOURCES := $(sort ${BL1_SOURCES}) 1465434d0491SZelalem Aweke$(eval $(call MAKE_BL,bl1)) 1466c5e1da83SJayanth Dodderi Chidanandendif #(NEED_BL1) 146773c99d4eSJuan Castillo 146873c99d4eSJuan Castilloifeq (${NEED_BL2},yes) 1469c5e1da83SJayanth Dodderi Chidanand 147042d4d3baSArvind Ram Prakashifeq (${RESET_TO_BL2}, 0) 1471c9b31ae8SRoberto VargasFIP_BL2_ARGS := tb-fw 1472c9b31ae8SRoberto Vargasendif 1473c9b31ae8SRoberto Vargas 1474eb1acfb6SChris KayBL2_SOURCES := $(sort ${BL2_SOURCES}) 1475eb1acfb6SChris Kay 147633950dd8SMasahiro Yamada$(if ${BL2}, $(eval $(call TOOL_ADD_IMG,bl2,--${FIP_BL2_ARGS})),\ 1477434d0491SZelalem Aweke $(eval $(call MAKE_BL,bl2,${FIP_BL2_ARGS}))) 1478c5e1da83SJayanth Dodderi Chidanand 1479c5e1da83SJayanth Dodderi Chidanandendif #(NEED_BL2) 148073c99d4eSJuan Castillo 14814d045d0eSMasahiro Yamadaifeq (${NEED_SCP_BL2},yes) 148233950dd8SMasahiro Yamada$(eval $(call TOOL_ADD_IMG,scp_bl2,--scp-fw)) 1483c5e1da83SJayanth Dodderi Chidanandendif #(NEED_SCP_BL2) 14844d045d0eSMasahiro Yamada 148573c99d4eSJuan Castilloifeq (${NEED_BL31},yes) 148673c99d4eSJuan CastilloBL31_SOURCES += ${SPD_SOURCES} 148726d1e0c3SMadhukar Pappireddy# Sort BL31 source files to remove duplicates 148826d1e0c3SMadhukar PappireddyBL31_SOURCES := $(sort ${BL31_SOURCES}) 1489c6ba9b45SSumit Gargifneq (${DECRYPTION_SUPPORT},none) 1490c6ba9b45SSumit Garg$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw,,$(ENCRYPT_BL31))),\ 1491434d0491SZelalem Aweke $(eval $(call MAKE_BL,bl31,soc-fw,,$(ENCRYPT_BL31)))) 1492c6ba9b45SSumit Gargelse 149333950dd8SMasahiro Yamada$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw)),\ 1494434d0491SZelalem Aweke $(eval $(call MAKE_BL,bl31,soc-fw))) 1495c5e1da83SJayanth Dodderi Chidanandendif #(DECRYPTION_SUPPORT) 1496c5e1da83SJayanth Dodderi Chidanandendif #(NEED_BL31) 149773c99d4eSJuan Castillo 149870d1fc53SJuan Castillo# If a BL32 image is needed but neither BL32 nor BL32_SOURCES is defined, the 1499c939d13aSMasahiro Yamada# build system will call TOOL_ADD_IMG to print a warning message and abort the 150070d1fc53SJuan Castillo# process. Note that the dependency on BL32 applies to the FIP only. 150173c99d4eSJuan Castilloifeq (${NEED_BL32},yes) 150226d1e0c3SMadhukar Pappireddy# Sort BL32 source files to remove duplicates 150326d1e0c3SMadhukar PappireddyBL32_SOURCES := $(sort ${BL32_SOURCES}) 15049cd15239SMasahiro YamadaBUILD_BL32 := $(if $(BL32),,$(if $(BL32_SOURCES),1)) 15059cd15239SMasahiro Yamada 1506c6ba9b45SSumit Gargifneq (${DECRYPTION_SUPPORT},none) 1507434d0491SZelalem Aweke$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw,,$(ENCRYPT_BL32))),\ 1508c6ba9b45SSumit Garg $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw,,$(ENCRYPT_BL32)))) 1509c6ba9b45SSumit Gargelse 1510434d0491SZelalem Aweke$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw)),\ 151133950dd8SMasahiro Yamada $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw))) 1512c5e1da83SJayanth Dodderi Chidanandendif #(DECRYPTION_SUPPORT) 1513c5e1da83SJayanth Dodderi Chidanandendif #(NEED_BL32) 151473c99d4eSJuan Castillo 15155b18de09SZelalem Aweke# If RMM image is needed but RMM is not defined, Test Realm Payload (TRP) 15165b18de09SZelalem Aweke# needs to be built from RMM_SOURCES. 15175b18de09SZelalem Awekeifeq (${NEED_RMM},yes) 15185b18de09SZelalem Aweke# Sort RMM source files to remove duplicates 15195b18de09SZelalem AwekeRMM_SOURCES := $(sort ${RMM_SOURCES}) 15205b18de09SZelalem AwekeBUILD_RMM := $(if $(RMM),,$(if $(RMM_SOURCES),1)) 15215b18de09SZelalem Aweke 15225b18de09SZelalem Aweke$(if ${BUILD_RMM}, $(eval $(call MAKE_BL,rmm,rmm-fw)),\ 15235b18de09SZelalem Aweke $(eval $(call TOOL_ADD_IMG,rmm,--rmm-fw))) 1524c5e1da83SJayanth Dodderi Chidanandendif #(NEED_RMM) 15255b18de09SZelalem Aweke 152673c99d4eSJuan Castillo# Add the BL33 image if required by the platform 152773c99d4eSJuan Castilloifeq (${NEED_BL33},yes) 152833950dd8SMasahiro Yamada$(eval $(call TOOL_ADD_IMG,bl33,--nt-fw)) 1529c5e1da83SJayanth Dodderi Chidanandendif #(NEED_BL33) 1530db6071c9SJuan Castillo 15319003fa0bSYatharth Kocharifeq (${NEED_BL2U},yes) 153233950dd8SMasahiro Yamada$(if ${BL2U}, $(eval $(call TOOL_ADD_IMG,bl2u,--ap-fwu-cfg,FWU_)),\ 1533434d0491SZelalem Aweke $(eval $(call MAKE_BL,bl2u,ap-fwu-cfg,FWU_))) 1534c5e1da83SJayanth Dodderi Chidanandendif #(NEED_BL2U) 15359003fa0bSYatharth Kochar 153603b397a8SNishanth Menon# Expand build macros for the different images 153703b397a8SNishanth Menonifeq (${NEED_FDT},yes) 153803b397a8SNishanth Menon $(eval $(call MAKE_DTBS,$(BUILD_PLAT)/fdts,$(FDT_SOURCES))) 1539c5e1da83SJayanth Dodderi Chidanandendif #(NEED_FDT) 154003b397a8SNishanth Menon 1541ce2b1ec6SManish Pandey# Add Secure Partition packages 1542ce2b1ec6SManish Pandeyifeq (${NEED_SP_PKG},yes) 1543ce2b1ec6SManish Pandey$(BUILD_PLAT)/sp_gen.mk: ${SP_MK_GEN} ${SP_LAYOUT_FILE} | ${BUILD_PLAT} 15441e7528ecSRuari Phipps ${Q}${PYTHON} "$<" "$@" $(filter-out $<,$^) $(BUILD_PLAT) ${COT} 1545822c7279SJ-Alvessp: $(DTBS) $(BUILD_PLAT)/sp_gen.mk $(SP_PKGS) 1546ce2b1ec6SManish Pandey @${ECHO_BLANK_LINE} 1547ce2b1ec6SManish Pandey @echo "Built SP Images successfully" 1548ce2b1ec6SManish Pandey @${ECHO_BLANK_LINE} 1549c5e1da83SJayanth Dodderi Chidanandendif #(NEED_SP_PKG) 1550ce2b1ec6SManish Pandey 155136eaaf37SIan Spraylocate-checkpatch: 155236eaaf37SIan Sprayifndef CHECKPATCH 155366079b04SEtienne Carriere $(error "Please set CHECKPATCH to point to the Linux checkpatch.pl file, eg: CHECKPATCH=../linux/scripts/checkpatch.pl") 155436eaaf37SIan Sprayelse 155536eaaf37SIan Sprayifeq (,$(wildcard ${CHECKPATCH})) 155666079b04SEtienne Carriere $(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/scripts/checkpatch.pl") 155736eaaf37SIan Sprayendif 1558c5e1da83SJayanth Dodderi Chidanandendif #(CHECKPATCH) 155936eaaf37SIan Spray 15604f6ad66aSAchin Guptaclean: 15614f6ad66aSAchin Gupta @echo " CLEAN" 1562f1477d4aSEvan Lloyd $(call SHELL_REMOVE_DIR,${BUILD_PLAT}) 156388a1cf1eSSami Mujawarifdef UNIX_MK 15642f2cef46SJeenu Viswambharan ${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean 156588a1cf1eSSami Mujawarelse 156688a1cf1eSSami Mujawar# Clear the MAKEFLAGS as we do not want 156788a1cf1eSSami Mujawar# to pass the gnumake flags to nmake. 156888a1cf1eSSami Mujawar ${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) clean 1569c5e1da83SJayanth Dodderi Chidanandendif #(UNIX_MK) 15706f971622SJuan Castillo ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean 157190aa901fSSumit Garg ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} clean 15725accce5bSRoberto Vargas ${Q}${MAKE} --no-print-directory -C ${ROMLIBPATH} clean 15734f6ad66aSAchin Gupta 1574eaaeece2SJames Morrisseyrealclean distclean: 1575eaaeece2SJames Morrissey @echo " REALCLEAN" 1576f1477d4aSEvan Lloyd $(call SHELL_REMOVE_DIR,${BUILD_BASE}) 1577f1477d4aSEvan Lloyd $(call SHELL_DELETE_ALL, ${CURDIR}/cscope.*) 157888a1cf1eSSami Mujawarifdef UNIX_MK 15792f2cef46SJeenu Viswambharan ${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean 158088a1cf1eSSami Mujawarelse 158188a1cf1eSSami Mujawar# Clear the MAKEFLAGS as we do not want 158288a1cf1eSSami Mujawar# to pass the gnumake flags to nmake. 158388a1cf1eSSami Mujawar ${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) realclean 1584c5e1da83SJayanth Dodderi Chidanandendif #(UNIX_MK) 1585e15591aaSNicolas Boulenguez ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} realclean 158690aa901fSSumit Garg ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} realclean 15875accce5bSRoberto Vargas ${Q}${MAKE} --no-print-directory -C ${ROMLIBPATH} clean 15884f6ad66aSAchin Gupta 158936eaaf37SIan Spraycheckcodebase: locate-checkpatch 159036eaaf37SIan Spray @echo " CHECKING STYLE" 159136eaaf37SIan Spray @if test -d .git ; then \ 15921ef35512SPaul Beesley git ls-files | grep -E -v 'libfdt|libc|docs|\.rst' | \ 15931a41e8c1SDan Handley while read GIT_FILE ; \ 15941a41e8c1SDan Handley do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ; \ 15951a41e8c1SDan Handley done ; \ 159636eaaf37SIan Spray else \ 15971a41e8c1SDan Handley find . -type f -not -iwholename "*.git*" \ 15981a41e8c1SDan Handley -not -iwholename "*build*" \ 15991a41e8c1SDan Handley -not -iwholename "*libfdt*" \ 160061f72a34SRoberto Vargas -not -iwholename "*libc*" \ 16011a41e8c1SDan Handley -not -iwholename "*docs*" \ 16021ef35512SPaul Beesley -not -iwholename "*.rst" \ 16031a41e8c1SDan Handley -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ; \ 160436eaaf37SIan Spray fi 160536eaaf37SIan Spray 160636eaaf37SIan Spraycheckpatch: locate-checkpatch 160736eaaf37SIan Spray @echo " CHECKING STYLE" 160802a76d5fSYann Gautier @if test -n "${CHECKPATCH_OPTS}"; then \ 160902a76d5fSYann Gautier echo " with ${CHECKPATCH_OPTS} option(s)"; \ 161002a76d5fSYann Gautier fi 161151d28937SAntonio Nino Diaz ${Q}COMMON_COMMIT=$$(git merge-base HEAD ${BASE_COMMIT}); \ 161277a0a7f1SYann Gautier for commit in `git rev-list --no-merges $$COMMON_COMMIT..HEAD`; \ 161377a0a7f1SYann Gautier do \ 161451d28937SAntonio Nino Diaz printf "\n[*] Checking style of '$$commit'\n\n"; \ 161551d28937SAntonio Nino Diaz git log --format=email "$$commit~..$$commit" \ 161602a76d5fSYann Gautier -- ${CHECK_PATHS} | \ 161702a76d5fSYann Gautier ${CHECKPATCH} ${CHECKPATCH_OPTS} - || true; \ 161851d28937SAntonio Nino Diaz git diff --format=email "$$commit~..$$commit" \ 161902a76d5fSYann Gautier -- ${CHECK_PATHS} | \ 162002a76d5fSYann Gautier ${CHECKPATCH} ${CHECKPATCH_OPTS} - || true; \ 162151d28937SAntonio Nino Diaz done 162236eaaf37SIan Spray 162373c99d4eSJuan Castillocerttool: ${CRTTOOL} 162473c99d4eSJuan Castillo 1625a9812206SPali Rohár${CRTTOOL}: FORCE 1626598b166bSLionel Debieve ${Q}${MAKE} PLAT=${PLAT} USE_TBBR_DEFS=${USE_TBBR_DEFS} COT=${COT} OPENSSL_DIR=${OPENSSL_DIR} CRTTOOL=${CRTTOOL} DEBUG=${DEBUG} V=${V} --no-print-directory -C ${CRTTOOLPATH} all 1627f1477d4aSEvan Lloyd @${ECHO_BLANK_LINE} 16286f971622SJuan Castillo @echo "Built $@ successfully" 1629f1477d4aSEvan Lloyd @${ECHO_BLANK_LINE} 16306f971622SJuan Castillo 16316f971622SJuan Castilloifneq (${GENERATE_COT},0) 163273c99d4eSJuan Castillocertificates: ${CRT_DEPS} ${CRTTOOL} 16336f971622SJuan Castillo ${Q}${CRTTOOL} ${CRT_ARGS} 1634f1477d4aSEvan Lloyd @${ECHO_BLANK_LINE} 16356f971622SJuan Castillo @echo "Built $@ successfully" 16366f971622SJuan Castillo @echo "Certificates can be found in ${BUILD_PLAT}" 1637f1477d4aSEvan Lloyd @${ECHO_BLANK_LINE} 1638c5e1da83SJayanth Dodderi Chidanandendif #(GENERATE_COT) 163927713fb4SSoby Mathew 164073c99d4eSJuan Castillo${BUILD_PLAT}/${FIP_NAME}: ${FIP_DEPS} ${FIPTOOL} 16414727fd13SPali Rohár $(eval ${CHECK_FIP_CMD}) 1642819281eeSdp-arm ${Q}${FIPTOOL} create ${FIP_ARGS} $@ 1643819281eeSdp-arm ${Q}${FIPTOOL} info $@ 1644f1477d4aSEvan Lloyd @${ECHO_BLANK_LINE} 16452f2cef46SJeenu Viswambharan @echo "Built $@ successfully" 1646f1477d4aSEvan Lloyd @${ECHO_BLANK_LINE} 1647f58ad36fSHarry Liebel 16480191262dSYatharth Kocharifneq (${GENERATE_COT},0) 16490191262dSYatharth Kocharfwu_certificates: ${FWU_CRT_DEPS} ${CRTTOOL} 16500191262dSYatharth Kochar ${Q}${CRTTOOL} ${FWU_CRT_ARGS} 1651052ab529SEvan Lloyd @${ECHO_BLANK_LINE} 16520191262dSYatharth Kochar @echo "Built $@ successfully" 16530191262dSYatharth Kochar @echo "FWU certificates can be found in ${BUILD_PLAT}" 1654052ab529SEvan Lloyd @${ECHO_BLANK_LINE} 1655c5e1da83SJayanth Dodderi Chidanandendif #(GENERATE_COT) 16560191262dSYatharth Kochar 16570191262dSYatharth Kochar${BUILD_PLAT}/${FWU_FIP_NAME}: ${FWU_FIP_DEPS} ${FIPTOOL} 16584727fd13SPali Rohár $(eval ${CHECK_FWU_FIP_CMD}) 1659819281eeSdp-arm ${Q}${FIPTOOL} create ${FWU_FIP_ARGS} $@ 1660819281eeSdp-arm ${Q}${FIPTOOL} info $@ 1661052ab529SEvan Lloyd @${ECHO_BLANK_LINE} 16620191262dSYatharth Kochar @echo "Built $@ successfully" 1663052ab529SEvan Lloyd @${ECHO_BLANK_LINE} 16640191262dSYatharth Kochar 166573c99d4eSJuan Castillofiptool: ${FIPTOOL} 166673c99d4eSJuan Castillofip: ${BUILD_PLAT}/${FIP_NAME} 16670191262dSYatharth Kocharfwu_fip: ${BUILD_PLAT}/${FWU_FIP_NAME} 166873c99d4eSJuan Castillo 1669a9812206SPali Rohár${FIPTOOL}: FORCE 167088a1cf1eSSami Mujawarifdef UNIX_MK 1671598b166bSLionel Debieve ${Q}${MAKE} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" FIPTOOL=${FIPTOOL} OPENSSL_DIR=${OPENSSL_DIR} DEBUG=${DEBUG} V=${V} --no-print-directory -C ${FIPTOOLPATH} all 167288a1cf1eSSami Mujawarelse 167388a1cf1eSSami Mujawar# Clear the MAKEFLAGS as we do not want 167488a1cf1eSSami Mujawar# to pass the gnumake flags to nmake. 167588a1cf1eSSami Mujawar ${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) 1676c5e1da83SJayanth Dodderi Chidanandendif #(UNIX_MK) 1677f58ad36fSHarry Liebel 1678a9812206SPali Rohárromlib.bin: libraries FORCE 1679bbb24f61SJohn 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 16805accce5bSRoberto Vargas 1681cfe83910SLouis Mayencourtmemmap: all 1682af5b49e9SHarrison Mutaiifdef UNIX_MK 1683af5b49e9SHarrison Mutai ${Q}PYTHONPATH=${CURDIR}/tools/memory \ 1684af5b49e9SHarrison Mutai ${PYTHON} -m memory.memmap -sr ${BUILD_PLAT} 1685af5b49e9SHarrison Mutaielse 1686af5b49e9SHarrison Mutai ${Q}set PYTHONPATH=${CURDIR}/tools/memory && \ 1687af5b49e9SHarrison Mutai ${PYTHON} -m memory.memmap -sr ${BUILD_PLAT} 1688af5b49e9SHarrison Mutaiendif 1689cfe83910SLouis Mayencourt 16906de32378SMadhukar Pappireddydoc: 16916de32378SMadhukar Pappireddy @echo " BUILD DOCUMENTATION" 16926de32378SMadhukar Pappireddy ${Q}${MAKE} --no-print-directory -C ${DOCS_PATH} html 16936de32378SMadhukar Pappireddy 169490aa901fSSumit Gargenctool: ${ENCTOOL} 169590aa901fSSumit Garg 1696a9812206SPali Rohár${ENCTOOL}: FORCE 1697598b166bSLionel Debieve ${Q}${MAKE} PLAT=${PLAT} BUILD_INFO=0 OPENSSL_DIR=${OPENSSL_DIR} ENCTOOL=${ENCTOOL} DEBUG=${DEBUG} V=${V} --no-print-directory -C ${ENCTOOLPATH} all 169890aa901fSSumit Garg @${ECHO_BLANK_LINE} 169990aa901fSSumit Garg @echo "Built $@ successfully" 170090aa901fSSumit Garg @${ECHO_BLANK_LINE} 170190aa901fSSumit Garg 170235fab8c9SJoakim Bechcscope: 170335fab8c9SJoakim Bech @echo " CSCOPE" 170435fab8c9SJoakim Bech ${Q}find ${CURDIR} -name "*.[chsS]" > cscope.files 170535fab8c9SJoakim Bech ${Q}cscope -b -q -k 170635fab8c9SJoakim Bech 170772ee3314SRyan Harkinhelp: 17087c23126cSJohn Tsichritzis @echo "usage: ${MAKE} [PLAT=<platform>] [OPTIONS] [TARGET]" 170972ee3314SRyan Harkin @echo "" 171072ee3314SRyan Harkin @echo "PLAT is used to specify which platform you wish to build." 171108c7ed0fSSandrine Bailleux @echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}" 171272ee3314SRyan Harkin @echo "" 17137c23126cSJohn Tsichritzis @echo "platform = ${PLATFORM_LIST}" 17147c23126cSJohn Tsichritzis @echo "" 17151b578596SSandrine Bailleux @echo "Please refer to the User Guide for a list of all supported options." 17161b578596SSandrine Bailleux @echo "Note that the build system doesn't track dependencies for build " 17171b578596SSandrine Bailleux @echo "options. Therefore, if any of the build options are changed " 17181b578596SSandrine Bailleux @echo "from a previous build, a clean build must be performed." 17191b578596SSandrine Bailleux @echo "" 172072ee3314SRyan Harkin @echo "Supported Targets:" 17211b578596SSandrine Bailleux @echo " all Build all individual bootloader binaries" 172236eaaf37SIan Spray @echo " bl1 Build the BL1 binary" 17238aa559c0SJeenu Viswambharan @echo " bl2 Build the BL2 binary" 17249003fa0bSYatharth Kochar @echo " bl2u Build the BL2U binary" 1725d178637dSJuan Castillo @echo " bl31 Build the BL31 binary" 17269d29c227SSoby Mathew @echo " bl32 Build the BL32 binary. If ARCH=aarch32, then " 17279d29c227SSoby Mathew @echo " this builds secure payload specified by AARCH32_SP" 172873c99d4eSJuan Castillo @echo " certificates Build the certificates (requires 'GENERATE_COT=1')" 17291b578596SSandrine Bailleux @echo " fip Build the Firmware Image Package (FIP)" 17300191262dSYatharth Kochar @echo " fwu_fip Build the FWU Firmware Image Package (FIP)" 173136eaaf37SIan Spray @echo " checkcodebase Check the coding style of the entire source tree" 173236eaaf37SIan Spray @echo " checkpatch Check the coding style on changes in the current" 173336eaaf37SIan Spray @echo " branch against BASE_COMMIT (default origin/master)" 173472ee3314SRyan Harkin @echo " clean Clean the build for the selected platform" 173535fab8c9SJoakim Bech @echo " cscope Generate cscope index" 173672ee3314SRyan Harkin @echo " distclean Remove all build artifacts for all platforms" 17376f971622SJuan Castillo @echo " certtool Build the Certificate generation tool" 173890aa901fSSumit Garg @echo " enctool Build the Firmware encryption tool" 1739f58ad36fSHarry Liebel @echo " fiptool Build the Firmware Image Package (FIP) creation tool" 1740ce2b1ec6SManish Pandey @echo " sp Build the Secure Partition Packages" 174126010da1SAntonio Nino Diaz @echo " sptool Build the Secure Partition Package creation tool" 174238c14d88SSoby Mathew @echo " dtbs Build the Device Tree Blobs (if required for the platform)" 1743cfe83910SLouis Mayencourt @echo " memmap Print the memory map of the built binaries" 17446de32378SMadhukar Pappireddy @echo " doc Build html based documentation using Sphinx tool" 174572ee3314SRyan Harkin @echo "" 17461b578596SSandrine Bailleux @echo "Note: most build targets require PLAT to be set to a specific platform." 174772ee3314SRyan Harkin @echo "" 174872ee3314SRyan Harkin @echo "example: build all targets for the FVP platform:" 174972ee3314SRyan Harkin @echo " CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all" 1750a9812206SPali Rohár 1751a9812206SPali Rohár.PHONY: FORCE 1752a9812206SPali RohárFORCE:; 1753