14f6ad66aSAchin Gupta# 20a33adc0SGovindraj Raja# Copyright (c) 2013-2024, 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 1198735809SManish V BadarkheVERSION_MINOR := 10 123e56c69fSYann GautierVERSION_PATCH := 0 # Only used for LTS releases 13055ebecaSYann GautierVERSION := ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH} 14aaa3e722SJuan Castillo 1588154678SJuan Castillo# Default goal is build all images 1688154678SJuan Castillo.DEFAULT_GOAL := all 1788154678SJuan Castillo 1872fc70edSDouglas Raillard# Avoid any implicit propagation of command line variable definitions to 1972fc70edSDouglas Raillard# sub-Makefiles, like CFLAGS that we reserved for the firmware images' 2072fc70edSDouglas Raillard# usage. Other command line options like "-s" are still propagated as usual. 2172fc70edSDouglas RaillardMAKEOVERRIDES = 2272fc70edSDouglas Raillard 23231c1470SEvan LloydMAKE_HELPERS_DIRECTORY := make_helpers/ 24231c1470SEvan Lloydinclude ${MAKE_HELPERS_DIRECTORY}build_macros.mk 25e7f54dbdSEvan Lloydinclude ${MAKE_HELPERS_DIRECTORY}build_env.mk 2673c99d4eSJuan Castillo 2773c99d4eSJuan Castillo################################################################################ 282fae4b1eSJeenu Viswambharan# Default values for build configurations, and their dependencies 2973c99d4eSJuan Castillo################################################################################ 30e35c4045SJeenu Viswambharan 312fae4b1eSJeenu Viswambharaninclude ${MAKE_HELPERS_DIRECTORY}defaults.mk 32872be88aSdp-arm 33cc8b5632SAntonio Nino Diaz# Assertions enabled for DEBUG builds by default 34cc8b5632SAntonio Nino DiazENABLE_ASSERTIONS := ${DEBUG} 352fae4b1eSJeenu ViswambharanENABLE_PMF := ${ENABLE_RUNTIME_INSTRUMENTATION} 362fae4b1eSJeenu ViswambharanPLAT := ${DEFAULT_PLAT} 3773c99d4eSJuan Castillo 3873c99d4eSJuan Castillo################################################################################ 3973c99d4eSJuan Castillo# Checkpatch script options 4073c99d4eSJuan Castillo################################################################################ 4173c99d4eSJuan Castillo 42f607739cSSandrine BailleuxCHECKCODE_ARGS := --no-patch 43f0b489c1SDan Handley# Do not check the coding style on imported library files or documentation files 444501843fSGilad Ben-YossefINC_DRV_DIRS_TO_CHECK := $(sort $(filter-out \ 454501843fSGilad Ben-Yossef include/drivers/arm, \ 464501843fSGilad Ben-Yossef $(wildcard include/drivers/*))) 47f0b489c1SDan HandleyINC_LIB_DIRS_TO_CHECK := $(sort $(filter-out \ 481a41e8c1SDan Handley include/lib/libfdt \ 4961f72a34SRoberto Vargas include/lib/libc, \ 50f0b489c1SDan Handley $(wildcard include/lib/*))) 51f0b489c1SDan HandleyINC_DIRS_TO_CHECK := $(sort $(filter-out \ 524501843fSGilad Ben-Yossef include/lib \ 534501843fSGilad Ben-Yossef include/drivers, \ 54f0b489c1SDan Handley $(wildcard include/*))) 55f0b489c1SDan HandleyLIB_DIRS_TO_CHECK := $(sort $(filter-out \ 56d801fbb0Sdp-arm lib/compiler-rt \ 5755cdcf75SAntonio Nino Diaz lib/libfdt% \ 5861f72a34SRoberto Vargas lib/libc, \ 59a194255dSDaniel Boulby lib/zlib \ 60f0b489c1SDan Handley $(wildcard lib/*))) 61f0b489c1SDan HandleyROOT_DIRS_TO_CHECK := $(sort $(filter-out \ 62f0b489c1SDan Handley lib \ 63f0b489c1SDan Handley include \ 64f0b489c1SDan Handley docs \ 651ef35512SPaul Beesley %.rst, \ 66f0b489c1SDan Handley $(wildcard *))) 67f0b489c1SDan HandleyCHECK_PATHS := ${ROOT_DIRS_TO_CHECK} \ 68f0b489c1SDan Handley ${INC_DIRS_TO_CHECK} \ 69f0b489c1SDan Handley ${INC_LIB_DIRS_TO_CHECK} \ 704501843fSGilad Ben-Yossef ${LIB_DIRS_TO_CHECK} \ 714501843fSGilad Ben-Yossef ${INC_DRV_DIRS_TO_CHECK} \ 724501843fSGilad Ben-Yossef ${INC_ARM_DIRS_TO_CHECK} 7336eaaf37SIan Spray 7473c99d4eSJuan Castillo################################################################################ 7573c99d4eSJuan Castillo# Process build options 7673c99d4eSJuan Castillo################################################################################ 7773c99d4eSJuan Castillo 7873c99d4eSJuan Castillo# Verbose flag 79e35c4045SJeenu Viswambharanifeq (${V},0) 80b169f6a9SEvan Lloyd Q:=@ 81ee1ba6d4SAndre Przywara ECHO:=@echo 8236eaaf37SIan Spray CHECKCODE_ARGS += --no-summary --terse 834f6ad66aSAchin Guptaelse 84b169f6a9SEvan Lloyd Q:= 85b5a0f4bdSAntonio Nino Diaz ECHO:=$(ECHO_QUIET) 864f6ad66aSAchin Guptaendif 87ee1ba6d4SAndre Przywara 88ee1ba6d4SAndre Przywaraifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),) 89ee1ba6d4SAndre Przywara Q:=@ 90b5a0f4bdSAntonio Nino Diaz ECHO:=$(ECHO_QUIET) 91ee1ba6d4SAndre Przywaraendif 92ee1ba6d4SAndre Przywara 93ee1ba6d4SAndre Przywaraexport Q ECHO 942f2cef46SJeenu Viswambharan 9573c99d4eSJuan Castillo################################################################################ 9673c99d4eSJuan Castillo# Toolchain 9773c99d4eSJuan Castillo################################################################################ 9873c99d4eSJuan Castillo 9972610c41Sdp-armHOSTCC := gcc 10072610c41Sdp-armexport HOSTCC 10172610c41Sdp-arm 10273c99d4eSJuan CastilloCC := ${CROSS_COMPILE}gcc 103781cb314SChris KayCPP := ${CROSS_COMPILE}gcc -E 10473c99d4eSJuan CastilloAS := ${CROSS_COMPILE}gcc 1057e387589SChris KayAR := ${CROSS_COMPILE}gcc-ar 1062adee763SRoberto VargasLINKER := ${CROSS_COMPILE}ld 10773c99d4eSJuan CastilloOC := ${CROSS_COMPILE}objcopy 10873c99d4eSJuan CastilloOD := ${CROSS_COMPILE}objdump 10938c14d88SSoby MathewDTC := dtc 11073c99d4eSJuan Castillo 111b25a577fSJulius Werner# Use ${LD}.bfd instead if it exists (as absolute path or together with $PATH). 112b25a577fSJulius Wernerifneq ($(strip $(wildcard ${LD}.bfd) \ 1132adee763SRoberto Vargas $(foreach dir,$(subst :, ,${PATH}),$(wildcard ${dir}/${LINKER}.bfd))),) 1142adee763SRoberto VargasLINKER := ${LINKER}.bfd 115b25a577fSJulius Wernerendif 116b25a577fSJulius Werner 117c5e1da83SJayanth Dodderi Chidanand################################################################################ 118c5e1da83SJayanth Dodderi Chidanand# Auxiliary tools (fiptool, cert_create, etc) 119c5e1da83SJayanth Dodderi Chidanand################################################################################ 120c5e1da83SJayanth Dodderi Chidanand 121c5e1da83SJayanth Dodderi Chidanand# Variables for use with Certificate Generation Tool 122c5e1da83SJayanth Dodderi ChidanandCRTTOOLPATH ?= tools/cert_create 123c5e1da83SJayanth Dodderi ChidanandCRTTOOL ?= ${CRTTOOLPATH}/cert_create${BIN_EXT} 124c5e1da83SJayanth Dodderi Chidanand 125c5e1da83SJayanth Dodderi Chidanand# Variables for use with Firmware Encryption Tool 126c5e1da83SJayanth Dodderi ChidanandENCTOOLPATH ?= tools/encrypt_fw 127c5e1da83SJayanth Dodderi ChidanandENCTOOL ?= ${ENCTOOLPATH}/encrypt_fw${BIN_EXT} 128c5e1da83SJayanth Dodderi Chidanand 129c5e1da83SJayanth Dodderi Chidanand# Variables for use with Firmware Image Package 130c5e1da83SJayanth Dodderi ChidanandFIPTOOLPATH ?= tools/fiptool 131c5e1da83SJayanth Dodderi ChidanandFIPTOOL ?= ${FIPTOOLPATH}/fiptool${BIN_EXT} 132c5e1da83SJayanth Dodderi Chidanand 133c5e1da83SJayanth Dodderi Chidanand# Variables for use with sptool 134c5e1da83SJayanth Dodderi ChidanandSPTOOLPATH ?= tools/sptool 135c5e1da83SJayanth Dodderi ChidanandSPTOOL ?= ${SPTOOLPATH}/sptool.py 136c5e1da83SJayanth Dodderi ChidanandSP_MK_GEN ?= ${SPTOOLPATH}/sp_mk_generator.py 13720629b31SKarl MeakinSP_DTS_LIST_FRAGMENT ?= ${BUILD_PLAT}/sp_list_fragment.dts 138c5e1da83SJayanth Dodderi Chidanand 139c5e1da83SJayanth Dodderi Chidanand# Variables for use with ROMLIB 140c5e1da83SJayanth Dodderi ChidanandROMLIBPATH ?= lib/romlib 141c5e1da83SJayanth Dodderi Chidanand 142c5e1da83SJayanth Dodderi Chidanand# Variable for use with Python 143c5e1da83SJayanth Dodderi ChidanandPYTHON ?= python3 144c5e1da83SJayanth Dodderi Chidanand 145c5e1da83SJayanth Dodderi Chidanand# Variables for use with documentation build using Sphinx tool 146c5e1da83SJayanth Dodderi ChidanandDOCS_PATH ?= docs 147c5e1da83SJayanth Dodderi Chidanand 148c5e1da83SJayanth Dodderi Chidanand################################################################################ 149c5e1da83SJayanth Dodderi Chidanand# Compiler Configuration based on ARCH_MAJOR and ARCH_MINOR flags 150c5e1da83SJayanth Dodderi Chidanand################################################################################ 15126e63c44SEtienne Carriereifeq (${ARM_ARCH_MAJOR},7) 15226e63c44SEtienne Carriere target32-directive = -target arm-none-eabi 153d4089fb8SGovindraj Raja# Will set march-directive from platform configuration 15426e63c44SEtienne Carriereelse 15526e63c44SEtienne Carriere target32-directive = -target armv8a-none-eabi 156c5e1da83SJayanth Dodderi Chidanandendif #(ARM_ARCH_MAJOR) 157c5e1da83SJayanth Dodderi Chidanand 158c5e1da83SJayanth Dodderi Chidanand################################################################################ 159c5e1da83SJayanth Dodderi Chidanand# Get Architecture Feature Modifiers 160c5e1da83SJayanth Dodderi Chidanand################################################################################ 161c5e1da83SJayanth Dodderi Chidanandarch-features = ${ARM_ARCH_FEATURE} 162c5e1da83SJayanth Dodderi Chidanand 163c8a992fdSoriginifneq ($(findstring clang,$(notdir $(CC))),) 164fd18a8fcSVarun Wadekar ifneq ($(findstring armclang,$(notdir $(CC))),) 1657794d6c8SGovindraj Raja TF_CFLAGS_aarch32 := -target arm-arm-none-eabi 1667794d6c8SGovindraj Raja TF_CFLAGS_aarch64 := -target aarch64-arm-none-eabi 167c8a992fdSorigin LD := $(LINKER) 168c8a992fdSorigin else 1697794d6c8SGovindraj Raja TF_CFLAGS_aarch32 = $(target32-directive) 1707794d6c8SGovindraj Raja TF_CFLAGS_aarch64 := -target aarch64-elf 171c8a992fdSorigin LD := $(shell $(CC) --print-prog-name ld.lld) 172c8a992fdSorigin 173c8a992fdSorigin AR := $(shell $(CC) --print-prog-name llvm-ar) 174c8a992fdSorigin OD := $(shell $(CC) --print-prog-name llvm-objdump) 175c8a992fdSorigin OC := $(shell $(CC) --print-prog-name llvm-objcopy) 176641f16e7SAmbroise Vincent endif 177c8a992fdSorigin 178c8a992fdSorigin CPP := $(CC) -E $(TF_CFLAGS_$(ARCH)) 179c8a992fdSorigin AS := $(CC) -c -x assembler-with-cpp $(TF_CFLAGS_$(ARCH)) 180edbce9aaSzelalem-awekeelse ifneq ($(findstring gcc,$(notdir $(CC))),) 181edbce9aaSzelalem-aweke ifeq ($(ENABLE_LTO),1) 182edbce9aaSzelalem-aweke # Enable LTO only for aarch64 183edbce9aaSzelalem-aweke ifeq (${ARCH},aarch64) 184edbce9aaSzelalem-aweke LTO_CFLAGS = -flto 185edbce9aaSzelalem-aweke # Use gcc as a wrapper for the ld, recommended for LTO 186edbce9aaSzelalem-aweke LINKER := ${CROSS_COMPILE}gcc 187edbce9aaSzelalem-aweke endif 188edbce9aaSzelalem-aweke endif 189edbce9aaSzelalem-aweke LD = $(LINKER) 190d5461857Sdp-armelse 1912adee763SRoberto Vargas LD = $(LINKER) 192c5e1da83SJayanth Dodderi Chidanandendif #(clang) 193d5461857Sdp-arm 19432b209bfSAhmad Fatoum# Process Debug flag 19532b209bfSAhmad Fatoum$(eval $(call add_define,DEBUG)) 19632b209bfSAhmad Fatoumifneq (${DEBUG}, 0) 19732b209bfSAhmad Fatoum BUILD_TYPE := debug 1984466cf82SDaniel Boulby TF_CFLAGS += -g -gdwarf-4 1994466cf82SDaniel Boulby ASFLAGS += -g -Wa,-gdwarf-4 20032b209bfSAhmad Fatoum 20132b209bfSAhmad Fatoum # Use LOG_LEVEL_INFO by default for debug builds 20232b209bfSAhmad Fatoum LOG_LEVEL := 40 20332b209bfSAhmad Fatoumelse 20432b209bfSAhmad Fatoum BUILD_TYPE := release 20532b209bfSAhmad Fatoum # Use LOG_LEVEL_NOTICE by default for release builds 20632b209bfSAhmad Fatoum LOG_LEVEL := 20 207c5e1da83SJayanth Dodderi Chidanandendif #(Debug) 20832b209bfSAhmad Fatoum 209f1de4c8fSPeiyuan Song# Default build string (git branch and commit) 210f1de4c8fSPeiyuan Songifeq (${BUILD_STRING},) 211f1de4c8fSPeiyuan Song BUILD_STRING := $(shell git describe --always --dirty --tags 2> /dev/null) 212f1de4c8fSPeiyuan Songendif 213dddf4283Slaurenw-armVERSION_STRING := v${VERSION}(${BUILD_TYPE}):${BUILD_STRING} 214f1de4c8fSPeiyuan Song 2158fd9d4d5SAntonio Nino Diazifeq (${AARCH32_INSTRUCTION_SET},A32) 2168fd9d4d5SAntonio Nino Diaz TF_CFLAGS_aarch32 += -marm 2178fd9d4d5SAntonio Nino Diazelse ifeq (${AARCH32_INSTRUCTION_SET},T32) 2188fd9d4d5SAntonio Nino Diaz TF_CFLAGS_aarch32 += -mthumb 2198fd9d4d5SAntonio Nino Diazelse 2208fd9d4d5SAntonio Nino Diaz $(error Error: Unknown AArch32 instruction set ${AARCH32_INSTRUCTION_SET}) 221c5e1da83SJayanth Dodderi Chidanandendif #(AARCH32_INSTRUCTION_SET) 2228fd9d4d5SAntonio Nino Diaz 223a9c4dde3SSandrine BailleuxTF_CFLAGS_aarch32 += -mno-unaligned-access 224d5461857Sdp-armTF_CFLAGS_aarch64 += -mgeneral-regs-only -mstrict-align 2259d29c227SSoby Mathew 226c5e1da83SJayanth Dodderi Chidanand############################################################################## 227c5e1da83SJayanth Dodderi Chidanand# WARNINGS Configuration 228c5e1da83SJayanth Dodderi Chidanand############################################################################### 2299ab81b5eSJustin Chadwell# General warnings 2309ab81b5eSJustin ChadwellWARNINGS := -Wall -Wmissing-include-dirs -Wunused \ 231b7f6525dSJustin Chadwell -Wdisabled-optimization -Wvla -Wshadow \ 232d75a9ecdSBoyan Karatotev -Wredundant-decls 233d75a9ecdSBoyan Karatotev# stricter warnings 234d75a9ecdSBoyan KaratotevWARNINGS += -Wextra -Wno-trigraphs 235d75a9ecdSBoyan Karatotev# too verbose for generic build 236d75a9ecdSBoyan KaratotevWARNINGS += -Wno-missing-field-initializers \ 237d75a9ecdSBoyan Karatotev -Wno-type-limits -Wno-sign-compare \ 238d75a9ecdSBoyan Karatotev# on clang this flag gets reset if -Wextra is set after it. No difference on gcc 239d75a9ecdSBoyan KaratotevWARNINGS += -Wno-unused-parameter 2409ab81b5eSJustin Chadwell 2419ab81b5eSJustin Chadwell# Additional warnings 242d75a9ecdSBoyan Karatotev# Level 1 - infrequent warnings we should have none of 243d75a9ecdSBoyan Karatotev# full -Wextra 244d75a9ecdSBoyan KaratotevWARNING1 += -Wsign-compare 245d75a9ecdSBoyan KaratotevWARNING1 += -Wtype-limits 246d75a9ecdSBoyan KaratotevWARNING1 += -Wmissing-field-initializers 247e7c645b5SYann Gautier 248d75a9ecdSBoyan Karatotev# Level 2 - problematic warnings that we want 249d75a9ecdSBoyan Karatotev# zlib, compiler-rt, coreboot, and mbdedtls blow up with these 250d75a9ecdSBoyan Karatotev# TODO: disable just for them and move into default build 251d75a9ecdSBoyan KaratotevWARNING2 += -Wold-style-definition 252d75a9ecdSBoyan KaratotevWARNING2 += -Wmissing-prototypes 253d75a9ecdSBoyan KaratotevWARNING2 += -Wmissing-format-attribute 254d75a9ecdSBoyan Karatotev# TF-A aims to comply with this eventually. Effort too large at present 255d75a9ecdSBoyan KaratotevWARNING2 += -Wundef 256d141e638SBoyan Karatotev# currently very involved and many platforms set this off 257d141e638SBoyan KaratotevWARNING2 += -Wunused-const-variable=2 258e7c645b5SYann Gautier 259d75a9ecdSBoyan Karatotev# Level 3 - very pedantic, frequently ignored 260e7c645b5SYann GautierWARNING3 := -Wbad-function-cast 261d75a9ecdSBoyan KaratotevWARNING3 += -Waggregate-return 262d75a9ecdSBoyan KaratotevWARNING3 += -Wnested-externs 263d75a9ecdSBoyan KaratotevWARNING3 += -Wcast-align 264e7c645b5SYann GautierWARNING3 += -Wcast-qual 265e7c645b5SYann GautierWARNING3 += -Wconversion 266e7c645b5SYann GautierWARNING3 += -Wpacked 267e7c645b5SYann GautierWARNING3 += -Wpointer-arith 268e7c645b5SYann GautierWARNING3 += -Wswitch-default 269e7c645b5SYann Gautier 270d75a9ecdSBoyan Karatotev# Setting W is quite verbose and most warnings will be pre-existing issues 271d75a9ecdSBoyan Karatotev# outside of the contributor's control. Don't fail the build on them so warnings 272d75a9ecdSBoyan Karatotev# can be seen and hopefully addressed 273d75a9ecdSBoyan Karatotevifdef W 274d75a9ecdSBoyan Karatotev ifneq (${W},0) 275d75a9ecdSBoyan Karatotev E ?= 0 276d75a9ecdSBoyan Karatotev endif 277d75a9ecdSBoyan Karatotevendif 278d75a9ecdSBoyan Karatotev 279e7c645b5SYann Gautierifeq (${W},1) 2809ab81b5eSJustin Chadwell WARNINGS += $(WARNING1) 281e7c645b5SYann Gautierelse ifeq (${W},2) 2829ab81b5eSJustin Chadwell WARNINGS += $(WARNING1) $(WARNING2) 283e7c645b5SYann Gautierelse ifeq (${W},3) 2849ab81b5eSJustin Chadwell WARNINGS += $(WARNING1) $(WARNING2) $(WARNING3) 285c5e1da83SJayanth Dodderi Chidanandendif #(W) 286e7c645b5SYann Gautier 2879ab81b5eSJustin Chadwell# Compiler specific warnings 28800296576SAmbroise Vincentifeq ($(findstring clang,$(notdir $(CC))),) 28993c690ebSJustin Chadwell# not using clang 290d7b4cd41SJustin ChadwellWARNINGS += -Wunused-but-set-variable -Wmaybe-uninitialized \ 291d7b4cd41SJustin Chadwell -Wpacked-bitfield-compat -Wshift-overflow=2 \ 292d7b4cd41SJustin Chadwell -Wlogical-op 293dea23e24SGovindraj Raja 294dea23e24SGovindraj Raja# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105523 295dea23e24SGovindraj RajaTF_CFLAGS += $(call cc_option, --param=min-pagesize=0) 296dea23e24SGovindraj Raja 297538516f5SBipin Raviifeq ($(HARDEN_SLS), 1) 298538516f5SBipin Ravi TF_CFLAGS_aarch64 += $(call cc_option, -mharden-sls=all) 299538516f5SBipin Raviendif 300538516f5SBipin Ravi 30193c690ebSJustin Chadwellelse 30293c690ebSJustin Chadwell# using clang 303d7b4cd41SJustin ChadwellWARNINGS += -Wshift-overflow -Wshift-sign-overflow \ 304d7b4cd41SJustin Chadwell -Wlogical-op-parentheses 305c5e1da83SJayanth Dodderi Chidanandendif #(Clang Warning) 30600296576SAmbroise Vincent 3076336b07aSYann Gautierifneq (${E},0) 3086336b07aSYann Gautier ERRORS := -Werror 309c5e1da83SJayanth Dodderi Chidanandendif #(E) 3106336b07aSYann Gautier 311c5e1da83SJayanth Dodderi Chidanand################################################################################ 312c5e1da83SJayanth Dodderi Chidanand# Compiler and Linker Directives 313c5e1da83SJayanth Dodderi Chidanand################################################################################ 314ea7a57a3SRoberto VargasCPPFLAGS = ${DEFINES} ${INCLUDES} ${MBEDTLS_INC} -nostdinc \ 3159ab81b5eSJustin Chadwell $(ERRORS) $(WARNINGS) 316d4089fb8SGovindraj RajaASFLAGS += $(CPPFLAGS) \ 317d5dfdeb6SJulius Werner -ffreestanding -Wa,--fatal-warnings 31859de5096SMasahiro YamadaTF_CFLAGS += $(CPPFLAGS) $(TF_CFLAGS_$(ARCH)) \ 319ebd6efaeSSamuel Holland -ffunction-sections -fdata-sections \ 320ebd6efaeSSamuel Holland -ffreestanding -fno-builtin -fno-common \ 321ebd6efaeSSamuel Holland -Os -std=gnu99 32273c99d4eSJuan Castillo 3231f461979SJustin Chadwellifeq (${SANITIZE_UB},on) 3241f461979SJustin Chadwell TF_CFLAGS += -fsanitize=undefined -fno-sanitize-recover 325c5e1da83SJayanth Dodderi Chidanandendif #(${SANITIZE_UB},on) 326c5e1da83SJayanth Dodderi Chidanand 3271f461979SJustin Chadwellifeq (${SANITIZE_UB},trap) 3281f461979SJustin Chadwell TF_CFLAGS += -fsanitize=undefined -fno-sanitize-recover \ 3291f461979SJustin Chadwell -fsanitize-undefined-trap-on-error 330c5e1da83SJayanth Dodderi Chidanandendif #(${SANITIZE_UB},trap) 3311f461979SJustin Chadwell 332f7ec31dbSdavid cunadoGCC_V_OUTPUT := $(shell $(CC) -v 2>&1) 333f7ec31dbSdavid cunado 3341f49db5fSMarco FelschTF_LDFLAGS += -z noexecstack 3351f49db5fSMarco Felsch 336641f16e7SAmbroise Vincent# LD = armlink 337c2ad38ceSVarun Wadekarifneq ($(findstring armlink,$(notdir $(LD))),) 338c2ad38ceSVarun Wadekar TF_LDFLAGS += --diag_error=warning --lto_level=O1 339c2ad38ceSVarun Wadekar TF_LDFLAGS += --remove --info=unused,unusedsymbols 340edbce9aaSzelalem-aweke TF_LDFLAGS += $(TF_LDFLAGS_$(ARCH)) 341641f16e7SAmbroise Vincent 342641f16e7SAmbroise Vincent# LD = gcc (used when GCC LTO is enabled) 343edbce9aaSzelalem-awekeelse ifneq ($(findstring gcc,$(notdir $(LD))),) 344edbce9aaSzelalem-aweke # Pass ld options with Wl or Xlinker switches 34586e489c1SChris Kay TF_LDFLAGS += $(call ld_option,-Xlinker --no-warn-rwx-segments) 346edbce9aaSzelalem-aweke TF_LDFLAGS += -Wl,--fatal-warnings -O1 347edbce9aaSzelalem-aweke TF_LDFLAGS += -Wl,--gc-sections 348ac98b82aSChris Kay 349ac98b82aSChris Kay TF_LDFLAGS += -Wl,-z,common-page-size=4096 #Configure page size constants 350ac98b82aSChris Kay TF_LDFLAGS += -Wl,-z,max-page-size=4096 351304ad94bSAndrey Skvortsov TF_LDFLAGS += -Wl,--build-id=none 352ac98b82aSChris Kay 353edbce9aaSzelalem-aweke ifeq ($(ENABLE_LTO),1) 354edbce9aaSzelalem-aweke ifeq (${ARCH},aarch64) 355edbce9aaSzelalem-aweke TF_LDFLAGS += -flto -fuse-linker-plugin 356edbce9aaSzelalem-aweke endif 357c5e1da83SJayanth Dodderi Chidanand endif #(ENABLE_LTO) 358c5e1da83SJayanth Dodderi Chidanand 359edbce9aaSzelalem-aweke# GCC automatically adds fix-cortex-a53-843419 flag when used to link 360edbce9aaSzelalem-aweke# which breaks some builds, so disable if errata fix is not explicitly enabled 361cfe6767fSYann Gautier ifeq (${ARCH},aarch64) 362edbce9aaSzelalem-aweke ifneq (${ERRATA_A53_843419},1) 363edbce9aaSzelalem-aweke TF_LDFLAGS += -mno-fix-cortex-a53-843419 364edbce9aaSzelalem-aweke endif 365cfe6767fSYann Gautier endif 366edbce9aaSzelalem-aweke TF_LDFLAGS += -nostdlib 367edbce9aaSzelalem-aweke TF_LDFLAGS += $(subst --,-Xlinker --,$(TF_LDFLAGS_$(ARCH))) 368641f16e7SAmbroise Vincent 369641f16e7SAmbroise Vincent# LD = gcc-ld (ld) or llvm-ld (ld.lld) or other 370c2ad38ceSVarun Wadekarelse 3711f49db5fSMarco Felsch# With ld.bfd version 2.39 and newer new warnings are added. Skip those since we 3721f49db5fSMarco Felsch# are not loaded by a elf loader. 3731f49db5fSMarco Felsch TF_LDFLAGS += $(call ld_option, --no-warn-rwx-segments) 374ebac6922SYabin Cui TF_LDFLAGS += -O1 375c2b8806fSDouglas Raillard TF_LDFLAGS += --gc-sections 376ac98b82aSChris Kay 377ac98b82aSChris Kay TF_LDFLAGS += -z common-page-size=4096 # Configure page size constants 378ac98b82aSChris Kay TF_LDFLAGS += -z max-page-size=4096 379304ad94bSAndrey Skvortsov TF_LDFLAGS += --build-id=none 380ac98b82aSChris Kay 381641f16e7SAmbroise Vincent# ld.lld doesn't recognize the errata flags, 382ebac6922SYabin Cui# therefore don't add those in that case. 383ebac6922SYabin Cui# ld.lld reports section type mismatch warnings, 384ebac6922SYabin Cui# therefore don't add --fatal-warnings to it. 385641f16e7SAmbroise Vincent ifeq ($(findstring ld.lld,$(notdir $(LD))),) 386ebac6922SYabin Cui TF_LDFLAGS += $(TF_LDFLAGS_$(ARCH)) --fatal-warnings 387edbce9aaSzelalem-aweke endif 388c5e1da83SJayanth Dodderi Chidanand 389c5e1da83SJayanth Dodderi Chidanandendif #(LD = armlink) 39073c99d4eSJuan Castillo 39173c99d4eSJuan Castillo################################################################################ 392f5211420SGovindraj Raja# Setup ARCH_MAJOR/MINOR before parsing arch_features. 393f5211420SGovindraj Raja################################################################################ 394f5211420SGovindraj Rajaifeq (${ENABLE_RME},1) 395f5211420SGovindraj Raja ARM_ARCH_MAJOR := 8 396f5211420SGovindraj Raja ARM_ARCH_MINOR := 6 397f5211420SGovindraj Rajaendif 398f5211420SGovindraj Raja 399f5211420SGovindraj Raja################################################################################ 40073c99d4eSJuan Castillo# Common sources and include directories 40173c99d4eSJuan Castillo################################################################################ 402d801fbb0Sdp-arminclude lib/compiler-rt/compiler-rt.mk 40373c99d4eSJuan Castillo 40473c99d4eSJuan CastilloBL_COMMON_SOURCES += common/bl_common.c \ 4057f56e9a3SSoby Mathew common/tf_log.c \ 4069d29c227SSoby Mathew common/${ARCH}/debug.S \ 40791b48c9fSJulius Werner drivers/console/multi_console.c \ 4089d29c227SSoby Mathew lib/${ARCH}/cache_helpers.S \ 4099d29c227SSoby Mathew lib/${ARCH}/misc_helpers.S \ 410c73686a1SBoyan Karatotev lib/extensions/pmuv3/${ARCH}/pmuv3.c \ 411566034fcSSoby Mathew plat/common/plat_bl_common.c \ 4127f56e9a3SSoby Mathew plat/common/plat_log_common.c \ 41375311203Sdp-arm plat/common/${ARCH}/plat_common.c \ 4149d29c227SSoby Mathew plat/common/${ARCH}/platform_helpers.S \ 41561f72a34SRoberto Vargas ${COMPILER_RT_SRCS} 416d7a6b0f8SRyan Harkin 4178422a840SAntonio Nino Diazifeq ($(notdir $(CC)),armclang) 4188422a840SAntonio Nino Diaz BL_COMMON_SOURCES += lib/${ARCH}/armclang_printf.S 4198422a840SAntonio Nino Diazendif 4208422a840SAntonio Nino Diaz 4211f461979SJustin Chadwellifeq (${SANITIZE_UB},on) 4221f461979SJustin Chadwell BL_COMMON_SOURCES += plat/common/ubsan.c 4231f461979SJustin Chadwellendif 4241f461979SJustin Chadwell 42501d237cbSYann GautierINCLUDES += -Iinclude \ 426f5478dedSAntonio Nino Diaz -Iinclude/arch/${ARCH} \ 42709d40e0eSAntonio Nino Diaz -Iinclude/lib/cpus/${ARCH} \ 42809d40e0eSAntonio Nino Diaz -Iinclude/lib/el3_runtime/${ARCH} \ 42909d40e0eSAntonio Nino Diaz ${PLAT_INCLUDES} \ 43009d40e0eSAntonio Nino Diaz ${SPD_INCLUDES} 43109d40e0eSAntonio Nino Diaz 432e03dcc8fSNishant SharmaDTC_FLAGS += -I dts -O dtb 433e03dcc8fSNishant SharmaDTC_CPPFLAGS += -P -nostdinc $(INCLUDES) -Ifdts -undef \ 434e03dcc8fSNishant Sharma -x assembler-with-cpp $(DEFINES) 435e03dcc8fSNishant Sharma 4369c6d1c50SAntonio Nino Diazinclude common/backtrace/backtrace.mk 4379c6d1c50SAntonio Nino Diaz 43873c99d4eSJuan Castillo################################################################################ 4393547270fSGovindraj Raja# Generic definitions 4403547270fSGovindraj Raja################################################################################ 4413547270fSGovindraj Rajainclude ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk 4423547270fSGovindraj Raja 4433547270fSGovindraj Rajaifeq (${BUILD_BASE},) 4443547270fSGovindraj Raja BUILD_BASE := ./build 4453547270fSGovindraj Rajaendif 4463547270fSGovindraj RajaBUILD_PLAT := $(abspath ${BUILD_BASE})/${PLAT}/${BUILD_TYPE} 4473547270fSGovindraj Raja 4483547270fSGovindraj RajaSPDS := $(sort $(filter-out none, $(patsubst services/spd/%,%,$(wildcard services/spd/*)))) 4493547270fSGovindraj Raja 4503547270fSGovindraj Raja# Platforms providing their own TBB makefile may override this value 4513547270fSGovindraj RajaINCLUDE_TBBR_MK := 1 4523547270fSGovindraj Raja 4533547270fSGovindraj Raja################################################################################ 4543547270fSGovindraj Raja# Include SPD Makefile if one has been specified 4553547270fSGovindraj Raja################################################################################ 4563547270fSGovindraj Raja 4573547270fSGovindraj Rajaifneq (${SPD},none) 4583547270fSGovindraj Raja ifeq (${ARCH},aarch32) 4593547270fSGovindraj Raja $(error "Error: SPD is incompatible with AArch32.") 4603547270fSGovindraj Raja endif 4613547270fSGovindraj Raja 4623547270fSGovindraj Raja ifdef EL3_PAYLOAD_BASE 4633547270fSGovindraj Raja $(warning "SPD and EL3_PAYLOAD_BASE are incompatible build options.") 4643547270fSGovindraj Raja $(warning "The SPD and its BL32 companion will be present but \ 4653547270fSGovindraj Raja ignored.") 4663547270fSGovindraj Raja endif 4673547270fSGovindraj Raja 4683547270fSGovindraj Raja ifeq (${SPD},spmd) 4693547270fSGovindraj Raja # SPMD is located in std_svc directory 4703547270fSGovindraj Raja SPD_DIR := std_svc 4713547270fSGovindraj Raja 4723547270fSGovindraj Raja ifeq ($(SPMD_SPM_AT_SEL2),1) 4733547270fSGovindraj Raja CTX_INCLUDE_EL2_REGS := 1 4743547270fSGovindraj Raja ifeq ($(SPMC_AT_EL3),1) 4753547270fSGovindraj Raja $(error SPM cannot be enabled in both S-EL2 and EL3.) 4763547270fSGovindraj Raja endif 4773547270fSGovindraj Raja endif 4783547270fSGovindraj Raja 4793547270fSGovindraj Raja ifeq ($(findstring optee_sp,$(ARM_SPMC_MANIFEST_DTS)),optee_sp) 4803547270fSGovindraj Raja DTC_CPPFLAGS += -DOPTEE_SP_FW_CONFIG 4813547270fSGovindraj Raja endif 4823547270fSGovindraj Raja 4833547270fSGovindraj Raja ifeq ($(TS_SP_FW_CONFIG),1) 4843547270fSGovindraj Raja DTC_CPPFLAGS += -DTS_SP_FW_CONFIG 4853547270fSGovindraj Raja endif 4863547270fSGovindraj Raja 4873547270fSGovindraj Raja ifneq ($(ARM_BL2_SP_LIST_DTS),) 4883547270fSGovindraj Raja DTC_CPPFLAGS += -DARM_BL2_SP_LIST_DTS=$(ARM_BL2_SP_LIST_DTS) 4893547270fSGovindraj Raja endif 4903547270fSGovindraj Raja 4913547270fSGovindraj Raja ifneq ($(SP_LAYOUT_FILE),) 4923547270fSGovindraj Raja BL2_ENABLE_SP_LOAD := 1 4933547270fSGovindraj Raja endif 494c189adbdSGovindraj Raja 495c189adbdSGovindraj Raja ifeq ($(SPMC_AT_EL3_SEL0_SP),1) 496c189adbdSGovindraj Raja ifneq ($(SPMC_AT_EL3),1) 497c189adbdSGovindraj Raja $(error SEL0 SP cannot be enabled without SPMC at EL3) 498c189adbdSGovindraj Raja endif 499c189adbdSGovindraj Raja endif 5003547270fSGovindraj Raja else 5013547270fSGovindraj Raja # All other SPDs in spd directory 5023547270fSGovindraj Raja SPD_DIR := spd 5033547270fSGovindraj Raja endif #(SPD) 5043547270fSGovindraj Raja 5053547270fSGovindraj Raja # We expect to locate an spd.mk under the specified SPD directory 5063547270fSGovindraj Raja SPD_MAKE := $(wildcard services/${SPD_DIR}/${SPD}/${SPD}.mk) 5073547270fSGovindraj Raja 5083547270fSGovindraj Raja ifeq (${SPD_MAKE},) 5093547270fSGovindraj Raja $(error Error: No services/${SPD_DIR}/${SPD}/${SPD}.mk located) 5103547270fSGovindraj Raja endif 5113547270fSGovindraj Raja $(info Including ${SPD_MAKE}) 5123547270fSGovindraj Raja include ${SPD_MAKE} 5133547270fSGovindraj Raja 5143547270fSGovindraj Raja # If there's BL32 companion for the chosen SPD, we expect that the SPD's 5153547270fSGovindraj Raja # Makefile would set NEED_BL32 to "yes". In this case, the build system 5163547270fSGovindraj Raja # supports two mutually exclusive options: 5173547270fSGovindraj Raja # * BL32 is built from source: then BL32_SOURCES must contain the list 5183547270fSGovindraj Raja # of source files to build BL32 5193547270fSGovindraj Raja # * BL32 is a prebuilt binary: then BL32 must point to the image file 5203547270fSGovindraj Raja # that will be included in the FIP 5213547270fSGovindraj Raja # If both BL32_SOURCES and BL32 are defined, the binary takes precedence 5223547270fSGovindraj Raja # over the sources. 5233547270fSGovindraj Rajaendif #(SPD=none) 5243547270fSGovindraj Raja 5253547270fSGovindraj Rajaifeq (${ENABLE_SPMD_LP}, 1) 5263547270fSGovindraj Rajaifneq (${SPD},spmd) 5273547270fSGovindraj Raja $(error Error: ENABLE_SPMD_LP requires SPD=spmd.) 5283547270fSGovindraj Rajaendif 5293547270fSGovindraj Rajaifeq ($(SPMC_AT_EL3),1) 5303547270fSGovindraj Raja $(error SPMC at EL3 not supported when enabling SPMD Logical partitions.) 5313547270fSGovindraj Rajaendif 5323547270fSGovindraj Rajaendif 5333547270fSGovindraj Raja 5343547270fSGovindraj Raja################################################################################ 535f5211420SGovindraj Raja# Process BRANCH_PROTECTION value and set 536f5211420SGovindraj Raja# Pointer Authentication and Branch Target Identification flags 537f5211420SGovindraj Raja################################################################################ 538f5211420SGovindraj Rajaifeq (${BRANCH_PROTECTION},0) 539f5211420SGovindraj Raja # Default value turns off all types of branch protection 540f5211420SGovindraj Raja BP_OPTION := none 541f5211420SGovindraj Rajaelse ifneq (${ARCH},aarch64) 542f5211420SGovindraj Raja $(error BRANCH_PROTECTION requires AArch64) 543f5211420SGovindraj Rajaelse ifeq (${BRANCH_PROTECTION},1) 544f5211420SGovindraj Raja # Enables all types of branch protection features 545f5211420SGovindraj Raja BP_OPTION := standard 546f5211420SGovindraj Raja ENABLE_BTI := 1 547f5211420SGovindraj Raja ENABLE_PAUTH := 1 548f5211420SGovindraj Rajaelse ifeq (${BRANCH_PROTECTION},2) 549f5211420SGovindraj Raja # Return address signing to its standard level 550f5211420SGovindraj Raja BP_OPTION := pac-ret 551f5211420SGovindraj Raja ENABLE_PAUTH := 1 552f5211420SGovindraj Rajaelse ifeq (${BRANCH_PROTECTION},3) 553f5211420SGovindraj Raja # Extend the signing to include leaf functions 554f5211420SGovindraj Raja BP_OPTION := pac-ret+leaf 555f5211420SGovindraj Raja ENABLE_PAUTH := 1 556f5211420SGovindraj Rajaelse ifeq (${BRANCH_PROTECTION},4) 557f5211420SGovindraj Raja # Turn on branch target identification mechanism 558f5211420SGovindraj Raja BP_OPTION := bti 559f5211420SGovindraj Raja ENABLE_BTI := 1 560f5211420SGovindraj Rajaelse 561f5211420SGovindraj Raja $(error Unknown BRANCH_PROTECTION value ${BRANCH_PROTECTION}) 562f5211420SGovindraj Rajaendif #(BRANCH_PROTECTION) 563f5211420SGovindraj Raja 564f5211420SGovindraj Rajaifeq ($(ENABLE_PAUTH),1) 565f5211420SGovindraj Raja CTX_INCLUDE_PAUTH_REGS := 1 566f5211420SGovindraj Rajaendif 567f5211420SGovindraj Rajaifneq (${BP_OPTION},none) 568f5211420SGovindraj Raja TF_CFLAGS_aarch64 += -mbranch-protection=${BP_OPTION} 569f5211420SGovindraj Rajaendif #(BP_OPTION) 570f5211420SGovindraj Raja 571f5211420SGovindraj Raja# Pointer Authentication sources 572f5211420SGovindraj Rajaifeq (${ENABLE_PAUTH}, 1) 573f5211420SGovindraj Raja# arm/common/aarch64/arm_pauth.c contains a sample platform hook to complete the 574f5211420SGovindraj Raja# Pauth support. As it's not secure, it must be reimplemented for real platforms 575f5211420SGovindraj Raja BL_COMMON_SOURCES += lib/extensions/pauth/pauth_helpers.S 576f5211420SGovindraj Rajaendif 577f5211420SGovindraj Raja 5783547270fSGovindraj Raja################################################################################ 5793547270fSGovindraj Raja# Include the platform specific Makefile after the SPD Makefile (the platform 5803547270fSGovindraj Raja# makefile may use all previous definitions in this file) 5813547270fSGovindraj Raja################################################################################ 5823547270fSGovindraj Rajainclude ${PLAT_MAKEFILE_FULL} 5833547270fSGovindraj Raja 5843547270fSGovindraj Raja################################################################################ 5853547270fSGovindraj Raja# Setup arch_features based on ARM_ARCH_MAJOR, ARM_ARCH_MINOR provided from 5863547270fSGovindraj Raja# platform. 5873547270fSGovindraj Raja################################################################################ 5883547270fSGovindraj Rajainclude ${MAKE_HELPERS_DIRECTORY}arch_features.mk 5893547270fSGovindraj Raja 590f5211420SGovindraj Raja#################################################### 591f5211420SGovindraj Raja# Enable required options for Memory Stack Tagging. 592f5211420SGovindraj Raja#################################################### 593f5211420SGovindraj Raja 594f5211420SGovindraj Raja# Currently, these options are enabled only for clang and armclang compiler. 595f5211420SGovindraj Rajaifeq (${SUPPORT_STACK_MEMTAG},yes) 596f5211420SGovindraj Raja ifdef mem_tag_arch_support 597f5211420SGovindraj Raja # Check for armclang and clang compilers 598f5211420SGovindraj Raja ifneq ( ,$(filter $(notdir $(CC)),armclang clang)) 599f5211420SGovindraj Raja # Add "memtag" architecture feature modifier if not specified 600f5211420SGovindraj Raja ifeq ( ,$(findstring memtag,$(arch-features))) 601f5211420SGovindraj Raja arch-features := $(arch-features)+memtag 602f5211420SGovindraj Raja endif # memtag 603f5211420SGovindraj Raja ifeq ($(notdir $(CC)),armclang) 604f5211420SGovindraj Raja TF_CFLAGS += -mmemtag-stack 605f5211420SGovindraj Raja else ifeq ($(notdir $(CC)),clang) 606f5211420SGovindraj Raja TF_CFLAGS += -fsanitize=memtag 607f5211420SGovindraj Raja endif # armclang 608f5211420SGovindraj Raja endif 609f5211420SGovindraj Raja else 610f5211420SGovindraj Raja $(error "Error: stack memory tagging is not supported for \ 611f5211420SGovindraj Raja architecture ${ARCH},armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a") 612f5211420SGovindraj Raja endif #(mem_tag_arch_support) 613f5211420SGovindraj Rajaendif #(SUPPORT_STACK_MEMTAG) 614f5211420SGovindraj Raja 615f5211420SGovindraj Raja################################################################################ 616f5211420SGovindraj Raja# RME dependent flags configuration, Enable optional features for RME. 617f5211420SGovindraj Raja################################################################################ 618f5211420SGovindraj Raja# FEAT_RME 619f5211420SGovindraj Rajaifeq (${ENABLE_RME},1) 620d638029fSGovindraj Raja # RME doesn't support BRBE 621d638029fSGovindraj Raja ENABLE_BRBE_FOR_NS := 0 622d638029fSGovindraj Raja 623f5211420SGovindraj Raja # RME doesn't support PIE 624f5211420SGovindraj Raja ifneq (${ENABLE_PIE},0) 625f5211420SGovindraj Raja $(error ENABLE_RME does not support PIE) 626f5211420SGovindraj Raja endif 627f5211420SGovindraj Raja 628f5211420SGovindraj Raja # RME doesn't support BRBE 629f5211420SGovindraj Raja ifneq (${ENABLE_BRBE_FOR_NS},0) 630f5211420SGovindraj Raja $(error ENABLE_RME does not support BRBE.) 631f5211420SGovindraj Raja endif 632f5211420SGovindraj Raja 633f5211420SGovindraj Raja # RME requires AARCH64 634f5211420SGovindraj Raja ifneq (${ARCH},aarch64) 635f5211420SGovindraj Raja $(error ENABLE_RME requires AArch64) 636f5211420SGovindraj Raja endif 637f5211420SGovindraj Raja 638f5211420SGovindraj Raja # RME requires el2 context to be saved for now. 639f5211420SGovindraj Raja CTX_INCLUDE_EL2_REGS := 1 640f5211420SGovindraj Raja CTX_INCLUDE_AARCH32_REGS := 0 641f5211420SGovindraj Raja CTX_INCLUDE_PAUTH_REGS := 1 642f5211420SGovindraj Raja 643f5211420SGovindraj Raja # RME enables CSV2_2 extension by default. 644f5211420SGovindraj Raja ENABLE_FEAT_CSV2_2 = 1 645f5211420SGovindraj Rajaendif #(FEAT_RME) 646f5211420SGovindraj Raja 647f5211420SGovindraj Raja################################################################################ 6485b18de09SZelalem Aweke# Include rmmd Makefile if RME is enabled 6495b18de09SZelalem Aweke################################################################################ 6505b18de09SZelalem Awekeifneq (${ENABLE_RME},0) 6515b18de09SZelalem Aweke ifneq (${ARCH},aarch64) 6525b18de09SZelalem Aweke $(error ENABLE_RME requires AArch64) 6535b18de09SZelalem Aweke endif 6541d63ae4dSMarc Bonnici ifeq ($(SPMC_AT_EL3),1) 6551d63ae4dSMarc Bonnici $(error SPMC_AT_EL3 and ENABLE_RME cannot both be enabled.) 6561d63ae4dSMarc Bonnici endif 657c5e1da83SJayanth Dodderi Chidanand 6584fba2e1fSBoyan Karatotev ifneq (${SPD}, none) 6594fba2e1fSBoyan Karatotev ifneq (${SPD}, spmd) 6604fba2e1fSBoyan Karatotev $(error ENABLE_RME is incompatible with SPD=${SPD}. Use SPD=spmd) 6614fba2e1fSBoyan Karatotev endif 6624fba2e1fSBoyan Karatotev endif 6635b18de09SZelalem Awekeinclude services/std_svc/rmmd/rmmd.mk 6645b18de09SZelalem Aweke$(warning "RME is an experimental feature") 6655b18de09SZelalem Awekeendif 6665b18de09SZelalem Aweke 6673547270fSGovindraj Rajaifeq (${CTX_INCLUDE_EL2_REGS}, 1) 6683547270fSGovindraj Raja ifeq (${SPD},none) 6693547270fSGovindraj Raja ifeq (${ENABLE_RME},0) 6703547270fSGovindraj Raja $(error CTX_INCLUDE_EL2_REGS is available only when SPD \ 6713547270fSGovindraj Raja or RME is enabled) 6723547270fSGovindraj Raja endif 6733547270fSGovindraj Raja endif 6743547270fSGovindraj Rajaendif 6750f21c547SJuan Castillo 6767794d6c8SGovindraj Raja################################################################################ 6777794d6c8SGovindraj Raja# Platform specific Makefile might provide us ARCH_MAJOR/MINOR use that to come 6787794d6c8SGovindraj Raja# up with appropriate march values for compiler. 6797794d6c8SGovindraj Raja################################################################################ 6807794d6c8SGovindraj Rajainclude ${MAKE_HELPERS_DIRECTORY}march.mk 6817794d6c8SGovindraj Raja 6827794d6c8SGovindraj RajaTF_CFLAGS += $(march-directive) 683*7275ac2aSGovindraj RajaASFLAGS += $(march-directive) 6847794d6c8SGovindraj Raja 68542d4d3baSArvind Ram Prakash# This internal flag is common option which is set to 1 for scenarios 68642d4d3baSArvind Ram Prakash# when the BL2 is running in EL3 level. This occurs in two scenarios - 68742d4d3baSArvind Ram Prakash# 4 world system running BL2 at EL3 and two world system without BL1 running 68842d4d3baSArvind Ram Prakash# BL2 in EL3 68942d4d3baSArvind Ram Prakash 69042d4d3baSArvind Ram Prakashifeq (${RESET_TO_BL2},1) 69142d4d3baSArvind Ram Prakash BL2_RUNS_AT_EL3 := 1 69242d4d3baSArvind Ram Prakash ifeq (${ENABLE_RME},1) 693c5e1da83SJayanth Dodderi Chidanand $(error RESET_TO_BL2=1 and ENABLE_RME=1 configuration is not \ 694c5e1da83SJayanth Dodderi Chidanand supported at the moment.) 69542d4d3baSArvind Ram Prakash endif 69642d4d3baSArvind Ram Prakashelse ifeq (${ENABLE_RME},1) 69742d4d3baSArvind Ram Prakash BL2_RUNS_AT_EL3 := 1 69842d4d3baSArvind Ram Prakashelse 69942d4d3baSArvind Ram Prakash BL2_RUNS_AT_EL3 := 0 70042d4d3baSArvind Ram Prakashendif 70142d4d3baSArvind Ram Prakash 702f87e54f7SManish Pandey# This internal flag is set to 1 when Firmware First handling of External aborts 703f87e54f7SManish Pandey# is required by lowe ELs. Currently only NS requires this support. 704f87e54f7SManish Pandeyifeq ($(HANDLE_EA_EL3_FIRST_NS),1) 705f87e54f7SManish Pandey FFH_SUPPORT := 1 706f87e54f7SManish Pandeyelse 707f87e54f7SManish Pandey FFH_SUPPORT := 0 708f87e54f7SManish Pandeyendif 709f87e54f7SManish Pandey 7108012cc5cSMasahiro Yamada$(eval $(call MAKE_PREREQ_DIR,${BUILD_PLAT})) 7118012cc5cSMasahiro Yamada 71226e63c44SEtienne Carriereifeq (${ARM_ARCH_MAJOR},7) 71326e63c44SEtienne Carriereinclude make_helpers/armv7-a-cpus.mk 71426e63c44SEtienne Carriereendif 71526e63c44SEtienne Carriere 7163bd17c0fSSoby MathewPIE_FOUND := $(findstring --enable-default-pie,${GCC_V_OUTPUT}) 7173bd17c0fSSoby Mathewifneq ($(PIE_FOUND),) 7183bd17c0fSSoby Mathew TF_CFLAGS += -fno-PIE 7197b592418SSamuel Hollandifneq ($(findstring gcc,$(notdir $(LD))),) 7207b592418SSamuel Holland TF_LDFLAGS += -no-pie 7217b592418SSamuel Hollandendif 722c5e1da83SJayanth Dodderi Chidanandendif #(PIE_FOUND) 723320920c1SMasahiro Yamada 724320920c1SMasahiro Yamadaifneq ($(findstring gcc,$(notdir $(LD))),) 725320920c1SMasahiro Yamada PIE_LDFLAGS += -Wl,-pie -Wl,--no-dynamic-linker 726320920c1SMasahiro Yamadaelse 727320920c1SMasahiro Yamada PIE_LDFLAGS += -pie --no-dynamic-linker 728320920c1SMasahiro Yamadaendif 729320920c1SMasahiro Yamada 730320920c1SMasahiro Yamadaifeq ($(ENABLE_PIE),1) 73142d4d3baSArvind Ram Prakash ifeq ($(RESET_TO_BL2),1) 73269af7fcfSMasahiro Yamada ifneq ($(BL2_IN_XIP_MEM),1) 733966660ecSChris Kay BL2_CPPFLAGS += -fpie 73469af7fcfSMasahiro Yamada BL2_CFLAGS += -fpie 73569af7fcfSMasahiro Yamada BL2_LDFLAGS += $(PIE_LDFLAGS) 736c5e1da83SJayanth Dodderi Chidanand endif #(BL2_IN_XIP_MEM) 737c5e1da83SJayanth Dodderi Chidanand endif #(RESET_TO_BL2) 738966660ecSChris Kay BL31_CPPFLAGS += -fpie 739320920c1SMasahiro Yamada BL31_CFLAGS += -fpie 740320920c1SMasahiro Yamada BL31_LDFLAGS += $(PIE_LDFLAGS) 741966660ecSChris Kay 742966660ecSChris Kay BL32_CPPFLAGS += -fpie 743d974301dSMasahiro Yamada BL32_CFLAGS += -fpie 744d974301dSMasahiro Yamada BL32_LDFLAGS += $(PIE_LDFLAGS) 745c5e1da83SJayanth Dodderi Chidanandendif #(ENABLE_PIE) 7463bd17c0fSSoby Mathew 747007433d8SBoyan KaratotevBL1_CPPFLAGS += -DREPORT_ERRATA=${DEBUG} 748007433d8SBoyan KaratotevBL31_CPPFLAGS += -DREPORT_ERRATA=${DEBUG} 749007433d8SBoyan KaratotevBL32_CPPFLAGS += -DREPORT_ERRATA=${DEBUG} 750007433d8SBoyan Karatotev 7519cefb4b1SMasahiro YamadaBL1_CPPFLAGS += -DIMAGE_AT_EL3 75242d4d3baSArvind Ram Prakashifeq ($(RESET_TO_BL2),1) 7539cefb4b1SMasahiro Yamada BL2_CPPFLAGS += -DIMAGE_AT_EL3 754d5e97a1dSMasahiro Yamadaelse 7559cefb4b1SMasahiro Yamada BL2_CPPFLAGS += -DIMAGE_AT_EL1 756c5e1da83SJayanth Dodderi Chidanandendif #(RESET_TO_BL2) 757007433d8SBoyan Karatotev 758007433d8SBoyan Karatotevifeq (${ARCH},aarch64) 7599cefb4b1SMasahiro Yamada BL2U_CPPFLAGS += -DIMAGE_AT_EL1 7609cefb4b1SMasahiro Yamada BL31_CPPFLAGS += -DIMAGE_AT_EL3 7619cefb4b1SMasahiro Yamada BL32_CPPFLAGS += -DIMAGE_AT_EL1 762007433d8SBoyan Karatotevelse 763007433d8SBoyan Karatotev BL32_CPPFLAGS += -DIMAGE_AT_EL3 764d5e97a1dSMasahiro Yamadaendif 765d5e97a1dSMasahiro Yamada 76654035fc4SSandrine Bailleux# Include the CPU specific operations makefile, which provides default 76754035fc4SSandrine Bailleux# values for all CPU errata workarounds and CPU specific optimisations. 76854035fc4SSandrine Bailleux# This can be overridden by the platform. 76973c99d4eSJuan Castilloinclude lib/cpus/cpu-ops.mk 7704f6ad66aSAchin Gupta 771a4409008Sdp-arm################################################################################ 772a4409008Sdp-arm# Build `AARCH32_SP` as BL32 image for AArch32 773a4409008Sdp-arm################################################################################ 774c5e1da83SJayanth Dodderi Chidanandifeq (${ARCH},aarch32) 775c5e1da83SJayanth Dodderi Chidanand NEED_BL32 := yes 776c5e1da83SJayanth Dodderi Chidanand 777a4409008Sdp-arm ifneq (${AARCH32_SP},none) 778a4409008Sdp-arm # We expect to locate an sp.mk under the specified AARCH32_SP directory 779a4409008Sdp-arm AARCH32_SP_MAKE := $(wildcard bl32/${AARCH32_SP}/${AARCH32_SP}.mk) 780a4409008Sdp-arm 781a4409008Sdp-arm ifeq (${AARCH32_SP_MAKE},) 782a4409008Sdp-arm $(error Error: No bl32/${AARCH32_SP}/${AARCH32_SP}.mk located) 783a4409008Sdp-arm endif 784a4409008Sdp-arm $(info Including ${AARCH32_SP_MAKE}) 785a4409008Sdp-arm include ${AARCH32_SP_MAKE} 786a4409008Sdp-arm endif 787c5e1da83SJayanth Dodderi Chidanandendif #(ARCH=aarch32) 7884f6ad66aSAchin Gupta 78973c99d4eSJuan Castillo################################################################################ 79077f1f7a1SVarun Wadekar# Include libc if not overridden 79177f1f7a1SVarun Wadekar################################################################################ 79277f1f7a1SVarun Wadekarifeq (${OVERRIDE_LIBC},0) 79377f1f7a1SVarun Wadekarinclude lib/libc/libc.mk 79477f1f7a1SVarun Wadekarendif 79577f1f7a1SVarun Wadekar 79677f1f7a1SVarun Wadekar################################################################################ 797c5e1da83SJayanth Dodderi Chidanand# Check incompatible options and dependencies 798cf2c8a33SAntonio Nino Diaz################################################################################ 799cf2c8a33SAntonio Nino Diaz 800c5e1da83SJayanth Dodderi Chidanand# USE_DEBUGFS experimental feature recommended only in debug builds 801c5e1da83SJayanth Dodderi Chidanandifeq (${USE_DEBUGFS},1) 802c5e1da83SJayanth Dodderi Chidanand ifeq (${DEBUG},1) 803c5e1da83SJayanth Dodderi Chidanand $(warning DEBUGFS experimental feature is enabled.) 804c5e1da83SJayanth Dodderi Chidanand else 805c5e1da83SJayanth Dodderi Chidanand $(warning DEBUGFS experimental, recommended in DEBUG builds ONLY) 806c5e1da83SJayanth Dodderi Chidanand endif 807c5e1da83SJayanth Dodderi Chidanandendif #(USE_DEBUGFS) 808c5e1da83SJayanth Dodderi Chidanand 809c5e1da83SJayanth Dodderi Chidanand# USE_SPINLOCK_CAS requires AArch64 build 810c5e1da83SJayanth Dodderi Chidanandifeq (${USE_SPINLOCK_CAS},1) 811c5e1da83SJayanth Dodderi Chidanand ifneq (${ARCH},aarch64) 812c5e1da83SJayanth Dodderi Chidanand $(error USE_SPINLOCK_CAS requires AArch64) 813c5e1da83SJayanth Dodderi Chidanand endif 814c5e1da83SJayanth Dodderi Chidanandendif #(USE_SPINLOCK_CAS) 815c5e1da83SJayanth Dodderi Chidanand 816c5e1da83SJayanth Dodderi Chidanand# The cert_create tool cannot generate certificates individually, so we use the 817c5e1da83SJayanth Dodderi Chidanand# target 'certificates' to create them all 818c5e1da83SJayanth Dodderi Chidanandifneq (${GENERATE_COT},0) 819c5e1da83SJayanth Dodderi Chidanand FIP_DEPS += certificates 820c5e1da83SJayanth Dodderi Chidanand FWU_FIP_DEPS += fwu_certificates 821c5e1da83SJayanth Dodderi Chidanandendif 822c5e1da83SJayanth Dodderi Chidanand 823c5e1da83SJayanth Dodderi Chidanandifneq (${DECRYPTION_SUPPORT},none) 824c5e1da83SJayanth Dodderi Chidanand ENC_ARGS += -f ${FW_ENC_STATUS} 825c5e1da83SJayanth Dodderi Chidanand ENC_ARGS += -k ${ENC_KEY} 826c5e1da83SJayanth Dodderi Chidanand ENC_ARGS += -n ${ENC_NONCE} 827c5e1da83SJayanth Dodderi Chidanand FIP_DEPS += enctool 828c5e1da83SJayanth Dodderi Chidanand FWU_FIP_DEPS += enctool 829c5e1da83SJayanth Dodderi Chidanandendif #(DECRYPTION_SUPPORT) 830c5e1da83SJayanth Dodderi Chidanand 831cf2c8a33SAntonio Nino Diazifdef EL3_PAYLOAD_BASE 83268450a6dSAntonio Nino Diaz ifdef PRELOADED_BL33_BASE 83368450a6dSAntonio Nino Diaz $(warning "PRELOADED_BL33_BASE and EL3_PAYLOAD_BASE are \ 83468450a6dSAntonio Nino Diaz incompatible build options. EL3_PAYLOAD_BASE has priority.") 835cf2c8a33SAntonio Nino Diaz endif 83676580f3dSQixiang Xu ifneq (${GENERATE_COT},0) 837c5e1da83SJayanth Dodderi Chidanand $(error "GENERATE_COT and EL3_PAYLOAD_BASE are incompatible \ 838c5e1da83SJayanth Dodderi Chidanand build options.") 83976580f3dSQixiang Xu endif 84076580f3dSQixiang Xu ifneq (${TRUSTED_BOARD_BOOT},0) 841c5e1da83SJayanth Dodderi Chidanand $(error "TRUSTED_BOARD_BOOT and EL3_PAYLOAD_BASE are \ 842c5e1da83SJayanth Dodderi Chidanand incompatible \ build options.") 84376580f3dSQixiang Xu endif 844c5e1da83SJayanth Dodderi Chidanandendif #(EL3_PAYLOAD_BASE) 845cf2c8a33SAntonio Nino Diaz 846cf2c8a33SAntonio Nino Diazifeq (${NEED_BL33},yes) 847cf2c8a33SAntonio Nino Diaz ifdef EL3_PAYLOAD_BASE 848cf2c8a33SAntonio Nino Diaz $(warning "BL33 image is not needed when option \ 849cf2c8a33SAntonio Nino Diaz BL33_PAYLOAD_BASE is used and won't be added to the FIP file.") 850cf2c8a33SAntonio Nino Diaz endif 85168450a6dSAntonio Nino Diaz ifdef PRELOADED_BL33_BASE 85268450a6dSAntonio Nino Diaz $(warning "BL33 image is not needed when option \ 853c5e1da83SJayanth Dodderi Chidanand PRELOADED_BL33_BASE is used and won't be added to the FIP file.") 854cf2c8a33SAntonio Nino Diaz endif 855c5e1da83SJayanth Dodderi Chidanandendif #(NEED_BL33) 856cf2c8a33SAntonio Nino Diaz 857d4593e47SJeenu Viswambharan# When building for systems with hardware-assisted coherency, there's no need to 858d4593e47SJeenu Viswambharan# use USE_COHERENT_MEM. Require that USE_COHERENT_MEM must be set to 0 too. 859d4593e47SJeenu Viswambharanifeq ($(HW_ASSISTED_COHERENCY)-$(USE_COHERENT_MEM),1-1) 860d4593e47SJeenu Viswambharan $(error USE_COHERENT_MEM cannot be enabled with HW_ASSISTED_COHERENCY) 861d4593e47SJeenu Viswambharanendif 8621a0a3f06SYatharth Kochar 86342d4d3baSArvind Ram Prakash#For now, BL2_IN_XIP_MEM is only supported when RESET_TO_BL2 is 1. 86442d4d3baSArvind Ram Prakashifeq ($(RESET_TO_BL2)-$(BL2_IN_XIP_MEM),0-1) 86542d4d3baSArvind Ram Prakash $(error "BL2_IN_XIP_MEM is only supported when RESET_TO_BL2 is enabled") 8667d173fc5SJiafei Panendif 8677d173fc5SJiafei Pan 8689202d519SManish Pandey# RAS_EXTENSION is deprecated, provide alternate build options 86914c6016aSJeenu Viswambharanifeq ($(RAS_EXTENSION),1) 870c5e1da83SJayanth Dodderi Chidanand $(error "RAS_EXTENSION is now deprecated, please use ENABLE_FEAT_RAS \ 871f87e54f7SManish Pandey and HANDLE_EA_EL3_FIRST_NS instead") 8729202d519SManish Pandeyendif 873c5e1da83SJayanth Dodderi Chidanand 874c5e1da83SJayanth Dodderi Chidanand 8759202d519SManish Pandey# When FAULT_INJECTION_SUPPORT is used, require that FEAT_RAS is enabled 8761a7c1cfeSJeenu Viswambharanifeq ($(FAULT_INJECTION_SUPPORT),1) 8776503ff29SAndre Przywara ifeq ($(ENABLE_FEAT_RAS),0) 8786503ff29SAndre Przywara $(error For FAULT_INJECTION_SUPPORT, ENABLE_FEAT_RAS must not be 0) 8791a7c1cfeSJeenu Viswambharan endif 880c5e1da83SJayanth Dodderi Chidanandendif #(FAULT_INJECTION_SUPPORT) 8811a7c1cfeSJeenu Viswambharan 882ed51b51fSRoberto Vargas# DYN_DISABLE_AUTH can be set only when TRUSTED_BOARD_BOOT=1 883209a60ccSSoby Mathewifeq ($(DYN_DISABLE_AUTH), 1) 884209a60ccSSoby Mathew ifeq (${TRUSTED_BOARD_BOOT}, 0) 885c5e1da83SJayanth Dodderi Chidanand $(error "TRUSTED_BOARD_BOOT must be enabled for DYN_DISABLE_AUTH \ 886c5e1da83SJayanth Dodderi Chidanand to be set.") 887209a60ccSSoby Mathew endif 888c5e1da83SJayanth Dodderi Chidanandendif #(DYN_DISABLE_AUTH) 889209a60ccSSoby Mathew 8902bf4f27fSManish V Badarkheifeq ($(MEASURED_BOOT)-$(TRUSTED_BOARD_BOOT),1-1) 8912bf4f27fSManish V Badarkhe# Support authentication verification and hash calculation 8922bf4f27fSManish V Badarkhe CRYPTO_SUPPORT := 3 8932bf4f27fSManish V Badarkheelse ifeq ($(DRTM_SUPPORT)-$(TRUSTED_BOARD_BOOT),1-1) 8942bf4f27fSManish V Badarkhe# Support authentication verification and hash calculation 8952bf4f27fSManish V Badarkhe CRYPTO_SUPPORT := 3 8962bf4f27fSManish V Badarkheelse ifneq ($(filter 1,${MEASURED_BOOT} ${DRTM_SUPPORT}),) 8972bf4f27fSManish V Badarkhe# Support hash calculation only 8982bf4f27fSManish V Badarkhe CRYPTO_SUPPORT := 2 8992bf4f27fSManish V Badarkheelse ifeq (${TRUSTED_BOARD_BOOT},1) 9002bf4f27fSManish V Badarkhe# Support authentication verification only 901c9c56f6eSManish V Badarkhe CRYPTO_SUPPORT := 1 902c9c56f6eSManish V Badarkheelse 903c9c56f6eSManish V Badarkhe CRYPTO_SUPPORT := 0 904c5e1da83SJayanth Dodderi Chidanandendif #($(MEASURED_BOOT)-$(TRUSTED_BOARD_BOOT)) 905c9c56f6eSManish V Badarkhe 906cbf9e84aSBalint Dobszay# SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled. 907cbf9e84aSBalint Dobszayifeq ($(SDEI_SUPPORT)-$(SDEI_IN_FCONF),0-1) 908700e7685SManish Pandey $(error "SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled") 90984ef9cd8SManish V Badarkheendif 91084ef9cd8SManish V Badarkhe 911b86048c4SAntonio Nino Diaz# If pointer authentication is used in the firmware, make sure that all the 9129fc59639SAlexei Fedorov# registers associated to it are also saved and restored. 9139fc59639SAlexei Fedorov# Not doing it would leak the value of the keys used by EL3 to EL1 and S-EL1. 914b86048c4SAntonio Nino Diazifeq ($(ENABLE_PAUTH),1) 9159fc59639SAlexei Fedorov ifeq ($(CTX_INCLUDE_PAUTH_REGS),0) 9169fc59639SAlexei Fedorov $(error Pointer Authentication requires CTX_INCLUDE_PAUTH_REGS=1) 91706715f85SAlexei Fedorov endif 918c5e1da83SJayanth Dodderi Chidanandendif #(ENABLE_PAUTH) 9199fc59639SAlexei Fedorov 92006715f85SAlexei Fedorovifeq ($(CTX_INCLUDE_PAUTH_REGS),1) 9219fc59639SAlexei Fedorov ifneq (${ARCH},aarch64) 9229fc59639SAlexei Fedorov $(error CTX_INCLUDE_PAUTH_REGS requires AArch64) 923b86048c4SAntonio Nino Diaz endif 924c5e1da83SJayanth Dodderi Chidanandendif #(CTX_INCLUDE_PAUTH_REGS) 9259fc59639SAlexei Fedorov 926396b339dSManish V Badarkheifeq ($(PSA_FWU_SUPPORT),1) 927396b339dSManish V Badarkhe $(info PSA_FWU_SUPPORT is an experimental feature) 928c5e1da83SJayanth Dodderi Chidanandendif #(PSA_FWU_SUPPORT) 929396b339dSManish V Badarkhe 9306a0da736SJayanth Dodderi Chidanandifeq ($(FEATURE_DETECTION),1) 9316a0da736SJayanth Dodderi Chidanand $(info FEATURE_DETECTION is an experimental feature) 932c5e1da83SJayanth Dodderi Chidanandendif #(FEATURE_DETECTION) 9336a0da736SJayanth Dodderi Chidanand 93403d3c0d7SJayanth Dodderi Chidanandifneq ($(ENABLE_SME2_FOR_NS), 0) 93503d3c0d7SJayanth Dodderi Chidanand ifeq (${ENABLE_SME_FOR_NS}, 0) 936c5e1da83SJayanth Dodderi Chidanand $(warning "ENABLE_SME2_FOR_NS requires ENABLE_SME_FOR_NS also \ 937c5e1da83SJayanth Dodderi Chidanand to be set") 93803d3c0d7SJayanth Dodderi Chidanand $(warning "Forced ENABLE_SME_FOR_NS=1") 93903d3c0d7SJayanth Dodderi Chidanand override ENABLE_SME_FOR_NS := 1 94003d3c0d7SJayanth Dodderi Chidanand endif 941c5e1da83SJayanth Dodderi Chidanandendif #(ENABLE_SME2_FOR_NS) 94245007acdSJayanth Dodderi Chidanand 94360e8f3cfSPetre-Ionut Tudorifeq (${ARM_XLAT_TABLES_LIB_V1}, 1) 94460e8f3cfSPetre-Ionut Tudor ifeq (${ALLOW_RO_XLAT_TABLES}, 1) 945c5e1da83SJayanth Dodderi Chidanand $(error "ALLOW_RO_XLAT_TABLES requires translation tables \ 946c5e1da83SJayanth Dodderi Chidanand library v2") 94760e8f3cfSPetre-Ionut Tudor endif 948c5e1da83SJayanth Dodderi Chidanandendif #(ARM_XLAT_TABLES_LIB_V1) 94960e8f3cfSPetre-Ionut Tudor 9507cda17bbSSumit Gargifneq (${DECRYPTION_SUPPORT},none) 9517cda17bbSSumit Garg ifeq (${TRUSTED_BOARD_BOOT}, 0) 952c5e1da83SJayanth Dodderi Chidanand $(error TRUSTED_BOARD_BOOT must be enabled for DECRYPTION_SUPPORT \ 953c5e1da83SJayanth Dodderi Chidanand to be set) 9547cda17bbSSumit Garg endif 955c5e1da83SJayanth Dodderi Chidanandendif #(DECRYPTION_SUPPORT) 9567cda17bbSSumit Garg 957744ad974Sjohpow01# Ensure that no Aarch64-only features are enabled in Aarch32 build 958dc78e62dSjohpow01ifeq (${ARCH},aarch32) 959744ad974Sjohpow01 960744ad974Sjohpow01 # SME/SVE only supported on AArch64 96145007acdSJayanth Dodderi Chidanand ifneq (${ENABLE_SME_FOR_NS},0) 962dc78e62dSjohpow01 $(error "ENABLE_SME_FOR_NS cannot be used with ARCH=aarch32") 963dc78e62dSjohpow01 endif 96403d3c0d7SJayanth Dodderi Chidanand 965dc78e62dSjohpow01 ifeq (${ENABLE_SVE_FOR_NS},1) 966dc78e62dSjohpow01 # Warning instead of error due to CI dependency on this 96724ab2c0aSYann Gautier $(error "ENABLE_SVE_FOR_NS cannot be used with ARCH=aarch32") 968dc78e62dSjohpow01 endif 969744ad974Sjohpow01 970ff86e0b4SJuan Pablo Conde # BRBE is not supported in AArch32 971744ad974Sjohpow01 ifeq (${ENABLE_BRBE_FOR_NS},1) 972744ad974Sjohpow01 $(error "ENABLE_BRBE_FOR_NS cannot be used with ARCH=aarch32") 973744ad974Sjohpow01 endif 974744ad974Sjohpow01 975ff86e0b4SJuan Pablo Conde # FEAT_RNG_TRAP is not supported in AArch32 976ff86e0b4SJuan Pablo Conde ifeq (${ENABLE_FEAT_RNG_TRAP},1) 977ff86e0b4SJuan Pablo Conde $(error "ENABLE_FEAT_RNG_TRAP cannot be used with ARCH=aarch32") 978ff86e0b4SJuan Pablo Conde endif 979c5e1da83SJayanth Dodderi Chidanandendif #(ARCH=aarch32) 980dc78e62dSjohpow01 9810d122947SBoyan Karatotevifneq (${ENABLE_SME_FOR_NS},0) 9820d122947SBoyan Karatotev ifeq (${ENABLE_SVE_FOR_NS},0) 9830d122947SBoyan Karatotev $(error "ENABLE_SME_FOR_NS requires ENABLE_SVE_FOR_NS") 9840d122947SBoyan Karatotev endif 985c5e1da83SJayanth Dodderi Chidanandendif #(ENABLE_SME_FOR_NS) 9860d122947SBoyan Karatotev 987dc78e62dSjohpow01# Secure SME/SVE requires the non-secure component as well 988dc78e62dSjohpow01ifeq (${ENABLE_SME_FOR_SWD},1) 989dc78e62dSjohpow01 ifeq (${ENABLE_SME_FOR_NS},0) 990dc78e62dSjohpow01 $(error "ENABLE_SME_FOR_SWD requires ENABLE_SME_FOR_NS") 991dc78e62dSjohpow01 endif 9920d122947SBoyan Karatotev ifeq (${ENABLE_SVE_FOR_SWD},0) 9930d122947SBoyan Karatotev $(error "ENABLE_SME_FOR_SWD requires ENABLE_SVE_FOR_SWD") 9940d122947SBoyan Karatotev endif 995c5e1da83SJayanth Dodderi Chidanandendif #(ENABLE_SME_FOR_SWD) 996c5e1da83SJayanth Dodderi Chidanand 997dc78e62dSjohpow01ifeq (${ENABLE_SVE_FOR_SWD},1) 998dc78e62dSjohpow01 ifeq (${ENABLE_SVE_FOR_NS},0) 999dc78e62dSjohpow01 $(error "ENABLE_SVE_FOR_SWD requires ENABLE_SVE_FOR_NS") 1000dc78e62dSjohpow01 endif 1001c5e1da83SJayanth Dodderi Chidanandendif #(ENABLE_SVE_FOR_SWD) 1002dc78e62dSjohpow01 1003dc78e62dSjohpow01# SVE and SME cannot be used with CTX_INCLUDE_FPREGS since secure manager does 1004dc78e62dSjohpow01# its own context management including FPU registers. 1005dc78e62dSjohpow01ifeq (${CTX_INCLUDE_FPREGS},1) 100645007acdSJayanth Dodderi Chidanand ifneq (${ENABLE_SME_FOR_NS},0) 1007dc78e62dSjohpow01 $(error "ENABLE_SME_FOR_NS cannot be used with CTX_INCLUDE_FPREGS") 1008dc78e62dSjohpow01 endif 100903d3c0d7SJayanth Dodderi Chidanand 1010dc78e62dSjohpow01 ifeq (${ENABLE_SVE_FOR_NS},1) 1011dc78e62dSjohpow01 # Warning instead of error due to CI dependency on this 1012dc78e62dSjohpow01 $(warning "ENABLE_SVE_FOR_NS cannot be used with CTX_INCLUDE_FPREGS") 1013dc78e62dSjohpow01 $(warning "Forced ENABLE_SVE_FOR_NS=0") 1014dc78e62dSjohpow01 override ENABLE_SVE_FOR_NS := 0 1015dc78e62dSjohpow01 endif 1016c5e1da83SJayanth Dodderi Chidanandendif #(CTX_INCLUDE_FPREGS) 1017dc78e62dSjohpow01 101800e28874SManish V Badarkheifeq ($(DRTM_SUPPORT),1) 101900e28874SManish V Badarkhe $(info DRTM_SUPPORT is an experimental feature) 102000e28874SManish V Badarkheendif 102100e28874SManish V Badarkhe 10223ba2c151SRaymond Maoifeq (${TRANSFER_LIST},1) 10233ba2c151SRaymond Mao $(info TRANSFER_LIST is an experimental feature) 10243ba2c151SRaymond Maoendif 10253ba2c151SRaymond Mao 1026274a69e7SChris Kayifeq (${ENABLE_RME},1) 1027274a69e7SChris Kay ifneq (${SEPARATE_CODE_AND_RODATA},1) 1028274a69e7SChris Kay $(error `ENABLE_RME=1` requires `SEPARATE_CODE_AND_RODATA=1`) 1029274a69e7SChris Kay endif 1030274a69e7SChris Kayendif 1031274a69e7SChris Kay 1032c5e1da83SJayanth Dodderi Chidanand# Determine if FEAT_RNG is supported 1033c5e1da83SJayanth Dodderi ChidanandENABLE_FEAT_RNG = $(if $(findstring rng,${arch-features}),1,0) 1034c5e1da83SJayanth Dodderi Chidanand 1035c5e1da83SJayanth Dodderi Chidanand# Determine if FEAT_SB is supported 1036c5e1da83SJayanth Dodderi ChidanandENABLE_FEAT_SB = $(if $(findstring sb,${arch-features}),1,0) 1037c5e1da83SJayanth Dodderi Chidanand 10385782b890SManish V Badarkheifeq ($(PSA_CRYPTO),1) 10395782b890SManish V Badarkhe $(info PSA_CRYPTO is an experimental feature) 10405782b890SManish V Badarkheendif 10415782b890SManish V Badarkhe 1042cf2c8a33SAntonio Nino Diaz################################################################################ 104373c99d4eSJuan Castillo# Process platform overrideable behaviour 104473c99d4eSJuan Castillo################################################################################ 10454f6ad66aSAchin Gupta 10465f24ce96SManish Pandeyifdef BL1_SOURCES 10475f24ce96SManish Pandey NEED_BL1 := yes 1048c5e1da83SJayanth Dodderi Chidanandendif #(BL1_SOURCES) 10495f24ce96SManish Pandey 10505f24ce96SManish Pandeyifdef BL2_SOURCES 10515f24ce96SManish Pandey NEED_BL2 := yes 10525f24ce96SManish Pandey 1053bd97f83aSJohn Tsichritzis # Using BL2 implies that a BL33 image also needs to be supplied for the FIP and 1054bd97f83aSJohn Tsichritzis # Certificate generation tools. This flag can be overridden by the platform. 1055cf2c8a33SAntonio Nino Diaz ifdef EL3_PAYLOAD_BASE 1056cf2c8a33SAntonio Nino Diaz # If booting an EL3 payload there is no need for a BL33 image 1057cf2c8a33SAntonio Nino Diaz # in the FIP file. 10584c117f6cSSandrine Bailleux NEED_BL33 := no 1059cf2c8a33SAntonio Nino Diaz else 106068450a6dSAntonio Nino Diaz ifdef PRELOADED_BL33_BASE 1061cf2c8a33SAntonio Nino Diaz # If booting a BL33 preloaded image there is no need of 1062cf2c8a33SAntonio Nino Diaz # another one in the FIP file. 1063cf2c8a33SAntonio Nino Diaz NEED_BL33 := no 1064cf2c8a33SAntonio Nino Diaz else 1065cf2c8a33SAntonio Nino Diaz NEED_BL33 ?= yes 1066cf2c8a33SAntonio Nino Diaz endif 10674c117f6cSSandrine Bailleux endif 1068c5e1da83SJayanth Dodderi Chidanandendif #(BL2_SOURCES) 10696f971622SJuan Castillo 10705f24ce96SManish Pandeyifdef BL2U_SOURCES 10715f24ce96SManish Pandey NEED_BL2U := yes 1072c5e1da83SJayanth Dodderi Chidanandendif #(BL2U_SOURCES) 10735f24ce96SManish Pandey 10744d045d0eSMasahiro Yamada# If SCP_BL2 is given, we always want FIP to include it. 10754d045d0eSMasahiro Yamadaifdef SCP_BL2 10764d045d0eSMasahiro Yamada NEED_SCP_BL2 := yes 1077c5e1da83SJayanth Dodderi Chidanandendif #(SCP_BL2) 10784d045d0eSMasahiro Yamada 10795744e874SSoby Mathew# For AArch32, BL31 is not currently supported. 10805744e874SSoby Mathewifneq (${ARCH},aarch32) 10815744e874SSoby Mathew ifdef BL31_SOURCES 1082c5e1da83SJayanth Dodderi Chidanand # When booting an EL3 payload, there is no need to compile the BL31 1083c5e1da83SJayanth Dodderi Chidanand # image nor put it in the FIP. 10845744e874SSoby Mathew ifndef EL3_PAYLOAD_BASE 10855744e874SSoby Mathew NEED_BL31 := yes 10865744e874SSoby Mathew endif 10875744e874SSoby Mathew endif 1088c5e1da83SJayanth Dodderi Chidanandendif #(ARCH=aarch64) 10895744e874SSoby Mathew 109073c99d4eSJuan Castillo# Process TBB related flags 10916f971622SJuan Castilloifneq (${GENERATE_COT},0) 109273c99d4eSJuan Castillo # Common cert_create options 10936f971622SJuan Castillo ifneq (${CREATE_KEYS},0) 10946f971622SJuan Castillo $(eval CRT_ARGS += -n) 10950191262dSYatharth Kochar $(eval FWU_CRT_ARGS += -n) 1096fd34e7baSJuan Castillo ifneq (${SAVE_KEYS},0) 1097fd34e7baSJuan Castillo $(eval CRT_ARGS += -k) 10980191262dSYatharth Kochar $(eval FWU_CRT_ARGS += -k) 1099fd34e7baSJuan Castillo endif 11006f971622SJuan Castillo endif 110173c99d4eSJuan Castillo # Include TBBR makefile (unless the platform indicates otherwise) 110273c99d4eSJuan Castillo ifeq (${INCLUDE_TBBR_MK},1) 110373c99d4eSJuan Castillo include make_helpers/tbbr/tbbr_tools.mk 110473c99d4eSJuan Castillo endif 1105c5e1da83SJayanth Dodderi Chidanandendif #(GENERATE_COT) 11066f971622SJuan Castillo 11071c75d5dfSMasahiro Yamadaifneq (${FIP_ALIGN},0) 11081c75d5dfSMasahiro Yamada FIP_ARGS += --align ${FIP_ALIGN} 1109c5e1da83SJayanth Dodderi Chidanandendif #(FIP_ALIGN) 11101c75d5dfSMasahiro Yamada 11115f24ce96SManish Pandeyifdef FDT_SOURCES 11125f24ce96SManish Pandey NEED_FDT := yes 1113c5e1da83SJayanth Dodderi Chidanandendif #(FDT_SOURCES) 11145f24ce96SManish Pandey 111573c99d4eSJuan Castillo################################################################################ 111646e5e035SMichalis Pappas# Include libraries' Makefile that are used in all BL 111746e5e035SMichalis Pappas################################################################################ 111846e5e035SMichalis Pappas 111946e5e035SMichalis Pappasinclude lib/stack_protector/stack_protector.mk 112046e5e035SMichalis Pappas 112146e5e035SMichalis Pappas################################################################################ 11228a86052dSSoby Mathew# Include BL specific makefiles 11238a86052dSSoby Mathew################################################################################ 11245f24ce96SManish Pandey 11255f24ce96SManish Pandeyifeq (${NEED_BL1},yes) 11268a86052dSSoby Mathewinclude bl1/bl1.mk 11278a86052dSSoby Mathewendif 11288a86052dSSoby Mathew 11295f24ce96SManish Pandeyifeq (${NEED_BL2},yes) 11308a86052dSSoby Mathewinclude bl2/bl2.mk 11318a86052dSSoby Mathewendif 11328a86052dSSoby Mathew 11335f24ce96SManish Pandeyifeq (${NEED_BL2U},yes) 11348a86052dSSoby Mathewinclude bl2u/bl2u.mk 11358a86052dSSoby Mathewendif 11368a86052dSSoby Mathew 11375744e874SSoby Mathewifeq (${NEED_BL31},yes) 11388a86052dSSoby Mathewinclude bl31/bl31.mk 11398a86052dSSoby Mathewendif 114003b397a8SNishanth Menon 114173c99d4eSJuan Castillo################################################################################ 114273c99d4eSJuan Castillo# Build options checks 114373c99d4eSJuan Castillo################################################################################ 114473c99d4eSJuan Castillo 1145c5e1da83SJayanth Dodderi Chidanand# Boolean_Flags 1146327131c4SLeonardo Sandoval$(eval $(call assert_booleans,\ 1147327131c4SLeonardo Sandoval $(sort \ 1148327131c4SLeonardo Sandoval ALLOW_RO_XLAT_TABLES \ 114946789a7cSBalint Dobszay BL2_ENABLE_SP_LOAD \ 1150327131c4SLeonardo Sandoval COLD_BOOT_SINGLE_CPU \ 1151327131c4SLeonardo Sandoval CREATE_KEYS \ 1152327131c4SLeonardo Sandoval CTX_INCLUDE_AARCH32_REGS \ 1153327131c4SLeonardo Sandoval CTX_INCLUDE_FPREGS \ 1154327131c4SLeonardo Sandoval CTX_INCLUDE_EL2_REGS \ 11559acff28aSArvind Ram Prakash CTX_INCLUDE_MPAM_REGS \ 1156327131c4SLeonardo Sandoval DEBUG \ 1157327131c4SLeonardo Sandoval DYN_DISABLE_AUTH \ 1158327131c4SLeonardo Sandoval EL3_EXCEPTION_HANDLING \ 11591fd685a7SChris Kay ENABLE_AMU_AUXILIARY_COUNTERS \ 1160742ca230SChris Kay ENABLE_AMU_FCONF \ 1161873d4241Sjohpow01 AMU_RESTRICT_COUNTERS \ 1162327131c4SLeonardo Sandoval ENABLE_ASSERTIONS \ 116324077098SAndre Przywara ENABLE_FEAT_SB \ 1164327131c4SLeonardo Sandoval ENABLE_PIE \ 1165327131c4SLeonardo Sandoval ENABLE_PMF \ 1166327131c4SLeonardo Sandoval ENABLE_PSCI_STAT \ 1167327131c4SLeonardo Sandoval ENABLE_RUNTIME_INSTRUMENTATION \ 1168dc78e62dSjohpow01 ENABLE_SME_FOR_SWD \ 11690c5e7d1cSMax Shvetsov ENABLE_SVE_FOR_SWD \ 1170970a4a8dSManish Pandey ENABLE_FEAT_RAS \ 1171f87e54f7SManish Pandey FFH_SUPPORT \ 1172327131c4SLeonardo Sandoval ERROR_DEPRECATED \ 1173327131c4SLeonardo Sandoval FAULT_INJECTION_SUPPORT \ 1174327131c4SLeonardo Sandoval GENERATE_COT \ 1175327131c4SLeonardo Sandoval GICV2_G0_FOR_EL3 \ 117646cc41d5SManish Pandey HANDLE_EA_EL3_FIRST_NS \ 1177538516f5SBipin Ravi HARDEN_SLS \ 1178327131c4SLeonardo Sandoval HW_ASSISTED_COHERENCY \ 1179327131c4SLeonardo Sandoval MEASURED_BOOT \ 118000e28874SManish V Badarkhe DRTM_SUPPORT \ 1181327131c4SLeonardo Sandoval NS_TIMER_SWITCH \ 1182327131c4SLeonardo Sandoval OVERRIDE_LIBC \ 1183327131c4SLeonardo Sandoval PL011_GENERIC_UART \ 1184327131c4SLeonardo Sandoval PROGRAMMABLE_RESET_ADDRESS \ 1185327131c4SLeonardo Sandoval PSCI_EXTENDED_STATE_ID \ 118664b4710bSWing Li PSCI_OS_INIT_MODE \ 1187327131c4SLeonardo Sandoval RESET_TO_BL31 \ 1188327131c4SLeonardo Sandoval SAVE_KEYS \ 1189327131c4SLeonardo Sandoval SEPARATE_CODE_AND_RODATA \ 119096a8ed14SJiafei Pan SEPARATE_BL2_NOLOAD_REGION \ 1191327131c4SLeonardo Sandoval SEPARATE_NOBITS_REGION \ 1192327131c4SLeonardo Sandoval SPIN_ON_BL1_EXIT \ 1193327131c4SLeonardo Sandoval SPM_MM \ 11941d63ae4dSMarc Bonnici SPMC_AT_EL3 \ 1195801cd3c8SNishant Sharma SPMC_AT_EL3_SEL0_SP \ 1196327131c4SLeonardo Sandoval SPMD_SPM_AT_SEL2 \ 1197890b5088SRaghu Krishnamurthy ENABLE_SPMD_LP \ 11983ba2c151SRaymond Mao TRANSFER_LIST \ 1199327131c4SLeonardo Sandoval TRUSTED_BOARD_BOOT \ 1200327131c4SLeonardo Sandoval USE_COHERENT_MEM \ 1201327131c4SLeonardo Sandoval USE_DEBUGFS \ 1202327131c4SLeonardo Sandoval ARM_IO_IN_DTB \ 1203327131c4SLeonardo Sandoval SDEI_IN_FCONF \ 1204327131c4SLeonardo Sandoval SEC_INT_DESC_IN_FCONF \ 1205327131c4SLeonardo Sandoval USE_ROMLIB \ 1206327131c4SLeonardo Sandoval USE_TBBR_DEFS \ 1207327131c4SLeonardo Sandoval WARMBOOT_ENABLE_DCACHE_EARLY \ 120842d4d3baSArvind Ram Prakash RESET_TO_BL2 \ 1209327131c4SLeonardo Sandoval BL2_IN_XIP_MEM \ 1210327131c4SLeonardo Sandoval BL2_INV_DCACHE \ 1211327131c4SLeonardo Sandoval USE_SPINLOCK_CAS \ 1212327131c4SLeonardo Sandoval ENCRYPT_BL31 \ 1213327131c4SLeonardo Sandoval ENCRYPT_BL32 \ 1214327131c4SLeonardo Sandoval ERRATA_SPECULATIVE_AT \ 121500e8f79cSManish Pandey RAS_TRAP_NS_ERR_REC_ACCESS \ 1216327131c4SLeonardo Sandoval COT_DESC_IN_DTB \ 1217327131c4SLeonardo Sandoval USE_SP804_TIMER \ 1218396b339dSManish V Badarkhe PSA_FWU_SUPPORT \ 121968120783SChris Kay ENABLE_MPMM \ 122068120783SChris Kay ENABLE_MPMM_FCONF \ 12216a0da736SJayanth Dodderi Chidanand FEATURE_DETECTION \ 12220b22e591SJayanth Dodderi Chidanand TRNG_SUPPORT \ 1223ffea3844SSona Mathew ERRATA_ABI_SUPPORT \ 1224ef63f5beSSona Mathew ERRATA_NON_ARM_INTERCONNECT \ 122504c7303bSOkash Khawaja CONDITIONAL_CMO \ 12265782b890SManish V Badarkhe PSA_CRYPTO \ 122785bebe18SSandrine Bailleux ENABLE_CONSOLE_GETC \ 1228183329a5SArvind Ram Prakash INIT_UNUSED_NS_EL2 \ 1229bfef8b90SJuan Pablo Conde PLATFORM_REPORT_CTX_MEM_USE \ 1230327131c4SLeonardo Sandoval))) 123173c99d4eSJuan Castillo 1232c5e1da83SJayanth Dodderi Chidanand# Numeric_Flags 1233327131c4SLeonardo Sandoval$(eval $(call assert_numerics,\ 1234327131c4SLeonardo Sandoval $(sort \ 1235327131c4SLeonardo Sandoval ARM_ARCH_MAJOR \ 1236327131c4SLeonardo Sandoval ARM_ARCH_MINOR \ 1237327131c4SLeonardo Sandoval BRANCH_PROTECTION \ 12386a0da736SJayanth Dodderi Chidanand CTX_INCLUDE_PAUTH_REGS \ 12396a0da736SJayanth Dodderi Chidanand CTX_INCLUDE_NEVE_REGS \ 12402bf4f27fSManish V Badarkhe CRYPTO_SUPPORT \ 124183a4dae1SBoyan Karatotev DISABLE_MTPMU \ 12421298f2f1SJayanth Dodderi Chidanand ENABLE_BRBE_FOR_NS \ 124347c681b7SJayanth Dodderi Chidanand ENABLE_TRBE_FOR_NS \ 12446a0da736SJayanth Dodderi Chidanand ENABLE_BTI \ 12456a0da736SJayanth Dodderi Chidanand ENABLE_PAUTH \ 1246d23acc9eSAndre Przywara ENABLE_FEAT_AMU \ 12476a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_AMUv1p1 \ 12486a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_CSV2_2 \ 124930019d86SSona Mathew ENABLE_FEAT_CSV2_3 \ 12506a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_DIT \ 12516a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_ECV \ 12526a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_FGT \ 12536a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_HCX \ 12540a33adc0SGovindraj Raja ENABLE_FEAT_MTE \ 12556a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_PAN \ 12566a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_RNG \ 1257ff86e0b4SJuan Pablo Conde ENABLE_FEAT_RNG_TRAP \ 12586a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_SEL2 \ 1259d3331603SMark Brown ENABLE_FEAT_TCR2 \ 1260062b6c6bSMark Brown ENABLE_FEAT_S2PIE \ 1261062b6c6bSMark Brown ENABLE_FEAT_S1PIE \ 1262062b6c6bSMark Brown ENABLE_FEAT_S2POE \ 1263062b6c6bSMark Brown ENABLE_FEAT_S1POE \ 1264688ab57bSMark Brown ENABLE_FEAT_GCS \ 12656a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_VHE \ 12664d0b6632SMaksims Svecovs ENABLE_FEAT_MTE_PERM \ 1267edebefbcSArvind Ram Prakash ENABLE_FEAT_MPAM \ 12686a0da736SJayanth Dodderi Chidanand ENABLE_RME \ 12696437a09aSAndre Przywara ENABLE_SPE_FOR_NS \ 1270603a0c6fSAndre Przywara ENABLE_SYS_REG_TRACE_FOR_NS \ 127145007acdSJayanth Dodderi Chidanand ENABLE_SME_FOR_NS \ 127203d3c0d7SJayanth Dodderi Chidanand ENABLE_SME2_FOR_NS \ 12732b0bc4e0SJayanth Dodderi Chidanand ENABLE_SVE_FOR_NS \ 12746a0da736SJayanth Dodderi Chidanand ENABLE_TRF_FOR_NS \ 1275327131c4SLeonardo Sandoval FW_ENC_STATUS \ 12765357f83dSManish V Badarkhe NR_OF_FW_BANKS \ 12775357f83dSManish V Badarkhe NR_OF_IMAGES_IN_FW_BANK \ 1278781d07a4SJayanth Dodderi Chidanand TWED_DELAY \ 1279781d07a4SJayanth Dodderi Chidanand ENABLE_FEAT_TWED \ 1280bebcf27fSMark Brown SVE_VECTOR_LEN \ 12810ed3be6fSVarun Wadekar IMPDEF_SYSREG_TRAP \ 1282327131c4SLeonardo Sandoval))) 1283c877b414SJeenu Viswambharan 1284aacff749SJustin Chadwellifdef KEY_SIZE 1285aacff749SJustin Chadwell $(eval $(call assert_numeric,KEY_SIZE)) 1286aacff749SJustin Chadwellendif 1287aacff749SJustin Chadwell 12881f461979SJustin Chadwellifeq ($(filter $(SANITIZE_UB), on off trap),) 12891f461979SJustin Chadwell $(error "Invalid value for SANITIZE_UB: can be one of on, off, trap") 12901f461979SJustin Chadwellendif 12911f461979SJustin Chadwell 129273c99d4eSJuan Castillo################################################################################ 129373c99d4eSJuan Castillo# Add definitions to the cpp preprocessor based on the current build options. 129473c99d4eSJuan Castillo# This is done after including the platform specific makefile to allow the 129573c99d4eSJuan Castillo# platform to overwrite the default options 129673c99d4eSJuan Castillo################################################################################ 129773c99d4eSJuan Castillo 1298327131c4SLeonardo Sandoval$(eval $(call add_defines,\ 1299327131c4SLeonardo Sandoval $(sort \ 1300327131c4SLeonardo Sandoval ALLOW_RO_XLAT_TABLES \ 1301327131c4SLeonardo Sandoval ARM_ARCH_MAJOR \ 1302327131c4SLeonardo Sandoval ARM_ARCH_MINOR \ 130346789a7cSBalint Dobszay BL2_ENABLE_SP_LOAD \ 1304327131c4SLeonardo Sandoval COLD_BOOT_SINGLE_CPU \ 1305327131c4SLeonardo Sandoval CTX_INCLUDE_AARCH32_REGS \ 1306327131c4SLeonardo Sandoval CTX_INCLUDE_FPREGS \ 1307327131c4SLeonardo Sandoval CTX_INCLUDE_PAUTH_REGS \ 13089acff28aSArvind Ram Prakash CTX_INCLUDE_MPAM_REGS \ 1309327131c4SLeonardo Sandoval EL3_EXCEPTION_HANDLING \ 1310327131c4SLeonardo Sandoval CTX_INCLUDE_EL2_REGS \ 1311062f8aafSArunachalam Ganapathy CTX_INCLUDE_NEVE_REGS \ 1312327131c4SLeonardo Sandoval DECRYPTION_SUPPORT_${DECRYPTION_SUPPORT} \ 13130063dd17SJavier Almansa Sobrino DISABLE_MTPMU \ 1314d23acc9eSAndre Przywara ENABLE_FEAT_AMU \ 13151fd685a7SChris Kay ENABLE_AMU_AUXILIARY_COUNTERS \ 1316742ca230SChris Kay ENABLE_AMU_FCONF \ 1317873d4241Sjohpow01 AMU_RESTRICT_COUNTERS \ 1318327131c4SLeonardo Sandoval ENABLE_ASSERTIONS \ 1319327131c4SLeonardo Sandoval ENABLE_BTI \ 1320edebefbcSArvind Ram Prakash ENABLE_FEAT_MPAM \ 1321327131c4SLeonardo Sandoval ENABLE_PAUTH \ 1322327131c4SLeonardo Sandoval ENABLE_PIE \ 1323327131c4SLeonardo Sandoval ENABLE_PMF \ 1324327131c4SLeonardo Sandoval ENABLE_PSCI_STAT \ 13255b18de09SZelalem Aweke ENABLE_RME \ 1326327131c4SLeonardo Sandoval ENABLE_RUNTIME_INSTRUMENTATION \ 1327dc78e62dSjohpow01 ENABLE_SME_FOR_NS \ 132803d3c0d7SJayanth Dodderi Chidanand ENABLE_SME2_FOR_NS \ 1329dc78e62dSjohpow01 ENABLE_SME_FOR_SWD \ 133090118bb5SAndre Przywara ENABLE_SPE_FOR_NS \ 1331327131c4SLeonardo Sandoval ENABLE_SVE_FOR_NS \ 13320c5e7d1cSMax Shvetsov ENABLE_SVE_FOR_SWD \ 1333970a4a8dSManish Pandey ENABLE_FEAT_RAS \ 1334f87e54f7SManish Pandey FFH_SUPPORT \ 1335327131c4SLeonardo Sandoval ENCRYPT_BL31 \ 1336327131c4SLeonardo Sandoval ENCRYPT_BL32 \ 1337327131c4SLeonardo Sandoval ERROR_DEPRECATED \ 1338327131c4SLeonardo Sandoval FAULT_INJECTION_SUPPORT \ 1339327131c4SLeonardo Sandoval GICV2_G0_FOR_EL3 \ 134046cc41d5SManish Pandey HANDLE_EA_EL3_FIRST_NS \ 1341327131c4SLeonardo Sandoval HW_ASSISTED_COHERENCY \ 1342327131c4SLeonardo Sandoval LOG_LEVEL \ 1343327131c4SLeonardo Sandoval MEASURED_BOOT \ 134400e28874SManish V Badarkhe DRTM_SUPPORT \ 1345327131c4SLeonardo Sandoval NS_TIMER_SWITCH \ 1346327131c4SLeonardo Sandoval PL011_GENERIC_UART \ 1347327131c4SLeonardo Sandoval PLAT_${PLAT} \ 1348327131c4SLeonardo Sandoval PROGRAMMABLE_RESET_ADDRESS \ 1349327131c4SLeonardo Sandoval PSCI_EXTENDED_STATE_ID \ 135064b4710bSWing Li PSCI_OS_INIT_MODE \ 1351327131c4SLeonardo Sandoval RESET_TO_BL31 \ 1352327131c4SLeonardo Sandoval SEPARATE_CODE_AND_RODATA \ 135396a8ed14SJiafei Pan SEPARATE_BL2_NOLOAD_REGION \ 1354327131c4SLeonardo Sandoval SEPARATE_NOBITS_REGION \ 1355327131c4SLeonardo Sandoval RECLAIM_INIT_CODE \ 1356327131c4SLeonardo Sandoval SPD_${SPD} \ 1357327131c4SLeonardo Sandoval SPIN_ON_BL1_EXIT \ 1358327131c4SLeonardo Sandoval SPM_MM \ 13591d63ae4dSMarc Bonnici SPMC_AT_EL3 \ 1360801cd3c8SNishant Sharma SPMC_AT_EL3_SEL0_SP \ 1361327131c4SLeonardo Sandoval SPMD_SPM_AT_SEL2 \ 13623ba2c151SRaymond Mao TRANSFER_LIST \ 1363327131c4SLeonardo Sandoval TRUSTED_BOARD_BOOT \ 1364c9c56f6eSManish V Badarkhe CRYPTO_SUPPORT \ 13657dfb9911SJimmy Brisson TRNG_SUPPORT \ 1366ffea3844SSona Mathew ERRATA_ABI_SUPPORT \ 1367ef63f5beSSona Mathew ERRATA_NON_ARM_INTERCONNECT \ 1368327131c4SLeonardo Sandoval USE_COHERENT_MEM \ 1369327131c4SLeonardo Sandoval USE_DEBUGFS \ 1370327131c4SLeonardo Sandoval ARM_IO_IN_DTB \ 1371327131c4SLeonardo Sandoval SDEI_IN_FCONF \ 1372327131c4SLeonardo Sandoval SEC_INT_DESC_IN_FCONF \ 1373327131c4SLeonardo Sandoval USE_ROMLIB \ 1374327131c4SLeonardo Sandoval USE_TBBR_DEFS \ 1375327131c4SLeonardo Sandoval WARMBOOT_ENABLE_DCACHE_EARLY \ 137642d4d3baSArvind Ram Prakash RESET_TO_BL2 \ 137742d4d3baSArvind Ram Prakash BL2_RUNS_AT_EL3 \ 1378327131c4SLeonardo Sandoval BL2_IN_XIP_MEM \ 1379327131c4SLeonardo Sandoval BL2_INV_DCACHE \ 1380327131c4SLeonardo Sandoval USE_SPINLOCK_CAS \ 1381327131c4SLeonardo Sandoval ERRATA_SPECULATIVE_AT \ 138200e8f79cSManish Pandey RAS_TRAP_NS_ERR_REC_ACCESS \ 1383327131c4SLeonardo Sandoval COT_DESC_IN_DTB \ 1384327131c4SLeonardo Sandoval USE_SP804_TIMER \ 138512cd65e0STomas Pilar ENABLE_FEAT_RNG \ 1386ff86e0b4SJuan Pablo Conde ENABLE_FEAT_RNG_TRAP \ 13874e04478aSChris Kay ENABLE_FEAT_SB \ 13887d33ffe4SDaniel Boulby ENABLE_FEAT_DIT \ 13895357f83dSManish V Badarkhe NR_OF_FW_BANKS \ 13905357f83dSManish V Badarkhe NR_OF_IMAGES_IN_FW_BANK \ 1391396b339dSManish V Badarkhe PSA_FWU_SUPPORT \ 1392744ad974Sjohpow01 ENABLE_BRBE_FOR_NS \ 1393813524eaSManish V Badarkhe ENABLE_TRBE_FOR_NS \ 1394d4582d30SManish V Badarkhe ENABLE_SYS_REG_TRACE_FOR_NS \ 13958fcd3d96SManish V Badarkhe ENABLE_TRF_FOR_NS \ 1396cb4ec47bSjohpow01 ENABLE_FEAT_HCX \ 139768120783SChris Kay ENABLE_MPMM \ 139868120783SChris Kay ENABLE_MPMM_FCONF \ 1399f74cb0beSJayanth Dodderi Chidanand ENABLE_FEAT_FGT \ 1400f74cb0beSJayanth Dodderi Chidanand ENABLE_FEAT_ECV \ 14016a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_AMUv1p1 \ 14026a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_SEL2 \ 14036a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_VHE \ 14046a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_CSV2_2 \ 140530019d86SSona Mathew ENABLE_FEAT_CSV2_3 \ 14066a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_PAN \ 1407d3331603SMark Brown ENABLE_FEAT_TCR2 \ 1408062b6c6bSMark Brown ENABLE_FEAT_S2PIE \ 1409062b6c6bSMark Brown ENABLE_FEAT_S1PIE \ 1410062b6c6bSMark Brown ENABLE_FEAT_S2POE \ 1411062b6c6bSMark Brown ENABLE_FEAT_S1POE \ 1412688ab57bSMark Brown ENABLE_FEAT_GCS \ 14130a33adc0SGovindraj Raja ENABLE_FEAT_MTE \ 14144d0b6632SMaksims Svecovs ENABLE_FEAT_MTE_PERM \ 14156a0da736SJayanth Dodderi Chidanand FEATURE_DETECTION \ 1416781d07a4SJayanth Dodderi Chidanand TWED_DELAY \ 1417781d07a4SJayanth Dodderi Chidanand ENABLE_FEAT_TWED \ 141804c7303bSOkash Khawaja CONDITIONAL_CMO \ 14190ed3be6fSVarun Wadekar IMPDEF_SYSREG_TRAP \ 1420a8cf6faeSJayanth Dodderi Chidanand SVE_VECTOR_LEN \ 1421890b5088SRaghu Krishnamurthy ENABLE_SPMD_LP \ 14225782b890SManish V Badarkhe PSA_CRYPTO \ 142385bebe18SSandrine Bailleux ENABLE_CONSOLE_GETC \ 1424183329a5SArvind Ram Prakash INIT_UNUSED_NS_EL2 \ 1425bfef8b90SJuan Pablo Conde PLATFORM_REPORT_CTX_MEM_USE \ 1426327131c4SLeonardo Sandoval))) 14272fae4b1eSJeenu Viswambharan 1428bfef8b90SJuan Pablo Condeifeq (${PLATFORM_REPORT_CTX_MEM_USE}, 1) 1429bfef8b90SJuan Pablo Condeifeq (${DEBUG}, 0) 1430bfef8b90SJuan Pablo Conde $(warning "PLATFORM_REPORT_CTX_MEM_USE can be applied when DEBUG=1 only") 1431bfef8b90SJuan Pablo Conde override PLATFORM_REPORT_CTX_MEM_USE := 0 1432bfef8b90SJuan Pablo Condeendif 1433bfef8b90SJuan Pablo Condeendif 1434bfef8b90SJuan Pablo Conde 14351f461979SJustin Chadwellifeq (${SANITIZE_UB},trap) 14361f461979SJustin Chadwell $(eval $(call add_define,MONITOR_TRAPS)) 1437c5e1da83SJayanth Dodderi Chidanandendif #(SANITIZE_UB) 14381f461979SJustin Chadwell 14394c117f6cSSandrine Bailleux# Define the EL3_PAYLOAD_BASE flag only if it is provided. 14404c117f6cSSandrine Bailleuxifdef EL3_PAYLOAD_BASE 14414c117f6cSSandrine Bailleux $(eval $(call add_define,EL3_PAYLOAD_BASE)) 1442cf2c8a33SAntonio Nino Diazelse 144368450a6dSAntonio Nino Diaz# Define the PRELOADED_BL33_BASE flag only if it is provided and 144468450a6dSAntonio Nino Diaz# EL3_PAYLOAD_BASE is not defined, as it has priority. 144568450a6dSAntonio Nino Diaz ifdef PRELOADED_BL33_BASE 144668450a6dSAntonio Nino Diaz $(eval $(call add_define,PRELOADED_BL33_BASE)) 14474c117f6cSSandrine Bailleux endif 1448c5e1da83SJayanth Dodderi Chidanandendif #(EL3_PAYLOAD_BASE) 144973c99d4eSJuan Castillo 1450209a60ccSSoby Mathew# Define the DYN_DISABLE_AUTH flag only if set. 1451209a60ccSSoby Mathewifeq (${DYN_DISABLE_AUTH},1) 1452209a60ccSSoby Mathew $(eval $(call add_define,DYN_DISABLE_AUTH)) 1453209a60ccSSoby Mathewendif 1454209a60ccSSoby Mathew 1455c2ad38ceSVarun Wadekarifneq ($(findstring armlink,$(notdir $(LD))),) 1456c2ad38ceSVarun Wadekar $(eval $(call add_define,USE_ARM_LINK)) 1457c2ad38ceSVarun Wadekarendif 1458c2ad38ceSVarun Wadekar 1459ce2b1ec6SManish Pandey# Generate and include sp_gen.mk if SPD is spmd and SP_LAYOUT_FILE is defined 1460ce2b1ec6SManish Pandeyifeq (${SPD},spmd) 1461c33ff198SOlivier Deprezifdef SP_LAYOUT_FILE 1462ce2b1ec6SManish Pandey -include $(BUILD_PLAT)/sp_gen.mk 1463ce2b1ec6SManish Pandey FIP_DEPS += sp 146407c44475SManish Pandey CRT_DEPS += sp 1465ce2b1ec6SManish Pandey NEED_SP_PKG := yes 1466ce2b1ec6SManish Pandeyelse 1467c33ff198SOlivier Deprez ifeq (${SPMD_SPM_AT_SEL2},1) 1468c33ff198SOlivier Deprez $(error "SPMD with SPM at S-EL2 require SP_LAYOUT_FILE") 1469c33ff198SOlivier Deprez endif 1470c5e1da83SJayanth Dodderi Chidanandendif #(SP_LAYOUT_FILE) 1471c5e1da83SJayanth Dodderi Chidanandendif #(SPD) 1472ce2b1ec6SManish Pandey 147373c99d4eSJuan Castillo################################################################################ 147473c99d4eSJuan Castillo# Build targets 147573c99d4eSJuan Castillo################################################################################ 147673c99d4eSJuan Castillo 147790aa901fSSumit Garg.PHONY: all msg_start clean realclean distclean cscope locate-checkpatch checkcodebase checkpatch fiptool sptool fip sp fwu_fip certtool dtbs memmap doc enctool 147873c99d4eSJuan Castillo.SUFFIXES: 147973c99d4eSJuan Castillo 148073c99d4eSJuan Castilloall: msg_start 148173c99d4eSJuan Castillo 148273c99d4eSJuan Castillomsg_start: 148373c99d4eSJuan Castillo @echo "Building ${PLAT}" 148473c99d4eSJuan Castillo 14857a24cba5SSoby Mathewifeq (${ERROR_DEPRECATED},0) 1486d5dfdeb6SJulius Werner# Check if deprecated declarations and cpp warnings should be treated as error or not. 1487c2ad38ceSVarun Wadekarifneq ($(findstring clang,$(notdir $(CC))),) 1488c2ad38ceSVarun Wadekar CPPFLAGS += -Wno-error=deprecated-declarations 1489c2ad38ceSVarun Wadekarelse 1490bc1a03c7SDan Handley CPPFLAGS += -Wno-error=deprecated-declarations -Wno-error=cpp 14917a24cba5SSoby Mathewendif 1492c5e1da83SJayanth Dodderi Chidanandendif #(!ERROR_DEPRECATED) 14937a24cba5SSoby Mathew 14945accce5bSRoberto Vargas$(eval $(call MAKE_LIB_DIRS)) 149561f72a34SRoberto Vargas$(eval $(call MAKE_LIB,c)) 14965fee0287SRoberto Vargas 149773c99d4eSJuan Castillo# Expand build macros for the different images 149873c99d4eSJuan Castilloifeq (${NEED_BL1},yes) 1499b34635a0SChris KayBL1_SOURCES := $(sort ${BL1_SOURCES}) 1500434d0491SZelalem Aweke$(eval $(call MAKE_BL,bl1)) 1501c5e1da83SJayanth Dodderi Chidanandendif #(NEED_BL1) 150273c99d4eSJuan Castillo 150373c99d4eSJuan Castilloifeq (${NEED_BL2},yes) 1504c5e1da83SJayanth Dodderi Chidanand 150542d4d3baSArvind Ram Prakashifeq (${RESET_TO_BL2}, 0) 1506c9b31ae8SRoberto VargasFIP_BL2_ARGS := tb-fw 1507c9b31ae8SRoberto Vargasendif 1508c9b31ae8SRoberto Vargas 1509eb1acfb6SChris KayBL2_SOURCES := $(sort ${BL2_SOURCES}) 1510eb1acfb6SChris Kay 151133950dd8SMasahiro Yamada$(if ${BL2}, $(eval $(call TOOL_ADD_IMG,bl2,--${FIP_BL2_ARGS})),\ 1512434d0491SZelalem Aweke $(eval $(call MAKE_BL,bl2,${FIP_BL2_ARGS}))) 1513c5e1da83SJayanth Dodderi Chidanand 1514c5e1da83SJayanth Dodderi Chidanandendif #(NEED_BL2) 151573c99d4eSJuan Castillo 15164d045d0eSMasahiro Yamadaifeq (${NEED_SCP_BL2},yes) 151733950dd8SMasahiro Yamada$(eval $(call TOOL_ADD_IMG,scp_bl2,--scp-fw)) 1518c5e1da83SJayanth Dodderi Chidanandendif #(NEED_SCP_BL2) 15194d045d0eSMasahiro Yamada 152073c99d4eSJuan Castilloifeq (${NEED_BL31},yes) 152173c99d4eSJuan CastilloBL31_SOURCES += ${SPD_SOURCES} 152226d1e0c3SMadhukar Pappireddy# Sort BL31 source files to remove duplicates 152326d1e0c3SMadhukar PappireddyBL31_SOURCES := $(sort ${BL31_SOURCES}) 1524c6ba9b45SSumit Gargifneq (${DECRYPTION_SUPPORT},none) 1525c6ba9b45SSumit Garg$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw,,$(ENCRYPT_BL31))),\ 1526434d0491SZelalem Aweke $(eval $(call MAKE_BL,bl31,soc-fw,,$(ENCRYPT_BL31)))) 1527c6ba9b45SSumit Gargelse 152833950dd8SMasahiro Yamada$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw)),\ 1529434d0491SZelalem Aweke $(eval $(call MAKE_BL,bl31,soc-fw))) 1530c5e1da83SJayanth Dodderi Chidanandendif #(DECRYPTION_SUPPORT) 1531c5e1da83SJayanth Dodderi Chidanandendif #(NEED_BL31) 153273c99d4eSJuan Castillo 153370d1fc53SJuan Castillo# If a BL32 image is needed but neither BL32 nor BL32_SOURCES is defined, the 1534c939d13aSMasahiro Yamada# build system will call TOOL_ADD_IMG to print a warning message and abort the 153570d1fc53SJuan Castillo# process. Note that the dependency on BL32 applies to the FIP only. 153673c99d4eSJuan Castilloifeq (${NEED_BL32},yes) 153726d1e0c3SMadhukar Pappireddy# Sort BL32 source files to remove duplicates 153826d1e0c3SMadhukar PappireddyBL32_SOURCES := $(sort ${BL32_SOURCES}) 15399cd15239SMasahiro YamadaBUILD_BL32 := $(if $(BL32),,$(if $(BL32_SOURCES),1)) 15409cd15239SMasahiro Yamada 1541c6ba9b45SSumit Gargifneq (${DECRYPTION_SUPPORT},none) 1542434d0491SZelalem Aweke$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw,,$(ENCRYPT_BL32))),\ 1543c6ba9b45SSumit Garg $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw,,$(ENCRYPT_BL32)))) 1544c6ba9b45SSumit Gargelse 1545434d0491SZelalem Aweke$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw)),\ 154633950dd8SMasahiro Yamada $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw))) 1547c5e1da83SJayanth Dodderi Chidanandendif #(DECRYPTION_SUPPORT) 1548c5e1da83SJayanth Dodderi Chidanandendif #(NEED_BL32) 154973c99d4eSJuan Castillo 15505b18de09SZelalem Aweke# If RMM image is needed but RMM is not defined, Test Realm Payload (TRP) 15515b18de09SZelalem Aweke# needs to be built from RMM_SOURCES. 15525b18de09SZelalem Awekeifeq (${NEED_RMM},yes) 15535b18de09SZelalem Aweke# Sort RMM source files to remove duplicates 15545b18de09SZelalem AwekeRMM_SOURCES := $(sort ${RMM_SOURCES}) 15555b18de09SZelalem AwekeBUILD_RMM := $(if $(RMM),,$(if $(RMM_SOURCES),1)) 15565b18de09SZelalem Aweke 15575b18de09SZelalem Aweke$(if ${BUILD_RMM}, $(eval $(call MAKE_BL,rmm,rmm-fw)),\ 15585b18de09SZelalem Aweke $(eval $(call TOOL_ADD_IMG,rmm,--rmm-fw))) 1559c5e1da83SJayanth Dodderi Chidanandendif #(NEED_RMM) 15605b18de09SZelalem Aweke 156173c99d4eSJuan Castillo# Add the BL33 image if required by the platform 156273c99d4eSJuan Castilloifeq (${NEED_BL33},yes) 156333950dd8SMasahiro Yamada$(eval $(call TOOL_ADD_IMG,bl33,--nt-fw)) 1564c5e1da83SJayanth Dodderi Chidanandendif #(NEED_BL33) 1565db6071c9SJuan Castillo 15669003fa0bSYatharth Kocharifeq (${NEED_BL2U},yes) 156733950dd8SMasahiro Yamada$(if ${BL2U}, $(eval $(call TOOL_ADD_IMG,bl2u,--ap-fwu-cfg,FWU_)),\ 1568434d0491SZelalem Aweke $(eval $(call MAKE_BL,bl2u,ap-fwu-cfg,FWU_))) 1569c5e1da83SJayanth Dodderi Chidanandendif #(NEED_BL2U) 15709003fa0bSYatharth Kochar 157103b397a8SNishanth Menon# Expand build macros for the different images 157203b397a8SNishanth Menonifeq (${NEED_FDT},yes) 157303b397a8SNishanth Menon $(eval $(call MAKE_DTBS,$(BUILD_PLAT)/fdts,$(FDT_SOURCES))) 1574c5e1da83SJayanth Dodderi Chidanandendif #(NEED_FDT) 157503b397a8SNishanth Menon 1576ce2b1ec6SManish Pandey# Add Secure Partition packages 1577ce2b1ec6SManish Pandeyifeq (${NEED_SP_PKG},yes) 1578ce2b1ec6SManish Pandey$(BUILD_PLAT)/sp_gen.mk: ${SP_MK_GEN} ${SP_LAYOUT_FILE} | ${BUILD_PLAT} 1579fbd32ac0SOlivier Deprez @${PYTHON} "$<" "$@" $(filter-out $<,$^) $(BUILD_PLAT) ${COT} ${SP_DTS_LIST_FRAGMENT} 1580822c7279SJ-Alvessp: $(DTBS) $(BUILD_PLAT)/sp_gen.mk $(SP_PKGS) 1581ce2b1ec6SManish Pandey @${ECHO_BLANK_LINE} 1582ce2b1ec6SManish Pandey @echo "Built SP Images successfully" 1583ce2b1ec6SManish Pandey @${ECHO_BLANK_LINE} 1584c5e1da83SJayanth Dodderi Chidanandendif #(NEED_SP_PKG) 1585ce2b1ec6SManish Pandey 158636eaaf37SIan Spraylocate-checkpatch: 158736eaaf37SIan Sprayifndef CHECKPATCH 158866079b04SEtienne Carriere $(error "Please set CHECKPATCH to point to the Linux checkpatch.pl file, eg: CHECKPATCH=../linux/scripts/checkpatch.pl") 158936eaaf37SIan Sprayelse 159036eaaf37SIan Sprayifeq (,$(wildcard ${CHECKPATCH})) 159166079b04SEtienne Carriere $(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/scripts/checkpatch.pl") 159236eaaf37SIan Sprayendif 1593c5e1da83SJayanth Dodderi Chidanandendif #(CHECKPATCH) 159436eaaf37SIan Spray 15954f6ad66aSAchin Guptaclean: 15964f6ad66aSAchin Gupta @echo " CLEAN" 1597f1477d4aSEvan Lloyd $(call SHELL_REMOVE_DIR,${BUILD_PLAT}) 159888a1cf1eSSami Mujawarifdef UNIX_MK 15992f2cef46SJeenu Viswambharan ${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean 160088a1cf1eSSami Mujawarelse 160188a1cf1eSSami Mujawar# Clear the MAKEFLAGS as we do not want 160288a1cf1eSSami Mujawar# to pass the gnumake flags to nmake. 160388a1cf1eSSami Mujawar ${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) clean 1604c5e1da83SJayanth Dodderi Chidanandendif #(UNIX_MK) 16056f971622SJuan Castillo ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean 160690aa901fSSumit Garg ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} clean 16075accce5bSRoberto Vargas ${Q}${MAKE} --no-print-directory -C ${ROMLIBPATH} clean 16084f6ad66aSAchin Gupta 1609eaaeece2SJames Morrisseyrealclean distclean: 1610eaaeece2SJames Morrissey @echo " REALCLEAN" 1611f1477d4aSEvan Lloyd $(call SHELL_REMOVE_DIR,${BUILD_BASE}) 1612f1477d4aSEvan Lloyd $(call SHELL_DELETE_ALL, ${CURDIR}/cscope.*) 161388a1cf1eSSami Mujawarifdef UNIX_MK 16142f2cef46SJeenu Viswambharan ${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean 161588a1cf1eSSami Mujawarelse 161688a1cf1eSSami Mujawar# Clear the MAKEFLAGS as we do not want 161788a1cf1eSSami Mujawar# to pass the gnumake flags to nmake. 161888a1cf1eSSami Mujawar ${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) realclean 1619c5e1da83SJayanth Dodderi Chidanandendif #(UNIX_MK) 1620e15591aaSNicolas Boulenguez ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} realclean 162190aa901fSSumit Garg ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} realclean 16225accce5bSRoberto Vargas ${Q}${MAKE} --no-print-directory -C ${ROMLIBPATH} clean 16234f6ad66aSAchin Gupta 162436eaaf37SIan Spraycheckcodebase: locate-checkpatch 162536eaaf37SIan Spray @echo " CHECKING STYLE" 162636eaaf37SIan Spray @if test -d .git ; then \ 16271ef35512SPaul Beesley git ls-files | grep -E -v 'libfdt|libc|docs|\.rst' | \ 16281a41e8c1SDan Handley while read GIT_FILE ; \ 16291a41e8c1SDan Handley do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ; \ 16301a41e8c1SDan Handley done ; \ 163136eaaf37SIan Spray else \ 16321a41e8c1SDan Handley find . -type f -not -iwholename "*.git*" \ 16331a41e8c1SDan Handley -not -iwholename "*build*" \ 16341a41e8c1SDan Handley -not -iwholename "*libfdt*" \ 163561f72a34SRoberto Vargas -not -iwholename "*libc*" \ 16361a41e8c1SDan Handley -not -iwholename "*docs*" \ 16371ef35512SPaul Beesley -not -iwholename "*.rst" \ 16381a41e8c1SDan Handley -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ; \ 163936eaaf37SIan Spray fi 164036eaaf37SIan Spray 164136eaaf37SIan Spraycheckpatch: locate-checkpatch 164236eaaf37SIan Spray @echo " CHECKING STYLE" 164302a76d5fSYann Gautier @if test -n "${CHECKPATCH_OPTS}"; then \ 164402a76d5fSYann Gautier echo " with ${CHECKPATCH_OPTS} option(s)"; \ 164502a76d5fSYann Gautier fi 164651d28937SAntonio Nino Diaz ${Q}COMMON_COMMIT=$$(git merge-base HEAD ${BASE_COMMIT}); \ 164777a0a7f1SYann Gautier for commit in `git rev-list --no-merges $$COMMON_COMMIT..HEAD`; \ 164877a0a7f1SYann Gautier do \ 164951d28937SAntonio Nino Diaz printf "\n[*] Checking style of '$$commit'\n\n"; \ 165051d28937SAntonio Nino Diaz git log --format=email "$$commit~..$$commit" \ 165102a76d5fSYann Gautier -- ${CHECK_PATHS} | \ 165202a76d5fSYann Gautier ${CHECKPATCH} ${CHECKPATCH_OPTS} - || true; \ 165351d28937SAntonio Nino Diaz git diff --format=email "$$commit~..$$commit" \ 165402a76d5fSYann Gautier -- ${CHECK_PATHS} | \ 165502a76d5fSYann Gautier ${CHECKPATCH} ${CHECKPATCH_OPTS} - || true; \ 165651d28937SAntonio Nino Diaz done 165736eaaf37SIan Spray 165873c99d4eSJuan Castillocerttool: ${CRTTOOL} 165973c99d4eSJuan Castillo 1660a9812206SPali Rohár${CRTTOOL}: FORCE 1661598b166bSLionel 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 1662f1477d4aSEvan Lloyd @${ECHO_BLANK_LINE} 16636f971622SJuan Castillo @echo "Built $@ successfully" 1664f1477d4aSEvan Lloyd @${ECHO_BLANK_LINE} 16656f971622SJuan Castillo 16666f971622SJuan Castilloifneq (${GENERATE_COT},0) 166773c99d4eSJuan Castillocertificates: ${CRT_DEPS} ${CRTTOOL} 16686f971622SJuan Castillo ${Q}${CRTTOOL} ${CRT_ARGS} 1669f1477d4aSEvan Lloyd @${ECHO_BLANK_LINE} 16706f971622SJuan Castillo @echo "Built $@ successfully" 16716f971622SJuan Castillo @echo "Certificates can be found in ${BUILD_PLAT}" 1672f1477d4aSEvan Lloyd @${ECHO_BLANK_LINE} 1673c5e1da83SJayanth Dodderi Chidanandendif #(GENERATE_COT) 167427713fb4SSoby Mathew 167573c99d4eSJuan Castillo${BUILD_PLAT}/${FIP_NAME}: ${FIP_DEPS} ${FIPTOOL} 16764727fd13SPali Rohár $(eval ${CHECK_FIP_CMD}) 1677819281eeSdp-arm ${Q}${FIPTOOL} create ${FIP_ARGS} $@ 1678819281eeSdp-arm ${Q}${FIPTOOL} info $@ 1679f1477d4aSEvan Lloyd @${ECHO_BLANK_LINE} 16802f2cef46SJeenu Viswambharan @echo "Built $@ successfully" 1681f1477d4aSEvan Lloyd @${ECHO_BLANK_LINE} 1682f58ad36fSHarry Liebel 16830191262dSYatharth Kocharifneq (${GENERATE_COT},0) 16840191262dSYatharth Kocharfwu_certificates: ${FWU_CRT_DEPS} ${CRTTOOL} 16850191262dSYatharth Kochar ${Q}${CRTTOOL} ${FWU_CRT_ARGS} 1686052ab529SEvan Lloyd @${ECHO_BLANK_LINE} 16870191262dSYatharth Kochar @echo "Built $@ successfully" 16880191262dSYatharth Kochar @echo "FWU certificates can be found in ${BUILD_PLAT}" 1689052ab529SEvan Lloyd @${ECHO_BLANK_LINE} 1690c5e1da83SJayanth Dodderi Chidanandendif #(GENERATE_COT) 16910191262dSYatharth Kochar 16920191262dSYatharth Kochar${BUILD_PLAT}/${FWU_FIP_NAME}: ${FWU_FIP_DEPS} ${FIPTOOL} 16934727fd13SPali Rohár $(eval ${CHECK_FWU_FIP_CMD}) 1694819281eeSdp-arm ${Q}${FIPTOOL} create ${FWU_FIP_ARGS} $@ 1695819281eeSdp-arm ${Q}${FIPTOOL} info $@ 1696052ab529SEvan Lloyd @${ECHO_BLANK_LINE} 16970191262dSYatharth Kochar @echo "Built $@ successfully" 1698052ab529SEvan Lloyd @${ECHO_BLANK_LINE} 16990191262dSYatharth Kochar 170073c99d4eSJuan Castillofiptool: ${FIPTOOL} 170173c99d4eSJuan Castillofip: ${BUILD_PLAT}/${FIP_NAME} 17020191262dSYatharth Kocharfwu_fip: ${BUILD_PLAT}/${FWU_FIP_NAME} 170373c99d4eSJuan Castillo 1704a9812206SPali Rohár${FIPTOOL}: FORCE 170588a1cf1eSSami Mujawarifdef UNIX_MK 1706598b166bSLionel Debieve ${Q}${MAKE} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" FIPTOOL=${FIPTOOL} OPENSSL_DIR=${OPENSSL_DIR} DEBUG=${DEBUG} V=${V} --no-print-directory -C ${FIPTOOLPATH} all 170788a1cf1eSSami Mujawarelse 170888a1cf1eSSami Mujawar# Clear the MAKEFLAGS as we do not want 170988a1cf1eSSami Mujawar# to pass the gnumake flags to nmake. 171088a1cf1eSSami Mujawar ${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) 1711c5e1da83SJayanth Dodderi Chidanandendif #(UNIX_MK) 1712f58ad36fSHarry Liebel 1713a9812206SPali Rohárromlib.bin: libraries FORCE 1714bbb24f61SJohn 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 17155accce5bSRoberto Vargas 1716cfe83910SLouis Mayencourtmemmap: all 1717af5b49e9SHarrison Mutaiifdef UNIX_MK 1718af5b49e9SHarrison Mutai ${Q}PYTHONPATH=${CURDIR}/tools/memory \ 1719af5b49e9SHarrison Mutai ${PYTHON} -m memory.memmap -sr ${BUILD_PLAT} 1720af5b49e9SHarrison Mutaielse 1721af5b49e9SHarrison Mutai ${Q}set PYTHONPATH=${CURDIR}/tools/memory && \ 1722af5b49e9SHarrison Mutai ${PYTHON} -m memory.memmap -sr ${BUILD_PLAT} 1723af5b49e9SHarrison Mutaiendif 1724cfe83910SLouis Mayencourt 17256de32378SMadhukar Pappireddydoc: 17266de32378SMadhukar Pappireddy @echo " BUILD DOCUMENTATION" 17276de32378SMadhukar Pappireddy ${Q}${MAKE} --no-print-directory -C ${DOCS_PATH} html 17286de32378SMadhukar Pappireddy 172990aa901fSSumit Gargenctool: ${ENCTOOL} 173090aa901fSSumit Garg 1731a9812206SPali Rohár${ENCTOOL}: FORCE 1732598b166bSLionel Debieve ${Q}${MAKE} PLAT=${PLAT} BUILD_INFO=0 OPENSSL_DIR=${OPENSSL_DIR} ENCTOOL=${ENCTOOL} DEBUG=${DEBUG} V=${V} --no-print-directory -C ${ENCTOOLPATH} all 173390aa901fSSumit Garg @${ECHO_BLANK_LINE} 173490aa901fSSumit Garg @echo "Built $@ successfully" 173590aa901fSSumit Garg @${ECHO_BLANK_LINE} 173690aa901fSSumit Garg 173735fab8c9SJoakim Bechcscope: 173835fab8c9SJoakim Bech @echo " CSCOPE" 173935fab8c9SJoakim Bech ${Q}find ${CURDIR} -name "*.[chsS]" > cscope.files 174035fab8c9SJoakim Bech ${Q}cscope -b -q -k 174135fab8c9SJoakim Bech 174272ee3314SRyan Harkinhelp: 17437c23126cSJohn Tsichritzis @echo "usage: ${MAKE} [PLAT=<platform>] [OPTIONS] [TARGET]" 174472ee3314SRyan Harkin @echo "" 174572ee3314SRyan Harkin @echo "PLAT is used to specify which platform you wish to build." 174608c7ed0fSSandrine Bailleux @echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}" 174772ee3314SRyan Harkin @echo "" 17487c23126cSJohn Tsichritzis @echo "platform = ${PLATFORM_LIST}" 17497c23126cSJohn Tsichritzis @echo "" 17501b578596SSandrine Bailleux @echo "Please refer to the User Guide for a list of all supported options." 17511b578596SSandrine Bailleux @echo "Note that the build system doesn't track dependencies for build " 17521b578596SSandrine Bailleux @echo "options. Therefore, if any of the build options are changed " 17531b578596SSandrine Bailleux @echo "from a previous build, a clean build must be performed." 17541b578596SSandrine Bailleux @echo "" 175572ee3314SRyan Harkin @echo "Supported Targets:" 17561b578596SSandrine Bailleux @echo " all Build all individual bootloader binaries" 175736eaaf37SIan Spray @echo " bl1 Build the BL1 binary" 17588aa559c0SJeenu Viswambharan @echo " bl2 Build the BL2 binary" 17599003fa0bSYatharth Kochar @echo " bl2u Build the BL2U binary" 1760d178637dSJuan Castillo @echo " bl31 Build the BL31 binary" 17619d29c227SSoby Mathew @echo " bl32 Build the BL32 binary. If ARCH=aarch32, then " 17629d29c227SSoby Mathew @echo " this builds secure payload specified by AARCH32_SP" 176373c99d4eSJuan Castillo @echo " certificates Build the certificates (requires 'GENERATE_COT=1')" 17641b578596SSandrine Bailleux @echo " fip Build the Firmware Image Package (FIP)" 17650191262dSYatharth Kochar @echo " fwu_fip Build the FWU Firmware Image Package (FIP)" 176636eaaf37SIan Spray @echo " checkcodebase Check the coding style of the entire source tree" 176736eaaf37SIan Spray @echo " checkpatch Check the coding style on changes in the current" 176836eaaf37SIan Spray @echo " branch against BASE_COMMIT (default origin/master)" 176972ee3314SRyan Harkin @echo " clean Clean the build for the selected platform" 177035fab8c9SJoakim Bech @echo " cscope Generate cscope index" 177172ee3314SRyan Harkin @echo " distclean Remove all build artifacts for all platforms" 17726f971622SJuan Castillo @echo " certtool Build the Certificate generation tool" 177390aa901fSSumit Garg @echo " enctool Build the Firmware encryption tool" 1774f58ad36fSHarry Liebel @echo " fiptool Build the Firmware Image Package (FIP) creation tool" 1775ce2b1ec6SManish Pandey @echo " sp Build the Secure Partition Packages" 177626010da1SAntonio Nino Diaz @echo " sptool Build the Secure Partition Package creation tool" 177738c14d88SSoby Mathew @echo " dtbs Build the Device Tree Blobs (if required for the platform)" 1778cfe83910SLouis Mayencourt @echo " memmap Print the memory map of the built binaries" 17796de32378SMadhukar Pappireddy @echo " doc Build html based documentation using Sphinx tool" 178072ee3314SRyan Harkin @echo "" 17811b578596SSandrine Bailleux @echo "Note: most build targets require PLAT to be set to a specific platform." 178272ee3314SRyan Harkin @echo "" 178372ee3314SRyan Harkin @echo "example: build all targets for the FVP platform:" 178472ee3314SRyan Harkin @echo " CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all" 1785a9812206SPali Rohár 1786a9812206SPali Rohár.PHONY: FORCE 1787a9812206SPali RohárFORCE:; 1788