14f6ad66aSAchin Gupta# 201cf14ddSMaksims Svecovs# Copyright (c) 2013-2023, Arm Limited and Contributors. All rights reserved. 34f6ad66aSAchin Gupta# 482cb2c1aSdp-arm# SPDX-License-Identifier: BSD-3-Clause 54f6ad66aSAchin Gupta# 64f6ad66aSAchin Gupta 7e35c4045SJeenu Viswambharan# 8aaa3e722SJuan Castillo# Trusted Firmware Version 9aaa3e722SJuan Castillo# 101a0f1121SSoby MathewVERSION_MAJOR := 2 11b78ad00eSJuan Pablo CondeVERSION_MINOR := 9 12dddf4283Slaurenw-armVERSION := ${VERSION_MAJOR}.${VERSION_MINOR} 13aaa3e722SJuan Castillo 1488154678SJuan Castillo# Default goal is build all images 1588154678SJuan Castillo.DEFAULT_GOAL := all 1688154678SJuan Castillo 1772fc70edSDouglas Raillard# Avoid any implicit propagation of command line variable definitions to 1872fc70edSDouglas Raillard# sub-Makefiles, like CFLAGS that we reserved for the firmware images' 1972fc70edSDouglas Raillard# usage. Other command line options like "-s" are still propagated as usual. 2072fc70edSDouglas RaillardMAKEOVERRIDES = 2172fc70edSDouglas Raillard 22231c1470SEvan LloydMAKE_HELPERS_DIRECTORY := make_helpers/ 23231c1470SEvan Lloydinclude ${MAKE_HELPERS_DIRECTORY}build_macros.mk 24e7f54dbdSEvan Lloydinclude ${MAKE_HELPERS_DIRECTORY}build_env.mk 2573c99d4eSJuan Castillo 2673c99d4eSJuan Castillo################################################################################ 272fae4b1eSJeenu Viswambharan# Default values for build configurations, and their dependencies 2873c99d4eSJuan Castillo################################################################################ 29e35c4045SJeenu Viswambharan 302fae4b1eSJeenu Viswambharaninclude ${MAKE_HELPERS_DIRECTORY}defaults.mk 31872be88aSdp-arm 32cc8b5632SAntonio Nino Diaz# Assertions enabled for DEBUG builds by default 33cc8b5632SAntonio Nino DiazENABLE_ASSERTIONS := ${DEBUG} 342fae4b1eSJeenu ViswambharanENABLE_PMF := ${ENABLE_RUNTIME_INSTRUMENTATION} 352fae4b1eSJeenu ViswambharanPLAT := ${DEFAULT_PLAT} 3673c99d4eSJuan Castillo 3773c99d4eSJuan Castillo################################################################################ 3873c99d4eSJuan Castillo# Checkpatch script options 3973c99d4eSJuan Castillo################################################################################ 4073c99d4eSJuan Castillo 41f607739cSSandrine BailleuxCHECKCODE_ARGS := --no-patch 42f0b489c1SDan Handley# Do not check the coding style on imported library files or documentation files 434501843fSGilad Ben-YossefINC_ARM_DIRS_TO_CHECK := $(sort $(filter-out \ 444501843fSGilad Ben-Yossef include/drivers/arm/cryptocell, \ 454501843fSGilad Ben-Yossef $(wildcard include/drivers/arm/*))) 464501843fSGilad Ben-YossefINC_ARM_DIRS_TO_CHECK += include/drivers/arm/cryptocell/*.h 474501843fSGilad Ben-YossefINC_DRV_DIRS_TO_CHECK := $(sort $(filter-out \ 484501843fSGilad Ben-Yossef include/drivers/arm, \ 494501843fSGilad Ben-Yossef $(wildcard include/drivers/*))) 50f0b489c1SDan HandleyINC_LIB_DIRS_TO_CHECK := $(sort $(filter-out \ 511a41e8c1SDan Handley include/lib/libfdt \ 5261f72a34SRoberto Vargas include/lib/libc, \ 53f0b489c1SDan Handley $(wildcard include/lib/*))) 54f0b489c1SDan HandleyINC_DIRS_TO_CHECK := $(sort $(filter-out \ 554501843fSGilad Ben-Yossef include/lib \ 564501843fSGilad Ben-Yossef include/drivers, \ 57f0b489c1SDan Handley $(wildcard include/*))) 58f0b489c1SDan HandleyLIB_DIRS_TO_CHECK := $(sort $(filter-out \ 59d801fbb0Sdp-arm lib/compiler-rt \ 6055cdcf75SAntonio Nino Diaz lib/libfdt% \ 6161f72a34SRoberto Vargas lib/libc, \ 62a194255dSDaniel Boulby lib/zlib \ 63f0b489c1SDan Handley $(wildcard lib/*))) 64f0b489c1SDan HandleyROOT_DIRS_TO_CHECK := $(sort $(filter-out \ 65f0b489c1SDan Handley lib \ 66f0b489c1SDan Handley include \ 67f0b489c1SDan Handley docs \ 681ef35512SPaul Beesley %.rst, \ 69f0b489c1SDan Handley $(wildcard *))) 70f0b489c1SDan HandleyCHECK_PATHS := ${ROOT_DIRS_TO_CHECK} \ 71f0b489c1SDan Handley ${INC_DIRS_TO_CHECK} \ 72f0b489c1SDan Handley ${INC_LIB_DIRS_TO_CHECK} \ 734501843fSGilad Ben-Yossef ${LIB_DIRS_TO_CHECK} \ 744501843fSGilad Ben-Yossef ${INC_DRV_DIRS_TO_CHECK} \ 754501843fSGilad Ben-Yossef ${INC_ARM_DIRS_TO_CHECK} 7636eaaf37SIan Spray 7773c99d4eSJuan Castillo################################################################################ 7873c99d4eSJuan Castillo# Process build options 7973c99d4eSJuan Castillo################################################################################ 8073c99d4eSJuan Castillo 8173c99d4eSJuan Castillo# Verbose flag 82e35c4045SJeenu Viswambharanifeq (${V},0) 83b169f6a9SEvan Lloyd Q:=@ 84ee1ba6d4SAndre Przywara ECHO:=@echo 8536eaaf37SIan Spray CHECKCODE_ARGS += --no-summary --terse 864f6ad66aSAchin Guptaelse 87b169f6a9SEvan Lloyd Q:= 88b5a0f4bdSAntonio Nino Diaz ECHO:=$(ECHO_QUIET) 894f6ad66aSAchin Guptaendif 90ee1ba6d4SAndre Przywara 91ee1ba6d4SAndre Przywaraifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),) 92ee1ba6d4SAndre Przywara Q:=@ 93b5a0f4bdSAntonio Nino Diaz ECHO:=$(ECHO_QUIET) 94ee1ba6d4SAndre Przywaraendif 95ee1ba6d4SAndre Przywara 96ee1ba6d4SAndre Przywaraexport Q ECHO 972f2cef46SJeenu Viswambharan 9873c99d4eSJuan Castillo################################################################################ 9973c99d4eSJuan Castillo# Toolchain 10073c99d4eSJuan Castillo################################################################################ 10173c99d4eSJuan Castillo 10272610c41Sdp-armHOSTCC := gcc 10372610c41Sdp-armexport HOSTCC 10472610c41Sdp-arm 10573c99d4eSJuan CastilloCC := ${CROSS_COMPILE}gcc 10673c99d4eSJuan CastilloCPP := ${CROSS_COMPILE}cpp 10773c99d4eSJuan CastilloAS := ${CROSS_COMPILE}gcc 10873c99d4eSJuan CastilloAR := ${CROSS_COMPILE}ar 1092adee763SRoberto VargasLINKER := ${CROSS_COMPILE}ld 11073c99d4eSJuan CastilloOC := ${CROSS_COMPILE}objcopy 11173c99d4eSJuan CastilloOD := ${CROSS_COMPILE}objdump 11273c99d4eSJuan CastilloNM := ${CROSS_COMPILE}nm 11373c99d4eSJuan CastilloPP := ${CROSS_COMPILE}gcc -E 11438c14d88SSoby MathewDTC := dtc 11573c99d4eSJuan Castillo 116b25a577fSJulius Werner# Use ${LD}.bfd instead if it exists (as absolute path or together with $PATH). 117b25a577fSJulius Wernerifneq ($(strip $(wildcard ${LD}.bfd) \ 1182adee763SRoberto Vargas $(foreach dir,$(subst :, ,${PATH}),$(wildcard ${dir}/${LINKER}.bfd))),) 1192adee763SRoberto VargasLINKER := ${LINKER}.bfd 120b25a577fSJulius Wernerendif 121b25a577fSJulius Werner 122c5e1da83SJayanth Dodderi Chidanand################################################################################ 123c5e1da83SJayanth Dodderi Chidanand# Auxiliary tools (fiptool, cert_create, etc) 124c5e1da83SJayanth Dodderi Chidanand################################################################################ 125c5e1da83SJayanth Dodderi Chidanand 126c5e1da83SJayanth Dodderi Chidanand# Variables for use with Certificate Generation Tool 127c5e1da83SJayanth Dodderi ChidanandCRTTOOLPATH ?= tools/cert_create 128c5e1da83SJayanth Dodderi ChidanandCRTTOOL ?= ${CRTTOOLPATH}/cert_create${BIN_EXT} 129c5e1da83SJayanth Dodderi Chidanand 130c5e1da83SJayanth Dodderi Chidanand# Variables for use with Firmware Encryption Tool 131c5e1da83SJayanth Dodderi ChidanandENCTOOLPATH ?= tools/encrypt_fw 132c5e1da83SJayanth Dodderi ChidanandENCTOOL ?= ${ENCTOOLPATH}/encrypt_fw${BIN_EXT} 133c5e1da83SJayanth Dodderi Chidanand 134c5e1da83SJayanth Dodderi Chidanand# Variables for use with Firmware Image Package 135c5e1da83SJayanth Dodderi ChidanandFIPTOOLPATH ?= tools/fiptool 136c5e1da83SJayanth Dodderi ChidanandFIPTOOL ?= ${FIPTOOLPATH}/fiptool${BIN_EXT} 137c5e1da83SJayanth Dodderi Chidanand 138c5e1da83SJayanth Dodderi Chidanand# Variables for use with sptool 139c5e1da83SJayanth Dodderi ChidanandSPTOOLPATH ?= tools/sptool 140c5e1da83SJayanth Dodderi ChidanandSPTOOL ?= ${SPTOOLPATH}/sptool.py 141c5e1da83SJayanth Dodderi ChidanandSP_MK_GEN ?= ${SPTOOLPATH}/sp_mk_generator.py 14220629b31SKarl MeakinSP_DTS_LIST_FRAGMENT ?= ${BUILD_PLAT}/sp_list_fragment.dts 143c5e1da83SJayanth Dodderi Chidanand 144c5e1da83SJayanth Dodderi Chidanand# Variables for use with ROMLIB 145c5e1da83SJayanth Dodderi ChidanandROMLIBPATH ?= lib/romlib 146c5e1da83SJayanth Dodderi Chidanand 147c5e1da83SJayanth Dodderi Chidanand# Variable for use with Python 148c5e1da83SJayanth Dodderi ChidanandPYTHON ?= python3 149c5e1da83SJayanth Dodderi Chidanand 150c5e1da83SJayanth Dodderi Chidanand# Variables for use with documentation build using Sphinx tool 151c5e1da83SJayanth Dodderi ChidanandDOCS_PATH ?= docs 152c5e1da83SJayanth Dodderi Chidanand 153c5e1da83SJayanth Dodderi Chidanand################################################################################ 154c5e1da83SJayanth Dodderi Chidanand# Compiler Configuration based on ARCH_MAJOR and ARCH_MINOR flags 155c5e1da83SJayanth Dodderi Chidanand################################################################################ 15626e63c44SEtienne Carriereifeq (${ARM_ARCH_MAJOR},7) 15726e63c44SEtienne Carriere target32-directive = -target arm-none-eabi 158d4089fb8SGovindraj Raja# Will set march-directive from platform configuration 15926e63c44SEtienne Carriereelse 16026e63c44SEtienne Carriere target32-directive = -target armv8a-none-eabi 161c5e1da83SJayanth Dodderi Chidanandendif #(ARM_ARCH_MAJOR) 162c5e1da83SJayanth Dodderi Chidanand 163c5e1da83SJayanth Dodderi Chidanand################################################################################ 164c5e1da83SJayanth Dodderi Chidanand# Get Architecture Feature Modifiers 165c5e1da83SJayanth Dodderi Chidanand################################################################################ 166c5e1da83SJayanth Dodderi Chidanandarch-features = ${ARM_ARCH_FEATURE} 167c5e1da83SJayanth Dodderi Chidanand 168f1821790SAlexei Fedorov# Set the compiler's architecture feature modifiers 169f1821790SAlexei Fedorovifneq ($(arch-features), none) 170f1821790SAlexei Fedorov # Strip "none+" from arch-features 171f1821790SAlexei Fedorov arch-features := $(subst none+,,$(arch-features)) 172d4089fb8SGovindraj Raja march-directive := $(march-directive)+$(arch-features) 173f1821790SAlexei Fedorov# Print features 174f1821790SAlexei Fedorov $(info Arm Architecture Features specified: $(subst +, ,$(arch-features))) 175c5e1da83SJayanth Dodderi Chidanandendif #(arch-features) 1764e04478aSChris Kay 177c8a992fdSoriginifneq ($(findstring clang,$(notdir $(CC))),) 178fd18a8fcSVarun Wadekar ifneq ($(findstring armclang,$(notdir $(CC))),) 1797794d6c8SGovindraj Raja TF_CFLAGS_aarch32 := -target arm-arm-none-eabi 1807794d6c8SGovindraj Raja TF_CFLAGS_aarch64 := -target aarch64-arm-none-eabi 181c8a992fdSorigin LD := $(LINKER) 182c8a992fdSorigin else 1837794d6c8SGovindraj Raja TF_CFLAGS_aarch32 = $(target32-directive) 1847794d6c8SGovindraj Raja TF_CFLAGS_aarch64 := -target aarch64-elf 185c8a992fdSorigin LD := $(shell $(CC) --print-prog-name ld.lld) 186c8a992fdSorigin 187c8a992fdSorigin AR := $(shell $(CC) --print-prog-name llvm-ar) 188c8a992fdSorigin OD := $(shell $(CC) --print-prog-name llvm-objdump) 189c8a992fdSorigin OC := $(shell $(CC) --print-prog-name llvm-objcopy) 190641f16e7SAmbroise Vincent endif 191c8a992fdSorigin 192c8a992fdSorigin CPP := $(CC) -E $(TF_CFLAGS_$(ARCH)) 193c8a992fdSorigin PP := $(CC) -E $(TF_CFLAGS_$(ARCH)) 194c8a992fdSorigin AS := $(CC) -c -x assembler-with-cpp $(TF_CFLAGS_$(ARCH)) 195edbce9aaSzelalem-awekeelse ifneq ($(findstring gcc,$(notdir $(CC))),) 196edbce9aaSzelalem-aweke ifeq ($(ENABLE_LTO),1) 197edbce9aaSzelalem-aweke # Enable LTO only for aarch64 198edbce9aaSzelalem-aweke ifeq (${ARCH},aarch64) 199edbce9aaSzelalem-aweke LTO_CFLAGS = -flto 200edbce9aaSzelalem-aweke # Use gcc as a wrapper for the ld, recommended for LTO 201edbce9aaSzelalem-aweke LINKER := ${CROSS_COMPILE}gcc 202edbce9aaSzelalem-aweke endif 203edbce9aaSzelalem-aweke endif 204edbce9aaSzelalem-aweke LD = $(LINKER) 205d5461857Sdp-armelse 2062adee763SRoberto Vargas LD = $(LINKER) 207c5e1da83SJayanth Dodderi Chidanandendif #(clang) 208d5461857Sdp-arm 20932b209bfSAhmad Fatoum# Process Debug flag 21032b209bfSAhmad Fatoum$(eval $(call add_define,DEBUG)) 21132b209bfSAhmad Fatoumifneq (${DEBUG}, 0) 21232b209bfSAhmad Fatoum BUILD_TYPE := debug 2134466cf82SDaniel Boulby TF_CFLAGS += -g -gdwarf-4 2144466cf82SDaniel Boulby ASFLAGS += -g -Wa,-gdwarf-4 21532b209bfSAhmad Fatoum 21632b209bfSAhmad Fatoum # Use LOG_LEVEL_INFO by default for debug builds 21732b209bfSAhmad Fatoum LOG_LEVEL := 40 21832b209bfSAhmad Fatoumelse 21932b209bfSAhmad Fatoum BUILD_TYPE := release 22032b209bfSAhmad Fatoum # Use LOG_LEVEL_NOTICE by default for release builds 22132b209bfSAhmad Fatoum LOG_LEVEL := 20 222c5e1da83SJayanth Dodderi Chidanandendif #(Debug) 22332b209bfSAhmad Fatoum 224f1de4c8fSPeiyuan Song# Default build string (git branch and commit) 225f1de4c8fSPeiyuan Songifeq (${BUILD_STRING},) 226f1de4c8fSPeiyuan Song BUILD_STRING := $(shell git describe --always --dirty --tags 2> /dev/null) 227f1de4c8fSPeiyuan Songendif 228dddf4283Slaurenw-armVERSION_STRING := v${VERSION}(${BUILD_TYPE}):${BUILD_STRING} 229f1de4c8fSPeiyuan Song 2308fd9d4d5SAntonio Nino Diazifeq (${AARCH32_INSTRUCTION_SET},A32) 2318fd9d4d5SAntonio Nino Diaz TF_CFLAGS_aarch32 += -marm 2328fd9d4d5SAntonio Nino Diazelse ifeq (${AARCH32_INSTRUCTION_SET},T32) 2338fd9d4d5SAntonio Nino Diaz TF_CFLAGS_aarch32 += -mthumb 2348fd9d4d5SAntonio Nino Diazelse 2358fd9d4d5SAntonio Nino Diaz $(error Error: Unknown AArch32 instruction set ${AARCH32_INSTRUCTION_SET}) 236c5e1da83SJayanth Dodderi Chidanandendif #(AARCH32_INSTRUCTION_SET) 2378fd9d4d5SAntonio Nino Diaz 238a9c4dde3SSandrine BailleuxTF_CFLAGS_aarch32 += -mno-unaligned-access 239d5461857Sdp-armTF_CFLAGS_aarch64 += -mgeneral-regs-only -mstrict-align 2409d29c227SSoby Mathew 241d4089fb8SGovindraj RajaASFLAGS += $(march-directive) 242b86048c4SAntonio Nino Diaz 243c5e1da83SJayanth Dodderi Chidanand############################################################################## 244c5e1da83SJayanth Dodderi Chidanand# WARNINGS Configuration 245c5e1da83SJayanth Dodderi Chidanand############################################################################### 2469ab81b5eSJustin Chadwell# General warnings 2479ab81b5eSJustin ChadwellWARNINGS := -Wall -Wmissing-include-dirs -Wunused \ 248b7f6525dSJustin Chadwell -Wdisabled-optimization -Wvla -Wshadow \ 249d75a9ecdSBoyan Karatotev -Wredundant-decls 250d75a9ecdSBoyan Karatotev# stricter warnings 251d75a9ecdSBoyan KaratotevWARNINGS += -Wextra -Wno-trigraphs 252d75a9ecdSBoyan Karatotev# too verbose for generic build 253d75a9ecdSBoyan KaratotevWARNINGS += -Wno-missing-field-initializers \ 254d75a9ecdSBoyan Karatotev -Wno-type-limits -Wno-sign-compare \ 255d75a9ecdSBoyan Karatotev# on clang this flag gets reset if -Wextra is set after it. No difference on gcc 256d75a9ecdSBoyan KaratotevWARNINGS += -Wno-unused-parameter 2579ab81b5eSJustin Chadwell 2589ab81b5eSJustin Chadwell# Additional warnings 259d75a9ecdSBoyan Karatotev# Level 1 - infrequent warnings we should have none of 260d75a9ecdSBoyan Karatotev# full -Wextra 261d75a9ecdSBoyan KaratotevWARNING1 += -Wsign-compare 262d75a9ecdSBoyan KaratotevWARNING1 += -Wtype-limits 263d75a9ecdSBoyan KaratotevWARNING1 += -Wmissing-field-initializers 264e7c645b5SYann Gautier 265d75a9ecdSBoyan Karatotev# Level 2 - problematic warnings that we want 266d75a9ecdSBoyan Karatotev# zlib, compiler-rt, coreboot, and mbdedtls blow up with these 267d75a9ecdSBoyan Karatotev# TODO: disable just for them and move into default build 268d75a9ecdSBoyan KaratotevWARNING2 += -Wold-style-definition 269d75a9ecdSBoyan KaratotevWARNING2 += -Wmissing-prototypes 270d75a9ecdSBoyan KaratotevWARNING2 += -Wmissing-format-attribute 271d75a9ecdSBoyan Karatotev# TF-A aims to comply with this eventually. Effort too large at present 272d75a9ecdSBoyan KaratotevWARNING2 += -Wundef 273d141e638SBoyan Karatotev# currently very involved and many platforms set this off 274d141e638SBoyan KaratotevWARNING2 += -Wunused-const-variable=2 275e7c645b5SYann Gautier 276d75a9ecdSBoyan Karatotev# Level 3 - very pedantic, frequently ignored 277e7c645b5SYann GautierWARNING3 := -Wbad-function-cast 278d75a9ecdSBoyan KaratotevWARNING3 += -Waggregate-return 279d75a9ecdSBoyan KaratotevWARNING3 += -Wnested-externs 280d75a9ecdSBoyan KaratotevWARNING3 += -Wcast-align 281e7c645b5SYann GautierWARNING3 += -Wcast-qual 282e7c645b5SYann GautierWARNING3 += -Wconversion 283e7c645b5SYann GautierWARNING3 += -Wpacked 284e7c645b5SYann GautierWARNING3 += -Wpointer-arith 285e7c645b5SYann GautierWARNING3 += -Wswitch-default 286e7c645b5SYann Gautier 287d75a9ecdSBoyan Karatotev# Setting W is quite verbose and most warnings will be pre-existing issues 288d75a9ecdSBoyan Karatotev# outside of the contributor's control. Don't fail the build on them so warnings 289d75a9ecdSBoyan Karatotev# can be seen and hopefully addressed 290d75a9ecdSBoyan Karatotevifdef W 291d75a9ecdSBoyan Karatotev ifneq (${W},0) 292d75a9ecdSBoyan Karatotev E ?= 0 293d75a9ecdSBoyan Karatotev endif 294d75a9ecdSBoyan Karatotevendif 295d75a9ecdSBoyan Karatotev 296e7c645b5SYann Gautierifeq (${W},1) 2979ab81b5eSJustin Chadwell WARNINGS += $(WARNING1) 298e7c645b5SYann Gautierelse ifeq (${W},2) 2999ab81b5eSJustin Chadwell WARNINGS += $(WARNING1) $(WARNING2) 300e7c645b5SYann Gautierelse ifeq (${W},3) 3019ab81b5eSJustin Chadwell WARNINGS += $(WARNING1) $(WARNING2) $(WARNING3) 302c5e1da83SJayanth Dodderi Chidanandendif #(W) 303e7c645b5SYann Gautier 3049ab81b5eSJustin Chadwell# Compiler specific warnings 30500296576SAmbroise Vincentifeq ($(findstring clang,$(notdir $(CC))),) 30693c690ebSJustin Chadwell# not using clang 307d7b4cd41SJustin ChadwellWARNINGS += -Wunused-but-set-variable -Wmaybe-uninitialized \ 308d7b4cd41SJustin Chadwell -Wpacked-bitfield-compat -Wshift-overflow=2 \ 309d7b4cd41SJustin Chadwell -Wlogical-op 310dea23e24SGovindraj Raja 311dea23e24SGovindraj Raja# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105523 312dea23e24SGovindraj RajaTF_CFLAGS += $(call cc_option, --param=min-pagesize=0) 313dea23e24SGovindraj Raja 31493c690ebSJustin Chadwellelse 31593c690ebSJustin Chadwell# using clang 316d7b4cd41SJustin ChadwellWARNINGS += -Wshift-overflow -Wshift-sign-overflow \ 317d7b4cd41SJustin Chadwell -Wlogical-op-parentheses 318c5e1da83SJayanth Dodderi Chidanandendif #(Clang Warning) 31900296576SAmbroise Vincent 3206336b07aSYann Gautierifneq (${E},0) 3216336b07aSYann Gautier ERRORS := -Werror 322c5e1da83SJayanth Dodderi Chidanandendif #(E) 3236336b07aSYann Gautier 324c5e1da83SJayanth Dodderi Chidanand################################################################################ 325c5e1da83SJayanth Dodderi Chidanand# Compiler and Linker Directives 326c5e1da83SJayanth Dodderi Chidanand################################################################################ 327ea7a57a3SRoberto VargasCPPFLAGS = ${DEFINES} ${INCLUDES} ${MBEDTLS_INC} -nostdinc \ 3289ab81b5eSJustin Chadwell $(ERRORS) $(WARNINGS) 329d4089fb8SGovindraj RajaASFLAGS += $(CPPFLAGS) \ 330d5dfdeb6SJulius Werner -ffreestanding -Wa,--fatal-warnings 33159de5096SMasahiro YamadaTF_CFLAGS += $(CPPFLAGS) $(TF_CFLAGS_$(ARCH)) \ 332ebd6efaeSSamuel Holland -ffunction-sections -fdata-sections \ 333ebd6efaeSSamuel Holland -ffreestanding -fno-builtin -fno-common \ 334ebd6efaeSSamuel Holland -Os -std=gnu99 33573c99d4eSJuan Castillo 3361f461979SJustin Chadwellifeq (${SANITIZE_UB},on) 3371f461979SJustin Chadwell TF_CFLAGS += -fsanitize=undefined -fno-sanitize-recover 338c5e1da83SJayanth Dodderi Chidanandendif #(${SANITIZE_UB},on) 339c5e1da83SJayanth Dodderi Chidanand 3401f461979SJustin Chadwellifeq (${SANITIZE_UB},trap) 3411f461979SJustin Chadwell TF_CFLAGS += -fsanitize=undefined -fno-sanitize-recover \ 3421f461979SJustin Chadwell -fsanitize-undefined-trap-on-error 343c5e1da83SJayanth Dodderi Chidanandendif #(${SANITIZE_UB},trap) 3441f461979SJustin Chadwell 345f7ec31dbSdavid cunadoGCC_V_OUTPUT := $(shell $(CC) -v 2>&1) 346f7ec31dbSdavid cunado 3471f49db5fSMarco FelschTF_LDFLAGS += -z noexecstack 3481f49db5fSMarco Felsch 349641f16e7SAmbroise Vincent# LD = armlink 350c2ad38ceSVarun Wadekarifneq ($(findstring armlink,$(notdir $(LD))),) 351c2ad38ceSVarun Wadekar TF_LDFLAGS += --diag_error=warning --lto_level=O1 352c2ad38ceSVarun Wadekar TF_LDFLAGS += --remove --info=unused,unusedsymbols 353edbce9aaSzelalem-aweke TF_LDFLAGS += $(TF_LDFLAGS_$(ARCH)) 354641f16e7SAmbroise Vincent 355641f16e7SAmbroise Vincent# LD = gcc (used when GCC LTO is enabled) 356edbce9aaSzelalem-awekeelse ifneq ($(findstring gcc,$(notdir $(LD))),) 357edbce9aaSzelalem-aweke # Pass ld options with Wl or Xlinker switches 358edbce9aaSzelalem-aweke TF_LDFLAGS += -Wl,--fatal-warnings -O1 359edbce9aaSzelalem-aweke TF_LDFLAGS += -Wl,--gc-sections 360ac98b82aSChris Kay 361ac98b82aSChris Kay TF_LDFLAGS += -Wl,-z,common-page-size=4096 #Configure page size constants 362ac98b82aSChris Kay TF_LDFLAGS += -Wl,-z,max-page-size=4096 363ac98b82aSChris Kay 364edbce9aaSzelalem-aweke ifeq ($(ENABLE_LTO),1) 365edbce9aaSzelalem-aweke ifeq (${ARCH},aarch64) 366edbce9aaSzelalem-aweke TF_LDFLAGS += -flto -fuse-linker-plugin 367edbce9aaSzelalem-aweke endif 368c5e1da83SJayanth Dodderi Chidanand endif #(ENABLE_LTO) 369c5e1da83SJayanth Dodderi Chidanand 370edbce9aaSzelalem-aweke# GCC automatically adds fix-cortex-a53-843419 flag when used to link 371edbce9aaSzelalem-aweke# which breaks some builds, so disable if errata fix is not explicitly enabled 372edbce9aaSzelalem-aweke ifneq (${ERRATA_A53_843419},1) 373edbce9aaSzelalem-aweke TF_LDFLAGS += -mno-fix-cortex-a53-843419 374edbce9aaSzelalem-aweke endif 375edbce9aaSzelalem-aweke TF_LDFLAGS += -nostdlib 376edbce9aaSzelalem-aweke TF_LDFLAGS += $(subst --,-Xlinker --,$(TF_LDFLAGS_$(ARCH))) 377641f16e7SAmbroise Vincent 378641f16e7SAmbroise Vincent# LD = gcc-ld (ld) or llvm-ld (ld.lld) or other 379c2ad38ceSVarun Wadekarelse 3801f49db5fSMarco Felsch# With ld.bfd version 2.39 and newer new warnings are added. Skip those since we 3811f49db5fSMarco Felsch# are not loaded by a elf loader. 3821f49db5fSMarco Felsch TF_LDFLAGS += $(call ld_option, --no-warn-rwx-segments) 383ebac6922SYabin Cui TF_LDFLAGS += -O1 384c2b8806fSDouglas Raillard TF_LDFLAGS += --gc-sections 385ac98b82aSChris Kay 386ac98b82aSChris Kay TF_LDFLAGS += -z common-page-size=4096 # Configure page size constants 387ac98b82aSChris Kay TF_LDFLAGS += -z max-page-size=4096 388ac98b82aSChris Kay 389641f16e7SAmbroise Vincent# ld.lld doesn't recognize the errata flags, 390ebac6922SYabin Cui# therefore don't add those in that case. 391ebac6922SYabin Cui# ld.lld reports section type mismatch warnings, 392ebac6922SYabin Cui# therefore don't add --fatal-warnings to it. 393641f16e7SAmbroise Vincent ifeq ($(findstring ld.lld,$(notdir $(LD))),) 394ebac6922SYabin Cui TF_LDFLAGS += $(TF_LDFLAGS_$(ARCH)) --fatal-warnings 395edbce9aaSzelalem-aweke endif 396c5e1da83SJayanth Dodderi Chidanand 397c5e1da83SJayanth Dodderi Chidanandendif #(LD = armlink) 39873c99d4eSJuan Castillo 39903b397a8SNishanth MenonDTC_FLAGS += -I dts -O dtb 400a6de824fSLouis MayencourtDTC_CPPFLAGS += -P -nostdinc -Iinclude -Ifdts -undef \ 401a6de824fSLouis Mayencourt -x assembler-with-cpp $(DEFINES) 40203b397a8SNishanth Menon 40373c99d4eSJuan Castillo################################################################################ 404f5211420SGovindraj Raja# Setup ARCH_MAJOR/MINOR before parsing arch_features. 405f5211420SGovindraj Raja################################################################################ 406f5211420SGovindraj Rajaifeq (${ENABLE_RME},1) 407f5211420SGovindraj Raja ARM_ARCH_MAJOR := 8 408f5211420SGovindraj Raja ARM_ARCH_MINOR := 6 409f5211420SGovindraj Rajaendif 410f5211420SGovindraj Raja 411f5211420SGovindraj Raja################################################################################ 41273c99d4eSJuan Castillo# Common sources and include directories 41373c99d4eSJuan Castillo################################################################################ 4146a0da736SJayanth Dodderi Chidanandinclude ${MAKE_HELPERS_DIRECTORY}arch_features.mk 415d801fbb0Sdp-arminclude lib/compiler-rt/compiler-rt.mk 41673c99d4eSJuan Castillo 41773c99d4eSJuan CastilloBL_COMMON_SOURCES += common/bl_common.c \ 4187f56e9a3SSoby Mathew common/tf_log.c \ 4199d29c227SSoby Mathew common/${ARCH}/debug.S \ 42091b48c9fSJulius Werner drivers/console/multi_console.c \ 4219d29c227SSoby Mathew lib/${ARCH}/cache_helpers.S \ 4229d29c227SSoby Mathew lib/${ARCH}/misc_helpers.S \ 423c73686a1SBoyan Karatotev lib/extensions/pmuv3/${ARCH}/pmuv3.c \ 424566034fcSSoby Mathew plat/common/plat_bl_common.c \ 4257f56e9a3SSoby Mathew plat/common/plat_log_common.c \ 42675311203Sdp-arm plat/common/${ARCH}/plat_common.c \ 4279d29c227SSoby Mathew plat/common/${ARCH}/platform_helpers.S \ 42861f72a34SRoberto Vargas ${COMPILER_RT_SRCS} 429d7a6b0f8SRyan Harkin 4308422a840SAntonio Nino Diazifeq ($(notdir $(CC)),armclang) 4318422a840SAntonio Nino Diaz BL_COMMON_SOURCES += lib/${ARCH}/armclang_printf.S 4328422a840SAntonio Nino Diazendif 4338422a840SAntonio Nino Diaz 4341f461979SJustin Chadwellifeq (${SANITIZE_UB},on) 4351f461979SJustin Chadwell BL_COMMON_SOURCES += plat/common/ubsan.c 4361f461979SJustin Chadwellendif 4371f461979SJustin Chadwell 43801d237cbSYann GautierINCLUDES += -Iinclude \ 439f5478dedSAntonio Nino Diaz -Iinclude/arch/${ARCH} \ 44009d40e0eSAntonio Nino Diaz -Iinclude/lib/cpus/${ARCH} \ 44109d40e0eSAntonio Nino Diaz -Iinclude/lib/el3_runtime/${ARCH} \ 44209d40e0eSAntonio Nino Diaz ${PLAT_INCLUDES} \ 44309d40e0eSAntonio Nino Diaz ${SPD_INCLUDES} 44409d40e0eSAntonio Nino Diaz 4459c6d1c50SAntonio Nino Diazinclude common/backtrace/backtrace.mk 4469c6d1c50SAntonio Nino Diaz 44773c99d4eSJuan Castillo################################################################################ 448f5211420SGovindraj Raja# Process BRANCH_PROTECTION value and set 449f5211420SGovindraj Raja# Pointer Authentication and Branch Target Identification flags 450f5211420SGovindraj Raja################################################################################ 451f5211420SGovindraj Rajaifeq (${BRANCH_PROTECTION},0) 452f5211420SGovindraj Raja # Default value turns off all types of branch protection 453f5211420SGovindraj Raja BP_OPTION := none 454f5211420SGovindraj Rajaelse ifneq (${ARCH},aarch64) 455f5211420SGovindraj Raja $(error BRANCH_PROTECTION requires AArch64) 456f5211420SGovindraj Rajaelse ifeq (${BRANCH_PROTECTION},1) 457f5211420SGovindraj Raja # Enables all types of branch protection features 458f5211420SGovindraj Raja BP_OPTION := standard 459f5211420SGovindraj Raja ENABLE_BTI := 1 460f5211420SGovindraj Raja ENABLE_PAUTH := 1 461f5211420SGovindraj Rajaelse ifeq (${BRANCH_PROTECTION},2) 462f5211420SGovindraj Raja # Return address signing to its standard level 463f5211420SGovindraj Raja BP_OPTION := pac-ret 464f5211420SGovindraj Raja ENABLE_PAUTH := 1 465f5211420SGovindraj Rajaelse ifeq (${BRANCH_PROTECTION},3) 466f5211420SGovindraj Raja # Extend the signing to include leaf functions 467f5211420SGovindraj Raja BP_OPTION := pac-ret+leaf 468f5211420SGovindraj Raja ENABLE_PAUTH := 1 469f5211420SGovindraj Rajaelse ifeq (${BRANCH_PROTECTION},4) 470f5211420SGovindraj Raja # Turn on branch target identification mechanism 471f5211420SGovindraj Raja BP_OPTION := bti 472f5211420SGovindraj Raja ENABLE_BTI := 1 473f5211420SGovindraj Rajaelse 474f5211420SGovindraj Raja $(error Unknown BRANCH_PROTECTION value ${BRANCH_PROTECTION}) 475f5211420SGovindraj Rajaendif #(BRANCH_PROTECTION) 476f5211420SGovindraj Raja 477f5211420SGovindraj Rajaifeq ($(ENABLE_PAUTH),1) 478f5211420SGovindraj Raja CTX_INCLUDE_PAUTH_REGS := 1 479f5211420SGovindraj Rajaendif 480f5211420SGovindraj Rajaifneq (${BP_OPTION},none) 481f5211420SGovindraj Raja TF_CFLAGS_aarch64 += -mbranch-protection=${BP_OPTION} 482f5211420SGovindraj Rajaendif #(BP_OPTION) 483f5211420SGovindraj Raja 484f5211420SGovindraj Raja# Pointer Authentication sources 485f5211420SGovindraj Rajaifeq (${ENABLE_PAUTH}, 1) 486f5211420SGovindraj Raja# arm/common/aarch64/arm_pauth.c contains a sample platform hook to complete the 487f5211420SGovindraj Raja# Pauth support. As it's not secure, it must be reimplemented for real platforms 488f5211420SGovindraj Raja BL_COMMON_SOURCES += lib/extensions/pauth/pauth_helpers.S 489f5211420SGovindraj Rajaendif 490f5211420SGovindraj Raja 491f5211420SGovindraj Raja#################################################### 492f5211420SGovindraj Raja# Enable required options for Memory Stack Tagging. 493f5211420SGovindraj Raja#################################################### 494f5211420SGovindraj Raja 495f5211420SGovindraj Raja# Currently, these options are enabled only for clang and armclang compiler. 496f5211420SGovindraj Rajaifeq (${SUPPORT_STACK_MEMTAG},yes) 497f5211420SGovindraj Raja ifdef mem_tag_arch_support 498f5211420SGovindraj Raja # Check for armclang and clang compilers 499f5211420SGovindraj Raja ifneq ( ,$(filter $(notdir $(CC)),armclang clang)) 500f5211420SGovindraj Raja # Add "memtag" architecture feature modifier if not specified 501f5211420SGovindraj Raja ifeq ( ,$(findstring memtag,$(arch-features))) 502f5211420SGovindraj Raja arch-features := $(arch-features)+memtag 503f5211420SGovindraj Raja endif # memtag 504f5211420SGovindraj Raja ifeq ($(notdir $(CC)),armclang) 505f5211420SGovindraj Raja TF_CFLAGS += -mmemtag-stack 506f5211420SGovindraj Raja else ifeq ($(notdir $(CC)),clang) 507f5211420SGovindraj Raja TF_CFLAGS += -fsanitize=memtag 508f5211420SGovindraj Raja endif # armclang 509f5211420SGovindraj Raja endif 510f5211420SGovindraj Raja else 511f5211420SGovindraj Raja $(error "Error: stack memory tagging is not supported for \ 512f5211420SGovindraj Raja architecture ${ARCH},armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a") 513f5211420SGovindraj Raja endif #(mem_tag_arch_support) 514f5211420SGovindraj Rajaendif #(SUPPORT_STACK_MEMTAG) 515f5211420SGovindraj Raja 516f5211420SGovindraj Raja################################################################################ 517f5211420SGovindraj Raja# RME dependent flags configuration, Enable optional features for RME. 518f5211420SGovindraj Raja################################################################################ 519f5211420SGovindraj Raja# FEAT_RME 520f5211420SGovindraj Rajaifeq (${ENABLE_RME},1) 521f5211420SGovindraj Raja # RME doesn't support PIE 522f5211420SGovindraj Raja ifneq (${ENABLE_PIE},0) 523f5211420SGovindraj Raja $(error ENABLE_RME does not support PIE) 524f5211420SGovindraj Raja endif 525f5211420SGovindraj Raja 526f5211420SGovindraj Raja # RME doesn't support BRBE 527f5211420SGovindraj Raja ifneq (${ENABLE_BRBE_FOR_NS},0) 528f5211420SGovindraj Raja $(error ENABLE_RME does not support BRBE.) 529f5211420SGovindraj Raja endif 530f5211420SGovindraj Raja 531f5211420SGovindraj Raja # RME requires AARCH64 532f5211420SGovindraj Raja ifneq (${ARCH},aarch64) 533f5211420SGovindraj Raja $(error ENABLE_RME requires AArch64) 534f5211420SGovindraj Raja endif 535f5211420SGovindraj Raja 536f5211420SGovindraj Raja # RME requires el2 context to be saved for now. 537f5211420SGovindraj Raja CTX_INCLUDE_EL2_REGS := 1 538f5211420SGovindraj Raja CTX_INCLUDE_AARCH32_REGS := 0 539f5211420SGovindraj Raja CTX_INCLUDE_PAUTH_REGS := 1 540f5211420SGovindraj Raja 541f5211420SGovindraj Raja # RME enables CSV2_2 extension by default. 542f5211420SGovindraj Raja ENABLE_FEAT_CSV2_2 = 1 543f5211420SGovindraj Rajaendif #(FEAT_RME) 544f5211420SGovindraj Raja 545f5211420SGovindraj Raja################################################################################ 54673c99d4eSJuan Castillo# Generic definitions 54773c99d4eSJuan Castillo################################################################################ 548231c1470SEvan Lloydinclude ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk 549231c1470SEvan Lloyd 55029214e95SGrant Likelyifeq (${BUILD_BASE},) 55173c99d4eSJuan Castillo BUILD_BASE := ./build 55229214e95SGrant Likelyendif 55329214e95SGrant LikelyBUILD_PLAT := $(abspath ${BUILD_BASE})/${PLAT}/${BUILD_TYPE} 55473c99d4eSJuan Castillo 555231c1470SEvan LloydSPDS := $(sort $(filter-out none, $(patsubst services/spd/%,%,$(wildcard services/spd/*)))) 55673c99d4eSJuan Castillo 55773c99d4eSJuan Castillo# Platforms providing their own TBB makefile may override this value 55873c99d4eSJuan CastilloINCLUDE_TBBR_MK := 1 55973c99d4eSJuan Castillo 56073c99d4eSJuan Castillo################################################################################ 56173c99d4eSJuan Castillo# Include SPD Makefile if one has been specified 56273c99d4eSJuan Castillo################################################################################ 56373c99d4eSJuan Castillo 56473c99d4eSJuan Castilloifneq (${SPD},none) 5659d29c227SSoby Mathew ifeq (${ARCH},aarch32) 5669d29c227SSoby Mathew $(error "Error: SPD is incompatible with AArch32.") 5679d29c227SSoby Mathew endif 56828f39f02SMax Shvetsov 5694c117f6cSSandrine Bailleux ifdef EL3_PAYLOAD_BASE 5704c117f6cSSandrine Bailleux $(warning "SPD and EL3_PAYLOAD_BASE are incompatible build options.") 571c5e1da83SJayanth Dodderi Chidanand $(warning "The SPD and its BL32 companion will be present but \ 572c5e1da83SJayanth Dodderi Chidanand ignored.") 5734c117f6cSSandrine Bailleux endif 57428f39f02SMax Shvetsov 575c3fb00d9SAchin Gupta ifeq (${SPD},spmd) 576c3fb00d9SAchin Gupta # SPMD is located in std_svc directory 577c3fb00d9SAchin Gupta SPD_DIR := std_svc 57828f39f02SMax Shvetsov 579033039f8SMax Shvetsov ifeq ($(SPMD_SPM_AT_SEL2),1) 580f1910cc1SGovindraj Raja CTX_INCLUDE_EL2_REGS := 1 5811d63ae4dSMarc Bonnici ifeq ($(SPMC_AT_EL3),1) 5821d63ae4dSMarc Bonnici $(error SPM cannot be enabled in both S-EL2 and EL3.) 5831d63ae4dSMarc Bonnici endif 58428f39f02SMax Shvetsov endif 585db1ef41aSOlivier Deprez 586db1ef41aSOlivier Deprez ifeq ($(findstring optee_sp,$(ARM_SPMC_MANIFEST_DTS)),optee_sp) 587db1ef41aSOlivier Deprez DTC_CPPFLAGS += -DOPTEE_SP_FW_CONFIG 588db1ef41aSOlivier Deprez endif 589ca932481SDavidson K 590ca932481SDavidson K ifeq ($(TS_SP_FW_CONFIG),1) 591ca932481SDavidson K DTC_CPPFLAGS += -DTS_SP_FW_CONFIG 592ca932481SDavidson K endif 59333993a37SBalint Dobszay 59433993a37SBalint Dobszay ifneq ($(ARM_BL2_SP_LIST_DTS),) 59533993a37SBalint Dobszay DTC_CPPFLAGS += -DARM_BL2_SP_LIST_DTS=$(ARM_BL2_SP_LIST_DTS) 59633993a37SBalint Dobszay endif 59746789a7cSBalint Dobszay 59846789a7cSBalint Dobszay ifneq ($(SP_LAYOUT_FILE),) 59946789a7cSBalint Dobszay BL2_ENABLE_SP_LOAD := 1 60046789a7cSBalint Dobszay endif 601c3fb00d9SAchin Gupta else 602c3fb00d9SAchin Gupta # All other SPDs in spd directory 603c3fb00d9SAchin Gupta SPD_DIR := spd 604c5e1da83SJayanth Dodderi Chidanand endif #(SPD) 605c3fb00d9SAchin Gupta 60673c99d4eSJuan Castillo # We expect to locate an spd.mk under the specified SPD directory 607c3fb00d9SAchin Gupta SPD_MAKE := $(wildcard services/${SPD_DIR}/${SPD}/${SPD}.mk) 608c3fb00d9SAchin Gupta 60973c99d4eSJuan Castillo ifeq (${SPD_MAKE},) 610c3fb00d9SAchin Gupta $(error Error: No services/${SPD_DIR}/${SPD}/${SPD}.mk located) 61173c99d4eSJuan Castillo endif 61273c99d4eSJuan Castillo $(info Including ${SPD_MAKE}) 61373c99d4eSJuan Castillo include ${SPD_MAKE} 61473c99d4eSJuan Castillo 61570d1fc53SJuan Castillo # If there's BL32 companion for the chosen SPD, we expect that the SPD's 61670d1fc53SJuan Castillo # Makefile would set NEED_BL32 to "yes". In this case, the build system 61770d1fc53SJuan Castillo # supports two mutually exclusive options: 61870d1fc53SJuan Castillo # * BL32 is built from source: then BL32_SOURCES must contain the list 61970d1fc53SJuan Castillo # of source files to build BL32 62070d1fc53SJuan Castillo # * BL32 is a prebuilt binary: then BL32 must point to the image file 62170d1fc53SJuan Castillo # that will be included in the FIP 62270d1fc53SJuan Castillo # If both BL32_SOURCES and BL32 are defined, the binary takes precedence 62370d1fc53SJuan Castillo # over the sources. 624c5e1da83SJayanth Dodderi Chidanandendif #(SPD=none) 625e35c4045SJeenu Viswambharan 626890b5088SRaghu Krishnamurthyifeq (${ENABLE_SPMD_LP}, 1) 627890b5088SRaghu Krishnamurthyifneq (${SPD},spmd) 628890b5088SRaghu Krishnamurthy $(error Error: ENABLE_SPMD_LP requires SPD=spmd.) 629890b5088SRaghu Krishnamurthyendif 630890b5088SRaghu Krishnamurthyifeq ($(SPMC_AT_EL3),1) 631890b5088SRaghu Krishnamurthy $(error SPMC at EL3 not supported when enabling SPMD Logical partitions.) 632890b5088SRaghu Krishnamurthyendif 633890b5088SRaghu Krishnamurthyendif 634890b5088SRaghu Krishnamurthy 635f1910cc1SGovindraj Rajaifeq (${CTX_INCLUDE_EL2_REGS}, 1) 636f1910cc1SGovindraj Raja ifeq (${SPD},none) 637f1910cc1SGovindraj Raja ifeq (${ENABLE_RME},0) 638c5e1da83SJayanth Dodderi Chidanand $(error CTX_INCLUDE_EL2_REGS is available only when SPD \ 639c5e1da83SJayanth Dodderi Chidanand or RME is enabled) 640f1910cc1SGovindraj Raja endif 641f1910cc1SGovindraj Raja endif 642f1910cc1SGovindraj Rajaendif 643f1910cc1SGovindraj Raja 64451faada7SDouglas Raillard################################################################################ 6455b18de09SZelalem Aweke# Include rmmd Makefile if RME is enabled 6465b18de09SZelalem Aweke################################################################################ 6475b18de09SZelalem Awekeifneq (${ENABLE_RME},0) 6485b18de09SZelalem Aweke ifneq (${ARCH},aarch64) 6495b18de09SZelalem Aweke $(error ENABLE_RME requires AArch64) 6505b18de09SZelalem Aweke endif 6511d63ae4dSMarc Bonnici ifeq ($(SPMC_AT_EL3),1) 6521d63ae4dSMarc Bonnici $(error SPMC_AT_EL3 and ENABLE_RME cannot both be enabled.) 6531d63ae4dSMarc Bonnici endif 654c5e1da83SJayanth Dodderi Chidanand 6554fba2e1fSBoyan Karatotev ifneq (${SPD}, none) 6564fba2e1fSBoyan Karatotev ifneq (${SPD}, spmd) 6574fba2e1fSBoyan Karatotev $(error ENABLE_RME is incompatible with SPD=${SPD}. Use SPD=spmd) 6584fba2e1fSBoyan Karatotev endif 6594fba2e1fSBoyan Karatotev endif 6605b18de09SZelalem Awekeinclude services/std_svc/rmmd/rmmd.mk 6615b18de09SZelalem Aweke$(warning "RME is an experimental feature") 6625b18de09SZelalem Awekeendif 6635b18de09SZelalem Aweke 6645b18de09SZelalem Aweke################################################################################ 66573c99d4eSJuan Castillo# Include the platform specific Makefile after the SPD Makefile (the platform 66673c99d4eSJuan Castillo# makefile may use all previous definitions in this file) 66773c99d4eSJuan Castillo################################################################################ 6682da8d8bfSJeenu Viswambharan 66973c99d4eSJuan Castilloinclude ${PLAT_MAKEFILE_FULL} 6700f21c547SJuan Castillo 6717794d6c8SGovindraj Raja################################################################################ 6727794d6c8SGovindraj Raja# Platform specific Makefile might provide us ARCH_MAJOR/MINOR use that to come 6737794d6c8SGovindraj Raja# up with appropriate march values for compiler. 6747794d6c8SGovindraj Raja################################################################################ 6757794d6c8SGovindraj Rajainclude ${MAKE_HELPERS_DIRECTORY}march.mk 6767794d6c8SGovindraj Raja 6777794d6c8SGovindraj RajaTF_CFLAGS += $(march-directive) 6787794d6c8SGovindraj Raja 67942d4d3baSArvind Ram Prakash# This internal flag is common option which is set to 1 for scenarios 68042d4d3baSArvind Ram Prakash# when the BL2 is running in EL3 level. This occurs in two scenarios - 68142d4d3baSArvind Ram Prakash# 4 world system running BL2 at EL3 and two world system without BL1 running 68242d4d3baSArvind Ram Prakash# BL2 in EL3 68342d4d3baSArvind Ram Prakash 68442d4d3baSArvind Ram Prakashifeq (${RESET_TO_BL2},1) 68542d4d3baSArvind Ram Prakash BL2_RUNS_AT_EL3 := 1 68642d4d3baSArvind Ram Prakash ifeq (${ENABLE_RME},1) 687c5e1da83SJayanth Dodderi Chidanand $(error RESET_TO_BL2=1 and ENABLE_RME=1 configuration is not \ 688c5e1da83SJayanth Dodderi Chidanand supported at the moment.) 68942d4d3baSArvind Ram Prakash endif 69042d4d3baSArvind Ram Prakashelse ifeq (${ENABLE_RME},1) 69142d4d3baSArvind Ram Prakash BL2_RUNS_AT_EL3 := 1 69242d4d3baSArvind Ram Prakashelse 69342d4d3baSArvind Ram Prakash BL2_RUNS_AT_EL3 := 0 69442d4d3baSArvind Ram Prakashendif 69542d4d3baSArvind Ram Prakash 6968012cc5cSMasahiro Yamada$(eval $(call MAKE_PREREQ_DIR,${BUILD_PLAT})) 6978012cc5cSMasahiro Yamada 69826e63c44SEtienne Carriereifeq (${ARM_ARCH_MAJOR},7) 69926e63c44SEtienne Carriereinclude make_helpers/armv7-a-cpus.mk 70026e63c44SEtienne Carriereendif 70126e63c44SEtienne Carriere 7023bd17c0fSSoby MathewPIE_FOUND := $(findstring --enable-default-pie,${GCC_V_OUTPUT}) 7033bd17c0fSSoby Mathewifneq ($(PIE_FOUND),) 7043bd17c0fSSoby Mathew TF_CFLAGS += -fno-PIE 7057b592418SSamuel Hollandifneq ($(findstring gcc,$(notdir $(LD))),) 7067b592418SSamuel Holland TF_LDFLAGS += -no-pie 7077b592418SSamuel Hollandendif 708c5e1da83SJayanth Dodderi Chidanandendif #(PIE_FOUND) 709320920c1SMasahiro Yamada 710320920c1SMasahiro Yamadaifneq ($(findstring gcc,$(notdir $(LD))),) 711320920c1SMasahiro Yamada PIE_LDFLAGS += -Wl,-pie -Wl,--no-dynamic-linker 712320920c1SMasahiro Yamadaelse 713320920c1SMasahiro Yamada PIE_LDFLAGS += -pie --no-dynamic-linker 714320920c1SMasahiro Yamadaendif 715320920c1SMasahiro Yamada 716320920c1SMasahiro Yamadaifeq ($(ENABLE_PIE),1) 71742d4d3baSArvind Ram Prakash ifeq ($(RESET_TO_BL2),1) 71869af7fcfSMasahiro Yamada ifneq ($(BL2_IN_XIP_MEM),1) 719966660ecSChris Kay BL2_CPPFLAGS += -fpie 72069af7fcfSMasahiro Yamada BL2_CFLAGS += -fpie 72169af7fcfSMasahiro Yamada BL2_LDFLAGS += $(PIE_LDFLAGS) 722c5e1da83SJayanth Dodderi Chidanand endif #(BL2_IN_XIP_MEM) 723c5e1da83SJayanth Dodderi Chidanand endif #(RESET_TO_BL2) 724966660ecSChris Kay BL31_CPPFLAGS += -fpie 725320920c1SMasahiro Yamada BL31_CFLAGS += -fpie 726320920c1SMasahiro Yamada BL31_LDFLAGS += $(PIE_LDFLAGS) 727966660ecSChris Kay 728966660ecSChris Kay BL32_CPPFLAGS += -fpie 729d974301dSMasahiro Yamada BL32_CFLAGS += -fpie 730d974301dSMasahiro Yamada BL32_LDFLAGS += $(PIE_LDFLAGS) 731c5e1da83SJayanth Dodderi Chidanandendif #(ENABLE_PIE) 7323bd17c0fSSoby Mathew 733007433d8SBoyan KaratotevBL1_CPPFLAGS += -DREPORT_ERRATA=${DEBUG} 734007433d8SBoyan KaratotevBL31_CPPFLAGS += -DREPORT_ERRATA=${DEBUG} 735007433d8SBoyan KaratotevBL32_CPPFLAGS += -DREPORT_ERRATA=${DEBUG} 736007433d8SBoyan Karatotev 7379cefb4b1SMasahiro YamadaBL1_CPPFLAGS += -DIMAGE_AT_EL3 73842d4d3baSArvind Ram Prakashifeq ($(RESET_TO_BL2),1) 7399cefb4b1SMasahiro Yamada BL2_CPPFLAGS += -DIMAGE_AT_EL3 740d5e97a1dSMasahiro Yamadaelse 7419cefb4b1SMasahiro Yamada BL2_CPPFLAGS += -DIMAGE_AT_EL1 742c5e1da83SJayanth Dodderi Chidanandendif #(RESET_TO_BL2) 743007433d8SBoyan Karatotev 744007433d8SBoyan Karatotevifeq (${ARCH},aarch64) 7459cefb4b1SMasahiro Yamada BL2U_CPPFLAGS += -DIMAGE_AT_EL1 7469cefb4b1SMasahiro Yamada BL31_CPPFLAGS += -DIMAGE_AT_EL3 7479cefb4b1SMasahiro Yamada BL32_CPPFLAGS += -DIMAGE_AT_EL1 748007433d8SBoyan Karatotevelse 749007433d8SBoyan Karatotev BL32_CPPFLAGS += -DIMAGE_AT_EL3 750d5e97a1dSMasahiro Yamadaendif 751d5e97a1dSMasahiro Yamada 75254035fc4SSandrine Bailleux# Include the CPU specific operations makefile, which provides default 75354035fc4SSandrine Bailleux# values for all CPU errata workarounds and CPU specific optimisations. 75454035fc4SSandrine Bailleux# This can be overridden by the platform. 75573c99d4eSJuan Castilloinclude lib/cpus/cpu-ops.mk 7564f6ad66aSAchin Gupta 757a4409008Sdp-arm################################################################################ 758a4409008Sdp-arm# Build `AARCH32_SP` as BL32 image for AArch32 759a4409008Sdp-arm################################################################################ 760c5e1da83SJayanth Dodderi Chidanandifeq (${ARCH},aarch32) 761c5e1da83SJayanth Dodderi Chidanand NEED_BL32 := yes 762c5e1da83SJayanth Dodderi Chidanand 763a4409008Sdp-arm ifneq (${AARCH32_SP},none) 764a4409008Sdp-arm # We expect to locate an sp.mk under the specified AARCH32_SP directory 765a4409008Sdp-arm AARCH32_SP_MAKE := $(wildcard bl32/${AARCH32_SP}/${AARCH32_SP}.mk) 766a4409008Sdp-arm 767a4409008Sdp-arm ifeq (${AARCH32_SP_MAKE},) 768a4409008Sdp-arm $(error Error: No bl32/${AARCH32_SP}/${AARCH32_SP}.mk located) 769a4409008Sdp-arm endif 770a4409008Sdp-arm $(info Including ${AARCH32_SP_MAKE}) 771a4409008Sdp-arm include ${AARCH32_SP_MAKE} 772a4409008Sdp-arm endif 773c5e1da83SJayanth Dodderi Chidanandendif #(ARCH=aarch32) 7744f6ad66aSAchin Gupta 77573c99d4eSJuan Castillo################################################################################ 77677f1f7a1SVarun Wadekar# Include libc if not overridden 77777f1f7a1SVarun Wadekar################################################################################ 77877f1f7a1SVarun Wadekarifeq (${OVERRIDE_LIBC},0) 77977f1f7a1SVarun Wadekarinclude lib/libc/libc.mk 78077f1f7a1SVarun Wadekarendif 78177f1f7a1SVarun Wadekar 78277f1f7a1SVarun Wadekar################################################################################ 783c5e1da83SJayanth Dodderi Chidanand# Check incompatible options and dependencies 784cf2c8a33SAntonio Nino Diaz################################################################################ 785cf2c8a33SAntonio Nino Diaz 786c5e1da83SJayanth Dodderi Chidanand# USE_DEBUGFS experimental feature recommended only in debug builds 787c5e1da83SJayanth Dodderi Chidanandifeq (${USE_DEBUGFS},1) 788c5e1da83SJayanth Dodderi Chidanand ifeq (${DEBUG},1) 789c5e1da83SJayanth Dodderi Chidanand $(warning DEBUGFS experimental feature is enabled.) 790c5e1da83SJayanth Dodderi Chidanand else 791c5e1da83SJayanth Dodderi Chidanand $(warning DEBUGFS experimental, recommended in DEBUG builds ONLY) 792c5e1da83SJayanth Dodderi Chidanand endif 793c5e1da83SJayanth Dodderi Chidanandendif #(USE_DEBUGFS) 794c5e1da83SJayanth Dodderi Chidanand 795c5e1da83SJayanth Dodderi Chidanand# USE_SPINLOCK_CAS requires AArch64 build 796c5e1da83SJayanth Dodderi Chidanandifeq (${USE_SPINLOCK_CAS},1) 797c5e1da83SJayanth Dodderi Chidanand ifneq (${ARCH},aarch64) 798c5e1da83SJayanth Dodderi Chidanand $(error USE_SPINLOCK_CAS requires AArch64) 799c5e1da83SJayanth Dodderi Chidanand endif 800c5e1da83SJayanth Dodderi Chidanandendif #(USE_SPINLOCK_CAS) 801c5e1da83SJayanth Dodderi Chidanand 802c5e1da83SJayanth Dodderi Chidanand# The cert_create tool cannot generate certificates individually, so we use the 803c5e1da83SJayanth Dodderi Chidanand# target 'certificates' to create them all 804c5e1da83SJayanth Dodderi Chidanandifneq (${GENERATE_COT},0) 805c5e1da83SJayanth Dodderi Chidanand FIP_DEPS += certificates 806c5e1da83SJayanth Dodderi Chidanand FWU_FIP_DEPS += fwu_certificates 807c5e1da83SJayanth Dodderi Chidanandendif 808c5e1da83SJayanth Dodderi Chidanand 809c5e1da83SJayanth Dodderi Chidanandifneq (${DECRYPTION_SUPPORT},none) 810c5e1da83SJayanth Dodderi Chidanand ENC_ARGS += -f ${FW_ENC_STATUS} 811c5e1da83SJayanth Dodderi Chidanand ENC_ARGS += -k ${ENC_KEY} 812c5e1da83SJayanth Dodderi Chidanand ENC_ARGS += -n ${ENC_NONCE} 813c5e1da83SJayanth Dodderi Chidanand FIP_DEPS += enctool 814c5e1da83SJayanth Dodderi Chidanand FWU_FIP_DEPS += enctool 815c5e1da83SJayanth Dodderi Chidanandendif #(DECRYPTION_SUPPORT) 816c5e1da83SJayanth Dodderi Chidanand 817cf2c8a33SAntonio Nino Diazifdef EL3_PAYLOAD_BASE 81868450a6dSAntonio Nino Diaz ifdef PRELOADED_BL33_BASE 81968450a6dSAntonio Nino Diaz $(warning "PRELOADED_BL33_BASE and EL3_PAYLOAD_BASE are \ 82068450a6dSAntonio Nino Diaz incompatible build options. EL3_PAYLOAD_BASE has priority.") 821cf2c8a33SAntonio Nino Diaz endif 82276580f3dSQixiang Xu ifneq (${GENERATE_COT},0) 823c5e1da83SJayanth Dodderi Chidanand $(error "GENERATE_COT and EL3_PAYLOAD_BASE are incompatible \ 824c5e1da83SJayanth Dodderi Chidanand build options.") 82576580f3dSQixiang Xu endif 82676580f3dSQixiang Xu ifneq (${TRUSTED_BOARD_BOOT},0) 827c5e1da83SJayanth Dodderi Chidanand $(error "TRUSTED_BOARD_BOOT and EL3_PAYLOAD_BASE are \ 828c5e1da83SJayanth Dodderi Chidanand incompatible \ build options.") 82976580f3dSQixiang Xu endif 830c5e1da83SJayanth Dodderi Chidanandendif #(EL3_PAYLOAD_BASE) 831cf2c8a33SAntonio Nino Diaz 832cf2c8a33SAntonio Nino Diazifeq (${NEED_BL33},yes) 833cf2c8a33SAntonio Nino Diaz ifdef EL3_PAYLOAD_BASE 834cf2c8a33SAntonio Nino Diaz $(warning "BL33 image is not needed when option \ 835cf2c8a33SAntonio Nino Diaz BL33_PAYLOAD_BASE is used and won't be added to the FIP file.") 836cf2c8a33SAntonio Nino Diaz endif 83768450a6dSAntonio Nino Diaz ifdef PRELOADED_BL33_BASE 83868450a6dSAntonio Nino Diaz $(warning "BL33 image is not needed when option \ 839c5e1da83SJayanth Dodderi Chidanand PRELOADED_BL33_BASE is used and won't be added to the FIP file.") 840cf2c8a33SAntonio Nino Diaz endif 841c5e1da83SJayanth Dodderi Chidanandendif #(NEED_BL33) 842cf2c8a33SAntonio Nino Diaz 843d4593e47SJeenu Viswambharan# When building for systems with hardware-assisted coherency, there's no need to 844d4593e47SJeenu Viswambharan# use USE_COHERENT_MEM. Require that USE_COHERENT_MEM must be set to 0 too. 845d4593e47SJeenu Viswambharanifeq ($(HW_ASSISTED_COHERENCY)-$(USE_COHERENT_MEM),1-1) 846d4593e47SJeenu Viswambharan $(error USE_COHERENT_MEM cannot be enabled with HW_ASSISTED_COHERENCY) 847d4593e47SJeenu Viswambharanendif 8481a0a3f06SYatharth Kochar 84942d4d3baSArvind Ram Prakash#For now, BL2_IN_XIP_MEM is only supported when RESET_TO_BL2 is 1. 85042d4d3baSArvind Ram Prakashifeq ($(RESET_TO_BL2)-$(BL2_IN_XIP_MEM),0-1) 85142d4d3baSArvind Ram Prakash $(error "BL2_IN_XIP_MEM is only supported when RESET_TO_BL2 is enabled") 8527d173fc5SJiafei Panendif 8537d173fc5SJiafei Pan 8549202d519SManish Pandey# RAS_EXTENSION is deprecated, provide alternate build options 85514c6016aSJeenu Viswambharanifeq ($(RAS_EXTENSION),1) 856c5e1da83SJayanth Dodderi Chidanand $(error "RAS_EXTENSION is now deprecated, please use ENABLE_FEAT_RAS \ 857c5e1da83SJayanth Dodderi Chidanand and RAS_FFH_SUPPORT instead") 8589202d519SManish Pandeyendif 859c5e1da83SJayanth Dodderi Chidanand 8609202d519SManish Pandey# RAS firmware first handling requires that EAs are handled in EL3 first 8619202d519SManish Pandeyifeq ($(RAS_FFH_SUPPORT),1) 8629202d519SManish Pandey ifneq ($(ENABLE_FEAT_RAS),1) 8639202d519SManish Pandey $(error For RAS_FFH_SUPPORT, ENABLE_FEAT_RAS must also be 1) 8649202d519SManish Pandey endif 86546cc41d5SManish Pandey ifneq ($(HANDLE_EA_EL3_FIRST_NS),1) 8669202d519SManish Pandey $(error For RAS_FFH_SUPPORT, HANDLE_EA_EL3_FIRST_NS must also be 1) 86714c6016aSJeenu Viswambharan endif 868c5e1da83SJayanth Dodderi Chidanandendif #(RAS_FFH_SUPPORT) 869c5e1da83SJayanth Dodderi Chidanand 8709202d519SManish Pandey# When FAULT_INJECTION_SUPPORT is used, require that FEAT_RAS is enabled 8711a7c1cfeSJeenu Viswambharanifeq ($(FAULT_INJECTION_SUPPORT),1) 8726503ff29SAndre Przywara ifeq ($(ENABLE_FEAT_RAS),0) 8736503ff29SAndre Przywara $(error For FAULT_INJECTION_SUPPORT, ENABLE_FEAT_RAS must not be 0) 8741a7c1cfeSJeenu Viswambharan endif 875c5e1da83SJayanth Dodderi Chidanandendif #(FAULT_INJECTION_SUPPORT) 8761a7c1cfeSJeenu Viswambharan 877ed51b51fSRoberto Vargas# DYN_DISABLE_AUTH can be set only when TRUSTED_BOARD_BOOT=1 878209a60ccSSoby Mathewifeq ($(DYN_DISABLE_AUTH), 1) 879209a60ccSSoby Mathew ifeq (${TRUSTED_BOARD_BOOT}, 0) 880c5e1da83SJayanth Dodderi Chidanand $(error "TRUSTED_BOARD_BOOT must be enabled for DYN_DISABLE_AUTH \ 881c5e1da83SJayanth Dodderi Chidanand to be set.") 882209a60ccSSoby Mathew endif 883c5e1da83SJayanth Dodderi Chidanandendif #(DYN_DISABLE_AUTH) 884209a60ccSSoby Mathew 8852bf4f27fSManish V Badarkheifeq ($(MEASURED_BOOT)-$(TRUSTED_BOARD_BOOT),1-1) 8862bf4f27fSManish V Badarkhe# Support authentication verification and hash calculation 8872bf4f27fSManish V Badarkhe CRYPTO_SUPPORT := 3 8882bf4f27fSManish V Badarkheelse ifeq ($(DRTM_SUPPORT)-$(TRUSTED_BOARD_BOOT),1-1) 8892bf4f27fSManish V Badarkhe# Support authentication verification and hash calculation 8902bf4f27fSManish V Badarkhe CRYPTO_SUPPORT := 3 8912bf4f27fSManish V Badarkheelse ifneq ($(filter 1,${MEASURED_BOOT} ${DRTM_SUPPORT}),) 8922bf4f27fSManish V Badarkhe# Support hash calculation only 8932bf4f27fSManish V Badarkhe CRYPTO_SUPPORT := 2 8942bf4f27fSManish V Badarkheelse ifeq (${TRUSTED_BOARD_BOOT},1) 8952bf4f27fSManish V Badarkhe# Support authentication verification only 896c9c56f6eSManish V Badarkhe CRYPTO_SUPPORT := 1 897c9c56f6eSManish V Badarkheelse 898c9c56f6eSManish V Badarkhe CRYPTO_SUPPORT := 0 899c5e1da83SJayanth Dodderi Chidanandendif #($(MEASURED_BOOT)-$(TRUSTED_BOARD_BOOT)) 900c9c56f6eSManish V Badarkhe 901cbf9e84aSBalint Dobszay# SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled. 902cbf9e84aSBalint Dobszayifeq ($(SDEI_SUPPORT)-$(SDEI_IN_FCONF),0-1) 903700e7685SManish Pandey $(error "SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled") 90484ef9cd8SManish V Badarkheendif 90584ef9cd8SManish V Badarkhe 906b86048c4SAntonio Nino Diaz# If pointer authentication is used in the firmware, make sure that all the 9079fc59639SAlexei Fedorov# registers associated to it are also saved and restored. 9089fc59639SAlexei Fedorov# Not doing it would leak the value of the keys used by EL3 to EL1 and S-EL1. 909b86048c4SAntonio Nino Diazifeq ($(ENABLE_PAUTH),1) 9109fc59639SAlexei Fedorov ifeq ($(CTX_INCLUDE_PAUTH_REGS),0) 9119fc59639SAlexei Fedorov $(error Pointer Authentication requires CTX_INCLUDE_PAUTH_REGS=1) 91206715f85SAlexei Fedorov endif 913c5e1da83SJayanth Dodderi Chidanandendif #(ENABLE_PAUTH) 9149fc59639SAlexei Fedorov 91506715f85SAlexei Fedorovifeq ($(CTX_INCLUDE_PAUTH_REGS),1) 9169fc59639SAlexei Fedorov ifneq (${ARCH},aarch64) 9179fc59639SAlexei Fedorov $(error CTX_INCLUDE_PAUTH_REGS requires AArch64) 918b86048c4SAntonio Nino Diaz endif 919c5e1da83SJayanth Dodderi Chidanandendif #(CTX_INCLUDE_PAUTH_REGS) 9209fc59639SAlexei Fedorov 9219dd94382SJustin Chadwellifeq ($(CTX_INCLUDE_MTE_REGS),1) 9229dd94382SJustin Chadwell ifneq (${ARCH},aarch64) 9239dd94382SJustin Chadwell $(error CTX_INCLUDE_MTE_REGS requires AArch64) 9249dd94382SJustin Chadwell endif 925c5e1da83SJayanth Dodderi Chidanandendif #(CTX_INCLUDE_MTE_REGS) 9269dd94382SJustin Chadwell 927396b339dSManish V Badarkheifeq ($(PSA_FWU_SUPPORT),1) 928396b339dSManish V Badarkhe $(info PSA_FWU_SUPPORT is an experimental feature) 929c5e1da83SJayanth Dodderi Chidanandendif #(PSA_FWU_SUPPORT) 930396b339dSManish V Badarkhe 9316a0da736SJayanth Dodderi Chidanandifeq ($(FEATURE_DETECTION),1) 9326a0da736SJayanth Dodderi Chidanand $(info FEATURE_DETECTION is an experimental feature) 933c5e1da83SJayanth Dodderi Chidanandendif #(FEATURE_DETECTION) 9346a0da736SJayanth Dodderi Chidanand 93503d3c0d7SJayanth Dodderi Chidanandifneq ($(ENABLE_SME2_FOR_NS), 0) 93603d3c0d7SJayanth Dodderi Chidanand ifeq (${ENABLE_SME_FOR_NS}, 0) 937c5e1da83SJayanth Dodderi Chidanand $(warning "ENABLE_SME2_FOR_NS requires ENABLE_SME_FOR_NS also \ 938c5e1da83SJayanth Dodderi Chidanand to be set") 93903d3c0d7SJayanth Dodderi Chidanand $(warning "Forced ENABLE_SME_FOR_NS=1") 94003d3c0d7SJayanth Dodderi Chidanand override ENABLE_SME_FOR_NS := 1 94103d3c0d7SJayanth Dodderi Chidanand endif 942c5e1da83SJayanth Dodderi Chidanandendif #(ENABLE_SME2_FOR_NS) 94345007acdSJayanth Dodderi Chidanand 94460e8f3cfSPetre-Ionut Tudorifeq (${ARM_XLAT_TABLES_LIB_V1}, 1) 94560e8f3cfSPetre-Ionut Tudor ifeq (${ALLOW_RO_XLAT_TABLES}, 1) 946c5e1da83SJayanth Dodderi Chidanand $(error "ALLOW_RO_XLAT_TABLES requires translation tables \ 947c5e1da83SJayanth Dodderi Chidanand library v2") 94860e8f3cfSPetre-Ionut Tudor endif 949c5e1da83SJayanth Dodderi Chidanandendif #(ARM_XLAT_TABLES_LIB_V1) 95060e8f3cfSPetre-Ionut Tudor 9517cda17bbSSumit Gargifneq (${DECRYPTION_SUPPORT},none) 9527cda17bbSSumit Garg ifeq (${TRUSTED_BOARD_BOOT}, 0) 953c5e1da83SJayanth Dodderi Chidanand $(error TRUSTED_BOARD_BOOT must be enabled for DECRYPTION_SUPPORT \ 954c5e1da83SJayanth Dodderi Chidanand to be set) 9557cda17bbSSumit Garg endif 956c5e1da83SJayanth Dodderi Chidanandendif #(DECRYPTION_SUPPORT) 9577cda17bbSSumit Garg 958744ad974Sjohpow01# Ensure that no Aarch64-only features are enabled in Aarch32 build 959dc78e62dSjohpow01ifeq (${ARCH},aarch32) 960744ad974Sjohpow01 961744ad974Sjohpow01 # SME/SVE only supported on AArch64 96245007acdSJayanth Dodderi Chidanand ifneq (${ENABLE_SME_FOR_NS},0) 963dc78e62dSjohpow01 $(error "ENABLE_SME_FOR_NS cannot be used with ARCH=aarch32") 964dc78e62dSjohpow01 endif 96503d3c0d7SJayanth Dodderi Chidanand 966dc78e62dSjohpow01 ifeq (${ENABLE_SVE_FOR_NS},1) 967dc78e62dSjohpow01 # Warning instead of error due to CI dependency on this 96824ab2c0aSYann Gautier $(error "ENABLE_SVE_FOR_NS cannot be used with ARCH=aarch32") 969dc78e62dSjohpow01 endif 970744ad974Sjohpow01 971ff86e0b4SJuan Pablo Conde # BRBE is not supported in AArch32 972744ad974Sjohpow01 ifeq (${ENABLE_BRBE_FOR_NS},1) 973744ad974Sjohpow01 $(error "ENABLE_BRBE_FOR_NS cannot be used with ARCH=aarch32") 974744ad974Sjohpow01 endif 975744ad974Sjohpow01 976ff86e0b4SJuan Pablo Conde # FEAT_RNG_TRAP is not supported in AArch32 977ff86e0b4SJuan Pablo Conde ifeq (${ENABLE_FEAT_RNG_TRAP},1) 978ff86e0b4SJuan Pablo Conde $(error "ENABLE_FEAT_RNG_TRAP cannot be used with ARCH=aarch32") 979ff86e0b4SJuan Pablo Conde endif 980c5e1da83SJayanth Dodderi Chidanandendif #(ARCH=aarch32) 981dc78e62dSjohpow01 982dc78e62dSjohpow01# Ensure ENABLE_RME is not used with SME 983dc78e62dSjohpow01ifeq (${ENABLE_RME},1) 98445007acdSJayanth Dodderi Chidanand ifneq (${ENABLE_SME_FOR_NS},0) 985dc78e62dSjohpow01 $(error "ENABLE_SME_FOR_NS cannot be used with ENABLE_RME") 986dc78e62dSjohpow01 endif 987dc78e62dSjohpow01endif 988dc78e62dSjohpow01 9890d122947SBoyan Karatotevifneq (${ENABLE_SME_FOR_NS},0) 9900d122947SBoyan Karatotev ifeq (${ENABLE_SVE_FOR_NS},0) 9910d122947SBoyan Karatotev $(error "ENABLE_SME_FOR_NS requires ENABLE_SVE_FOR_NS") 9920d122947SBoyan Karatotev endif 993c5e1da83SJayanth Dodderi Chidanandendif #(ENABLE_SME_FOR_NS) 9940d122947SBoyan Karatotev 995dc78e62dSjohpow01# Secure SME/SVE requires the non-secure component as well 996dc78e62dSjohpow01ifeq (${ENABLE_SME_FOR_SWD},1) 997dc78e62dSjohpow01 ifeq (${ENABLE_SME_FOR_NS},0) 998dc78e62dSjohpow01 $(error "ENABLE_SME_FOR_SWD requires ENABLE_SME_FOR_NS") 999dc78e62dSjohpow01 endif 10000d122947SBoyan Karatotev ifeq (${ENABLE_SVE_FOR_SWD},0) 10010d122947SBoyan Karatotev $(error "ENABLE_SME_FOR_SWD requires ENABLE_SVE_FOR_SWD") 10020d122947SBoyan Karatotev endif 1003c5e1da83SJayanth Dodderi Chidanandendif #(ENABLE_SME_FOR_SWD) 1004c5e1da83SJayanth Dodderi Chidanand 1005dc78e62dSjohpow01ifeq (${ENABLE_SVE_FOR_SWD},1) 1006dc78e62dSjohpow01 ifeq (${ENABLE_SVE_FOR_NS},0) 1007dc78e62dSjohpow01 $(error "ENABLE_SVE_FOR_SWD requires ENABLE_SVE_FOR_NS") 1008dc78e62dSjohpow01 endif 1009c5e1da83SJayanth Dodderi Chidanandendif #(ENABLE_SVE_FOR_SWD) 1010dc78e62dSjohpow01 1011dc78e62dSjohpow01# SVE and SME cannot be used with CTX_INCLUDE_FPREGS since secure manager does 1012dc78e62dSjohpow01# its own context management including FPU registers. 1013dc78e62dSjohpow01ifeq (${CTX_INCLUDE_FPREGS},1) 101445007acdSJayanth Dodderi Chidanand ifneq (${ENABLE_SME_FOR_NS},0) 1015dc78e62dSjohpow01 $(error "ENABLE_SME_FOR_NS cannot be used with CTX_INCLUDE_FPREGS") 1016dc78e62dSjohpow01 endif 101703d3c0d7SJayanth Dodderi Chidanand 1018dc78e62dSjohpow01 ifeq (${ENABLE_SVE_FOR_NS},1) 1019dc78e62dSjohpow01 # Warning instead of error due to CI dependency on this 1020dc78e62dSjohpow01 $(warning "ENABLE_SVE_FOR_NS cannot be used with CTX_INCLUDE_FPREGS") 1021dc78e62dSjohpow01 $(warning "Forced ENABLE_SVE_FOR_NS=0") 1022dc78e62dSjohpow01 override ENABLE_SVE_FOR_NS := 0 1023dc78e62dSjohpow01 endif 1024c5e1da83SJayanth Dodderi Chidanandendif #(CTX_INCLUDE_FPREGS) 1025dc78e62dSjohpow01 102600e28874SManish V Badarkheifeq ($(DRTM_SUPPORT),1) 102700e28874SManish V Badarkhe $(info DRTM_SUPPORT is an experimental feature) 102800e28874SManish V Badarkheendif 102900e28874SManish V Badarkhe 1030*3ba2c151SRaymond Maoifeq (${TRANSFER_LIST},1) 1031*3ba2c151SRaymond Mao $(info TRANSFER_LIST is an experimental feature) 1032*3ba2c151SRaymond Maoendif 1033*3ba2c151SRaymond Mao 1034274a69e7SChris Kayifeq (${ENABLE_RME},1) 1035274a69e7SChris Kay ifneq (${SEPARATE_CODE_AND_RODATA},1) 1036274a69e7SChris Kay $(error `ENABLE_RME=1` requires `SEPARATE_CODE_AND_RODATA=1`) 1037274a69e7SChris Kay endif 1038274a69e7SChris Kayendif 1039274a69e7SChris Kay 1040c5e1da83SJayanth Dodderi Chidanand# Determine if FEAT_RNG is supported 1041c5e1da83SJayanth Dodderi ChidanandENABLE_FEAT_RNG = $(if $(findstring rng,${arch-features}),1,0) 1042c5e1da83SJayanth Dodderi Chidanand 1043c5e1da83SJayanth Dodderi Chidanand# Determine if FEAT_SB is supported 1044c5e1da83SJayanth Dodderi ChidanandENABLE_FEAT_SB = $(if $(findstring sb,${arch-features}),1,0) 1045c5e1da83SJayanth Dodderi Chidanand 1046cf2c8a33SAntonio Nino Diaz################################################################################ 104773c99d4eSJuan Castillo# Process platform overrideable behaviour 104873c99d4eSJuan Castillo################################################################################ 10494f6ad66aSAchin Gupta 10505f24ce96SManish Pandeyifdef BL1_SOURCES 10515f24ce96SManish Pandey NEED_BL1 := yes 1052c5e1da83SJayanth Dodderi Chidanandendif #(BL1_SOURCES) 10535f24ce96SManish Pandey 10545f24ce96SManish Pandeyifdef BL2_SOURCES 10555f24ce96SManish Pandey NEED_BL2 := yes 10565f24ce96SManish Pandey 1057bd97f83aSJohn Tsichritzis # Using BL2 implies that a BL33 image also needs to be supplied for the FIP and 1058bd97f83aSJohn Tsichritzis # Certificate generation tools. This flag can be overridden by the platform. 1059cf2c8a33SAntonio Nino Diaz ifdef EL3_PAYLOAD_BASE 1060cf2c8a33SAntonio Nino Diaz # If booting an EL3 payload there is no need for a BL33 image 1061cf2c8a33SAntonio Nino Diaz # in the FIP file. 10624c117f6cSSandrine Bailleux NEED_BL33 := no 1063cf2c8a33SAntonio Nino Diaz else 106468450a6dSAntonio Nino Diaz ifdef PRELOADED_BL33_BASE 1065cf2c8a33SAntonio Nino Diaz # If booting a BL33 preloaded image there is no need of 1066cf2c8a33SAntonio Nino Diaz # another one in the FIP file. 1067cf2c8a33SAntonio Nino Diaz NEED_BL33 := no 1068cf2c8a33SAntonio Nino Diaz else 1069cf2c8a33SAntonio Nino Diaz NEED_BL33 ?= yes 1070cf2c8a33SAntonio Nino Diaz endif 10714c117f6cSSandrine Bailleux endif 1072c5e1da83SJayanth Dodderi Chidanandendif #(BL2_SOURCES) 10736f971622SJuan Castillo 10745f24ce96SManish Pandeyifdef BL2U_SOURCES 10755f24ce96SManish Pandey NEED_BL2U := yes 1076c5e1da83SJayanth Dodderi Chidanandendif #(BL2U_SOURCES) 10775f24ce96SManish Pandey 10784d045d0eSMasahiro Yamada# If SCP_BL2 is given, we always want FIP to include it. 10794d045d0eSMasahiro Yamadaifdef SCP_BL2 10804d045d0eSMasahiro Yamada NEED_SCP_BL2 := yes 1081c5e1da83SJayanth Dodderi Chidanandendif #(SCP_BL2) 10824d045d0eSMasahiro Yamada 10835744e874SSoby Mathew# For AArch32, BL31 is not currently supported. 10845744e874SSoby Mathewifneq (${ARCH},aarch32) 10855744e874SSoby Mathew ifdef BL31_SOURCES 1086c5e1da83SJayanth Dodderi Chidanand # When booting an EL3 payload, there is no need to compile the BL31 1087c5e1da83SJayanth Dodderi Chidanand # image nor put it in the FIP. 10885744e874SSoby Mathew ifndef EL3_PAYLOAD_BASE 10895744e874SSoby Mathew NEED_BL31 := yes 10905744e874SSoby Mathew endif 10915744e874SSoby Mathew endif 1092c5e1da83SJayanth Dodderi Chidanandendif #(ARCH=aarch64) 10935744e874SSoby Mathew 109473c99d4eSJuan Castillo# Process TBB related flags 10956f971622SJuan Castilloifneq (${GENERATE_COT},0) 109673c99d4eSJuan Castillo # Common cert_create options 10976f971622SJuan Castillo ifneq (${CREATE_KEYS},0) 10986f971622SJuan Castillo $(eval CRT_ARGS += -n) 10990191262dSYatharth Kochar $(eval FWU_CRT_ARGS += -n) 1100fd34e7baSJuan Castillo ifneq (${SAVE_KEYS},0) 1101fd34e7baSJuan Castillo $(eval CRT_ARGS += -k) 11020191262dSYatharth Kochar $(eval FWU_CRT_ARGS += -k) 1103fd34e7baSJuan Castillo endif 11046f971622SJuan Castillo endif 110573c99d4eSJuan Castillo # Include TBBR makefile (unless the platform indicates otherwise) 110673c99d4eSJuan Castillo ifeq (${INCLUDE_TBBR_MK},1) 110773c99d4eSJuan Castillo include make_helpers/tbbr/tbbr_tools.mk 110873c99d4eSJuan Castillo endif 1109c5e1da83SJayanth Dodderi Chidanandendif #(GENERATE_COT) 11106f971622SJuan Castillo 11111c75d5dfSMasahiro Yamadaifneq (${FIP_ALIGN},0) 11121c75d5dfSMasahiro Yamada FIP_ARGS += --align ${FIP_ALIGN} 1113c5e1da83SJayanth Dodderi Chidanandendif #(FIP_ALIGN) 11141c75d5dfSMasahiro Yamada 11155f24ce96SManish Pandeyifdef FDT_SOURCES 11165f24ce96SManish Pandey NEED_FDT := yes 1117c5e1da83SJayanth Dodderi Chidanandendif #(FDT_SOURCES) 11185f24ce96SManish Pandey 111973c99d4eSJuan Castillo################################################################################ 112046e5e035SMichalis Pappas# Include libraries' Makefile that are used in all BL 112146e5e035SMichalis Pappas################################################################################ 112246e5e035SMichalis Pappas 112346e5e035SMichalis Pappasinclude lib/stack_protector/stack_protector.mk 112446e5e035SMichalis Pappas 112546e5e035SMichalis Pappas################################################################################ 11268a86052dSSoby Mathew# Include BL specific makefiles 11278a86052dSSoby Mathew################################################################################ 11285f24ce96SManish Pandey 11295f24ce96SManish Pandeyifeq (${NEED_BL1},yes) 11308a86052dSSoby Mathewinclude bl1/bl1.mk 11318a86052dSSoby Mathewendif 11328a86052dSSoby Mathew 11335f24ce96SManish Pandeyifeq (${NEED_BL2},yes) 11348a86052dSSoby Mathewinclude bl2/bl2.mk 11358a86052dSSoby Mathewendif 11368a86052dSSoby Mathew 11375f24ce96SManish Pandeyifeq (${NEED_BL2U},yes) 11388a86052dSSoby Mathewinclude bl2u/bl2u.mk 11398a86052dSSoby Mathewendif 11408a86052dSSoby Mathew 11415744e874SSoby Mathewifeq (${NEED_BL31},yes) 11428a86052dSSoby Mathewinclude bl31/bl31.mk 11438a86052dSSoby Mathewendif 114403b397a8SNishanth Menon 114573c99d4eSJuan Castillo################################################################################ 114673c99d4eSJuan Castillo# Build options checks 114773c99d4eSJuan Castillo################################################################################ 114873c99d4eSJuan Castillo 1149c5e1da83SJayanth Dodderi Chidanand# Boolean_Flags 1150327131c4SLeonardo Sandoval$(eval $(call assert_booleans,\ 1151327131c4SLeonardo Sandoval $(sort \ 1152327131c4SLeonardo Sandoval ALLOW_RO_XLAT_TABLES \ 115346789a7cSBalint Dobszay BL2_ENABLE_SP_LOAD \ 1154327131c4SLeonardo Sandoval COLD_BOOT_SINGLE_CPU \ 1155327131c4SLeonardo Sandoval CREATE_KEYS \ 1156327131c4SLeonardo Sandoval CTX_INCLUDE_AARCH32_REGS \ 1157327131c4SLeonardo Sandoval CTX_INCLUDE_FPREGS \ 1158327131c4SLeonardo Sandoval CTX_INCLUDE_EL2_REGS \ 1159327131c4SLeonardo Sandoval DEBUG \ 1160327131c4SLeonardo Sandoval DYN_DISABLE_AUTH \ 1161327131c4SLeonardo Sandoval EL3_EXCEPTION_HANDLING \ 11621fd685a7SChris Kay ENABLE_AMU_AUXILIARY_COUNTERS \ 1163742ca230SChris Kay ENABLE_AMU_FCONF \ 1164873d4241Sjohpow01 AMU_RESTRICT_COUNTERS \ 1165327131c4SLeonardo Sandoval ENABLE_ASSERTIONS \ 116624077098SAndre Przywara ENABLE_FEAT_SB \ 1167327131c4SLeonardo Sandoval ENABLE_PIE \ 1168327131c4SLeonardo Sandoval ENABLE_PMF \ 1169327131c4SLeonardo Sandoval ENABLE_PSCI_STAT \ 1170327131c4SLeonardo Sandoval ENABLE_RUNTIME_INSTRUMENTATION \ 1171dc78e62dSjohpow01 ENABLE_SME_FOR_SWD \ 11720c5e7d1cSMax Shvetsov ENABLE_SVE_FOR_SWD \ 1173327131c4SLeonardo Sandoval ERROR_DEPRECATED \ 1174327131c4SLeonardo Sandoval FAULT_INJECTION_SUPPORT \ 1175327131c4SLeonardo Sandoval GENERATE_COT \ 1176327131c4SLeonardo Sandoval GICV2_G0_FOR_EL3 \ 117746cc41d5SManish Pandey HANDLE_EA_EL3_FIRST_NS \ 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 \ 11840ce2072dSTamas Ban PLAT_RSS_NOT_SUPPORTED \ 1185327131c4SLeonardo Sandoval PROGRAMMABLE_RESET_ADDRESS \ 1186327131c4SLeonardo Sandoval PSCI_EXTENDED_STATE_ID \ 118764b4710bSWing Li PSCI_OS_INIT_MODE \ 1188327131c4SLeonardo Sandoval RESET_TO_BL31 \ 1189327131c4SLeonardo Sandoval SAVE_KEYS \ 1190327131c4SLeonardo Sandoval SEPARATE_CODE_AND_RODATA \ 119196a8ed14SJiafei Pan SEPARATE_BL2_NOLOAD_REGION \ 1192327131c4SLeonardo Sandoval SEPARATE_NOBITS_REGION \ 1193327131c4SLeonardo Sandoval SPIN_ON_BL1_EXIT \ 1194327131c4SLeonardo Sandoval SPM_MM \ 11951d63ae4dSMarc Bonnici SPMC_AT_EL3 \ 1196327131c4SLeonardo Sandoval SPMD_SPM_AT_SEL2 \ 1197890b5088SRaghu Krishnamurthy ENABLE_SPMD_LP \ 1198*3ba2c151SRaymond 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 \ 12269202d519SManish Pandey RAS_FFH_SUPPORT \ 1227327131c4SLeonardo Sandoval))) 122873c99d4eSJuan Castillo 1229c5e1da83SJayanth Dodderi Chidanand# Numeric_Flags 1230327131c4SLeonardo Sandoval$(eval $(call assert_numerics,\ 1231327131c4SLeonardo Sandoval $(sort \ 1232327131c4SLeonardo Sandoval ARM_ARCH_MAJOR \ 1233327131c4SLeonardo Sandoval ARM_ARCH_MINOR \ 1234327131c4SLeonardo Sandoval BRANCH_PROTECTION \ 12356a0da736SJayanth Dodderi Chidanand CTX_INCLUDE_PAUTH_REGS \ 12366a0da736SJayanth Dodderi Chidanand CTX_INCLUDE_MTE_REGS \ 12376a0da736SJayanth Dodderi Chidanand CTX_INCLUDE_NEVE_REGS \ 12382bf4f27fSManish V Badarkhe CRYPTO_SUPPORT \ 123983a4dae1SBoyan Karatotev DISABLE_MTPMU \ 12401298f2f1SJayanth Dodderi Chidanand ENABLE_BRBE_FOR_NS \ 124147c681b7SJayanth Dodderi Chidanand ENABLE_TRBE_FOR_NS \ 12426a0da736SJayanth Dodderi Chidanand ENABLE_BTI \ 12436a0da736SJayanth Dodderi Chidanand ENABLE_PAUTH \ 1244d23acc9eSAndre Przywara ENABLE_FEAT_AMU \ 12456a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_AMUv1p1 \ 12466a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_CSV2_2 \ 12479202d519SManish Pandey ENABLE_FEAT_RAS \ 12486a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_DIT \ 12496a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_ECV \ 12506a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_FGT \ 12516a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_HCX \ 12526a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_PAN \ 12536a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_RNG \ 1254ff86e0b4SJuan Pablo Conde ENABLE_FEAT_RNG_TRAP \ 12556a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_SEL2 \ 1256d3331603SMark Brown ENABLE_FEAT_TCR2 \ 1257062b6c6bSMark Brown ENABLE_FEAT_S2PIE \ 1258062b6c6bSMark Brown ENABLE_FEAT_S1PIE \ 1259062b6c6bSMark Brown ENABLE_FEAT_S2POE \ 1260062b6c6bSMark Brown ENABLE_FEAT_S1POE \ 1261688ab57bSMark Brown ENABLE_FEAT_GCS \ 12626a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_VHE \ 12634d0b6632SMaksims Svecovs ENABLE_FEAT_MTE_PERM \ 12646a0da736SJayanth Dodderi Chidanand ENABLE_MPAM_FOR_LOWER_ELS \ 12656a0da736SJayanth Dodderi Chidanand ENABLE_RME \ 12666437a09aSAndre Przywara ENABLE_SPE_FOR_NS \ 1267603a0c6fSAndre Przywara ENABLE_SYS_REG_TRACE_FOR_NS \ 126845007acdSJayanth Dodderi Chidanand ENABLE_SME_FOR_NS \ 126903d3c0d7SJayanth Dodderi Chidanand ENABLE_SME2_FOR_NS \ 12702b0bc4e0SJayanth Dodderi Chidanand ENABLE_SVE_FOR_NS \ 12716a0da736SJayanth Dodderi Chidanand ENABLE_TRF_FOR_NS \ 1272327131c4SLeonardo Sandoval FW_ENC_STATUS \ 12735357f83dSManish V Badarkhe NR_OF_FW_BANKS \ 12745357f83dSManish V Badarkhe NR_OF_IMAGES_IN_FW_BANK \ 1275781d07a4SJayanth Dodderi Chidanand TWED_DELAY \ 1276781d07a4SJayanth Dodderi Chidanand ENABLE_FEAT_TWED \ 1277bebcf27fSMark Brown SVE_VECTOR_LEN \ 12780ed3be6fSVarun Wadekar IMPDEF_SYSREG_TRAP \ 1279327131c4SLeonardo Sandoval))) 1280c877b414SJeenu Viswambharan 1281aacff749SJustin Chadwellifdef KEY_SIZE 1282aacff749SJustin Chadwell $(eval $(call assert_numeric,KEY_SIZE)) 1283aacff749SJustin Chadwellendif 1284aacff749SJustin Chadwell 12851f461979SJustin Chadwellifeq ($(filter $(SANITIZE_UB), on off trap),) 12861f461979SJustin Chadwell $(error "Invalid value for SANITIZE_UB: can be one of on, off, trap") 12871f461979SJustin Chadwellendif 12881f461979SJustin Chadwell 128973c99d4eSJuan Castillo################################################################################ 129073c99d4eSJuan Castillo# Add definitions to the cpp preprocessor based on the current build options. 129173c99d4eSJuan Castillo# This is done after including the platform specific makefile to allow the 129273c99d4eSJuan Castillo# platform to overwrite the default options 129373c99d4eSJuan Castillo################################################################################ 129473c99d4eSJuan Castillo 1295327131c4SLeonardo Sandoval$(eval $(call add_defines,\ 1296327131c4SLeonardo Sandoval $(sort \ 1297327131c4SLeonardo Sandoval ALLOW_RO_XLAT_TABLES \ 1298327131c4SLeonardo Sandoval ARM_ARCH_MAJOR \ 1299327131c4SLeonardo Sandoval ARM_ARCH_MINOR \ 130046789a7cSBalint Dobszay BL2_ENABLE_SP_LOAD \ 1301327131c4SLeonardo Sandoval COLD_BOOT_SINGLE_CPU \ 1302327131c4SLeonardo Sandoval CTX_INCLUDE_AARCH32_REGS \ 1303327131c4SLeonardo Sandoval CTX_INCLUDE_FPREGS \ 1304327131c4SLeonardo Sandoval CTX_INCLUDE_PAUTH_REGS \ 1305327131c4SLeonardo Sandoval EL3_EXCEPTION_HANDLING \ 1306327131c4SLeonardo Sandoval CTX_INCLUDE_MTE_REGS \ 1307327131c4SLeonardo Sandoval CTX_INCLUDE_EL2_REGS \ 1308062f8aafSArunachalam Ganapathy CTX_INCLUDE_NEVE_REGS \ 1309327131c4SLeonardo Sandoval DECRYPTION_SUPPORT_${DECRYPTION_SUPPORT} \ 13100063dd17SJavier Almansa Sobrino DISABLE_MTPMU \ 1311d23acc9eSAndre Przywara ENABLE_FEAT_AMU \ 13121fd685a7SChris Kay ENABLE_AMU_AUXILIARY_COUNTERS \ 1313742ca230SChris Kay ENABLE_AMU_FCONF \ 1314873d4241Sjohpow01 AMU_RESTRICT_COUNTERS \ 1315327131c4SLeonardo Sandoval ENABLE_ASSERTIONS \ 1316327131c4SLeonardo Sandoval ENABLE_BTI \ 1317327131c4SLeonardo Sandoval ENABLE_MPAM_FOR_LOWER_ELS \ 1318327131c4SLeonardo Sandoval ENABLE_PAUTH \ 1319327131c4SLeonardo Sandoval ENABLE_PIE \ 1320327131c4SLeonardo Sandoval ENABLE_PMF \ 1321327131c4SLeonardo Sandoval ENABLE_PSCI_STAT \ 13225b18de09SZelalem Aweke ENABLE_RME \ 1323327131c4SLeonardo Sandoval ENABLE_RUNTIME_INSTRUMENTATION \ 1324dc78e62dSjohpow01 ENABLE_SME_FOR_NS \ 132503d3c0d7SJayanth Dodderi Chidanand ENABLE_SME2_FOR_NS \ 1326dc78e62dSjohpow01 ENABLE_SME_FOR_SWD \ 132790118bb5SAndre Przywara ENABLE_SPE_FOR_NS \ 1328327131c4SLeonardo Sandoval ENABLE_SVE_FOR_NS \ 13290c5e7d1cSMax Shvetsov ENABLE_SVE_FOR_SWD \ 1330327131c4SLeonardo Sandoval ENCRYPT_BL31 \ 1331327131c4SLeonardo Sandoval ENCRYPT_BL32 \ 1332327131c4SLeonardo Sandoval ERROR_DEPRECATED \ 1333327131c4SLeonardo Sandoval FAULT_INJECTION_SUPPORT \ 1334327131c4SLeonardo Sandoval GICV2_G0_FOR_EL3 \ 133546cc41d5SManish Pandey HANDLE_EA_EL3_FIRST_NS \ 1336327131c4SLeonardo Sandoval HW_ASSISTED_COHERENCY \ 1337327131c4SLeonardo Sandoval LOG_LEVEL \ 1338327131c4SLeonardo Sandoval MEASURED_BOOT \ 133900e28874SManish V Badarkhe DRTM_SUPPORT \ 1340327131c4SLeonardo Sandoval NS_TIMER_SWITCH \ 1341327131c4SLeonardo Sandoval PL011_GENERIC_UART \ 1342327131c4SLeonardo Sandoval PLAT_${PLAT} \ 13430ce2072dSTamas Ban PLAT_RSS_NOT_SUPPORTED \ 1344327131c4SLeonardo Sandoval PROGRAMMABLE_RESET_ADDRESS \ 1345327131c4SLeonardo Sandoval PSCI_EXTENDED_STATE_ID \ 134664b4710bSWing Li PSCI_OS_INIT_MODE \ 13479202d519SManish Pandey ENABLE_FEAT_RAS \ 13489202d519SManish Pandey RAS_FFH_SUPPORT \ 1349327131c4SLeonardo Sandoval RESET_TO_BL31 \ 1350327131c4SLeonardo Sandoval SEPARATE_CODE_AND_RODATA \ 135196a8ed14SJiafei Pan SEPARATE_BL2_NOLOAD_REGION \ 1352327131c4SLeonardo Sandoval SEPARATE_NOBITS_REGION \ 1353327131c4SLeonardo Sandoval RECLAIM_INIT_CODE \ 1354327131c4SLeonardo Sandoval SPD_${SPD} \ 1355327131c4SLeonardo Sandoval SPIN_ON_BL1_EXIT \ 1356327131c4SLeonardo Sandoval SPM_MM \ 13571d63ae4dSMarc Bonnici SPMC_AT_EL3 \ 1358327131c4SLeonardo Sandoval SPMD_SPM_AT_SEL2 \ 1359*3ba2c151SRaymond Mao TRANSFER_LIST \ 1360327131c4SLeonardo Sandoval TRUSTED_BOARD_BOOT \ 1361c9c56f6eSManish V Badarkhe CRYPTO_SUPPORT \ 13627dfb9911SJimmy Brisson TRNG_SUPPORT \ 1363ffea3844SSona Mathew ERRATA_ABI_SUPPORT \ 1364ef63f5beSSona Mathew ERRATA_NON_ARM_INTERCONNECT \ 1365327131c4SLeonardo Sandoval USE_COHERENT_MEM \ 1366327131c4SLeonardo Sandoval USE_DEBUGFS \ 1367327131c4SLeonardo Sandoval ARM_IO_IN_DTB \ 1368327131c4SLeonardo Sandoval SDEI_IN_FCONF \ 1369327131c4SLeonardo Sandoval SEC_INT_DESC_IN_FCONF \ 1370327131c4SLeonardo Sandoval USE_ROMLIB \ 1371327131c4SLeonardo Sandoval USE_TBBR_DEFS \ 1372327131c4SLeonardo Sandoval WARMBOOT_ENABLE_DCACHE_EARLY \ 137342d4d3baSArvind Ram Prakash RESET_TO_BL2 \ 137442d4d3baSArvind Ram Prakash BL2_RUNS_AT_EL3 \ 1375327131c4SLeonardo Sandoval BL2_IN_XIP_MEM \ 1376327131c4SLeonardo Sandoval BL2_INV_DCACHE \ 1377327131c4SLeonardo Sandoval USE_SPINLOCK_CAS \ 1378327131c4SLeonardo Sandoval ERRATA_SPECULATIVE_AT \ 137900e8f79cSManish Pandey RAS_TRAP_NS_ERR_REC_ACCESS \ 1380327131c4SLeonardo Sandoval COT_DESC_IN_DTB \ 1381327131c4SLeonardo Sandoval USE_SP804_TIMER \ 138212cd65e0STomas Pilar ENABLE_FEAT_RNG \ 1383ff86e0b4SJuan Pablo Conde ENABLE_FEAT_RNG_TRAP \ 13844e04478aSChris Kay ENABLE_FEAT_SB \ 13857d33ffe4SDaniel Boulby ENABLE_FEAT_DIT \ 13865357f83dSManish V Badarkhe NR_OF_FW_BANKS \ 13875357f83dSManish V Badarkhe NR_OF_IMAGES_IN_FW_BANK \ 1388396b339dSManish V Badarkhe PSA_FWU_SUPPORT \ 1389744ad974Sjohpow01 ENABLE_BRBE_FOR_NS \ 1390813524eaSManish V Badarkhe ENABLE_TRBE_FOR_NS \ 1391d4582d30SManish V Badarkhe ENABLE_SYS_REG_TRACE_FOR_NS \ 13928fcd3d96SManish V Badarkhe ENABLE_TRF_FOR_NS \ 1393cb4ec47bSjohpow01 ENABLE_FEAT_HCX \ 139468120783SChris Kay ENABLE_MPMM \ 139568120783SChris Kay ENABLE_MPMM_FCONF \ 1396f74cb0beSJayanth Dodderi Chidanand ENABLE_FEAT_FGT \ 1397f74cb0beSJayanth Dodderi Chidanand ENABLE_FEAT_ECV \ 13986a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_AMUv1p1 \ 13996a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_SEL2 \ 14006a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_VHE \ 14016a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_CSV2_2 \ 14026a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_PAN \ 1403d3331603SMark Brown ENABLE_FEAT_TCR2 \ 1404062b6c6bSMark Brown ENABLE_FEAT_S2PIE \ 1405062b6c6bSMark Brown ENABLE_FEAT_S1PIE \ 1406062b6c6bSMark Brown ENABLE_FEAT_S2POE \ 1407062b6c6bSMark Brown ENABLE_FEAT_S1POE \ 1408688ab57bSMark Brown ENABLE_FEAT_GCS \ 14094d0b6632SMaksims Svecovs ENABLE_FEAT_MTE_PERM \ 14106a0da736SJayanth Dodderi Chidanand FEATURE_DETECTION \ 1411781d07a4SJayanth Dodderi Chidanand TWED_DELAY \ 1412781d07a4SJayanth Dodderi Chidanand ENABLE_FEAT_TWED \ 141304c7303bSOkash Khawaja CONDITIONAL_CMO \ 14140ed3be6fSVarun Wadekar IMPDEF_SYSREG_TRAP \ 1415a8cf6faeSJayanth Dodderi Chidanand SVE_VECTOR_LEN \ 1416890b5088SRaghu Krishnamurthy ENABLE_SPMD_LP \ 1417327131c4SLeonardo Sandoval))) 14182fae4b1eSJeenu Viswambharan 14191f461979SJustin Chadwellifeq (${SANITIZE_UB},trap) 14201f461979SJustin Chadwell $(eval $(call add_define,MONITOR_TRAPS)) 1421c5e1da83SJayanth Dodderi Chidanandendif #(SANITIZE_UB) 14221f461979SJustin Chadwell 14234c117f6cSSandrine Bailleux# Define the EL3_PAYLOAD_BASE flag only if it is provided. 14244c117f6cSSandrine Bailleuxifdef EL3_PAYLOAD_BASE 14254c117f6cSSandrine Bailleux $(eval $(call add_define,EL3_PAYLOAD_BASE)) 1426cf2c8a33SAntonio Nino Diazelse 142768450a6dSAntonio Nino Diaz# Define the PRELOADED_BL33_BASE flag only if it is provided and 142868450a6dSAntonio Nino Diaz# EL3_PAYLOAD_BASE is not defined, as it has priority. 142968450a6dSAntonio Nino Diaz ifdef PRELOADED_BL33_BASE 143068450a6dSAntonio Nino Diaz $(eval $(call add_define,PRELOADED_BL33_BASE)) 14314c117f6cSSandrine Bailleux endif 1432c5e1da83SJayanth Dodderi Chidanandendif #(EL3_PAYLOAD_BASE) 143373c99d4eSJuan Castillo 1434209a60ccSSoby Mathew# Define the DYN_DISABLE_AUTH flag only if set. 1435209a60ccSSoby Mathewifeq (${DYN_DISABLE_AUTH},1) 1436209a60ccSSoby Mathew $(eval $(call add_define,DYN_DISABLE_AUTH)) 1437209a60ccSSoby Mathewendif 1438209a60ccSSoby Mathew 1439c2ad38ceSVarun Wadekarifneq ($(findstring armlink,$(notdir $(LD))),) 1440c2ad38ceSVarun Wadekar $(eval $(call add_define,USE_ARM_LINK)) 1441c2ad38ceSVarun Wadekarendif 1442c2ad38ceSVarun Wadekar 1443ce2b1ec6SManish Pandey# Generate and include sp_gen.mk if SPD is spmd and SP_LAYOUT_FILE is defined 1444ce2b1ec6SManish Pandeyifeq (${SPD},spmd) 1445c33ff198SOlivier Deprezifdef SP_LAYOUT_FILE 1446ce2b1ec6SManish Pandey -include $(BUILD_PLAT)/sp_gen.mk 1447ce2b1ec6SManish Pandey FIP_DEPS += sp 144807c44475SManish Pandey CRT_DEPS += sp 1449ce2b1ec6SManish Pandey NEED_SP_PKG := yes 1450ce2b1ec6SManish Pandeyelse 1451c33ff198SOlivier Deprez ifeq (${SPMD_SPM_AT_SEL2},1) 1452c33ff198SOlivier Deprez $(error "SPMD with SPM at S-EL2 require SP_LAYOUT_FILE") 1453c33ff198SOlivier Deprez endif 1454c5e1da83SJayanth Dodderi Chidanandendif #(SP_LAYOUT_FILE) 1455c5e1da83SJayanth Dodderi Chidanandendif #(SPD) 1456ce2b1ec6SManish Pandey 145773c99d4eSJuan Castillo################################################################################ 145873c99d4eSJuan Castillo# Build targets 145973c99d4eSJuan Castillo################################################################################ 146073c99d4eSJuan Castillo 146190aa901fSSumit Garg.PHONY: all msg_start clean realclean distclean cscope locate-checkpatch checkcodebase checkpatch fiptool sptool fip sp fwu_fip certtool dtbs memmap doc enctool 146273c99d4eSJuan Castillo.SUFFIXES: 146373c99d4eSJuan Castillo 146473c99d4eSJuan Castilloall: msg_start 146573c99d4eSJuan Castillo 146673c99d4eSJuan Castillomsg_start: 146773c99d4eSJuan Castillo @echo "Building ${PLAT}" 146873c99d4eSJuan Castillo 14697a24cba5SSoby Mathewifeq (${ERROR_DEPRECATED},0) 1470d5dfdeb6SJulius Werner# Check if deprecated declarations and cpp warnings should be treated as error or not. 1471c2ad38ceSVarun Wadekarifneq ($(findstring clang,$(notdir $(CC))),) 1472c2ad38ceSVarun Wadekar CPPFLAGS += -Wno-error=deprecated-declarations 1473c2ad38ceSVarun Wadekarelse 1474bc1a03c7SDan Handley CPPFLAGS += -Wno-error=deprecated-declarations -Wno-error=cpp 14757a24cba5SSoby Mathewendif 1476c5e1da83SJayanth Dodderi Chidanandendif #(!ERROR_DEPRECATED) 14777a24cba5SSoby Mathew 14785accce5bSRoberto Vargas$(eval $(call MAKE_LIB_DIRS)) 147961f72a34SRoberto Vargas$(eval $(call MAKE_LIB,c)) 14805fee0287SRoberto Vargas 148173c99d4eSJuan Castillo# Expand build macros for the different images 148273c99d4eSJuan Castilloifeq (${NEED_BL1},yes) 1483b34635a0SChris KayBL1_SOURCES := $(sort ${BL1_SOURCES}) 1484434d0491SZelalem Aweke$(eval $(call MAKE_BL,bl1)) 1485c5e1da83SJayanth Dodderi Chidanandendif #(NEED_BL1) 148673c99d4eSJuan Castillo 148773c99d4eSJuan Castilloifeq (${NEED_BL2},yes) 1488c5e1da83SJayanth Dodderi Chidanand 148942d4d3baSArvind Ram Prakashifeq (${RESET_TO_BL2}, 0) 1490c9b31ae8SRoberto VargasFIP_BL2_ARGS := tb-fw 1491c9b31ae8SRoberto Vargasendif 1492c9b31ae8SRoberto Vargas 1493eb1acfb6SChris KayBL2_SOURCES := $(sort ${BL2_SOURCES}) 1494eb1acfb6SChris Kay 149533950dd8SMasahiro Yamada$(if ${BL2}, $(eval $(call TOOL_ADD_IMG,bl2,--${FIP_BL2_ARGS})),\ 1496434d0491SZelalem Aweke $(eval $(call MAKE_BL,bl2,${FIP_BL2_ARGS}))) 1497c5e1da83SJayanth Dodderi Chidanand 1498c5e1da83SJayanth Dodderi Chidanandendif #(NEED_BL2) 149973c99d4eSJuan Castillo 15004d045d0eSMasahiro Yamadaifeq (${NEED_SCP_BL2},yes) 150133950dd8SMasahiro Yamada$(eval $(call TOOL_ADD_IMG,scp_bl2,--scp-fw)) 1502c5e1da83SJayanth Dodderi Chidanandendif #(NEED_SCP_BL2) 15034d045d0eSMasahiro Yamada 150473c99d4eSJuan Castilloifeq (${NEED_BL31},yes) 150573c99d4eSJuan CastilloBL31_SOURCES += ${SPD_SOURCES} 150626d1e0c3SMadhukar Pappireddy# Sort BL31 source files to remove duplicates 150726d1e0c3SMadhukar PappireddyBL31_SOURCES := $(sort ${BL31_SOURCES}) 1508c6ba9b45SSumit Gargifneq (${DECRYPTION_SUPPORT},none) 1509c6ba9b45SSumit Garg$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw,,$(ENCRYPT_BL31))),\ 1510434d0491SZelalem Aweke $(eval $(call MAKE_BL,bl31,soc-fw,,$(ENCRYPT_BL31)))) 1511c6ba9b45SSumit Gargelse 151233950dd8SMasahiro Yamada$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw)),\ 1513434d0491SZelalem Aweke $(eval $(call MAKE_BL,bl31,soc-fw))) 1514c5e1da83SJayanth Dodderi Chidanandendif #(DECRYPTION_SUPPORT) 1515c5e1da83SJayanth Dodderi Chidanandendif #(NEED_BL31) 151673c99d4eSJuan Castillo 151770d1fc53SJuan Castillo# If a BL32 image is needed but neither BL32 nor BL32_SOURCES is defined, the 1518c939d13aSMasahiro Yamada# build system will call TOOL_ADD_IMG to print a warning message and abort the 151970d1fc53SJuan Castillo# process. Note that the dependency on BL32 applies to the FIP only. 152073c99d4eSJuan Castilloifeq (${NEED_BL32},yes) 152126d1e0c3SMadhukar Pappireddy# Sort BL32 source files to remove duplicates 152226d1e0c3SMadhukar PappireddyBL32_SOURCES := $(sort ${BL32_SOURCES}) 15239cd15239SMasahiro YamadaBUILD_BL32 := $(if $(BL32),,$(if $(BL32_SOURCES),1)) 15249cd15239SMasahiro Yamada 1525c6ba9b45SSumit Gargifneq (${DECRYPTION_SUPPORT},none) 1526434d0491SZelalem Aweke$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw,,$(ENCRYPT_BL32))),\ 1527c6ba9b45SSumit Garg $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw,,$(ENCRYPT_BL32)))) 1528c6ba9b45SSumit Gargelse 1529434d0491SZelalem Aweke$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw)),\ 153033950dd8SMasahiro Yamada $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw))) 1531c5e1da83SJayanth Dodderi Chidanandendif #(DECRYPTION_SUPPORT) 1532c5e1da83SJayanth Dodderi Chidanandendif #(NEED_BL32) 153373c99d4eSJuan Castillo 15345b18de09SZelalem Aweke# If RMM image is needed but RMM is not defined, Test Realm Payload (TRP) 15355b18de09SZelalem Aweke# needs to be built from RMM_SOURCES. 15365b18de09SZelalem Awekeifeq (${NEED_RMM},yes) 15375b18de09SZelalem Aweke# Sort RMM source files to remove duplicates 15385b18de09SZelalem AwekeRMM_SOURCES := $(sort ${RMM_SOURCES}) 15395b18de09SZelalem AwekeBUILD_RMM := $(if $(RMM),,$(if $(RMM_SOURCES),1)) 15405b18de09SZelalem Aweke 15415b18de09SZelalem Aweke$(if ${BUILD_RMM}, $(eval $(call MAKE_BL,rmm,rmm-fw)),\ 15425b18de09SZelalem Aweke $(eval $(call TOOL_ADD_IMG,rmm,--rmm-fw))) 1543c5e1da83SJayanth Dodderi Chidanandendif #(NEED_RMM) 15445b18de09SZelalem Aweke 154573c99d4eSJuan Castillo# Add the BL33 image if required by the platform 154673c99d4eSJuan Castilloifeq (${NEED_BL33},yes) 154733950dd8SMasahiro Yamada$(eval $(call TOOL_ADD_IMG,bl33,--nt-fw)) 1548c5e1da83SJayanth Dodderi Chidanandendif #(NEED_BL33) 1549db6071c9SJuan Castillo 15509003fa0bSYatharth Kocharifeq (${NEED_BL2U},yes) 155133950dd8SMasahiro Yamada$(if ${BL2U}, $(eval $(call TOOL_ADD_IMG,bl2u,--ap-fwu-cfg,FWU_)),\ 1552434d0491SZelalem Aweke $(eval $(call MAKE_BL,bl2u,ap-fwu-cfg,FWU_))) 1553c5e1da83SJayanth Dodderi Chidanandendif #(NEED_BL2U) 15549003fa0bSYatharth Kochar 155503b397a8SNishanth Menon# Expand build macros for the different images 155603b397a8SNishanth Menonifeq (${NEED_FDT},yes) 155703b397a8SNishanth Menon $(eval $(call MAKE_DTBS,$(BUILD_PLAT)/fdts,$(FDT_SOURCES))) 1558c5e1da83SJayanth Dodderi Chidanandendif #(NEED_FDT) 155903b397a8SNishanth Menon 1560ce2b1ec6SManish Pandey# Add Secure Partition packages 1561ce2b1ec6SManish Pandeyifeq (${NEED_SP_PKG},yes) 1562ce2b1ec6SManish Pandey$(BUILD_PLAT)/sp_gen.mk : ${SP_MK_GEN} ${SP_LAYOUT_FILE} | ${BUILD_PLAT} 156320629b31SKarl Meakin ${PYTHON} "$<" "$@" $(filter-out $<,$^) $(BUILD_PLAT) ${COT} ${SP_DTS_LIST_FRAGMENT} 1564822c7279SJ-Alvessp: $(DTBS) $(BUILD_PLAT)/sp_gen.mk $(SP_PKGS) 1565ce2b1ec6SManish Pandey @${ECHO_BLANK_LINE} 1566ce2b1ec6SManish Pandey @echo "Built SP Images successfully" 1567ce2b1ec6SManish Pandey @${ECHO_BLANK_LINE} 1568c5e1da83SJayanth Dodderi Chidanandendif #(NEED_SP_PKG) 1569ce2b1ec6SManish Pandey 157036eaaf37SIan Spraylocate-checkpatch: 157136eaaf37SIan Sprayifndef CHECKPATCH 157266079b04SEtienne Carriere $(error "Please set CHECKPATCH to point to the Linux checkpatch.pl file, eg: CHECKPATCH=../linux/scripts/checkpatch.pl") 157336eaaf37SIan Sprayelse 157436eaaf37SIan Sprayifeq (,$(wildcard ${CHECKPATCH})) 157566079b04SEtienne Carriere $(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/scripts/checkpatch.pl") 157636eaaf37SIan Sprayendif 1577c5e1da83SJayanth Dodderi Chidanandendif #(CHECKPATCH) 157836eaaf37SIan Spray 15794f6ad66aSAchin Guptaclean: 15804f6ad66aSAchin Gupta @echo " CLEAN" 1581f1477d4aSEvan Lloyd $(call SHELL_REMOVE_DIR,${BUILD_PLAT}) 158288a1cf1eSSami Mujawarifdef UNIX_MK 15832f2cef46SJeenu Viswambharan ${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean 158488a1cf1eSSami Mujawarelse 158588a1cf1eSSami Mujawar# Clear the MAKEFLAGS as we do not want 158688a1cf1eSSami Mujawar# to pass the gnumake flags to nmake. 158788a1cf1eSSami Mujawar ${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) clean 1588c5e1da83SJayanth Dodderi Chidanandendif #(UNIX_MK) 15896f971622SJuan Castillo ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean 159090aa901fSSumit Garg ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} clean 15915accce5bSRoberto Vargas ${Q}${MAKE} --no-print-directory -C ${ROMLIBPATH} clean 15924f6ad66aSAchin Gupta 1593eaaeece2SJames Morrisseyrealclean distclean: 1594eaaeece2SJames Morrissey @echo " REALCLEAN" 1595f1477d4aSEvan Lloyd $(call SHELL_REMOVE_DIR,${BUILD_BASE}) 1596f1477d4aSEvan Lloyd $(call SHELL_DELETE_ALL, ${CURDIR}/cscope.*) 159788a1cf1eSSami Mujawarifdef UNIX_MK 15982f2cef46SJeenu Viswambharan ${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean 159988a1cf1eSSami Mujawarelse 160088a1cf1eSSami Mujawar# Clear the MAKEFLAGS as we do not want 160188a1cf1eSSami Mujawar# to pass the gnumake flags to nmake. 160288a1cf1eSSami Mujawar ${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) realclean 1603c5e1da83SJayanth Dodderi Chidanandendif #(UNIX_MK) 1604e15591aaSNicolas Boulenguez ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} realclean 160590aa901fSSumit Garg ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} realclean 16065accce5bSRoberto Vargas ${Q}${MAKE} --no-print-directory -C ${ROMLIBPATH} clean 16074f6ad66aSAchin Gupta 160836eaaf37SIan Spraycheckcodebase: locate-checkpatch 160936eaaf37SIan Spray @echo " CHECKING STYLE" 161036eaaf37SIan Spray @if test -d .git ; then \ 16111ef35512SPaul Beesley git ls-files | grep -E -v 'libfdt|libc|docs|\.rst' | \ 16121a41e8c1SDan Handley while read GIT_FILE ; \ 16131a41e8c1SDan Handley do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ; \ 16141a41e8c1SDan Handley done ; \ 161536eaaf37SIan Spray else \ 16161a41e8c1SDan Handley find . -type f -not -iwholename "*.git*" \ 16171a41e8c1SDan Handley -not -iwholename "*build*" \ 16181a41e8c1SDan Handley -not -iwholename "*libfdt*" \ 161961f72a34SRoberto Vargas -not -iwholename "*libc*" \ 16201a41e8c1SDan Handley -not -iwholename "*docs*" \ 16211ef35512SPaul Beesley -not -iwholename "*.rst" \ 16221a41e8c1SDan Handley -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ; \ 162336eaaf37SIan Spray fi 162436eaaf37SIan Spray 162536eaaf37SIan Spraycheckpatch: locate-checkpatch 162636eaaf37SIan Spray @echo " CHECKING STYLE" 162702a76d5fSYann Gautier @if test -n "${CHECKPATCH_OPTS}"; then \ 162802a76d5fSYann Gautier echo " with ${CHECKPATCH_OPTS} option(s)"; \ 162902a76d5fSYann Gautier fi 163051d28937SAntonio Nino Diaz ${Q}COMMON_COMMIT=$$(git merge-base HEAD ${BASE_COMMIT}); \ 163177a0a7f1SYann Gautier for commit in `git rev-list --no-merges $$COMMON_COMMIT..HEAD`; \ 163277a0a7f1SYann Gautier do \ 163351d28937SAntonio Nino Diaz printf "\n[*] Checking style of '$$commit'\n\n"; \ 163451d28937SAntonio Nino Diaz git log --format=email "$$commit~..$$commit" \ 163502a76d5fSYann Gautier -- ${CHECK_PATHS} | \ 163602a76d5fSYann Gautier ${CHECKPATCH} ${CHECKPATCH_OPTS} - || true; \ 163751d28937SAntonio Nino Diaz git diff --format=email "$$commit~..$$commit" \ 163802a76d5fSYann Gautier -- ${CHECK_PATHS} | \ 163902a76d5fSYann Gautier ${CHECKPATCH} ${CHECKPATCH_OPTS} - || true; \ 164051d28937SAntonio Nino Diaz done 164136eaaf37SIan Spray 164273c99d4eSJuan Castillocerttool: ${CRTTOOL} 164373c99d4eSJuan Castillo 1644a9812206SPali Rohár${CRTTOOL}: FORCE 1645598b166bSLionel 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 1646f1477d4aSEvan Lloyd @${ECHO_BLANK_LINE} 16476f971622SJuan Castillo @echo "Built $@ successfully" 1648f1477d4aSEvan Lloyd @${ECHO_BLANK_LINE} 16496f971622SJuan Castillo 16506f971622SJuan Castilloifneq (${GENERATE_COT},0) 165173c99d4eSJuan Castillocertificates: ${CRT_DEPS} ${CRTTOOL} 16526f971622SJuan Castillo ${Q}${CRTTOOL} ${CRT_ARGS} 1653f1477d4aSEvan Lloyd @${ECHO_BLANK_LINE} 16546f971622SJuan Castillo @echo "Built $@ successfully" 16556f971622SJuan Castillo @echo "Certificates can be found in ${BUILD_PLAT}" 1656f1477d4aSEvan Lloyd @${ECHO_BLANK_LINE} 1657c5e1da83SJayanth Dodderi Chidanandendif #(GENERATE_COT) 165827713fb4SSoby Mathew 165973c99d4eSJuan Castillo${BUILD_PLAT}/${FIP_NAME}: ${FIP_DEPS} ${FIPTOOL} 16604727fd13SPali Rohár $(eval ${CHECK_FIP_CMD}) 1661819281eeSdp-arm ${Q}${FIPTOOL} create ${FIP_ARGS} $@ 1662819281eeSdp-arm ${Q}${FIPTOOL} info $@ 1663f1477d4aSEvan Lloyd @${ECHO_BLANK_LINE} 16642f2cef46SJeenu Viswambharan @echo "Built $@ successfully" 1665f1477d4aSEvan Lloyd @${ECHO_BLANK_LINE} 1666f58ad36fSHarry Liebel 16670191262dSYatharth Kocharifneq (${GENERATE_COT},0) 16680191262dSYatharth Kocharfwu_certificates: ${FWU_CRT_DEPS} ${CRTTOOL} 16690191262dSYatharth Kochar ${Q}${CRTTOOL} ${FWU_CRT_ARGS} 1670052ab529SEvan Lloyd @${ECHO_BLANK_LINE} 16710191262dSYatharth Kochar @echo "Built $@ successfully" 16720191262dSYatharth Kochar @echo "FWU certificates can be found in ${BUILD_PLAT}" 1673052ab529SEvan Lloyd @${ECHO_BLANK_LINE} 1674c5e1da83SJayanth Dodderi Chidanandendif #(GENERATE_COT) 16750191262dSYatharth Kochar 16760191262dSYatharth Kochar${BUILD_PLAT}/${FWU_FIP_NAME}: ${FWU_FIP_DEPS} ${FIPTOOL} 16774727fd13SPali Rohár $(eval ${CHECK_FWU_FIP_CMD}) 1678819281eeSdp-arm ${Q}${FIPTOOL} create ${FWU_FIP_ARGS} $@ 1679819281eeSdp-arm ${Q}${FIPTOOL} info $@ 1680052ab529SEvan Lloyd @${ECHO_BLANK_LINE} 16810191262dSYatharth Kochar @echo "Built $@ successfully" 1682052ab529SEvan Lloyd @${ECHO_BLANK_LINE} 16830191262dSYatharth Kochar 168473c99d4eSJuan Castillofiptool: ${FIPTOOL} 168573c99d4eSJuan Castillofip: ${BUILD_PLAT}/${FIP_NAME} 16860191262dSYatharth Kocharfwu_fip: ${BUILD_PLAT}/${FWU_FIP_NAME} 168773c99d4eSJuan Castillo 1688a9812206SPali Rohár${FIPTOOL}: FORCE 168988a1cf1eSSami Mujawarifdef UNIX_MK 1690598b166bSLionel Debieve ${Q}${MAKE} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" FIPTOOL=${FIPTOOL} OPENSSL_DIR=${OPENSSL_DIR} DEBUG=${DEBUG} V=${V} --no-print-directory -C ${FIPTOOLPATH} all 169188a1cf1eSSami Mujawarelse 169288a1cf1eSSami Mujawar# Clear the MAKEFLAGS as we do not want 169388a1cf1eSSami Mujawar# to pass the gnumake flags to nmake. 169488a1cf1eSSami Mujawar ${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) 1695c5e1da83SJayanth Dodderi Chidanandendif #(UNIX_MK) 1696f58ad36fSHarry Liebel 1697a9812206SPali Rohárromlib.bin: libraries FORCE 1698bbb24f61SJohn 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 16995accce5bSRoberto Vargas 1700cfe83910SLouis Mayencourtmemmap: all 1701af5b49e9SHarrison Mutaiifdef UNIX_MK 1702af5b49e9SHarrison Mutai ${Q}PYTHONPATH=${CURDIR}/tools/memory \ 1703af5b49e9SHarrison Mutai ${PYTHON} -m memory.memmap -sr ${BUILD_PLAT} 1704af5b49e9SHarrison Mutaielse 1705af5b49e9SHarrison Mutai ${Q}set PYTHONPATH=${CURDIR}/tools/memory && \ 1706af5b49e9SHarrison Mutai ${PYTHON} -m memory.memmap -sr ${BUILD_PLAT} 1707af5b49e9SHarrison Mutaiendif 1708cfe83910SLouis Mayencourt 17096de32378SMadhukar Pappireddydoc: 17106de32378SMadhukar Pappireddy @echo " BUILD DOCUMENTATION" 17116de32378SMadhukar Pappireddy ${Q}${MAKE} --no-print-directory -C ${DOCS_PATH} html 17126de32378SMadhukar Pappireddy 171390aa901fSSumit Gargenctool: ${ENCTOOL} 171490aa901fSSumit Garg 1715a9812206SPali Rohár${ENCTOOL}: FORCE 1716598b166bSLionel Debieve ${Q}${MAKE} PLAT=${PLAT} BUILD_INFO=0 OPENSSL_DIR=${OPENSSL_DIR} ENCTOOL=${ENCTOOL} DEBUG=${DEBUG} V=${V} --no-print-directory -C ${ENCTOOLPATH} all 171790aa901fSSumit Garg @${ECHO_BLANK_LINE} 171890aa901fSSumit Garg @echo "Built $@ successfully" 171990aa901fSSumit Garg @${ECHO_BLANK_LINE} 172090aa901fSSumit Garg 172135fab8c9SJoakim Bechcscope: 172235fab8c9SJoakim Bech @echo " CSCOPE" 172335fab8c9SJoakim Bech ${Q}find ${CURDIR} -name "*.[chsS]" > cscope.files 172435fab8c9SJoakim Bech ${Q}cscope -b -q -k 172535fab8c9SJoakim Bech 172672ee3314SRyan Harkinhelp: 17277c23126cSJohn Tsichritzis @echo "usage: ${MAKE} [PLAT=<platform>] [OPTIONS] [TARGET]" 172872ee3314SRyan Harkin @echo "" 172972ee3314SRyan Harkin @echo "PLAT is used to specify which platform you wish to build." 173008c7ed0fSSandrine Bailleux @echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}" 173172ee3314SRyan Harkin @echo "" 17327c23126cSJohn Tsichritzis @echo "platform = ${PLATFORM_LIST}" 17337c23126cSJohn Tsichritzis @echo "" 17341b578596SSandrine Bailleux @echo "Please refer to the User Guide for a list of all supported options." 17351b578596SSandrine Bailleux @echo "Note that the build system doesn't track dependencies for build " 17361b578596SSandrine Bailleux @echo "options. Therefore, if any of the build options are changed " 17371b578596SSandrine Bailleux @echo "from a previous build, a clean build must be performed." 17381b578596SSandrine Bailleux @echo "" 173972ee3314SRyan Harkin @echo "Supported Targets:" 17401b578596SSandrine Bailleux @echo " all Build all individual bootloader binaries" 174136eaaf37SIan Spray @echo " bl1 Build the BL1 binary" 17428aa559c0SJeenu Viswambharan @echo " bl2 Build the BL2 binary" 17439003fa0bSYatharth Kochar @echo " bl2u Build the BL2U binary" 1744d178637dSJuan Castillo @echo " bl31 Build the BL31 binary" 17459d29c227SSoby Mathew @echo " bl32 Build the BL32 binary. If ARCH=aarch32, then " 17469d29c227SSoby Mathew @echo " this builds secure payload specified by AARCH32_SP" 174773c99d4eSJuan Castillo @echo " certificates Build the certificates (requires 'GENERATE_COT=1')" 17481b578596SSandrine Bailleux @echo " fip Build the Firmware Image Package (FIP)" 17490191262dSYatharth Kochar @echo " fwu_fip Build the FWU Firmware Image Package (FIP)" 175036eaaf37SIan Spray @echo " checkcodebase Check the coding style of the entire source tree" 175136eaaf37SIan Spray @echo " checkpatch Check the coding style on changes in the current" 175236eaaf37SIan Spray @echo " branch against BASE_COMMIT (default origin/master)" 175372ee3314SRyan Harkin @echo " clean Clean the build for the selected platform" 175435fab8c9SJoakim Bech @echo " cscope Generate cscope index" 175572ee3314SRyan Harkin @echo " distclean Remove all build artifacts for all platforms" 17566f971622SJuan Castillo @echo " certtool Build the Certificate generation tool" 175790aa901fSSumit Garg @echo " enctool Build the Firmware encryption tool" 1758f58ad36fSHarry Liebel @echo " fiptool Build the Firmware Image Package (FIP) creation tool" 1759ce2b1ec6SManish Pandey @echo " sp Build the Secure Partition Packages" 176026010da1SAntonio Nino Diaz @echo " sptool Build the Secure Partition Package creation tool" 176138c14d88SSoby Mathew @echo " dtbs Build the Device Tree Blobs (if required for the platform)" 1762cfe83910SLouis Mayencourt @echo " memmap Print the memory map of the built binaries" 17636de32378SMadhukar Pappireddy @echo " doc Build html based documentation using Sphinx tool" 176472ee3314SRyan Harkin @echo "" 17651b578596SSandrine Bailleux @echo "Note: most build targets require PLAT to be set to a specific platform." 176672ee3314SRyan Harkin @echo "" 176772ee3314SRyan Harkin @echo "example: build all targets for the FVP platform:" 176872ee3314SRyan Harkin @echo " CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all" 1769a9812206SPali Rohár 1770a9812206SPali Rohár.PHONY: FORCE 1771a9812206SPali RohárFORCE:; 1772