14f6ad66aSAchin Gupta# 20a33adc0SGovindraj Raja# Copyright (c) 2013-2024, Arm Limited and Contributors. All rights reserved. 34f6ad66aSAchin Gupta# 482cb2c1aSdp-arm# SPDX-License-Identifier: BSD-3-Clause 54f6ad66aSAchin Gupta# 64f6ad66aSAchin Gupta 7e35c4045SJeenu Viswambharan# 8aaa3e722SJuan Castillo# Trusted Firmware Version 9aaa3e722SJuan Castillo# 101a0f1121SSoby MathewVERSION_MAJOR := 2 11669e2b15SManish V BadarkheVERSION_MINOR := 11 12c25d1ccfSYann Gautier# VERSION_PATCH is only used for LTS releases 13c25d1ccfSYann GautierVERSION_PATCH := 0 14055ebecaSYann GautierVERSION := ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH} 15aaa3e722SJuan Castillo 1688154678SJuan Castillo# Default goal is build all images 1788154678SJuan Castillo.DEFAULT_GOAL := all 1888154678SJuan Castillo 1972fc70edSDouglas Raillard# Avoid any implicit propagation of command line variable definitions to 2072fc70edSDouglas Raillard# sub-Makefiles, like CFLAGS that we reserved for the firmware images' 2172fc70edSDouglas Raillard# usage. Other command line options like "-s" are still propagated as usual. 2272fc70edSDouglas RaillardMAKEOVERRIDES = 2372fc70edSDouglas Raillard 24231c1470SEvan LloydMAKE_HELPERS_DIRECTORY := make_helpers/ 25231c1470SEvan Lloydinclude ${MAKE_HELPERS_DIRECTORY}build_macros.mk 26e7f54dbdSEvan Lloydinclude ${MAKE_HELPERS_DIRECTORY}build_env.mk 27f4dd18c2SChris Kayinclude ${MAKE_HELPERS_DIRECTORY}build-rules.mk 287c4e1eeaSChris Kayinclude ${MAKE_HELPERS_DIRECTORY}common.mk 2973c99d4eSJuan Castillo 3073c99d4eSJuan Castillo################################################################################ 312fae4b1eSJeenu Viswambharan# Default values for build configurations, and their dependencies 3273c99d4eSJuan Castillo################################################################################ 33e35c4045SJeenu Viswambharan 342fae4b1eSJeenu Viswambharaninclude ${MAKE_HELPERS_DIRECTORY}defaults.mk 351b2fb6adSAndrey Skvortsovinclude ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk 361b2fb6adSAndrey Skvortsov 371b2fb6adSAndrey Skvortsov# To be able to set platform specific defaults 381b2fb6adSAndrey Skvortsovifneq ($(PLAT_DEFAULTS_MAKEFILE_FULL),) 391b2fb6adSAndrey Skvortsovinclude ${PLAT_DEFAULTS_MAKEFILE_FULL} 401b2fb6adSAndrey Skvortsovendif 41872be88aSdp-arm 42cc277de8SChris Kay################################################################################ 43cc277de8SChris Kay# Configure the toolchains used to build TF-A and its tools 44cc277de8SChris Kay################################################################################ 45cc277de8SChris Kay 46cc277de8SChris Kayinclude ${MAKE_HELPERS_DIRECTORY}toolchain.mk 47cc277de8SChris Kay 48cc8b5632SAntonio Nino Diaz# Assertions enabled for DEBUG builds by default 49cc8b5632SAntonio Nino DiazENABLE_ASSERTIONS := ${DEBUG} 502fae4b1eSJeenu ViswambharanENABLE_PMF := ${ENABLE_RUNTIME_INSTRUMENTATION} 5173c99d4eSJuan Castillo 5273c99d4eSJuan Castillo################################################################################ 5373c99d4eSJuan Castillo# Checkpatch script options 5473c99d4eSJuan Castillo################################################################################ 5573c99d4eSJuan Castillo 56f607739cSSandrine BailleuxCHECKCODE_ARGS := --no-patch 57f0b489c1SDan Handley# Do not check the coding style on imported library files or documentation files 584501843fSGilad Ben-YossefINC_DRV_DIRS_TO_CHECK := $(sort $(filter-out \ 594501843fSGilad Ben-Yossef include/drivers/arm, \ 604501843fSGilad Ben-Yossef $(wildcard include/drivers/*))) 61f0b489c1SDan HandleyINC_LIB_DIRS_TO_CHECK := $(sort $(filter-out \ 621a41e8c1SDan Handley include/lib/libfdt \ 6361f72a34SRoberto Vargas include/lib/libc, \ 64f0b489c1SDan Handley $(wildcard include/lib/*))) 65f0b489c1SDan HandleyINC_DIRS_TO_CHECK := $(sort $(filter-out \ 664501843fSGilad Ben-Yossef include/lib \ 674501843fSGilad Ben-Yossef include/drivers, \ 68f0b489c1SDan Handley $(wildcard include/*))) 69f0b489c1SDan HandleyLIB_DIRS_TO_CHECK := $(sort $(filter-out \ 70d801fbb0Sdp-arm lib/compiler-rt \ 7155cdcf75SAntonio Nino Diaz lib/libfdt% \ 7261f72a34SRoberto Vargas lib/libc, \ 73a194255dSDaniel Boulby lib/zlib \ 74f0b489c1SDan Handley $(wildcard lib/*))) 75f0b489c1SDan HandleyROOT_DIRS_TO_CHECK := $(sort $(filter-out \ 76f0b489c1SDan Handley lib \ 77f0b489c1SDan Handley include \ 78f0b489c1SDan Handley docs \ 791ef35512SPaul Beesley %.rst, \ 80f0b489c1SDan Handley $(wildcard *))) 81f0b489c1SDan HandleyCHECK_PATHS := ${ROOT_DIRS_TO_CHECK} \ 82f0b489c1SDan Handley ${INC_DIRS_TO_CHECK} \ 83f0b489c1SDan Handley ${INC_LIB_DIRS_TO_CHECK} \ 844501843fSGilad Ben-Yossef ${LIB_DIRS_TO_CHECK} \ 854501843fSGilad Ben-Yossef ${INC_DRV_DIRS_TO_CHECK} \ 864501843fSGilad Ben-Yossef ${INC_ARM_DIRS_TO_CHECK} 8736eaaf37SIan Spray 8873c99d4eSJuan Castillo################################################################################ 8973c99d4eSJuan Castillo# Process build options 9073c99d4eSJuan Castillo################################################################################ 9173c99d4eSJuan Castillo 927c4e1eeaSChris Kayifeq ($(verbose),) 9336eaaf37SIan Spray CHECKCODE_ARGS += --no-summary --terse 944f6ad66aSAchin Guptaendif 95ee1ba6d4SAndre Przywara 9673c99d4eSJuan Castillo################################################################################ 97c5e1da83SJayanth Dodderi Chidanand# Auxiliary tools (fiptool, cert_create, etc) 98c5e1da83SJayanth Dodderi Chidanand################################################################################ 99c5e1da83SJayanth Dodderi Chidanand 100c5e1da83SJayanth Dodderi Chidanand# Variables for use with Certificate Generation Tool 101c5e1da83SJayanth Dodderi ChidanandCRTTOOLPATH ?= tools/cert_create 102c5e1da83SJayanth Dodderi ChidanandCRTTOOL ?= ${CRTTOOLPATH}/cert_create${BIN_EXT} 103c5e1da83SJayanth Dodderi Chidanand 104c5e1da83SJayanth Dodderi Chidanand# Variables for use with Firmware Encryption Tool 105c5e1da83SJayanth Dodderi ChidanandENCTOOLPATH ?= tools/encrypt_fw 106c5e1da83SJayanth Dodderi ChidanandENCTOOL ?= ${ENCTOOLPATH}/encrypt_fw${BIN_EXT} 107c5e1da83SJayanth Dodderi Chidanand 108c5e1da83SJayanth Dodderi Chidanand# Variables for use with Firmware Image Package 109c5e1da83SJayanth Dodderi ChidanandFIPTOOLPATH ?= tools/fiptool 110c5e1da83SJayanth Dodderi ChidanandFIPTOOL ?= ${FIPTOOLPATH}/fiptool${BIN_EXT} 111c5e1da83SJayanth Dodderi Chidanand 112c5e1da83SJayanth Dodderi Chidanand# Variables for use with sptool 113c5e1da83SJayanth Dodderi ChidanandSPTOOLPATH ?= tools/sptool 114c5e1da83SJayanth Dodderi ChidanandSPTOOL ?= ${SPTOOLPATH}/sptool.py 115c5e1da83SJayanth Dodderi ChidanandSP_MK_GEN ?= ${SPTOOLPATH}/sp_mk_generator.py 11620629b31SKarl MeakinSP_DTS_LIST_FRAGMENT ?= ${BUILD_PLAT}/sp_list_fragment.dts 117c5e1da83SJayanth Dodderi Chidanand 118c5e1da83SJayanth Dodderi Chidanand# Variables for use with ROMLIB 119c5e1da83SJayanth Dodderi ChidanandROMLIBPATH ?= lib/romlib 120c5e1da83SJayanth Dodderi Chidanand 121c5e1da83SJayanth Dodderi Chidanand# Variable for use with Python 122c5e1da83SJayanth Dodderi ChidanandPYTHON ?= python3 123c5e1da83SJayanth Dodderi Chidanand 124c5e1da83SJayanth Dodderi Chidanand# Variables for use with documentation build using Sphinx tool 125c5e1da83SJayanth Dodderi ChidanandDOCS_PATH ?= docs 126c5e1da83SJayanth Dodderi Chidanand 127c5e1da83SJayanth Dodderi Chidanand################################################################################ 128c5e1da83SJayanth Dodderi Chidanand# Compiler Configuration based on ARCH_MAJOR and ARCH_MINOR flags 129c5e1da83SJayanth Dodderi Chidanand################################################################################ 13026e63c44SEtienne Carriereifeq (${ARM_ARCH_MAJOR},7) 13126e63c44SEtienne Carriere target32-directive = -target arm-none-eabi 132d4089fb8SGovindraj Raja# Will set march-directive from platform configuration 13326e63c44SEtienne Carriereelse 13426e63c44SEtienne Carriere target32-directive = -target armv8a-none-eabi 135c5e1da83SJayanth Dodderi Chidanandendif #(ARM_ARCH_MAJOR) 136c5e1da83SJayanth Dodderi Chidanand 137c5e1da83SJayanth Dodderi Chidanand################################################################################ 138c5e1da83SJayanth Dodderi Chidanand# Get Architecture Feature Modifiers 139c5e1da83SJayanth Dodderi Chidanand################################################################################ 140c5e1da83SJayanth Dodderi Chidanandarch-features = ${ARM_ARCH_FEATURE} 141c5e1da83SJayanth Dodderi Chidanand 1428620bd0bSChris Kayifneq ($(filter %-clang,$($(ARCH)-cc-id)),) 1438620bd0bSChris Kay ifeq ($($(ARCH)-cc-id),arm-clang) 1447794d6c8SGovindraj Raja TF_CFLAGS_aarch32 := -target arm-arm-none-eabi 1457794d6c8SGovindraj Raja TF_CFLAGS_aarch64 := -target aarch64-arm-none-eabi 146c8a992fdSorigin else 1477794d6c8SGovindraj Raja TF_CFLAGS_aarch32 = $(target32-directive) 1487794d6c8SGovindraj Raja TF_CFLAGS_aarch64 := -target aarch64-elf 149641f16e7SAmbroise Vincent endif 150c8a992fdSorigin 1518620bd0bSChris Kayelse ifeq ($($(ARCH)-cc-id),gnu-gcc) 152edbce9aaSzelalem-aweke # Enable LTO only for aarch64 153edbce9aaSzelalem-aweke ifeq (${ARCH},aarch64) 154fa402f38SChris Kay LTO_CFLAGS = $(if $(filter-out 0,$(ENABLE_LTO)),-flto) 155edbce9aaSzelalem-aweke endif 156c5e1da83SJayanth Dodderi Chidanandendif #(clang) 157d5461857Sdp-arm 15832b209bfSAhmad Fatoum# Process Debug flag 15932b209bfSAhmad Fatoum$(eval $(call add_define,DEBUG)) 16032b209bfSAhmad Fatoumifneq (${DEBUG}, 0) 16132b209bfSAhmad Fatoum BUILD_TYPE := debug 1624466cf82SDaniel Boulby TF_CFLAGS += -g -gdwarf-4 1634466cf82SDaniel Boulby ASFLAGS += -g -Wa,-gdwarf-4 16432b209bfSAhmad Fatoum 16532b209bfSAhmad Fatoum # Use LOG_LEVEL_INFO by default for debug builds 16632b209bfSAhmad Fatoum LOG_LEVEL := 40 16732b209bfSAhmad Fatoumelse 16832b209bfSAhmad Fatoum BUILD_TYPE := release 16932b209bfSAhmad Fatoum # Use LOG_LEVEL_NOTICE by default for release builds 17032b209bfSAhmad Fatoum LOG_LEVEL := 20 171c5e1da83SJayanth Dodderi Chidanandendif #(Debug) 17232b209bfSAhmad Fatoum 173f1de4c8fSPeiyuan Song# Default build string (git branch and commit) 174f1de4c8fSPeiyuan Songifeq (${BUILD_STRING},) 175f1de4c8fSPeiyuan Song BUILD_STRING := $(shell git describe --always --dirty --tags 2> /dev/null) 176f1de4c8fSPeiyuan Songendif 177dddf4283Slaurenw-armVERSION_STRING := v${VERSION}(${BUILD_TYPE}):${BUILD_STRING} 178f1de4c8fSPeiyuan Song 1798fd9d4d5SAntonio Nino Diazifeq (${AARCH32_INSTRUCTION_SET},A32) 1808fd9d4d5SAntonio Nino Diaz TF_CFLAGS_aarch32 += -marm 1818fd9d4d5SAntonio Nino Diazelse ifeq (${AARCH32_INSTRUCTION_SET},T32) 1828fd9d4d5SAntonio Nino Diaz TF_CFLAGS_aarch32 += -mthumb 1838fd9d4d5SAntonio Nino Diazelse 1848fd9d4d5SAntonio Nino Diaz $(error Error: Unknown AArch32 instruction set ${AARCH32_INSTRUCTION_SET}) 185c5e1da83SJayanth Dodderi Chidanandendif #(AARCH32_INSTRUCTION_SET) 1868fd9d4d5SAntonio Nino Diaz 187a9c4dde3SSandrine BailleuxTF_CFLAGS_aarch32 += -mno-unaligned-access 188d5461857Sdp-armTF_CFLAGS_aarch64 += -mgeneral-regs-only -mstrict-align 1899d29c227SSoby Mathew 190c5e1da83SJayanth Dodderi Chidanand############################################################################## 191c5e1da83SJayanth Dodderi Chidanand# WARNINGS Configuration 192c5e1da83SJayanth Dodderi Chidanand############################################################################### 1939ab81b5eSJustin Chadwell# General warnings 1949ab81b5eSJustin ChadwellWARNINGS := -Wall -Wmissing-include-dirs -Wunused \ 195b7f6525dSJustin Chadwell -Wdisabled-optimization -Wvla -Wshadow \ 196d75a9ecdSBoyan Karatotev -Wredundant-decls 197d75a9ecdSBoyan Karatotev# stricter warnings 198d75a9ecdSBoyan KaratotevWARNINGS += -Wextra -Wno-trigraphs 199d75a9ecdSBoyan Karatotev# too verbose for generic build 200d75a9ecdSBoyan KaratotevWARNINGS += -Wno-missing-field-initializers \ 201d75a9ecdSBoyan Karatotev -Wno-type-limits -Wno-sign-compare \ 202d75a9ecdSBoyan Karatotev# on clang this flag gets reset if -Wextra is set after it. No difference on gcc 203d75a9ecdSBoyan KaratotevWARNINGS += -Wno-unused-parameter 2049ab81b5eSJustin Chadwell 2059ab81b5eSJustin Chadwell# Additional warnings 206d75a9ecdSBoyan Karatotev# Level 1 - infrequent warnings we should have none of 207d75a9ecdSBoyan Karatotev# full -Wextra 208d75a9ecdSBoyan KaratotevWARNING1 += -Wsign-compare 209d75a9ecdSBoyan KaratotevWARNING1 += -Wtype-limits 210d75a9ecdSBoyan KaratotevWARNING1 += -Wmissing-field-initializers 211e7c645b5SYann Gautier 212d75a9ecdSBoyan Karatotev# Level 2 - problematic warnings that we want 213d75a9ecdSBoyan Karatotev# zlib, compiler-rt, coreboot, and mbdedtls blow up with these 214d75a9ecdSBoyan Karatotev# TODO: disable just for them and move into default build 215d75a9ecdSBoyan KaratotevWARNING2 += -Wold-style-definition 216d75a9ecdSBoyan KaratotevWARNING2 += -Wmissing-prototypes 217d75a9ecdSBoyan KaratotevWARNING2 += -Wmissing-format-attribute 218d75a9ecdSBoyan Karatotev# TF-A aims to comply with this eventually. Effort too large at present 219d75a9ecdSBoyan KaratotevWARNING2 += -Wundef 220d141e638SBoyan Karatotev# currently very involved and many platforms set this off 221d141e638SBoyan KaratotevWARNING2 += -Wunused-const-variable=2 222e7c645b5SYann Gautier 223d75a9ecdSBoyan Karatotev# Level 3 - very pedantic, frequently ignored 224e7c645b5SYann GautierWARNING3 := -Wbad-function-cast 225d75a9ecdSBoyan KaratotevWARNING3 += -Waggregate-return 226d75a9ecdSBoyan KaratotevWARNING3 += -Wnested-externs 227d75a9ecdSBoyan KaratotevWARNING3 += -Wcast-align 228e7c645b5SYann GautierWARNING3 += -Wcast-qual 229e7c645b5SYann GautierWARNING3 += -Wconversion 230e7c645b5SYann GautierWARNING3 += -Wpacked 231e7c645b5SYann GautierWARNING3 += -Wpointer-arith 232e7c645b5SYann GautierWARNING3 += -Wswitch-default 233e7c645b5SYann Gautier 234d75a9ecdSBoyan Karatotev# Setting W is quite verbose and most warnings will be pre-existing issues 235d75a9ecdSBoyan Karatotev# outside of the contributor's control. Don't fail the build on them so warnings 236d75a9ecdSBoyan Karatotev# can be seen and hopefully addressed 237d75a9ecdSBoyan Karatotevifdef W 238d75a9ecdSBoyan Karatotev ifneq (${W},0) 239d75a9ecdSBoyan Karatotev E ?= 0 240d75a9ecdSBoyan Karatotev endif 241d75a9ecdSBoyan Karatotevendif 242d75a9ecdSBoyan Karatotev 243e7c645b5SYann Gautierifeq (${W},1) 2449ab81b5eSJustin Chadwell WARNINGS += $(WARNING1) 245e7c645b5SYann Gautierelse ifeq (${W},2) 2469ab81b5eSJustin Chadwell WARNINGS += $(WARNING1) $(WARNING2) 247e7c645b5SYann Gautierelse ifeq (${W},3) 2489ab81b5eSJustin Chadwell WARNINGS += $(WARNING1) $(WARNING2) $(WARNING3) 249c5e1da83SJayanth Dodderi Chidanandendif #(W) 250e7c645b5SYann Gautier 2519ab81b5eSJustin Chadwell# Compiler specific warnings 2528620bd0bSChris Kayifeq ($(filter %-clang,$($(ARCH)-cc-id)),) 25393c690ebSJustin Chadwell# not using clang 254d7b4cd41SJustin ChadwellWARNINGS += -Wunused-but-set-variable -Wmaybe-uninitialized \ 255d7b4cd41SJustin Chadwell -Wpacked-bitfield-compat -Wshift-overflow=2 \ 256d7b4cd41SJustin Chadwell -Wlogical-op 257dea23e24SGovindraj Raja 258dea23e24SGovindraj Raja# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105523 259dea23e24SGovindraj RajaTF_CFLAGS += $(call cc_option, --param=min-pagesize=0) 260dea23e24SGovindraj Raja 261538516f5SBipin Raviifeq ($(HARDEN_SLS), 1) 262538516f5SBipin Ravi TF_CFLAGS_aarch64 += $(call cc_option, -mharden-sls=all) 263538516f5SBipin Raviendif 264538516f5SBipin Ravi 26593c690ebSJustin Chadwellelse 26693c690ebSJustin Chadwell# using clang 267d7b4cd41SJustin ChadwellWARNINGS += -Wshift-overflow -Wshift-sign-overflow \ 268d7b4cd41SJustin Chadwell -Wlogical-op-parentheses 269c5e1da83SJayanth Dodderi Chidanandendif #(Clang Warning) 27000296576SAmbroise Vincent 2716336b07aSYann Gautierifneq (${E},0) 2726336b07aSYann Gautier ERRORS := -Werror 273c5e1da83SJayanth Dodderi Chidanandendif #(E) 2746336b07aSYann Gautier 275c5e1da83SJayanth Dodderi Chidanand################################################################################ 276c5e1da83SJayanth Dodderi Chidanand# Compiler and Linker Directives 277c5e1da83SJayanth Dodderi Chidanand################################################################################ 278ea7a57a3SRoberto VargasCPPFLAGS = ${DEFINES} ${INCLUDES} ${MBEDTLS_INC} -nostdinc \ 2799ab81b5eSJustin Chadwell $(ERRORS) $(WARNINGS) 280d4089fb8SGovindraj RajaASFLAGS += $(CPPFLAGS) \ 281d5dfdeb6SJulius Werner -ffreestanding -Wa,--fatal-warnings 28259de5096SMasahiro YamadaTF_CFLAGS += $(CPPFLAGS) $(TF_CFLAGS_$(ARCH)) \ 283ebd6efaeSSamuel Holland -ffunction-sections -fdata-sections \ 284ebd6efaeSSamuel Holland -ffreestanding -fno-builtin -fno-common \ 285ebd6efaeSSamuel Holland -Os -std=gnu99 28673c99d4eSJuan Castillo 2871f461979SJustin Chadwellifeq (${SANITIZE_UB},on) 2881f461979SJustin Chadwell TF_CFLAGS += -fsanitize=undefined -fno-sanitize-recover 289c5e1da83SJayanth Dodderi Chidanandendif #(${SANITIZE_UB},on) 290c5e1da83SJayanth Dodderi Chidanand 2911f461979SJustin Chadwellifeq (${SANITIZE_UB},trap) 2921f461979SJustin Chadwell TF_CFLAGS += -fsanitize=undefined -fno-sanitize-recover \ 2931f461979SJustin Chadwell -fsanitize-undefined-trap-on-error 294c5e1da83SJayanth Dodderi Chidanandendif #(${SANITIZE_UB},trap) 2951f461979SJustin Chadwell 296291e7182SChris KayGCC_V_OUTPUT := $(if $($(ARCH)-cc),$(shell $($(ARCH)-cc) -v 2>&1)) 297f7ec31dbSdavid cunado 2981f49db5fSMarco FelschTF_LDFLAGS += -z noexecstack 2991f49db5fSMarco Felsch 300641f16e7SAmbroise Vincent# LD = armlink 3018620bd0bSChris Kayifeq ($($(ARCH)-ld-id),arm-link) 302c2ad38ceSVarun Wadekar TF_LDFLAGS += --diag_error=warning --lto_level=O1 303c2ad38ceSVarun Wadekar TF_LDFLAGS += --remove --info=unused,unusedsymbols 304edbce9aaSzelalem-aweke TF_LDFLAGS += $(TF_LDFLAGS_$(ARCH)) 305641f16e7SAmbroise Vincent 306641f16e7SAmbroise Vincent# LD = gcc (used when GCC LTO is enabled) 3078620bd0bSChris Kayelse ifeq ($($(ARCH)-ld-id),gnu-gcc) 308edbce9aaSzelalem-aweke # Pass ld options with Wl or Xlinker switches 30986e489c1SChris Kay TF_LDFLAGS += $(call ld_option,-Xlinker --no-warn-rwx-segments) 310edbce9aaSzelalem-aweke TF_LDFLAGS += -Wl,--fatal-warnings -O1 311edbce9aaSzelalem-aweke TF_LDFLAGS += -Wl,--gc-sections 312ac98b82aSChris Kay 313ac98b82aSChris Kay TF_LDFLAGS += -Wl,-z,common-page-size=4096 #Configure page size constants 314ac98b82aSChris Kay TF_LDFLAGS += -Wl,-z,max-page-size=4096 315304ad94bSAndrey Skvortsov TF_LDFLAGS += -Wl,--build-id=none 316ac98b82aSChris Kay 317edbce9aaSzelalem-aweke ifeq ($(ENABLE_LTO),1) 318edbce9aaSzelalem-aweke ifeq (${ARCH},aarch64) 319edbce9aaSzelalem-aweke TF_LDFLAGS += -flto -fuse-linker-plugin 32031f80efeSAndrey Skvortsov TF_LDFLAGS += -flto-partition=one 321edbce9aaSzelalem-aweke endif 322c5e1da83SJayanth Dodderi Chidanand endif #(ENABLE_LTO) 323c5e1da83SJayanth Dodderi Chidanand 324edbce9aaSzelalem-aweke# GCC automatically adds fix-cortex-a53-843419 flag when used to link 325edbce9aaSzelalem-aweke# which breaks some builds, so disable if errata fix is not explicitly enabled 326cfe6767fSYann Gautier ifeq (${ARCH},aarch64) 327edbce9aaSzelalem-aweke ifneq (${ERRATA_A53_843419},1) 328edbce9aaSzelalem-aweke TF_LDFLAGS += -mno-fix-cortex-a53-843419 329edbce9aaSzelalem-aweke endif 330cfe6767fSYann Gautier endif 331edbce9aaSzelalem-aweke TF_LDFLAGS += -nostdlib 332edbce9aaSzelalem-aweke TF_LDFLAGS += $(subst --,-Xlinker --,$(TF_LDFLAGS_$(ARCH))) 333641f16e7SAmbroise Vincent 334641f16e7SAmbroise Vincent# LD = gcc-ld (ld) or llvm-ld (ld.lld) or other 335c2ad38ceSVarun Wadekarelse 3361f49db5fSMarco Felsch# With ld.bfd version 2.39 and newer new warnings are added. Skip those since we 3371f49db5fSMarco Felsch# are not loaded by a elf loader. 3381f49db5fSMarco Felsch TF_LDFLAGS += $(call ld_option, --no-warn-rwx-segments) 339ebac6922SYabin Cui TF_LDFLAGS += -O1 340c2b8806fSDouglas Raillard TF_LDFLAGS += --gc-sections 341ac98b82aSChris Kay 342ac98b82aSChris Kay TF_LDFLAGS += -z common-page-size=4096 # Configure page size constants 343ac98b82aSChris Kay TF_LDFLAGS += -z max-page-size=4096 344304ad94bSAndrey Skvortsov TF_LDFLAGS += --build-id=none 345ac98b82aSChris Kay 346641f16e7SAmbroise Vincent# ld.lld doesn't recognize the errata flags, 347ebac6922SYabin Cui# therefore don't add those in that case. 348ebac6922SYabin Cui# ld.lld reports section type mismatch warnings, 349ebac6922SYabin Cui# therefore don't add --fatal-warnings to it. 3508620bd0bSChris Kay ifneq ($($(ARCH)-ld-id),llvm-lld) 351ebac6922SYabin Cui TF_LDFLAGS += $(TF_LDFLAGS_$(ARCH)) --fatal-warnings 352edbce9aaSzelalem-aweke endif 353c5e1da83SJayanth Dodderi Chidanand 354c5e1da83SJayanth Dodderi Chidanandendif #(LD = armlink) 35573c99d4eSJuan Castillo 35673c99d4eSJuan Castillo################################################################################ 357f5211420SGovindraj Raja# Setup ARCH_MAJOR/MINOR before parsing arch_features. 358f5211420SGovindraj Raja################################################################################ 359f5211420SGovindraj Rajaifeq (${ENABLE_RME},1) 3607d5fc98fSAlexeiFedorov ARM_ARCH_MAJOR := 9 3617d5fc98fSAlexeiFedorov ARM_ARCH_MINOR := 2 362f5211420SGovindraj Rajaendif 363f5211420SGovindraj Raja 364f5211420SGovindraj Raja################################################################################ 36573c99d4eSJuan Castillo# Common sources and include directories 36673c99d4eSJuan Castillo################################################################################ 367d801fbb0Sdp-arminclude lib/compiler-rt/compiler-rt.mk 36873c99d4eSJuan Castillo 369758ccb80SChris Kay# Allow overriding the timestamp, for example for reproducible builds, or to 370758ccb80SChris Kay# synchronize timestamps across multiple projects. 371758ccb80SChris Kay# This must be set to a C string (including quotes where applicable). 372758ccb80SChris KayBUILD_MESSAGE_TIMESTAMP ?= __TIME__", "__DATE__ 373758ccb80SChris Kay 374758ccb80SChris KayDEFINES += -DBUILD_MESSAGE_TIMESTAMP='$(BUILD_MESSAGE_TIMESTAMP)' 375758ccb80SChris KayDEFINES += -DBUILD_MESSAGE_VERSION_STRING='"$(VERSION_STRING)"' 376758ccb80SChris KayDEFINES += -DBUILD_MESSAGE_VERSION='"$(VERSION)"' 377758ccb80SChris Kay 37873c99d4eSJuan CastilloBL_COMMON_SOURCES += common/bl_common.c \ 3797f56e9a3SSoby Mathew common/tf_log.c \ 3809d29c227SSoby Mathew common/${ARCH}/debug.S \ 38191b48c9fSJulius Werner drivers/console/multi_console.c \ 3829d29c227SSoby Mathew lib/${ARCH}/cache_helpers.S \ 3839d29c227SSoby Mathew lib/${ARCH}/misc_helpers.S \ 384c73686a1SBoyan Karatotev lib/extensions/pmuv3/${ARCH}/pmuv3.c \ 385566034fcSSoby Mathew plat/common/plat_bl_common.c \ 3867f56e9a3SSoby Mathew plat/common/plat_log_common.c \ 38775311203Sdp-arm plat/common/${ARCH}/plat_common.c \ 3889d29c227SSoby Mathew plat/common/${ARCH}/platform_helpers.S \ 38961f72a34SRoberto Vargas ${COMPILER_RT_SRCS} 390d7a6b0f8SRyan Harkin 3918620bd0bSChris Kayifeq ($($(ARCH)-cc-id),arm-clang) 3928422a840SAntonio Nino Diaz BL_COMMON_SOURCES += lib/${ARCH}/armclang_printf.S 3938422a840SAntonio Nino Diazendif 3948422a840SAntonio Nino Diaz 3951f461979SJustin Chadwellifeq (${SANITIZE_UB},on) 3961f461979SJustin Chadwell BL_COMMON_SOURCES += plat/common/ubsan.c 3971f461979SJustin Chadwellendif 3981f461979SJustin Chadwell 39901d237cbSYann GautierINCLUDES += -Iinclude \ 400f5478dedSAntonio Nino Diaz -Iinclude/arch/${ARCH} \ 40109d40e0eSAntonio Nino Diaz -Iinclude/lib/cpus/${ARCH} \ 40209d40e0eSAntonio Nino Diaz -Iinclude/lib/el3_runtime/${ARCH} \ 40309d40e0eSAntonio Nino Diaz ${PLAT_INCLUDES} \ 40409d40e0eSAntonio Nino Diaz ${SPD_INCLUDES} 40509d40e0eSAntonio Nino Diaz 406e03dcc8fSNishant SharmaDTC_FLAGS += -I dts -O dtb 407e03dcc8fSNishant SharmaDTC_CPPFLAGS += -P -nostdinc $(INCLUDES) -Ifdts -undef \ 408e03dcc8fSNishant Sharma -x assembler-with-cpp $(DEFINES) 409e03dcc8fSNishant Sharma 4109c6d1c50SAntonio Nino Diazinclude common/backtrace/backtrace.mk 4119c6d1c50SAntonio Nino Diaz 41273c99d4eSJuan Castillo################################################################################ 4133547270fSGovindraj Raja# Generic definitions 4143547270fSGovindraj Raja################################################################################ 4153547270fSGovindraj Raja 4163547270fSGovindraj Rajaifeq (${BUILD_BASE},) 4173547270fSGovindraj Raja BUILD_BASE := ./build 4183547270fSGovindraj Rajaendif 4193547270fSGovindraj RajaBUILD_PLAT := $(abspath ${BUILD_BASE})/${PLAT}/${BUILD_TYPE} 4203547270fSGovindraj Raja 4213547270fSGovindraj RajaSPDS := $(sort $(filter-out none, $(patsubst services/spd/%,%,$(wildcard services/spd/*)))) 4223547270fSGovindraj Raja 4233547270fSGovindraj Raja# Platforms providing their own TBB makefile may override this value 4243547270fSGovindraj RajaINCLUDE_TBBR_MK := 1 4253547270fSGovindraj Raja 4263547270fSGovindraj Raja################################################################################ 4273547270fSGovindraj Raja# Include SPD Makefile if one has been specified 4283547270fSGovindraj Raja################################################################################ 4293547270fSGovindraj Raja 4303547270fSGovindraj Rajaifneq (${SPD},none) 4313547270fSGovindraj Raja ifeq (${ARCH},aarch32) 4323547270fSGovindraj Raja $(error "Error: SPD is incompatible with AArch32.") 4333547270fSGovindraj Raja endif 4343547270fSGovindraj Raja 4353547270fSGovindraj Raja ifdef EL3_PAYLOAD_BASE 4363547270fSGovindraj Raja $(warning "SPD and EL3_PAYLOAD_BASE are incompatible build options.") 4373547270fSGovindraj Raja $(warning "The SPD and its BL32 companion will be present but \ 4383547270fSGovindraj Raja ignored.") 4393547270fSGovindraj Raja endif 4403547270fSGovindraj Raja 4413547270fSGovindraj Raja ifeq (${SPD},spmd) 4423547270fSGovindraj Raja # SPMD is located in std_svc directory 4433547270fSGovindraj Raja SPD_DIR := std_svc 4443547270fSGovindraj Raja 4453547270fSGovindraj Raja ifeq ($(SPMD_SPM_AT_SEL2),1) 4463547270fSGovindraj Raja CTX_INCLUDE_EL2_REGS := 1 4473547270fSGovindraj Raja ifeq ($(SPMC_AT_EL3),1) 4483547270fSGovindraj Raja $(error SPM cannot be enabled in both S-EL2 and EL3.) 4493547270fSGovindraj Raja endif 45059bdcc58SMadhukar Pappireddy ifeq ($(CTX_INCLUDE_SVE_REGS),1) 45159bdcc58SMadhukar Pappireddy $(error SVE context management not needed with Hafnium SPMC.) 45259bdcc58SMadhukar Pappireddy endif 4533547270fSGovindraj Raja endif 4543547270fSGovindraj Raja 4553547270fSGovindraj Raja ifeq ($(findstring optee_sp,$(ARM_SPMC_MANIFEST_DTS)),optee_sp) 4563547270fSGovindraj Raja DTC_CPPFLAGS += -DOPTEE_SP_FW_CONFIG 4573547270fSGovindraj Raja endif 4583547270fSGovindraj Raja 4590686a01bSArunachalam Ganapathy ifeq ($(findstring trusty_sp,$(ARM_SPMC_MANIFEST_DTS)),trusty_sp) 4600686a01bSArunachalam Ganapathy DTC_CPPFLAGS += -DTRUSTY_SP_FW_CONFIG 4610686a01bSArunachalam Ganapathy endif 4620686a01bSArunachalam Ganapathy 4633547270fSGovindraj Raja ifeq ($(TS_SP_FW_CONFIG),1) 4643547270fSGovindraj Raja DTC_CPPFLAGS += -DTS_SP_FW_CONFIG 4653547270fSGovindraj Raja endif 4663547270fSGovindraj Raja 4673547270fSGovindraj Raja ifneq ($(ARM_BL2_SP_LIST_DTS),) 4683547270fSGovindraj Raja DTC_CPPFLAGS += -DARM_BL2_SP_LIST_DTS=$(ARM_BL2_SP_LIST_DTS) 4693547270fSGovindraj Raja endif 4703547270fSGovindraj Raja 4713547270fSGovindraj Raja ifneq ($(SP_LAYOUT_FILE),) 4723547270fSGovindraj Raja BL2_ENABLE_SP_LOAD := 1 4733547270fSGovindraj Raja endif 474c189adbdSGovindraj Raja 475c189adbdSGovindraj Raja ifeq ($(SPMC_AT_EL3_SEL0_SP),1) 476c189adbdSGovindraj Raja ifneq ($(SPMC_AT_EL3),1) 477c189adbdSGovindraj Raja $(error SEL0 SP cannot be enabled without SPMC at EL3) 478c189adbdSGovindraj Raja endif 479c189adbdSGovindraj Raja endif 4803547270fSGovindraj Raja else 4813547270fSGovindraj Raja # All other SPDs in spd directory 4823547270fSGovindraj Raja SPD_DIR := spd 4833547270fSGovindraj Raja endif #(SPD) 4843547270fSGovindraj Raja 4853547270fSGovindraj Raja # We expect to locate an spd.mk under the specified SPD directory 4863547270fSGovindraj Raja SPD_MAKE := $(wildcard services/${SPD_DIR}/${SPD}/${SPD}.mk) 4873547270fSGovindraj Raja 4883547270fSGovindraj Raja ifeq (${SPD_MAKE},) 4893547270fSGovindraj Raja $(error Error: No services/${SPD_DIR}/${SPD}/${SPD}.mk located) 4903547270fSGovindraj Raja endif 4913547270fSGovindraj Raja $(info Including ${SPD_MAKE}) 4923547270fSGovindraj Raja include ${SPD_MAKE} 4933547270fSGovindraj Raja 4943547270fSGovindraj Raja # If there's BL32 companion for the chosen SPD, we expect that the SPD's 4953547270fSGovindraj Raja # Makefile would set NEED_BL32 to "yes". In this case, the build system 4963547270fSGovindraj Raja # supports two mutually exclusive options: 4973547270fSGovindraj Raja # * BL32 is built from source: then BL32_SOURCES must contain the list 4983547270fSGovindraj Raja # of source files to build BL32 4993547270fSGovindraj Raja # * BL32 is a prebuilt binary: then BL32 must point to the image file 5003547270fSGovindraj Raja # that will be included in the FIP 5013547270fSGovindraj Raja # If both BL32_SOURCES and BL32 are defined, the binary takes precedence 5023547270fSGovindraj Raja # over the sources. 5033547270fSGovindraj Rajaendif #(SPD=none) 5043547270fSGovindraj Raja 5053547270fSGovindraj Rajaifeq (${ENABLE_SPMD_LP}, 1) 5063547270fSGovindraj Rajaifneq (${SPD},spmd) 5073547270fSGovindraj Raja $(error Error: ENABLE_SPMD_LP requires SPD=spmd.) 5083547270fSGovindraj Rajaendif 5093547270fSGovindraj Rajaifeq ($(SPMC_AT_EL3),1) 5103547270fSGovindraj Raja $(error SPMC at EL3 not supported when enabling SPMD Logical partitions.) 5113547270fSGovindraj Rajaendif 5123547270fSGovindraj Rajaendif 5133547270fSGovindraj Raja 5143547270fSGovindraj Raja################################################################################ 515f5211420SGovindraj Raja# Process BRANCH_PROTECTION value and set 516f5211420SGovindraj Raja# Pointer Authentication and Branch Target Identification flags 517f5211420SGovindraj Raja################################################################################ 518f5211420SGovindraj Rajaifeq (${BRANCH_PROTECTION},0) 519f5211420SGovindraj Raja # Default value turns off all types of branch protection 520f5211420SGovindraj Raja BP_OPTION := none 521f5211420SGovindraj Rajaelse ifneq (${ARCH},aarch64) 522f5211420SGovindraj Raja $(error BRANCH_PROTECTION requires AArch64) 523f5211420SGovindraj Rajaelse ifeq (${BRANCH_PROTECTION},1) 524f5211420SGovindraj Raja # Enables all types of branch protection features 525f5211420SGovindraj Raja BP_OPTION := standard 526f5211420SGovindraj Raja ENABLE_BTI := 1 527f5211420SGovindraj Raja ENABLE_PAUTH := 1 528f5211420SGovindraj Rajaelse ifeq (${BRANCH_PROTECTION},2) 529f5211420SGovindraj Raja # Return address signing to its standard level 530f5211420SGovindraj Raja BP_OPTION := pac-ret 531f5211420SGovindraj Raja ENABLE_PAUTH := 1 532f5211420SGovindraj Rajaelse ifeq (${BRANCH_PROTECTION},3) 533f5211420SGovindraj Raja # Extend the signing to include leaf functions 534f5211420SGovindraj Raja BP_OPTION := pac-ret+leaf 535f5211420SGovindraj Raja ENABLE_PAUTH := 1 536f5211420SGovindraj Rajaelse ifeq (${BRANCH_PROTECTION},4) 537f5211420SGovindraj Raja # Turn on branch target identification mechanism 538f5211420SGovindraj Raja BP_OPTION := bti 539f5211420SGovindraj Raja ENABLE_BTI := 1 540f5211420SGovindraj Rajaelse 541f5211420SGovindraj Raja $(error Unknown BRANCH_PROTECTION value ${BRANCH_PROTECTION}) 542f5211420SGovindraj Rajaendif #(BRANCH_PROTECTION) 543f5211420SGovindraj Raja 544f5211420SGovindraj Rajaifeq ($(ENABLE_PAUTH),1) 545f5211420SGovindraj Raja CTX_INCLUDE_PAUTH_REGS := 1 546f5211420SGovindraj Rajaendif 547f5211420SGovindraj Rajaifneq (${BP_OPTION},none) 548f5211420SGovindraj Raja TF_CFLAGS_aarch64 += -mbranch-protection=${BP_OPTION} 549f5211420SGovindraj Rajaendif #(BP_OPTION) 550f5211420SGovindraj Raja 551f5211420SGovindraj Raja# Pointer Authentication sources 552f5211420SGovindraj Rajaifeq (${ENABLE_PAUTH}, 1) 553f5211420SGovindraj Raja# arm/common/aarch64/arm_pauth.c contains a sample platform hook to complete the 554f5211420SGovindraj Raja# Pauth support. As it's not secure, it must be reimplemented for real platforms 555f5211420SGovindraj Raja BL_COMMON_SOURCES += lib/extensions/pauth/pauth_helpers.S 556f5211420SGovindraj Rajaendif 557f5211420SGovindraj Raja 5583547270fSGovindraj Raja################################################################################ 5593547270fSGovindraj Raja# Include the platform specific Makefile after the SPD Makefile (the platform 5603547270fSGovindraj Raja# makefile may use all previous definitions in this file) 5613547270fSGovindraj Raja################################################################################ 5623547270fSGovindraj Rajainclude ${PLAT_MAKEFILE_FULL} 5633547270fSGovindraj Raja 5643547270fSGovindraj Raja################################################################################ 5653547270fSGovindraj Raja# Setup arch_features based on ARM_ARCH_MAJOR, ARM_ARCH_MINOR provided from 5663547270fSGovindraj Raja# platform. 5673547270fSGovindraj Raja################################################################################ 5683547270fSGovindraj Rajainclude ${MAKE_HELPERS_DIRECTORY}arch_features.mk 5693547270fSGovindraj Raja 570f5211420SGovindraj Raja#################################################### 571f5211420SGovindraj Raja# Enable required options for Memory Stack Tagging. 572f5211420SGovindraj Raja#################################################### 573f5211420SGovindraj Raja 574f5211420SGovindraj Raja# Currently, these options are enabled only for clang and armclang compiler. 575f5211420SGovindraj Rajaifeq (${SUPPORT_STACK_MEMTAG},yes) 576f5211420SGovindraj Raja ifdef mem_tag_arch_support 577f5211420SGovindraj Raja # Check for armclang and clang compilers 5788620bd0bSChris Kay ifneq ($(filter %-clang,$($(ARCH)-cc-id)),) 579f5211420SGovindraj Raja # Add "memtag" architecture feature modifier if not specified 580f5211420SGovindraj Raja ifeq ( ,$(findstring memtag,$(arch-features))) 581f5211420SGovindraj Raja arch-features := $(arch-features)+memtag 582f5211420SGovindraj Raja endif # memtag 5838620bd0bSChris Kay ifeq ($($(ARCH)-cc-id),arm-clang) 584f5211420SGovindraj Raja TF_CFLAGS += -mmemtag-stack 5858620bd0bSChris Kay else ifeq ($($(ARCH)-cc-id),llvm-clang) 586f5211420SGovindraj Raja TF_CFLAGS += -fsanitize=memtag 587f5211420SGovindraj Raja endif # armclang 588f5211420SGovindraj Raja endif 589f5211420SGovindraj Raja else 590f5211420SGovindraj Raja $(error "Error: stack memory tagging is not supported for \ 591f5211420SGovindraj Raja architecture ${ARCH},armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a") 592f5211420SGovindraj Raja endif #(mem_tag_arch_support) 593f5211420SGovindraj Rajaendif #(SUPPORT_STACK_MEMTAG) 594f5211420SGovindraj Raja 595f5211420SGovindraj Raja################################################################################ 596f5211420SGovindraj Raja# RME dependent flags configuration, Enable optional features for RME. 597f5211420SGovindraj Raja################################################################################ 598f5211420SGovindraj Raja# FEAT_RME 599f5211420SGovindraj Rajaifeq (${ENABLE_RME},1) 600f5211420SGovindraj Raja # RME doesn't support PIE 601f5211420SGovindraj Raja ifneq (${ENABLE_PIE},0) 602f5211420SGovindraj Raja $(error ENABLE_RME does not support PIE) 603f5211420SGovindraj Raja endif 604f5211420SGovindraj Raja 605f5211420SGovindraj Raja # RME requires AARCH64 606f5211420SGovindraj Raja ifneq (${ARCH},aarch64) 607f5211420SGovindraj Raja $(error ENABLE_RME requires AArch64) 608f5211420SGovindraj Raja endif 609f5211420SGovindraj Raja 610f5211420SGovindraj Raja # RME requires el2 context to be saved for now. 611f5211420SGovindraj Raja CTX_INCLUDE_EL2_REGS := 1 612f5211420SGovindraj Raja CTX_INCLUDE_AARCH32_REGS := 0 613f5211420SGovindraj Raja CTX_INCLUDE_PAUTH_REGS := 1 614f5211420SGovindraj Raja 615f5211420SGovindraj Raja # RME enables CSV2_2 extension by default. 616f5211420SGovindraj Raja ENABLE_FEAT_CSV2_2 = 1 617f5211420SGovindraj Rajaendif #(FEAT_RME) 618f5211420SGovindraj Raja 619f5211420SGovindraj Raja################################################################################ 6205b18de09SZelalem Aweke# Include rmmd Makefile if RME is enabled 6215b18de09SZelalem Aweke################################################################################ 6225b18de09SZelalem Awekeifneq (${ENABLE_RME},0) 6235b18de09SZelalem Aweke ifneq (${ARCH},aarch64) 6245b18de09SZelalem Aweke $(error ENABLE_RME requires AArch64) 6255b18de09SZelalem Aweke endif 6261d63ae4dSMarc Bonnici ifeq ($(SPMC_AT_EL3),1) 6271d63ae4dSMarc Bonnici $(error SPMC_AT_EL3 and ENABLE_RME cannot both be enabled.) 6281d63ae4dSMarc Bonnici endif 629c5e1da83SJayanth Dodderi Chidanand 6304fba2e1fSBoyan Karatotev ifneq (${SPD}, none) 6314fba2e1fSBoyan Karatotev ifneq (${SPD}, spmd) 6324fba2e1fSBoyan Karatotev $(error ENABLE_RME is incompatible with SPD=${SPD}. Use SPD=spmd) 6334fba2e1fSBoyan Karatotev endif 6344fba2e1fSBoyan Karatotev endif 6355b18de09SZelalem Awekeinclude services/std_svc/rmmd/rmmd.mk 6365b18de09SZelalem Aweke$(warning "RME is an experimental feature") 6375b18de09SZelalem Awekeendif 6385b18de09SZelalem Aweke 6393547270fSGovindraj Rajaifeq (${CTX_INCLUDE_EL2_REGS}, 1) 6403547270fSGovindraj Raja ifeq (${SPD},none) 6413547270fSGovindraj Raja ifeq (${ENABLE_RME},0) 6423547270fSGovindraj Raja $(error CTX_INCLUDE_EL2_REGS is available only when SPD \ 6433547270fSGovindraj Raja or RME is enabled) 6443547270fSGovindraj Raja endif 6453547270fSGovindraj Raja endif 6463547270fSGovindraj Rajaendif 6470f21c547SJuan Castillo 6487794d6c8SGovindraj Raja################################################################################ 649*30655136SGovindraj Raja# Make 128-Bit sysreg read/writes availabe when FEAT_D128 is enabled. 650*30655136SGovindraj Raja################################################################################ 651*30655136SGovindraj Rajaifneq (${ENABLE_FEAT_D128}, 0) 652*30655136SGovindraj Raja BL_COMMON_SOURCES += lib/extensions/sysreg128/sysreg128.S 653*30655136SGovindraj Rajaendif 654*30655136SGovindraj Raja 655*30655136SGovindraj Raja################################################################################ 6567794d6c8SGovindraj Raja# Platform specific Makefile might provide us ARCH_MAJOR/MINOR use that to come 6577794d6c8SGovindraj Raja# up with appropriate march values for compiler. 6587794d6c8SGovindraj Raja################################################################################ 6597794d6c8SGovindraj Rajainclude ${MAKE_HELPERS_DIRECTORY}march.mk 6607794d6c8SGovindraj Raja 6617794d6c8SGovindraj RajaTF_CFLAGS += $(march-directive) 6627275ac2aSGovindraj RajaASFLAGS += $(march-directive) 6637794d6c8SGovindraj Raja 66442d4d3baSArvind Ram Prakash# This internal flag is common option which is set to 1 for scenarios 66542d4d3baSArvind Ram Prakash# when the BL2 is running in EL3 level. This occurs in two scenarios - 66642d4d3baSArvind Ram Prakash# 4 world system running BL2 at EL3 and two world system without BL1 running 66742d4d3baSArvind Ram Prakash# BL2 in EL3 66842d4d3baSArvind Ram Prakash 66942d4d3baSArvind Ram Prakashifeq (${RESET_TO_BL2},1) 67042d4d3baSArvind Ram Prakash BL2_RUNS_AT_EL3 := 1 67142d4d3baSArvind Ram Prakash ifeq (${ENABLE_RME},1) 672c5e1da83SJayanth Dodderi Chidanand $(error RESET_TO_BL2=1 and ENABLE_RME=1 configuration is not \ 673c5e1da83SJayanth Dodderi Chidanand supported at the moment.) 67442d4d3baSArvind Ram Prakash endif 67542d4d3baSArvind Ram Prakashelse ifeq (${ENABLE_RME},1) 67642d4d3baSArvind Ram Prakash BL2_RUNS_AT_EL3 := 1 67742d4d3baSArvind Ram Prakashelse 67842d4d3baSArvind Ram Prakash BL2_RUNS_AT_EL3 := 0 67942d4d3baSArvind Ram Prakashendif 68042d4d3baSArvind Ram Prakash 681f87e54f7SManish Pandey# This internal flag is set to 1 when Firmware First handling of External aborts 682f87e54f7SManish Pandey# is required by lowe ELs. Currently only NS requires this support. 683f87e54f7SManish Pandeyifeq ($(HANDLE_EA_EL3_FIRST_NS),1) 684f87e54f7SManish Pandey FFH_SUPPORT := 1 685f87e54f7SManish Pandeyelse 686f87e54f7SManish Pandey FFH_SUPPORT := 0 687f87e54f7SManish Pandeyendif 688f87e54f7SManish Pandey 68926e63c44SEtienne Carriereifeq (${ARM_ARCH_MAJOR},7) 69026e63c44SEtienne Carriereinclude make_helpers/armv7-a-cpus.mk 69126e63c44SEtienne Carriereendif 69226e63c44SEtienne Carriere 6933bd17c0fSSoby MathewPIE_FOUND := $(findstring --enable-default-pie,${GCC_V_OUTPUT}) 6943bd17c0fSSoby Mathewifneq ($(PIE_FOUND),) 6953bd17c0fSSoby Mathew TF_CFLAGS += -fno-PIE 6968620bd0bSChris Kayifeq ($($(ARCH)-ld-id),gnu-gcc) 6977b592418SSamuel Holland TF_LDFLAGS += -no-pie 6987b592418SSamuel Hollandendif 699c5e1da83SJayanth Dodderi Chidanandendif #(PIE_FOUND) 700320920c1SMasahiro Yamada 7018620bd0bSChris Kayifeq ($($(ARCH)-ld-id),gnu-gcc) 702320920c1SMasahiro Yamada PIE_LDFLAGS += -Wl,-pie -Wl,--no-dynamic-linker 703320920c1SMasahiro Yamadaelse 704320920c1SMasahiro Yamada PIE_LDFLAGS += -pie --no-dynamic-linker 705320920c1SMasahiro Yamadaendif 706320920c1SMasahiro Yamada 707320920c1SMasahiro Yamadaifeq ($(ENABLE_PIE),1) 70842d4d3baSArvind Ram Prakash ifeq ($(RESET_TO_BL2),1) 70969af7fcfSMasahiro Yamada ifneq ($(BL2_IN_XIP_MEM),1) 710966660ecSChris Kay BL2_CPPFLAGS += -fpie 71169af7fcfSMasahiro Yamada BL2_CFLAGS += -fpie 71269af7fcfSMasahiro Yamada BL2_LDFLAGS += $(PIE_LDFLAGS) 713c5e1da83SJayanth Dodderi Chidanand endif #(BL2_IN_XIP_MEM) 714c5e1da83SJayanth Dodderi Chidanand endif #(RESET_TO_BL2) 715966660ecSChris Kay BL31_CPPFLAGS += -fpie 716320920c1SMasahiro Yamada BL31_CFLAGS += -fpie 717320920c1SMasahiro Yamada BL31_LDFLAGS += $(PIE_LDFLAGS) 718966660ecSChris Kay 719966660ecSChris Kay BL32_CPPFLAGS += -fpie 720d974301dSMasahiro Yamada BL32_CFLAGS += -fpie 721d974301dSMasahiro Yamada BL32_LDFLAGS += $(PIE_LDFLAGS) 722c5e1da83SJayanth Dodderi Chidanandendif #(ENABLE_PIE) 7233bd17c0fSSoby Mathew 724007433d8SBoyan KaratotevBL1_CPPFLAGS += -DREPORT_ERRATA=${DEBUG} 725007433d8SBoyan KaratotevBL31_CPPFLAGS += -DREPORT_ERRATA=${DEBUG} 726007433d8SBoyan KaratotevBL32_CPPFLAGS += -DREPORT_ERRATA=${DEBUG} 727007433d8SBoyan Karatotev 7289cefb4b1SMasahiro YamadaBL1_CPPFLAGS += -DIMAGE_AT_EL3 72942d4d3baSArvind Ram Prakashifeq ($(RESET_TO_BL2),1) 7309cefb4b1SMasahiro Yamada BL2_CPPFLAGS += -DIMAGE_AT_EL3 731d5e97a1dSMasahiro Yamadaelse 7329cefb4b1SMasahiro Yamada BL2_CPPFLAGS += -DIMAGE_AT_EL1 733c5e1da83SJayanth Dodderi Chidanandendif #(RESET_TO_BL2) 734007433d8SBoyan Karatotev 735007433d8SBoyan Karatotevifeq (${ARCH},aarch64) 7369cefb4b1SMasahiro Yamada BL2U_CPPFLAGS += -DIMAGE_AT_EL1 7379cefb4b1SMasahiro Yamada BL31_CPPFLAGS += -DIMAGE_AT_EL3 7389cefb4b1SMasahiro Yamada BL32_CPPFLAGS += -DIMAGE_AT_EL1 739007433d8SBoyan Karatotevelse 740007433d8SBoyan Karatotev BL32_CPPFLAGS += -DIMAGE_AT_EL3 741d5e97a1dSMasahiro Yamadaendif 742d5e97a1dSMasahiro Yamada 74354035fc4SSandrine Bailleux# Include the CPU specific operations makefile, which provides default 74454035fc4SSandrine Bailleux# values for all CPU errata workarounds and CPU specific optimisations. 74554035fc4SSandrine Bailleux# This can be overridden by the platform. 74673c99d4eSJuan Castilloinclude lib/cpus/cpu-ops.mk 7474f6ad66aSAchin Gupta 748a4409008Sdp-arm################################################################################ 749a4409008Sdp-arm# Build `AARCH32_SP` as BL32 image for AArch32 750a4409008Sdp-arm################################################################################ 751c5e1da83SJayanth Dodderi Chidanandifeq (${ARCH},aarch32) 752c5e1da83SJayanth Dodderi Chidanand NEED_BL32 := yes 753c5e1da83SJayanth Dodderi Chidanand 754a4409008Sdp-arm ifneq (${AARCH32_SP},none) 755a4409008Sdp-arm # We expect to locate an sp.mk under the specified AARCH32_SP directory 756a4409008Sdp-arm AARCH32_SP_MAKE := $(wildcard bl32/${AARCH32_SP}/${AARCH32_SP}.mk) 757a4409008Sdp-arm 758a4409008Sdp-arm ifeq (${AARCH32_SP_MAKE},) 759a4409008Sdp-arm $(error Error: No bl32/${AARCH32_SP}/${AARCH32_SP}.mk located) 760a4409008Sdp-arm endif 761a4409008Sdp-arm $(info Including ${AARCH32_SP_MAKE}) 762a4409008Sdp-arm include ${AARCH32_SP_MAKE} 763a4409008Sdp-arm endif 764c5e1da83SJayanth Dodderi Chidanandendif #(ARCH=aarch32) 7654f6ad66aSAchin Gupta 76673c99d4eSJuan Castillo################################################################################ 76777f1f7a1SVarun Wadekar# Include libc if not overridden 76877f1f7a1SVarun Wadekar################################################################################ 76977f1f7a1SVarun Wadekarifeq (${OVERRIDE_LIBC},0) 77077f1f7a1SVarun Wadekarinclude lib/libc/libc.mk 77177f1f7a1SVarun Wadekarendif 77277f1f7a1SVarun Wadekar 77377f1f7a1SVarun Wadekar################################################################################ 774c5e1da83SJayanth Dodderi Chidanand# Check incompatible options and dependencies 775cf2c8a33SAntonio Nino Diaz################################################################################ 776cf2c8a33SAntonio Nino Diaz 777c5e1da83SJayanth Dodderi Chidanand# USE_DEBUGFS experimental feature recommended only in debug builds 778c5e1da83SJayanth Dodderi Chidanandifeq (${USE_DEBUGFS},1) 779c5e1da83SJayanth Dodderi Chidanand ifeq (${DEBUG},1) 780c5e1da83SJayanth Dodderi Chidanand $(warning DEBUGFS experimental feature is enabled.) 781c5e1da83SJayanth Dodderi Chidanand else 782c5e1da83SJayanth Dodderi Chidanand $(warning DEBUGFS experimental, recommended in DEBUG builds ONLY) 783c5e1da83SJayanth Dodderi Chidanand endif 784c5e1da83SJayanth Dodderi Chidanandendif #(USE_DEBUGFS) 785c5e1da83SJayanth Dodderi Chidanand 786c5e1da83SJayanth Dodderi Chidanand# USE_SPINLOCK_CAS requires AArch64 build 787c5e1da83SJayanth Dodderi Chidanandifeq (${USE_SPINLOCK_CAS},1) 788c5e1da83SJayanth Dodderi Chidanand ifneq (${ARCH},aarch64) 789c5e1da83SJayanth Dodderi Chidanand $(error USE_SPINLOCK_CAS requires AArch64) 790c5e1da83SJayanth Dodderi Chidanand endif 791c5e1da83SJayanth Dodderi Chidanandendif #(USE_SPINLOCK_CAS) 792c5e1da83SJayanth Dodderi Chidanand 793c5e1da83SJayanth Dodderi Chidanand# The cert_create tool cannot generate certificates individually, so we use the 794c5e1da83SJayanth Dodderi Chidanand# target 'certificates' to create them all 795c5e1da83SJayanth Dodderi Chidanandifneq (${GENERATE_COT},0) 796c5e1da83SJayanth Dodderi Chidanand FIP_DEPS += certificates 797c5e1da83SJayanth Dodderi Chidanand FWU_FIP_DEPS += fwu_certificates 798c5e1da83SJayanth Dodderi Chidanandendif 799c5e1da83SJayanth Dodderi Chidanand 800c5e1da83SJayanth Dodderi Chidanandifneq (${DECRYPTION_SUPPORT},none) 801c5e1da83SJayanth Dodderi Chidanand ENC_ARGS += -f ${FW_ENC_STATUS} 802c5e1da83SJayanth Dodderi Chidanand ENC_ARGS += -k ${ENC_KEY} 803c5e1da83SJayanth Dodderi Chidanand ENC_ARGS += -n ${ENC_NONCE} 804c5e1da83SJayanth Dodderi Chidanand FIP_DEPS += enctool 805c5e1da83SJayanth Dodderi Chidanand FWU_FIP_DEPS += enctool 806c5e1da83SJayanth Dodderi Chidanandendif #(DECRYPTION_SUPPORT) 807c5e1da83SJayanth Dodderi Chidanand 808cf2c8a33SAntonio Nino Diazifdef EL3_PAYLOAD_BASE 80968450a6dSAntonio Nino Diaz ifdef PRELOADED_BL33_BASE 81068450a6dSAntonio Nino Diaz $(warning "PRELOADED_BL33_BASE and EL3_PAYLOAD_BASE are \ 81168450a6dSAntonio Nino Diaz incompatible build options. EL3_PAYLOAD_BASE has priority.") 812cf2c8a33SAntonio Nino Diaz endif 81376580f3dSQixiang Xu ifneq (${GENERATE_COT},0) 814c5e1da83SJayanth Dodderi Chidanand $(error "GENERATE_COT and EL3_PAYLOAD_BASE are incompatible \ 815c5e1da83SJayanth Dodderi Chidanand build options.") 81676580f3dSQixiang Xu endif 81776580f3dSQixiang Xu ifneq (${TRUSTED_BOARD_BOOT},0) 818c5e1da83SJayanth Dodderi Chidanand $(error "TRUSTED_BOARD_BOOT and EL3_PAYLOAD_BASE are \ 819c5e1da83SJayanth Dodderi Chidanand incompatible \ build options.") 82076580f3dSQixiang Xu endif 821c5e1da83SJayanth Dodderi Chidanandendif #(EL3_PAYLOAD_BASE) 822cf2c8a33SAntonio Nino Diaz 823cf2c8a33SAntonio Nino Diazifeq (${NEED_BL33},yes) 824cf2c8a33SAntonio Nino Diaz ifdef EL3_PAYLOAD_BASE 825cf2c8a33SAntonio Nino Diaz $(warning "BL33 image is not needed when option \ 826cf2c8a33SAntonio Nino Diaz BL33_PAYLOAD_BASE is used and won't be added to the FIP file.") 827cf2c8a33SAntonio Nino Diaz endif 82868450a6dSAntonio Nino Diaz ifdef PRELOADED_BL33_BASE 82968450a6dSAntonio Nino Diaz $(warning "BL33 image is not needed when option \ 830c5e1da83SJayanth Dodderi Chidanand PRELOADED_BL33_BASE is used and won't be added to the FIP file.") 831cf2c8a33SAntonio Nino Diaz endif 832c5e1da83SJayanth Dodderi Chidanandendif #(NEED_BL33) 833cf2c8a33SAntonio Nino Diaz 834d4593e47SJeenu Viswambharan# When building for systems with hardware-assisted coherency, there's no need to 835d4593e47SJeenu Viswambharan# use USE_COHERENT_MEM. Require that USE_COHERENT_MEM must be set to 0 too. 836d4593e47SJeenu Viswambharanifeq ($(HW_ASSISTED_COHERENCY)-$(USE_COHERENT_MEM),1-1) 837d4593e47SJeenu Viswambharan $(error USE_COHERENT_MEM cannot be enabled with HW_ASSISTED_COHERENCY) 838d4593e47SJeenu Viswambharanendif 8391a0a3f06SYatharth Kochar 84042d4d3baSArvind Ram Prakash#For now, BL2_IN_XIP_MEM is only supported when RESET_TO_BL2 is 1. 84142d4d3baSArvind Ram Prakashifeq ($(RESET_TO_BL2)-$(BL2_IN_XIP_MEM),0-1) 84242d4d3baSArvind Ram Prakash $(error "BL2_IN_XIP_MEM is only supported when RESET_TO_BL2 is enabled") 8437d173fc5SJiafei Panendif 8447d173fc5SJiafei Pan 8459202d519SManish Pandey# RAS_EXTENSION is deprecated, provide alternate build options 84614c6016aSJeenu Viswambharanifeq ($(RAS_EXTENSION),1) 847c5e1da83SJayanth Dodderi Chidanand $(error "RAS_EXTENSION is now deprecated, please use ENABLE_FEAT_RAS \ 848f87e54f7SManish Pandey and HANDLE_EA_EL3_FIRST_NS instead") 8499202d519SManish Pandeyendif 850c5e1da83SJayanth Dodderi Chidanand 851c5e1da83SJayanth Dodderi Chidanand 8529202d519SManish Pandey# When FAULT_INJECTION_SUPPORT is used, require that FEAT_RAS is enabled 8531a7c1cfeSJeenu Viswambharanifeq ($(FAULT_INJECTION_SUPPORT),1) 8546503ff29SAndre Przywara ifeq ($(ENABLE_FEAT_RAS),0) 8556503ff29SAndre Przywara $(error For FAULT_INJECTION_SUPPORT, ENABLE_FEAT_RAS must not be 0) 8561a7c1cfeSJeenu Viswambharan endif 857c5e1da83SJayanth Dodderi Chidanandendif #(FAULT_INJECTION_SUPPORT) 8581a7c1cfeSJeenu Viswambharan 859ed51b51fSRoberto Vargas# DYN_DISABLE_AUTH can be set only when TRUSTED_BOARD_BOOT=1 860209a60ccSSoby Mathewifeq ($(DYN_DISABLE_AUTH), 1) 861209a60ccSSoby Mathew ifeq (${TRUSTED_BOARD_BOOT}, 0) 862c5e1da83SJayanth Dodderi Chidanand $(error "TRUSTED_BOARD_BOOT must be enabled for DYN_DISABLE_AUTH \ 863c5e1da83SJayanth Dodderi Chidanand to be set.") 864209a60ccSSoby Mathew endif 865c5e1da83SJayanth Dodderi Chidanandendif #(DYN_DISABLE_AUTH) 866209a60ccSSoby Mathew 8672bf4f27fSManish V Badarkheifeq ($(MEASURED_BOOT)-$(TRUSTED_BOARD_BOOT),1-1) 8682bf4f27fSManish V Badarkhe# Support authentication verification and hash calculation 8692bf4f27fSManish V Badarkhe CRYPTO_SUPPORT := 3 8702bf4f27fSManish V Badarkheelse ifeq ($(DRTM_SUPPORT)-$(TRUSTED_BOARD_BOOT),1-1) 8712bf4f27fSManish V Badarkhe# Support authentication verification and hash calculation 8722bf4f27fSManish V Badarkhe CRYPTO_SUPPORT := 3 8732bf4f27fSManish V Badarkheelse ifneq ($(filter 1,${MEASURED_BOOT} ${DRTM_SUPPORT}),) 8742bf4f27fSManish V Badarkhe# Support hash calculation only 8752bf4f27fSManish V Badarkhe CRYPTO_SUPPORT := 2 8762bf4f27fSManish V Badarkheelse ifeq (${TRUSTED_BOARD_BOOT},1) 8772bf4f27fSManish V Badarkhe# Support authentication verification only 878c9c56f6eSManish V Badarkhe CRYPTO_SUPPORT := 1 879c9c56f6eSManish V Badarkheelse 880c9c56f6eSManish V Badarkhe CRYPTO_SUPPORT := 0 881c5e1da83SJayanth Dodderi Chidanandendif #($(MEASURED_BOOT)-$(TRUSTED_BOARD_BOOT)) 882c9c56f6eSManish V Badarkhe 883cbf9e84aSBalint Dobszay# SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled. 884cbf9e84aSBalint Dobszayifeq ($(SDEI_SUPPORT)-$(SDEI_IN_FCONF),0-1) 885700e7685SManish Pandey $(error "SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled") 88684ef9cd8SManish V Badarkheendif 88784ef9cd8SManish V Badarkhe 888b86048c4SAntonio Nino Diaz# If pointer authentication is used in the firmware, make sure that all the 8899fc59639SAlexei Fedorov# registers associated to it are also saved and restored. 8909fc59639SAlexei Fedorov# Not doing it would leak the value of the keys used by EL3 to EL1 and S-EL1. 891b86048c4SAntonio Nino Diazifeq ($(ENABLE_PAUTH),1) 8929fc59639SAlexei Fedorov ifeq ($(CTX_INCLUDE_PAUTH_REGS),0) 8939fc59639SAlexei Fedorov $(error Pointer Authentication requires CTX_INCLUDE_PAUTH_REGS=1) 89406715f85SAlexei Fedorov endif 895c5e1da83SJayanth Dodderi Chidanandendif #(ENABLE_PAUTH) 8969fc59639SAlexei Fedorov 89706715f85SAlexei Fedorovifeq ($(CTX_INCLUDE_PAUTH_REGS),1) 8989fc59639SAlexei Fedorov ifneq (${ARCH},aarch64) 8999fc59639SAlexei Fedorov $(error CTX_INCLUDE_PAUTH_REGS requires AArch64) 900b86048c4SAntonio Nino Diaz endif 901c5e1da83SJayanth Dodderi Chidanandendif #(CTX_INCLUDE_PAUTH_REGS) 9029fc59639SAlexei Fedorov 9036a0da736SJayanth Dodderi Chidanandifeq ($(FEATURE_DETECTION),1) 9046a0da736SJayanth Dodderi Chidanand $(info FEATURE_DETECTION is an experimental feature) 905c5e1da83SJayanth Dodderi Chidanandendif #(FEATURE_DETECTION) 9066a0da736SJayanth Dodderi Chidanand 90703d3c0d7SJayanth Dodderi Chidanandifneq ($(ENABLE_SME2_FOR_NS), 0) 90803d3c0d7SJayanth Dodderi Chidanand ifeq (${ENABLE_SME_FOR_NS}, 0) 909c5e1da83SJayanth Dodderi Chidanand $(warning "ENABLE_SME2_FOR_NS requires ENABLE_SME_FOR_NS also \ 910c5e1da83SJayanth Dodderi Chidanand to be set") 91103d3c0d7SJayanth Dodderi Chidanand $(warning "Forced ENABLE_SME_FOR_NS=1") 91203d3c0d7SJayanth Dodderi Chidanand override ENABLE_SME_FOR_NS := 1 91303d3c0d7SJayanth Dodderi Chidanand endif 914c5e1da83SJayanth Dodderi Chidanandendif #(ENABLE_SME2_FOR_NS) 91545007acdSJayanth Dodderi Chidanand 91660e8f3cfSPetre-Ionut Tudorifeq (${ARM_XLAT_TABLES_LIB_V1}, 1) 91760e8f3cfSPetre-Ionut Tudor ifeq (${ALLOW_RO_XLAT_TABLES}, 1) 918c5e1da83SJayanth Dodderi Chidanand $(error "ALLOW_RO_XLAT_TABLES requires translation tables \ 919c5e1da83SJayanth Dodderi Chidanand library v2") 92060e8f3cfSPetre-Ionut Tudor endif 921c5e1da83SJayanth Dodderi Chidanandendif #(ARM_XLAT_TABLES_LIB_V1) 92260e8f3cfSPetre-Ionut Tudor 9237cda17bbSSumit Gargifneq (${DECRYPTION_SUPPORT},none) 9247cda17bbSSumit Garg ifeq (${TRUSTED_BOARD_BOOT}, 0) 925c5e1da83SJayanth Dodderi Chidanand $(error TRUSTED_BOARD_BOOT must be enabled for DECRYPTION_SUPPORT \ 926c5e1da83SJayanth Dodderi Chidanand to be set) 9277cda17bbSSumit Garg endif 928c5e1da83SJayanth Dodderi Chidanandendif #(DECRYPTION_SUPPORT) 9297cda17bbSSumit Garg 930744ad974Sjohpow01# Ensure that no Aarch64-only features are enabled in Aarch32 build 931dc78e62dSjohpow01ifeq (${ARCH},aarch32) 932744ad974Sjohpow01 933744ad974Sjohpow01 # SME/SVE only supported on AArch64 93445007acdSJayanth Dodderi Chidanand ifneq (${ENABLE_SME_FOR_NS},0) 935dc78e62dSjohpow01 $(error "ENABLE_SME_FOR_NS cannot be used with ARCH=aarch32") 936dc78e62dSjohpow01 endif 93703d3c0d7SJayanth Dodderi Chidanand 938dc78e62dSjohpow01 ifeq (${ENABLE_SVE_FOR_NS},1) 939dc78e62dSjohpow01 # Warning instead of error due to CI dependency on this 94024ab2c0aSYann Gautier $(error "ENABLE_SVE_FOR_NS cannot be used with ARCH=aarch32") 941dc78e62dSjohpow01 endif 942744ad974Sjohpow01 943ff86e0b4SJuan Pablo Conde # BRBE is not supported in AArch32 944744ad974Sjohpow01 ifeq (${ENABLE_BRBE_FOR_NS},1) 945744ad974Sjohpow01 $(error "ENABLE_BRBE_FOR_NS cannot be used with ARCH=aarch32") 946744ad974Sjohpow01 endif 947744ad974Sjohpow01 948ff86e0b4SJuan Pablo Conde # FEAT_RNG_TRAP is not supported in AArch32 949ff86e0b4SJuan Pablo Conde ifeq (${ENABLE_FEAT_RNG_TRAP},1) 950ff86e0b4SJuan Pablo Conde $(error "ENABLE_FEAT_RNG_TRAP cannot be used with ARCH=aarch32") 951ff86e0b4SJuan Pablo Conde endif 952c5e1da83SJayanth Dodderi Chidanandendif #(ARCH=aarch32) 953dc78e62dSjohpow01 9540d122947SBoyan Karatotevifneq (${ENABLE_SME_FOR_NS},0) 9550d122947SBoyan Karatotev ifeq (${ENABLE_SVE_FOR_NS},0) 9560d122947SBoyan Karatotev $(error "ENABLE_SME_FOR_NS requires ENABLE_SVE_FOR_NS") 9570d122947SBoyan Karatotev endif 958c5e1da83SJayanth Dodderi Chidanandendif #(ENABLE_SME_FOR_NS) 9590d122947SBoyan Karatotev 960dc78e62dSjohpow01# Secure SME/SVE requires the non-secure component as well 961dc78e62dSjohpow01ifeq (${ENABLE_SME_FOR_SWD},1) 962dc78e62dSjohpow01 ifeq (${ENABLE_SME_FOR_NS},0) 963dc78e62dSjohpow01 $(error "ENABLE_SME_FOR_SWD requires ENABLE_SME_FOR_NS") 964dc78e62dSjohpow01 endif 9650d122947SBoyan Karatotev ifeq (${ENABLE_SVE_FOR_SWD},0) 9660d122947SBoyan Karatotev $(error "ENABLE_SME_FOR_SWD requires ENABLE_SVE_FOR_SWD") 9670d122947SBoyan Karatotev endif 968c5e1da83SJayanth Dodderi Chidanandendif #(ENABLE_SME_FOR_SWD) 969c5e1da83SJayanth Dodderi Chidanand 9703524d074SMadhukar Pappireddy# Enabling SVE for SWD requires enabling SVE for NWD due to ENABLE_FEAT 9713524d074SMadhukar Pappireddy# mechanism. 972dc78e62dSjohpow01ifeq (${ENABLE_SVE_FOR_SWD},1) 973dc78e62dSjohpow01 ifeq (${ENABLE_SVE_FOR_NS},0) 974dc78e62dSjohpow01 $(error "ENABLE_SVE_FOR_SWD requires ENABLE_SVE_FOR_NS") 975dc78e62dSjohpow01 endif 9763524d074SMadhukar Pappireddyendif 977dc78e62dSjohpow01 9783524d074SMadhukar Pappireddy# Enabling SVE for both the worlds typically requires the context 9793524d074SMadhukar Pappireddy# management of SVE registers. The only exception being SPMC at S-EL2. 9803524d074SMadhukar Pappireddyifeq (${ENABLE_SVE_FOR_SWD}, 1) 9813524d074SMadhukar Pappireddy ifneq (${ENABLE_SVE_FOR_NS}, 0) 9823524d074SMadhukar Pappireddy ifeq (${CTX_INCLUDE_SVE_REGS}-$(SPMD_SPM_AT_SEL2),0-0) 9833524d074SMadhukar Pappireddy $(warning "ENABLE_SVE_FOR_SWD and ENABLE_SVE_FOR_NS together require CTX_INCLUDE_SVE_REGS") 9843524d074SMadhukar Pappireddy endif 9853524d074SMadhukar Pappireddy endif 9863524d074SMadhukar Pappireddyendif 9873524d074SMadhukar Pappireddy 9883524d074SMadhukar Pappireddy# Enabling SVE in either world while enabling CTX_INCLUDE_FPREGS requires 9893524d074SMadhukar Pappireddy# CTX_INCLUDE_SVE_REGS to be enabled due to architectural dependency between FP 9903524d074SMadhukar Pappireddy# and SVE registers. 9913524d074SMadhukar Pappireddyifeq (${CTX_INCLUDE_FPREGS}, 1) 9923524d074SMadhukar Pappireddy ifneq (${ENABLE_SVE_FOR_NS},0) 9933524d074SMadhukar Pappireddy ifeq (${CTX_INCLUDE_SVE_REGS},0) 9943524d074SMadhukar Pappireddy # Warning instead of error due to CI dependency on this 9953524d074SMadhukar Pappireddy $(warning "CTX_INCLUDE_FPREGS and ENABLE_SVE_FOR_NS together require CTX_INCLUDE_SVE_REGS") 9963524d074SMadhukar Pappireddy $(warning "Forced ENABLE_SVE_FOR_NS=0") 9973524d074SMadhukar Pappireddy override ENABLE_SVE_FOR_NS := 0 9983524d074SMadhukar Pappireddy endif 9993524d074SMadhukar Pappireddy endif 10003524d074SMadhukar Pappireddyendif #(CTX_INCLUDE_FPREGS) 10013524d074SMadhukar Pappireddy 10023524d074SMadhukar Pappireddy# SVE context management is only required if secure world has access to SVE/FP 10033524d074SMadhukar Pappireddy# functionality. 10043524d074SMadhukar Pappireddyifeq (${CTX_INCLUDE_SVE_REGS},1) 10053524d074SMadhukar Pappireddy ifeq (${ENABLE_SVE_FOR_SWD},0) 10063524d074SMadhukar Pappireddy $(error "CTX_INCLUDE_SVE_REGS requires ENABLE_SVE_FOR_SWD to also be enabled") 10073524d074SMadhukar Pappireddy endif 10083524d074SMadhukar Pappireddyendif 10093524d074SMadhukar Pappireddy 10103524d074SMadhukar Pappireddy# SME cannot be used with CTX_INCLUDE_FPREGS since SPM does its own context 10113524d074SMadhukar Pappireddy# management including FPU registers. 1012dc78e62dSjohpow01ifeq (${CTX_INCLUDE_FPREGS},1) 101345007acdSJayanth Dodderi Chidanand ifneq (${ENABLE_SME_FOR_NS},0) 1014dc78e62dSjohpow01 $(error "ENABLE_SME_FOR_NS cannot be used with CTX_INCLUDE_FPREGS") 1015dc78e62dSjohpow01 endif 1016c5e1da83SJayanth Dodderi Chidanandendif #(CTX_INCLUDE_FPREGS) 1017dc78e62dSjohpow01 101800e28874SManish V Badarkheifeq ($(DRTM_SUPPORT),1) 101900e28874SManish V Badarkhe $(info DRTM_SUPPORT is an experimental feature) 102000e28874SManish V Badarkheendif 102100e28874SManish V Badarkhe 10223ba2c151SRaymond Maoifeq (${TRANSFER_LIST},1) 10233ba2c151SRaymond Mao $(info TRANSFER_LIST is an experimental feature) 10243ba2c151SRaymond Maoendif 10253ba2c151SRaymond Mao 1026274a69e7SChris Kayifeq (${ENABLE_RME},1) 1027274a69e7SChris Kay ifneq (${SEPARATE_CODE_AND_RODATA},1) 1028274a69e7SChris Kay $(error `ENABLE_RME=1` requires `SEPARATE_CODE_AND_RODATA=1`) 1029274a69e7SChris Kay endif 1030274a69e7SChris Kayendif 1031274a69e7SChris Kay 10325782b890SManish V Badarkheifeq ($(PSA_CRYPTO),1) 10335782b890SManish V Badarkhe $(info PSA_CRYPTO is an experimental feature) 10345782b890SManish V Badarkheendif 10355782b890SManish V Badarkhe 103682222db8SManish V Badarkheifeq ($(DICE_PROTECTION_ENVIRONMENT),1) 103782222db8SManish V Badarkhe $(info DICE_PROTECTION_ENVIRONMENT is an experimental feature) 103882222db8SManish V Badarkheendif 103982222db8SManish V Badarkhe 1040cf2c8a33SAntonio Nino Diaz################################################################################ 104173c99d4eSJuan Castillo# Process platform overrideable behaviour 104273c99d4eSJuan Castillo################################################################################ 10434f6ad66aSAchin Gupta 10445f24ce96SManish Pandeyifdef BL1_SOURCES 10455f24ce96SManish Pandey NEED_BL1 := yes 1046c5e1da83SJayanth Dodderi Chidanandendif #(BL1_SOURCES) 10475f24ce96SManish Pandey 10485f24ce96SManish Pandeyifdef BL2_SOURCES 10495f24ce96SManish Pandey NEED_BL2 := yes 10505f24ce96SManish Pandey 1051bd97f83aSJohn Tsichritzis # Using BL2 implies that a BL33 image also needs to be supplied for the FIP and 1052bd97f83aSJohn Tsichritzis # Certificate generation tools. This flag can be overridden by the platform. 1053cf2c8a33SAntonio Nino Diaz ifdef EL3_PAYLOAD_BASE 1054cf2c8a33SAntonio Nino Diaz # If booting an EL3 payload there is no need for a BL33 image 1055cf2c8a33SAntonio Nino Diaz # in the FIP file. 10564c117f6cSSandrine Bailleux NEED_BL33 := no 1057cf2c8a33SAntonio Nino Diaz else 105868450a6dSAntonio Nino Diaz ifdef PRELOADED_BL33_BASE 1059cf2c8a33SAntonio Nino Diaz # If booting a BL33 preloaded image there is no need of 1060cf2c8a33SAntonio Nino Diaz # another one in the FIP file. 1061cf2c8a33SAntonio Nino Diaz NEED_BL33 := no 1062cf2c8a33SAntonio Nino Diaz else 1063cf2c8a33SAntonio Nino Diaz NEED_BL33 ?= yes 1064cf2c8a33SAntonio Nino Diaz endif 10654c117f6cSSandrine Bailleux endif 1066c5e1da83SJayanth Dodderi Chidanandendif #(BL2_SOURCES) 10676f971622SJuan Castillo 10685f24ce96SManish Pandeyifdef BL2U_SOURCES 10695f24ce96SManish Pandey NEED_BL2U := yes 1070c5e1da83SJayanth Dodderi Chidanandendif #(BL2U_SOURCES) 10715f24ce96SManish Pandey 10724d045d0eSMasahiro Yamada# If SCP_BL2 is given, we always want FIP to include it. 10734d045d0eSMasahiro Yamadaifdef SCP_BL2 10744d045d0eSMasahiro Yamada NEED_SCP_BL2 := yes 1075c5e1da83SJayanth Dodderi Chidanandendif #(SCP_BL2) 10764d045d0eSMasahiro Yamada 10775744e874SSoby Mathew# For AArch32, BL31 is not currently supported. 10785744e874SSoby Mathewifneq (${ARCH},aarch32) 10795744e874SSoby Mathew ifdef BL31_SOURCES 1080c5e1da83SJayanth Dodderi Chidanand # When booting an EL3 payload, there is no need to compile the BL31 1081c5e1da83SJayanth Dodderi Chidanand # image nor put it in the FIP. 10825744e874SSoby Mathew ifndef EL3_PAYLOAD_BASE 10835744e874SSoby Mathew NEED_BL31 := yes 10845744e874SSoby Mathew endif 10855744e874SSoby Mathew endif 1086c5e1da83SJayanth Dodderi Chidanandendif #(ARCH=aarch64) 10875744e874SSoby Mathew 108873c99d4eSJuan Castillo# Process TBB related flags 10896f971622SJuan Castilloifneq (${GENERATE_COT},0) 109073c99d4eSJuan Castillo # Common cert_create options 10916f971622SJuan Castillo ifneq (${CREATE_KEYS},0) 10926f971622SJuan Castillo $(eval CRT_ARGS += -n) 10930191262dSYatharth Kochar $(eval FWU_CRT_ARGS += -n) 1094fd34e7baSJuan Castillo ifneq (${SAVE_KEYS},0) 1095fd34e7baSJuan Castillo $(eval CRT_ARGS += -k) 10960191262dSYatharth Kochar $(eval FWU_CRT_ARGS += -k) 1097fd34e7baSJuan Castillo endif 10986f971622SJuan Castillo endif 109973c99d4eSJuan Castillo # Include TBBR makefile (unless the platform indicates otherwise) 110073c99d4eSJuan Castillo ifeq (${INCLUDE_TBBR_MK},1) 110173c99d4eSJuan Castillo include make_helpers/tbbr/tbbr_tools.mk 110273c99d4eSJuan Castillo endif 1103c5e1da83SJayanth Dodderi Chidanandendif #(GENERATE_COT) 11046f971622SJuan Castillo 11051c75d5dfSMasahiro Yamadaifneq (${FIP_ALIGN},0) 11061c75d5dfSMasahiro Yamada FIP_ARGS += --align ${FIP_ALIGN} 1107c5e1da83SJayanth Dodderi Chidanandendif #(FIP_ALIGN) 11081c75d5dfSMasahiro Yamada 11095f24ce96SManish Pandeyifdef FDT_SOURCES 11105f24ce96SManish Pandey NEED_FDT := yes 1111c5e1da83SJayanth Dodderi Chidanandendif #(FDT_SOURCES) 11125f24ce96SManish Pandey 111373c99d4eSJuan Castillo################################################################################ 111446e5e035SMichalis Pappas# Include libraries' Makefile that are used in all BL 111546e5e035SMichalis Pappas################################################################################ 111646e5e035SMichalis Pappas 111746e5e035SMichalis Pappasinclude lib/stack_protector/stack_protector.mk 111846e5e035SMichalis Pappas 111946e5e035SMichalis Pappas################################################################################ 11208a86052dSSoby Mathew# Include BL specific makefiles 11218a86052dSSoby Mathew################################################################################ 11225f24ce96SManish Pandey 11235f24ce96SManish Pandeyifeq (${NEED_BL1},yes) 11248a86052dSSoby Mathewinclude bl1/bl1.mk 11258a86052dSSoby Mathewendif 11268a86052dSSoby Mathew 11275f24ce96SManish Pandeyifeq (${NEED_BL2},yes) 11288a86052dSSoby Mathewinclude bl2/bl2.mk 11298a86052dSSoby Mathewendif 11308a86052dSSoby Mathew 11315f24ce96SManish Pandeyifeq (${NEED_BL2U},yes) 11328a86052dSSoby Mathewinclude bl2u/bl2u.mk 11338a86052dSSoby Mathewendif 11348a86052dSSoby Mathew 11355744e874SSoby Mathewifeq (${NEED_BL31},yes) 11368a86052dSSoby Mathewinclude bl31/bl31.mk 11378a86052dSSoby Mathewendif 113803b397a8SNishanth Menon 113973c99d4eSJuan Castillo################################################################################ 114073c99d4eSJuan Castillo# Build options checks 114173c99d4eSJuan Castillo################################################################################ 114273c99d4eSJuan Castillo 1143c5e1da83SJayanth Dodderi Chidanand# Boolean_Flags 1144327131c4SLeonardo Sandoval$(eval $(call assert_booleans,\ 1145327131c4SLeonardo Sandoval $(sort \ 1146327131c4SLeonardo Sandoval ALLOW_RO_XLAT_TABLES \ 114746789a7cSBalint Dobszay BL2_ENABLE_SP_LOAD \ 1148327131c4SLeonardo Sandoval COLD_BOOT_SINGLE_CPU \ 1149327131c4SLeonardo Sandoval CREATE_KEYS \ 1150327131c4SLeonardo Sandoval CTX_INCLUDE_AARCH32_REGS \ 1151327131c4SLeonardo Sandoval CTX_INCLUDE_FPREGS \ 115242422622SMadhukar Pappireddy CTX_INCLUDE_SVE_REGS \ 1153327131c4SLeonardo Sandoval CTX_INCLUDE_EL2_REGS \ 11549acff28aSArvind Ram Prakash CTX_INCLUDE_MPAM_REGS \ 1155327131c4SLeonardo Sandoval DEBUG \ 1156327131c4SLeonardo Sandoval DYN_DISABLE_AUTH \ 1157327131c4SLeonardo Sandoval EL3_EXCEPTION_HANDLING \ 11581fd685a7SChris Kay ENABLE_AMU_AUXILIARY_COUNTERS \ 1159742ca230SChris Kay ENABLE_AMU_FCONF \ 1160873d4241Sjohpow01 AMU_RESTRICT_COUNTERS \ 1161327131c4SLeonardo Sandoval ENABLE_ASSERTIONS \ 1162327131c4SLeonardo Sandoval ENABLE_PIE \ 1163327131c4SLeonardo Sandoval ENABLE_PMF \ 1164327131c4SLeonardo Sandoval ENABLE_PSCI_STAT \ 1165327131c4SLeonardo Sandoval ENABLE_RUNTIME_INSTRUMENTATION \ 1166dc78e62dSjohpow01 ENABLE_SME_FOR_SWD \ 11670c5e7d1cSMax Shvetsov ENABLE_SVE_FOR_SWD \ 1168970a4a8dSManish Pandey ENABLE_FEAT_RAS \ 1169f87e54f7SManish Pandey FFH_SUPPORT \ 1170327131c4SLeonardo Sandoval ERROR_DEPRECATED \ 1171327131c4SLeonardo Sandoval FAULT_INJECTION_SUPPORT \ 1172327131c4SLeonardo Sandoval GENERATE_COT \ 1173327131c4SLeonardo Sandoval GICV2_G0_FOR_EL3 \ 117446cc41d5SManish Pandey HANDLE_EA_EL3_FIRST_NS \ 1175538516f5SBipin Ravi HARDEN_SLS \ 1176327131c4SLeonardo Sandoval HW_ASSISTED_COHERENCY \ 1177327131c4SLeonardo Sandoval MEASURED_BOOT \ 1178e7f1181fSTamas Ban DICE_PROTECTION_ENVIRONMENT \ 11796a88ec8bSRaghu Krishnamurthy RMMD_ENABLE_EL3_TOKEN_SIGN \ 118000e28874SManish V Badarkhe DRTM_SUPPORT \ 1181327131c4SLeonardo Sandoval NS_TIMER_SWITCH \ 1182327131c4SLeonardo Sandoval OVERRIDE_LIBC \ 1183327131c4SLeonardo Sandoval PL011_GENERIC_UART \ 1184327131c4SLeonardo Sandoval PROGRAMMABLE_RESET_ADDRESS \ 1185327131c4SLeonardo Sandoval PSCI_EXTENDED_STATE_ID \ 118664b4710bSWing Li PSCI_OS_INIT_MODE \ 1187327131c4SLeonardo Sandoval RESET_TO_BL31 \ 1188327131c4SLeonardo Sandoval SAVE_KEYS \ 1189327131c4SLeonardo Sandoval SEPARATE_CODE_AND_RODATA \ 119096a8ed14SJiafei Pan SEPARATE_BL2_NOLOAD_REGION \ 1191327131c4SLeonardo Sandoval SEPARATE_NOBITS_REGION \ 1192308ebfa1SMadhukar Pappireddy SEPARATE_SIMD_SECTION \ 1193327131c4SLeonardo Sandoval SPIN_ON_BL1_EXIT \ 1194327131c4SLeonardo Sandoval SPM_MM \ 11951d63ae4dSMarc Bonnici SPMC_AT_EL3 \ 1196801cd3c8SNishant Sharma SPMC_AT_EL3_SEL0_SP \ 1197327131c4SLeonardo Sandoval SPMD_SPM_AT_SEL2 \ 1198890b5088SRaghu Krishnamurthy ENABLE_SPMD_LP \ 11993ba2c151SRaymond Mao TRANSFER_LIST \ 1200327131c4SLeonardo Sandoval TRUSTED_BOARD_BOOT \ 1201327131c4SLeonardo Sandoval USE_COHERENT_MEM \ 1202327131c4SLeonardo Sandoval USE_DEBUGFS \ 1203327131c4SLeonardo Sandoval ARM_IO_IN_DTB \ 1204327131c4SLeonardo Sandoval SDEI_IN_FCONF \ 1205327131c4SLeonardo Sandoval SEC_INT_DESC_IN_FCONF \ 1206327131c4SLeonardo Sandoval USE_ROMLIB \ 1207327131c4SLeonardo Sandoval USE_TBBR_DEFS \ 1208327131c4SLeonardo Sandoval WARMBOOT_ENABLE_DCACHE_EARLY \ 120942d4d3baSArvind Ram Prakash RESET_TO_BL2 \ 1210327131c4SLeonardo Sandoval BL2_IN_XIP_MEM \ 1211327131c4SLeonardo Sandoval BL2_INV_DCACHE \ 1212327131c4SLeonardo Sandoval USE_SPINLOCK_CAS \ 1213327131c4SLeonardo Sandoval ENCRYPT_BL31 \ 1214327131c4SLeonardo Sandoval ENCRYPT_BL32 \ 1215327131c4SLeonardo Sandoval ERRATA_SPECULATIVE_AT \ 121600e8f79cSManish Pandey RAS_TRAP_NS_ERR_REC_ACCESS \ 1217327131c4SLeonardo Sandoval COT_DESC_IN_DTB \ 1218327131c4SLeonardo Sandoval USE_SP804_TIMER \ 1219396b339dSManish V Badarkhe PSA_FWU_SUPPORT \ 122011d05a77SSughosh Ganu PSA_FWU_METADATA_FW_STORE_DESC \ 122168120783SChris Kay ENABLE_MPMM \ 122268120783SChris Kay ENABLE_MPMM_FCONF \ 12236a0da736SJayanth Dodderi Chidanand FEATURE_DETECTION \ 12240b22e591SJayanth Dodderi Chidanand TRNG_SUPPORT \ 1225ffea3844SSona Mathew ERRATA_ABI_SUPPORT \ 1226ef63f5beSSona Mathew ERRATA_NON_ARM_INTERCONNECT \ 122704c7303bSOkash Khawaja CONDITIONAL_CMO \ 12285782b890SManish V Badarkhe PSA_CRYPTO \ 122985bebe18SSandrine Bailleux ENABLE_CONSOLE_GETC \ 1230183329a5SArvind Ram Prakash INIT_UNUSED_NS_EL2 \ 1231bfef8b90SJuan Pablo Conde PLATFORM_REPORT_CTX_MEM_USE \ 1232ae770fedSYann Gautier EARLY_CONSOLE \ 1233f99a69c3SArvind Ram Prakash PRESERVE_DSU_PMU_REGS \ 1234327131c4SLeonardo Sandoval))) 123573c99d4eSJuan Castillo 1236c5e1da83SJayanth Dodderi Chidanand# Numeric_Flags 1237327131c4SLeonardo Sandoval$(eval $(call assert_numerics,\ 1238327131c4SLeonardo Sandoval $(sort \ 1239327131c4SLeonardo Sandoval ARM_ARCH_MAJOR \ 1240327131c4SLeonardo Sandoval ARM_ARCH_MINOR \ 1241327131c4SLeonardo Sandoval BRANCH_PROTECTION \ 12426a0da736SJayanth Dodderi Chidanand CTX_INCLUDE_PAUTH_REGS \ 12436a0da736SJayanth Dodderi Chidanand CTX_INCLUDE_NEVE_REGS \ 12442bf4f27fSManish V Badarkhe CRYPTO_SUPPORT \ 124583a4dae1SBoyan Karatotev DISABLE_MTPMU \ 12461298f2f1SJayanth Dodderi Chidanand ENABLE_BRBE_FOR_NS \ 124747c681b7SJayanth Dodderi Chidanand ENABLE_TRBE_FOR_NS \ 12486a0da736SJayanth Dodderi Chidanand ENABLE_BTI \ 12496a0da736SJayanth Dodderi Chidanand ENABLE_PAUTH \ 1250d23acc9eSAndre Przywara ENABLE_FEAT_AMU \ 12516a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_AMUv1p1 \ 12526a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_CSV2_2 \ 125330019d86SSona Mathew ENABLE_FEAT_CSV2_3 \ 125483271d5aSArvind Ram Prakash ENABLE_FEAT_DEBUGV8P9 \ 12556a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_DIT \ 12566a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_ECV \ 12576a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_FGT \ 125833e6aaacSArvind Ram Prakash ENABLE_FEAT_FGT2 \ 12596a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_HCX \ 12608e397889SGovindraj Raja ENABLE_FEAT_MTE2 \ 12616a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_PAN \ 12626a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_RNG \ 1263ff86e0b4SJuan Pablo Conde ENABLE_FEAT_RNG_TRAP \ 12646a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_SEL2 \ 1265d3331603SMark Brown ENABLE_FEAT_TCR2 \ 12666d0433f0SJayanth Dodderi Chidanand ENABLE_FEAT_THE \ 12670e4daed2SGovindraj Raja ENABLE_FEAT_SB \ 1268062b6c6bSMark Brown ENABLE_FEAT_S2PIE \ 1269062b6c6bSMark Brown ENABLE_FEAT_S1PIE \ 1270062b6c6bSMark Brown ENABLE_FEAT_S2POE \ 1271062b6c6bSMark Brown ENABLE_FEAT_S1POE \ 12724ec4e545SJayanth Dodderi Chidanand ENABLE_FEAT_SCTLR2 \ 1273*30655136SGovindraj Raja ENABLE_FEAT_D128 \ 1274688ab57bSMark Brown ENABLE_FEAT_GCS \ 12756a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_VHE \ 1276edebefbcSArvind Ram Prakash ENABLE_FEAT_MPAM \ 12776a0da736SJayanth Dodderi Chidanand ENABLE_RME \ 12786437a09aSAndre Przywara ENABLE_SPE_FOR_NS \ 1279603a0c6fSAndre Przywara ENABLE_SYS_REG_TRACE_FOR_NS \ 128045007acdSJayanth Dodderi Chidanand ENABLE_SME_FOR_NS \ 128103d3c0d7SJayanth Dodderi Chidanand ENABLE_SME2_FOR_NS \ 12822b0bc4e0SJayanth Dodderi Chidanand ENABLE_SVE_FOR_NS \ 12836a0da736SJayanth Dodderi Chidanand ENABLE_TRF_FOR_NS \ 1284327131c4SLeonardo Sandoval FW_ENC_STATUS \ 12855357f83dSManish V Badarkhe NR_OF_FW_BANKS \ 12865357f83dSManish V Badarkhe NR_OF_IMAGES_IN_FW_BANK \ 1287781d07a4SJayanth Dodderi Chidanand TWED_DELAY \ 1288781d07a4SJayanth Dodderi Chidanand ENABLE_FEAT_TWED \ 1289bebcf27fSMark Brown SVE_VECTOR_LEN \ 12900ed3be6fSVarun Wadekar IMPDEF_SYSREG_TRAP \ 1291327131c4SLeonardo Sandoval))) 1292c877b414SJeenu Viswambharan 1293aacff749SJustin Chadwellifdef KEY_SIZE 1294aacff749SJustin Chadwell $(eval $(call assert_numeric,KEY_SIZE)) 1295aacff749SJustin Chadwellendif 1296aacff749SJustin Chadwell 12971f461979SJustin Chadwellifeq ($(filter $(SANITIZE_UB), on off trap),) 12981f461979SJustin Chadwell $(error "Invalid value for SANITIZE_UB: can be one of on, off, trap") 12991f461979SJustin Chadwellendif 13001f461979SJustin Chadwell 130173c99d4eSJuan Castillo################################################################################ 130273c99d4eSJuan Castillo# Add definitions to the cpp preprocessor based on the current build options. 130373c99d4eSJuan Castillo# This is done after including the platform specific makefile to allow the 130473c99d4eSJuan Castillo# platform to overwrite the default options 130573c99d4eSJuan Castillo################################################################################ 130673c99d4eSJuan Castillo 1307327131c4SLeonardo Sandoval$(eval $(call add_defines,\ 1308327131c4SLeonardo Sandoval $(sort \ 1309327131c4SLeonardo Sandoval ALLOW_RO_XLAT_TABLES \ 1310327131c4SLeonardo Sandoval ARM_ARCH_MAJOR \ 1311327131c4SLeonardo Sandoval ARM_ARCH_MINOR \ 131246789a7cSBalint Dobszay BL2_ENABLE_SP_LOAD \ 1313327131c4SLeonardo Sandoval COLD_BOOT_SINGLE_CPU \ 1314327131c4SLeonardo Sandoval CTX_INCLUDE_AARCH32_REGS \ 1315327131c4SLeonardo Sandoval CTX_INCLUDE_FPREGS \ 131642422622SMadhukar Pappireddy CTX_INCLUDE_SVE_REGS \ 1317327131c4SLeonardo Sandoval CTX_INCLUDE_PAUTH_REGS \ 13189acff28aSArvind Ram Prakash CTX_INCLUDE_MPAM_REGS \ 1319327131c4SLeonardo Sandoval EL3_EXCEPTION_HANDLING \ 1320327131c4SLeonardo Sandoval CTX_INCLUDE_EL2_REGS \ 1321062f8aafSArunachalam Ganapathy CTX_INCLUDE_NEVE_REGS \ 1322327131c4SLeonardo Sandoval DECRYPTION_SUPPORT_${DECRYPTION_SUPPORT} \ 13230063dd17SJavier Almansa Sobrino DISABLE_MTPMU \ 1324d23acc9eSAndre Przywara ENABLE_FEAT_AMU \ 13251fd685a7SChris Kay ENABLE_AMU_AUXILIARY_COUNTERS \ 1326742ca230SChris Kay ENABLE_AMU_FCONF \ 1327873d4241Sjohpow01 AMU_RESTRICT_COUNTERS \ 1328327131c4SLeonardo Sandoval ENABLE_ASSERTIONS \ 1329327131c4SLeonardo Sandoval ENABLE_BTI \ 133083271d5aSArvind Ram Prakash ENABLE_FEAT_DEBUGV8P9 \ 1331edebefbcSArvind Ram Prakash ENABLE_FEAT_MPAM \ 1332327131c4SLeonardo Sandoval ENABLE_PAUTH \ 1333327131c4SLeonardo Sandoval ENABLE_PIE \ 1334327131c4SLeonardo Sandoval ENABLE_PMF \ 1335327131c4SLeonardo Sandoval ENABLE_PSCI_STAT \ 13365b18de09SZelalem Aweke ENABLE_RME \ 13376a88ec8bSRaghu Krishnamurthy RMMD_ENABLE_EL3_TOKEN_SIGN \ 1338327131c4SLeonardo Sandoval ENABLE_RUNTIME_INSTRUMENTATION \ 1339dc78e62dSjohpow01 ENABLE_SME_FOR_NS \ 134003d3c0d7SJayanth Dodderi Chidanand ENABLE_SME2_FOR_NS \ 1341dc78e62dSjohpow01 ENABLE_SME_FOR_SWD \ 134290118bb5SAndre Przywara ENABLE_SPE_FOR_NS \ 1343327131c4SLeonardo Sandoval ENABLE_SVE_FOR_NS \ 13440c5e7d1cSMax Shvetsov ENABLE_SVE_FOR_SWD \ 1345970a4a8dSManish Pandey ENABLE_FEAT_RAS \ 1346f87e54f7SManish Pandey FFH_SUPPORT \ 1347327131c4SLeonardo Sandoval ENCRYPT_BL31 \ 1348327131c4SLeonardo Sandoval ENCRYPT_BL32 \ 1349327131c4SLeonardo Sandoval ERROR_DEPRECATED \ 1350327131c4SLeonardo Sandoval FAULT_INJECTION_SUPPORT \ 1351327131c4SLeonardo Sandoval GICV2_G0_FOR_EL3 \ 135246cc41d5SManish Pandey HANDLE_EA_EL3_FIRST_NS \ 1353327131c4SLeonardo Sandoval HW_ASSISTED_COHERENCY \ 1354327131c4SLeonardo Sandoval LOG_LEVEL \ 1355327131c4SLeonardo Sandoval MEASURED_BOOT \ 1356e7f1181fSTamas Ban DICE_PROTECTION_ENVIRONMENT \ 135700e28874SManish V Badarkhe DRTM_SUPPORT \ 1358327131c4SLeonardo Sandoval NS_TIMER_SWITCH \ 1359327131c4SLeonardo Sandoval PL011_GENERIC_UART \ 1360327131c4SLeonardo Sandoval PLAT_${PLAT} \ 1361327131c4SLeonardo Sandoval PROGRAMMABLE_RESET_ADDRESS \ 1362327131c4SLeonardo Sandoval PSCI_EXTENDED_STATE_ID \ 136364b4710bSWing Li PSCI_OS_INIT_MODE \ 1364327131c4SLeonardo Sandoval RESET_TO_BL31 \ 1365d766084fSAlexeiFedorov RME_GPT_BITLOCK_BLOCK \ 1366ec0088bbSAlexeiFedorov RME_GPT_MAX_BLOCK \ 1367327131c4SLeonardo Sandoval SEPARATE_CODE_AND_RODATA \ 136896a8ed14SJiafei Pan SEPARATE_BL2_NOLOAD_REGION \ 1369327131c4SLeonardo Sandoval SEPARATE_NOBITS_REGION \ 1370308ebfa1SMadhukar Pappireddy SEPARATE_SIMD_SECTION \ 1371327131c4SLeonardo Sandoval RECLAIM_INIT_CODE \ 1372327131c4SLeonardo Sandoval SPD_${SPD} \ 1373327131c4SLeonardo Sandoval SPIN_ON_BL1_EXIT \ 1374327131c4SLeonardo Sandoval SPM_MM \ 13751d63ae4dSMarc Bonnici SPMC_AT_EL3 \ 1376801cd3c8SNishant Sharma SPMC_AT_EL3_SEL0_SP \ 1377327131c4SLeonardo Sandoval SPMD_SPM_AT_SEL2 \ 13783ba2c151SRaymond Mao TRANSFER_LIST \ 1379327131c4SLeonardo Sandoval TRUSTED_BOARD_BOOT \ 1380c9c56f6eSManish V Badarkhe CRYPTO_SUPPORT \ 13817dfb9911SJimmy Brisson TRNG_SUPPORT \ 1382ffea3844SSona Mathew ERRATA_ABI_SUPPORT \ 1383ef63f5beSSona Mathew ERRATA_NON_ARM_INTERCONNECT \ 1384327131c4SLeonardo Sandoval USE_COHERENT_MEM \ 1385327131c4SLeonardo Sandoval USE_DEBUGFS \ 1386327131c4SLeonardo Sandoval ARM_IO_IN_DTB \ 1387327131c4SLeonardo Sandoval SDEI_IN_FCONF \ 1388327131c4SLeonardo Sandoval SEC_INT_DESC_IN_FCONF \ 1389327131c4SLeonardo Sandoval USE_ROMLIB \ 1390327131c4SLeonardo Sandoval USE_TBBR_DEFS \ 1391327131c4SLeonardo Sandoval WARMBOOT_ENABLE_DCACHE_EARLY \ 139242d4d3baSArvind Ram Prakash RESET_TO_BL2 \ 139342d4d3baSArvind Ram Prakash BL2_RUNS_AT_EL3 \ 1394327131c4SLeonardo Sandoval BL2_IN_XIP_MEM \ 1395327131c4SLeonardo Sandoval BL2_INV_DCACHE \ 1396327131c4SLeonardo Sandoval USE_SPINLOCK_CAS \ 1397327131c4SLeonardo Sandoval ERRATA_SPECULATIVE_AT \ 139800e8f79cSManish Pandey RAS_TRAP_NS_ERR_REC_ACCESS \ 1399327131c4SLeonardo Sandoval COT_DESC_IN_DTB \ 1400327131c4SLeonardo Sandoval USE_SP804_TIMER \ 140112cd65e0STomas Pilar ENABLE_FEAT_RNG \ 1402ff86e0b4SJuan Pablo Conde ENABLE_FEAT_RNG_TRAP \ 14034e04478aSChris Kay ENABLE_FEAT_SB \ 14047d33ffe4SDaniel Boulby ENABLE_FEAT_DIT \ 14055357f83dSManish V Badarkhe NR_OF_FW_BANKS \ 14065357f83dSManish V Badarkhe NR_OF_IMAGES_IN_FW_BANK \ 1407396b339dSManish V Badarkhe PSA_FWU_SUPPORT \ 140811d05a77SSughosh Ganu PSA_FWU_METADATA_FW_STORE_DESC \ 1409744ad974Sjohpow01 ENABLE_BRBE_FOR_NS \ 1410813524eaSManish V Badarkhe ENABLE_TRBE_FOR_NS \ 1411d4582d30SManish V Badarkhe ENABLE_SYS_REG_TRACE_FOR_NS \ 14128fcd3d96SManish V Badarkhe ENABLE_TRF_FOR_NS \ 1413cb4ec47bSjohpow01 ENABLE_FEAT_HCX \ 141468120783SChris Kay ENABLE_MPMM \ 141568120783SChris Kay ENABLE_MPMM_FCONF \ 1416f74cb0beSJayanth Dodderi Chidanand ENABLE_FEAT_FGT \ 141733e6aaacSArvind Ram Prakash ENABLE_FEAT_FGT2 \ 1418f74cb0beSJayanth Dodderi Chidanand ENABLE_FEAT_ECV \ 14196a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_AMUv1p1 \ 14206a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_SEL2 \ 14216a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_VHE \ 14226a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_CSV2_2 \ 142330019d86SSona Mathew ENABLE_FEAT_CSV2_3 \ 14246a0da736SJayanth Dodderi Chidanand ENABLE_FEAT_PAN \ 1425d3331603SMark Brown ENABLE_FEAT_TCR2 \ 14266d0433f0SJayanth Dodderi Chidanand ENABLE_FEAT_THE \ 1427062b6c6bSMark Brown ENABLE_FEAT_S2PIE \ 1428062b6c6bSMark Brown ENABLE_FEAT_S1PIE \ 1429062b6c6bSMark Brown ENABLE_FEAT_S2POE \ 1430062b6c6bSMark Brown ENABLE_FEAT_S1POE \ 14314ec4e545SJayanth Dodderi Chidanand ENABLE_FEAT_SCTLR2 \ 1432*30655136SGovindraj Raja ENABLE_FEAT_D128 \ 1433688ab57bSMark Brown ENABLE_FEAT_GCS \ 14348e397889SGovindraj Raja ENABLE_FEAT_MTE2 \ 14356a0da736SJayanth Dodderi Chidanand FEATURE_DETECTION \ 1436781d07a4SJayanth Dodderi Chidanand TWED_DELAY \ 1437781d07a4SJayanth Dodderi Chidanand ENABLE_FEAT_TWED \ 143804c7303bSOkash Khawaja CONDITIONAL_CMO \ 14390ed3be6fSVarun Wadekar IMPDEF_SYSREG_TRAP \ 1440a8cf6faeSJayanth Dodderi Chidanand SVE_VECTOR_LEN \ 1441890b5088SRaghu Krishnamurthy ENABLE_SPMD_LP \ 14425782b890SManish V Badarkhe PSA_CRYPTO \ 144385bebe18SSandrine Bailleux ENABLE_CONSOLE_GETC \ 1444183329a5SArvind Ram Prakash INIT_UNUSED_NS_EL2 \ 1445bfef8b90SJuan Pablo Conde PLATFORM_REPORT_CTX_MEM_USE \ 1446ae770fedSYann Gautier EARLY_CONSOLE \ 1447f99a69c3SArvind Ram Prakash PRESERVE_DSU_PMU_REGS \ 1448327131c4SLeonardo Sandoval))) 14492fae4b1eSJeenu Viswambharan 1450bfef8b90SJuan Pablo Condeifeq (${PLATFORM_REPORT_CTX_MEM_USE}, 1) 1451bfef8b90SJuan Pablo Condeifeq (${DEBUG}, 0) 1452bfef8b90SJuan Pablo Conde $(warning "PLATFORM_REPORT_CTX_MEM_USE can be applied when DEBUG=1 only") 1453bfef8b90SJuan Pablo Conde override PLATFORM_REPORT_CTX_MEM_USE := 0 1454bfef8b90SJuan Pablo Condeendif 1455bfef8b90SJuan Pablo Condeendif 1456bfef8b90SJuan Pablo Conde 14571f461979SJustin Chadwellifeq (${SANITIZE_UB},trap) 14581f461979SJustin Chadwell $(eval $(call add_define,MONITOR_TRAPS)) 1459c5e1da83SJayanth Dodderi Chidanandendif #(SANITIZE_UB) 14601f461979SJustin Chadwell 14614c117f6cSSandrine Bailleux# Define the EL3_PAYLOAD_BASE flag only if it is provided. 14624c117f6cSSandrine Bailleuxifdef EL3_PAYLOAD_BASE 14634c117f6cSSandrine Bailleux $(eval $(call add_define,EL3_PAYLOAD_BASE)) 1464cf2c8a33SAntonio Nino Diazelse 146568450a6dSAntonio Nino Diaz# Define the PRELOADED_BL33_BASE flag only if it is provided and 146668450a6dSAntonio Nino Diaz# EL3_PAYLOAD_BASE is not defined, as it has priority. 146768450a6dSAntonio Nino Diaz ifdef PRELOADED_BL33_BASE 146868450a6dSAntonio Nino Diaz $(eval $(call add_define,PRELOADED_BL33_BASE)) 14694c117f6cSSandrine Bailleux endif 1470c5e1da83SJayanth Dodderi Chidanandendif #(EL3_PAYLOAD_BASE) 147173c99d4eSJuan Castillo 1472209a60ccSSoby Mathew# Define the DYN_DISABLE_AUTH flag only if set. 1473209a60ccSSoby Mathewifeq (${DYN_DISABLE_AUTH},1) 1474209a60ccSSoby Mathew $(eval $(call add_define,DYN_DISABLE_AUTH)) 1475209a60ccSSoby Mathewendif 1476209a60ccSSoby Mathew 14778620bd0bSChris Kayifeq ($($(ARCH)-ld-id),arm-link) 1478c2ad38ceSVarun Wadekar $(eval $(call add_define,USE_ARM_LINK)) 1479c2ad38ceSVarun Wadekarendif 1480c2ad38ceSVarun Wadekar 1481ce2b1ec6SManish Pandey# Generate and include sp_gen.mk if SPD is spmd and SP_LAYOUT_FILE is defined 1482ce2b1ec6SManish Pandeyifeq (${SPD},spmd) 1483c33ff198SOlivier Deprezifdef SP_LAYOUT_FILE 1484ce2b1ec6SManish Pandey -include $(BUILD_PLAT)/sp_gen.mk 1485ce2b1ec6SManish Pandey FIP_DEPS += sp 148607c44475SManish Pandey CRT_DEPS += sp 1487ce2b1ec6SManish Pandey NEED_SP_PKG := yes 1488ce2b1ec6SManish Pandeyelse 1489c33ff198SOlivier Deprez ifeq (${SPMD_SPM_AT_SEL2},1) 1490c33ff198SOlivier Deprez $(error "SPMD with SPM at S-EL2 require SP_LAYOUT_FILE") 1491c33ff198SOlivier Deprez endif 1492c5e1da83SJayanth Dodderi Chidanandendif #(SP_LAYOUT_FILE) 1493c5e1da83SJayanth Dodderi Chidanandendif #(SPD) 1494ce2b1ec6SManish Pandey 149573c99d4eSJuan Castillo################################################################################ 149673c99d4eSJuan Castillo# Build targets 149773c99d4eSJuan Castillo################################################################################ 149873c99d4eSJuan Castillo 14992329e22bSHarrison Mutai.PHONY: all msg_start clean realclean distclean cscope locate-checkpatch checkcodebase checkpatch fiptool sptool fip sp tl fwu_fip certtool dtbs memmap doc enctool 150073c99d4eSJuan Castillo.SUFFIXES: 150173c99d4eSJuan Castillo 150273c99d4eSJuan Castilloall: msg_start 150373c99d4eSJuan Castillo 150473c99d4eSJuan Castillomsg_start: 15057c4e1eeaSChris Kay $(s)echo "Building ${PLAT}" 150673c99d4eSJuan Castillo 15077a24cba5SSoby Mathewifeq (${ERROR_DEPRECATED},0) 1508d5dfdeb6SJulius Werner# Check if deprecated declarations and cpp warnings should be treated as error or not. 15098620bd0bSChris Kayifneq ($(filter %-clang,$($(ARCH)-cc-id)),) 1510c2ad38ceSVarun Wadekar CPPFLAGS += -Wno-error=deprecated-declarations 1511c2ad38ceSVarun Wadekarelse 1512bc1a03c7SDan Handley CPPFLAGS += -Wno-error=deprecated-declarations -Wno-error=cpp 15137a24cba5SSoby Mathewendif 1514c5e1da83SJayanth Dodderi Chidanandendif #(!ERROR_DEPRECATED) 15157a24cba5SSoby Mathew 151661f72a34SRoberto Vargas$(eval $(call MAKE_LIB,c)) 15175fee0287SRoberto Vargas 151873c99d4eSJuan Castillo# Expand build macros for the different images 151973c99d4eSJuan Castilloifeq (${NEED_BL1},yes) 1520b34635a0SChris KayBL1_SOURCES := $(sort ${BL1_SOURCES}) 1521434d0491SZelalem Aweke$(eval $(call MAKE_BL,bl1)) 1522c5e1da83SJayanth Dodderi Chidanandendif #(NEED_BL1) 152373c99d4eSJuan Castillo 152473c99d4eSJuan Castilloifeq (${NEED_BL2},yes) 1525c5e1da83SJayanth Dodderi Chidanand 152642d4d3baSArvind Ram Prakashifeq (${RESET_TO_BL2}, 0) 1527c9b31ae8SRoberto VargasFIP_BL2_ARGS := tb-fw 1528c9b31ae8SRoberto Vargasendif 1529c9b31ae8SRoberto Vargas 1530eb1acfb6SChris KayBL2_SOURCES := $(sort ${BL2_SOURCES}) 1531eb1acfb6SChris Kay 153233950dd8SMasahiro Yamada$(if ${BL2}, $(eval $(call TOOL_ADD_IMG,bl2,--${FIP_BL2_ARGS})),\ 1533434d0491SZelalem Aweke $(eval $(call MAKE_BL,bl2,${FIP_BL2_ARGS}))) 1534c5e1da83SJayanth Dodderi Chidanand 1535c5e1da83SJayanth Dodderi Chidanandendif #(NEED_BL2) 153673c99d4eSJuan Castillo 15374d045d0eSMasahiro Yamadaifeq (${NEED_SCP_BL2},yes) 153833950dd8SMasahiro Yamada$(eval $(call TOOL_ADD_IMG,scp_bl2,--scp-fw)) 1539c5e1da83SJayanth Dodderi Chidanandendif #(NEED_SCP_BL2) 15404d045d0eSMasahiro Yamada 154173c99d4eSJuan Castilloifeq (${NEED_BL31},yes) 154273c99d4eSJuan CastilloBL31_SOURCES += ${SPD_SOURCES} 154326d1e0c3SMadhukar Pappireddy# Sort BL31 source files to remove duplicates 154426d1e0c3SMadhukar PappireddyBL31_SOURCES := $(sort ${BL31_SOURCES}) 1545c6ba9b45SSumit Gargifneq (${DECRYPTION_SUPPORT},none) 1546c6ba9b45SSumit Garg$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw,,$(ENCRYPT_BL31))),\ 1547434d0491SZelalem Aweke $(eval $(call MAKE_BL,bl31,soc-fw,,$(ENCRYPT_BL31)))) 1548c6ba9b45SSumit Gargelse 154933950dd8SMasahiro Yamada$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw)),\ 1550434d0491SZelalem Aweke $(eval $(call MAKE_BL,bl31,soc-fw))) 1551c5e1da83SJayanth Dodderi Chidanandendif #(DECRYPTION_SUPPORT) 1552c5e1da83SJayanth Dodderi Chidanandendif #(NEED_BL31) 155373c99d4eSJuan Castillo 155470d1fc53SJuan Castillo# If a BL32 image is needed but neither BL32 nor BL32_SOURCES is defined, the 1555c939d13aSMasahiro Yamada# build system will call TOOL_ADD_IMG to print a warning message and abort the 155670d1fc53SJuan Castillo# process. Note that the dependency on BL32 applies to the FIP only. 155773c99d4eSJuan Castilloifeq (${NEED_BL32},yes) 155826d1e0c3SMadhukar Pappireddy# Sort BL32 source files to remove duplicates 155926d1e0c3SMadhukar PappireddyBL32_SOURCES := $(sort ${BL32_SOURCES}) 15609cd15239SMasahiro YamadaBUILD_BL32 := $(if $(BL32),,$(if $(BL32_SOURCES),1)) 15619cd15239SMasahiro Yamada 1562c6ba9b45SSumit Gargifneq (${DECRYPTION_SUPPORT},none) 1563434d0491SZelalem Aweke$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw,,$(ENCRYPT_BL32))),\ 1564c6ba9b45SSumit Garg $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw,,$(ENCRYPT_BL32)))) 1565c6ba9b45SSumit Gargelse 1566434d0491SZelalem Aweke$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw)),\ 156733950dd8SMasahiro Yamada $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw))) 1568c5e1da83SJayanth Dodderi Chidanandendif #(DECRYPTION_SUPPORT) 1569c5e1da83SJayanth Dodderi Chidanandendif #(NEED_BL32) 157073c99d4eSJuan Castillo 15715b18de09SZelalem Aweke# If RMM image is needed but RMM is not defined, Test Realm Payload (TRP) 15725b18de09SZelalem Aweke# needs to be built from RMM_SOURCES. 15735b18de09SZelalem Awekeifeq (${NEED_RMM},yes) 15745b18de09SZelalem Aweke# Sort RMM source files to remove duplicates 15755b18de09SZelalem AwekeRMM_SOURCES := $(sort ${RMM_SOURCES}) 15765b18de09SZelalem AwekeBUILD_RMM := $(if $(RMM),,$(if $(RMM_SOURCES),1)) 15775b18de09SZelalem Aweke 15785b18de09SZelalem Aweke$(if ${BUILD_RMM}, $(eval $(call MAKE_BL,rmm,rmm-fw)),\ 15795b18de09SZelalem Aweke $(eval $(call TOOL_ADD_IMG,rmm,--rmm-fw))) 1580c5e1da83SJayanth Dodderi Chidanandendif #(NEED_RMM) 15815b18de09SZelalem Aweke 158273c99d4eSJuan Castillo# Add the BL33 image if required by the platform 158373c99d4eSJuan Castilloifeq (${NEED_BL33},yes) 158433950dd8SMasahiro Yamada$(eval $(call TOOL_ADD_IMG,bl33,--nt-fw)) 1585c5e1da83SJayanth Dodderi Chidanandendif #(NEED_BL33) 1586db6071c9SJuan Castillo 15879003fa0bSYatharth Kocharifeq (${NEED_BL2U},yes) 158833950dd8SMasahiro Yamada$(if ${BL2U}, $(eval $(call TOOL_ADD_IMG,bl2u,--ap-fwu-cfg,FWU_)),\ 1589434d0491SZelalem Aweke $(eval $(call MAKE_BL,bl2u,ap-fwu-cfg,FWU_))) 1590c5e1da83SJayanth Dodderi Chidanandendif #(NEED_BL2U) 15919003fa0bSYatharth Kochar 159203b397a8SNishanth Menon# Expand build macros for the different images 159303b397a8SNishanth Menonifeq (${NEED_FDT},yes) 159403b397a8SNishanth Menon $(eval $(call MAKE_DTBS,$(BUILD_PLAT)/fdts,$(FDT_SOURCES))) 1595c5e1da83SJayanth Dodderi Chidanandendif #(NEED_FDT) 159603b397a8SNishanth Menon 1597ce2b1ec6SManish Pandey# Add Secure Partition packages 1598ce2b1ec6SManish Pandeyifeq (${NEED_SP_PKG},yes) 1599fd74ca0dSChris Kay$(BUILD_PLAT)/sp_gen.mk: ${SP_MK_GEN} ${SP_LAYOUT_FILE} | $$(@D)/ 16007c4e1eeaSChris Kay $(q)${PYTHON} "$<" "$@" $(filter-out $<,$^) $(BUILD_PLAT) ${COT} ${SP_DTS_LIST_FRAGMENT} 1601822c7279SJ-Alvessp: $(DTBS) $(BUILD_PLAT)/sp_gen.mk $(SP_PKGS) 16027c4e1eeaSChris Kay $(s)echo 16037c4e1eeaSChris Kay $(s)echo "Built SP Images successfully" 16047c4e1eeaSChris Kay $(s)echo 1605c5e1da83SJayanth Dodderi Chidanandendif #(NEED_SP_PKG) 1606ce2b1ec6SManish Pandey 160736eaaf37SIan Spraylocate-checkpatch: 160836eaaf37SIan Sprayifndef CHECKPATCH 160966079b04SEtienne Carriere $(error "Please set CHECKPATCH to point to the Linux checkpatch.pl file, eg: CHECKPATCH=../linux/scripts/checkpatch.pl") 161036eaaf37SIan Sprayelse 161136eaaf37SIan Sprayifeq (,$(wildcard ${CHECKPATCH})) 161266079b04SEtienne Carriere $(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/scripts/checkpatch.pl") 161336eaaf37SIan Sprayendif 1614c5e1da83SJayanth Dodderi Chidanandendif #(CHECKPATCH) 161536eaaf37SIan Spray 16164f6ad66aSAchin Guptaclean: 16177c4e1eeaSChris Kay $(s)echo " CLEAN" 1618f1477d4aSEvan Lloyd $(call SHELL_REMOVE_DIR,${BUILD_PLAT}) 161988a1cf1eSSami Mujawarifdef UNIX_MK 16207c4e1eeaSChris Kay $(q)${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean 162188a1cf1eSSami Mujawarelse 162288a1cf1eSSami Mujawar# Clear the MAKEFLAGS as we do not want 162388a1cf1eSSami Mujawar# to pass the gnumake flags to nmake. 16247c4e1eeaSChris Kay $(q)set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) clean 1625c5e1da83SJayanth Dodderi Chidanandendif #(UNIX_MK) 16267c4e1eeaSChris Kay $(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean 16277c4e1eeaSChris Kay $(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} clean 16287c4e1eeaSChris Kay $(q)${MAKE} --no-print-directory -C ${ROMLIBPATH} clean 16294f6ad66aSAchin Gupta 1630eaaeece2SJames Morrisseyrealclean distclean: 16317c4e1eeaSChris Kay $(s)echo " REALCLEAN" 1632f1477d4aSEvan Lloyd $(call SHELL_REMOVE_DIR,${BUILD_BASE}) 1633f1477d4aSEvan Lloyd $(call SHELL_DELETE_ALL, ${CURDIR}/cscope.*) 163488a1cf1eSSami Mujawarifdef UNIX_MK 16357c4e1eeaSChris Kay $(q)${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean 163688a1cf1eSSami Mujawarelse 163788a1cf1eSSami Mujawar# Clear the MAKEFLAGS as we do not want 163888a1cf1eSSami Mujawar# to pass the gnumake flags to nmake. 16397c4e1eeaSChris Kay $(q)set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) realclean 1640c5e1da83SJayanth Dodderi Chidanandendif #(UNIX_MK) 16417c4e1eeaSChris Kay $(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} realclean 16427c4e1eeaSChris Kay $(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} realclean 16437c4e1eeaSChris Kay $(q)${MAKE} --no-print-directory -C ${ROMLIBPATH} clean 16444f6ad66aSAchin Gupta 164536eaaf37SIan Spraycheckcodebase: locate-checkpatch 16467c4e1eeaSChris Kay $(s)echo " CHECKING STYLE" 16477c4e1eeaSChris Kay $(q)if test -d .git ; then \ 16481ef35512SPaul Beesley git ls-files | grep -E -v 'libfdt|libc|docs|\.rst' | \ 16491a41e8c1SDan Handley while read GIT_FILE ; \ 16501a41e8c1SDan Handley do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ; \ 16511a41e8c1SDan Handley done ; \ 165236eaaf37SIan Spray else \ 16531a41e8c1SDan Handley find . -type f -not -iwholename "*.git*" \ 16541a41e8c1SDan Handley -not -iwholename "*build*" \ 16551a41e8c1SDan Handley -not -iwholename "*libfdt*" \ 165661f72a34SRoberto Vargas -not -iwholename "*libc*" \ 16571a41e8c1SDan Handley -not -iwholename "*docs*" \ 16581ef35512SPaul Beesley -not -iwholename "*.rst" \ 16591a41e8c1SDan Handley -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ; \ 166036eaaf37SIan Spray fi 166136eaaf37SIan Spray 166236eaaf37SIan Spraycheckpatch: locate-checkpatch 16637c4e1eeaSChris Kay $(s)echo " CHECKING STYLE" 16647c4e1eeaSChris Kay $(q)if test -n "${CHECKPATCH_OPTS}"; then \ 166502a76d5fSYann Gautier echo " with ${CHECKPATCH_OPTS} option(s)"; \ 166602a76d5fSYann Gautier fi 16677c4e1eeaSChris Kay $(q)COMMON_COMMIT=$$(git merge-base HEAD ${BASE_COMMIT}); \ 166877a0a7f1SYann Gautier for commit in `git rev-list --no-merges $$COMMON_COMMIT..HEAD`; \ 166977a0a7f1SYann Gautier do \ 167051d28937SAntonio Nino Diaz printf "\n[*] Checking style of '$$commit'\n\n"; \ 16711a721748SYann Gautier ( git log --format=email "$$commit~..$$commit" \ 16721a721748SYann Gautier -- ${CHECK_PATHS} ; \ 167351d28937SAntonio Nino Diaz git diff --format=email "$$commit~..$$commit" \ 16741a721748SYann Gautier -- ${CHECK_PATHS}; ) | \ 167502a76d5fSYann Gautier ${CHECKPATCH} ${CHECKPATCH_OPTS} - || true; \ 167651d28937SAntonio Nino Diaz done 167736eaaf37SIan Spray 167873c99d4eSJuan Castillocerttool: ${CRTTOOL} 167973c99d4eSJuan Castillo 1680a9812206SPali Rohár${CRTTOOL}: FORCE 16817c4e1eeaSChris Kay $(q)${MAKE} PLAT=${PLAT} USE_TBBR_DEFS=${USE_TBBR_DEFS} COT=${COT} OPENSSL_DIR=${OPENSSL_DIR} CRTTOOL=${CRTTOOL} DEBUG=${DEBUG} --no-print-directory -C ${CRTTOOLPATH} all 16827c4e1eeaSChris Kay $(s)echo 16837c4e1eeaSChris Kay $(s)echo "Built $@ successfully" 16847c4e1eeaSChris Kay $(s)echo 16856f971622SJuan Castillo 16866f971622SJuan Castilloifneq (${GENERATE_COT},0) 168773c99d4eSJuan Castillocertificates: ${CRT_DEPS} ${CRTTOOL} 16887c4e1eeaSChris Kay $(q)${CRTTOOL} ${CRT_ARGS} 16897c4e1eeaSChris Kay $(s)echo 16907c4e1eeaSChris Kay $(s)echo "Built $@ successfully" 16917c4e1eeaSChris Kay $(s)echo "Certificates can be found in ${BUILD_PLAT}" 16927c4e1eeaSChris Kay $(s)echo 1693c5e1da83SJayanth Dodderi Chidanandendif #(GENERATE_COT) 169427713fb4SSoby Mathew 169573c99d4eSJuan Castillo${BUILD_PLAT}/${FIP_NAME}: ${FIP_DEPS} ${FIPTOOL} 16964727fd13SPali Rohár $(eval ${CHECK_FIP_CMD}) 16977c4e1eeaSChris Kay $(q)${FIPTOOL} create ${FIP_ARGS} $@ 16987c4e1eeaSChris Kay $(q)${FIPTOOL} info $@ 16997c4e1eeaSChris Kay $(s)echo 17007c4e1eeaSChris Kay $(s)echo "Built $@ successfully" 17017c4e1eeaSChris Kay $(s)echo 1702f58ad36fSHarry Liebel 17030191262dSYatharth Kocharifneq (${GENERATE_COT},0) 17040191262dSYatharth Kocharfwu_certificates: ${FWU_CRT_DEPS} ${CRTTOOL} 17057c4e1eeaSChris Kay $(q)${CRTTOOL} ${FWU_CRT_ARGS} 17067c4e1eeaSChris Kay $(s)echo 17077c4e1eeaSChris Kay $(s)echo "Built $@ successfully" 17087c4e1eeaSChris Kay $(s)echo "FWU certificates can be found in ${BUILD_PLAT}" 17097c4e1eeaSChris Kay $(s)echo 1710c5e1da83SJayanth Dodderi Chidanandendif #(GENERATE_COT) 17110191262dSYatharth Kochar 17120191262dSYatharth Kochar${BUILD_PLAT}/${FWU_FIP_NAME}: ${FWU_FIP_DEPS} ${FIPTOOL} 17134727fd13SPali Rohár $(eval ${CHECK_FWU_FIP_CMD}) 17147c4e1eeaSChris Kay $(q)${FIPTOOL} create ${FWU_FIP_ARGS} $@ 17157c4e1eeaSChris Kay $(q)${FIPTOOL} info $@ 17167c4e1eeaSChris Kay $(s)echo 17177c4e1eeaSChris Kay $(s)echo "Built $@ successfully" 17187c4e1eeaSChris Kay $(s)echo 17190191262dSYatharth Kochar 172073c99d4eSJuan Castillofiptool: ${FIPTOOL} 172173c99d4eSJuan Castillofip: ${BUILD_PLAT}/${FIP_NAME} 17220191262dSYatharth Kocharfwu_fip: ${BUILD_PLAT}/${FWU_FIP_NAME} 172373c99d4eSJuan Castillo 1724a9812206SPali Rohár${FIPTOOL}: FORCE 172588a1cf1eSSami Mujawarifdef UNIX_MK 172640469bf9SManish V Badarkhe $(q)${MAKE} PLAT=${PLAT} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" FIPTOOL=${FIPTOOL} OPENSSL_DIR=${OPENSSL_DIR} DEBUG=${DEBUG} --no-print-directory -C ${FIPTOOLPATH} all 172788a1cf1eSSami Mujawarelse 172888a1cf1eSSami Mujawar# Clear the MAKEFLAGS as we do not want 172988a1cf1eSSami Mujawar# to pass the gnumake flags to nmake. 17307c4e1eeaSChris Kay $(q)set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) 1731c5e1da83SJayanth Dodderi Chidanandendif #(UNIX_MK) 1732f58ad36fSHarry Liebel 1733a9812206SPali Rohárromlib.bin: libraries FORCE 17347c4e1eeaSChris Kay $(q)${MAKE} PLAT_DIR=${PLAT_DIR} BUILD_PLAT=${BUILD_PLAT} ENABLE_BTI=${ENABLE_BTI} ARM_ARCH_MINOR=${ARM_ARCH_MINOR} INCLUDES=$(call escape-shell,$(INCLUDES)) DEFINES=$(call escape-shell,$(DEFINES)) --no-print-directory -C ${ROMLIBPATH} all 17355accce5bSRoberto Vargas 1736cfe83910SLouis Mayencourtmemmap: all 1737af5b49e9SHarrison Mutaiifdef UNIX_MK 17387c4e1eeaSChris Kay $(q)PYTHONPATH=${CURDIR}/tools/memory \ 1739af5b49e9SHarrison Mutai ${PYTHON} -m memory.memmap -sr ${BUILD_PLAT} 1740af5b49e9SHarrison Mutaielse 17417c4e1eeaSChris Kay $(q)set PYTHONPATH=${CURDIR}/tools/memory && \ 1742af5b49e9SHarrison Mutai ${PYTHON} -m memory.memmap -sr ${BUILD_PLAT} 1743af5b49e9SHarrison Mutaiendif 1744cfe83910SLouis Mayencourt 17452329e22bSHarrison Mutaitl: ${BUILD_PLAT}/tl.bin 17462329e22bSHarrison Mutai${BUILD_PLAT}/tl.bin: ${HW_CONFIG} 1747d2867397SChris Kay $(if $(host-poetry),$(q)poetry -q install) 1748d2867397SChris Kay $(q)$(if $(host-poetry),poetry run )tlc create --fdt $< -s ${FW_HANDOFF_SIZE} $@ 17492329e22bSHarrison Mutai 17506de32378SMadhukar Pappireddydoc: 17517c4e1eeaSChris Kay $(s)echo " BUILD DOCUMENTATION" 17527c4e1eeaSChris Kay $(q)${MAKE} --no-print-directory -C ${DOCS_PATH} html 17536de32378SMadhukar Pappireddy 175490aa901fSSumit Gargenctool: ${ENCTOOL} 175590aa901fSSumit Garg 1756a9812206SPali Rohár${ENCTOOL}: FORCE 17577c4e1eeaSChris Kay $(q)${MAKE} PLAT=${PLAT} BUILD_INFO=0 OPENSSL_DIR=${OPENSSL_DIR} ENCTOOL=${ENCTOOL} DEBUG=${DEBUG} --no-print-directory -C ${ENCTOOLPATH} all 17587c4e1eeaSChris Kay $(s)echo 17597c4e1eeaSChris Kay $(s)echo "Built $@ successfully" 17607c4e1eeaSChris Kay $(s)echo 176190aa901fSSumit Garg 176235fab8c9SJoakim Bechcscope: 17637c4e1eeaSChris Kay $(s)echo " CSCOPE" 17647c4e1eeaSChris Kay $(q)find ${CURDIR} -name "*.[chsS]" > cscope.files 17657c4e1eeaSChris Kay $(q)cscope -b -q -k 176635fab8c9SJoakim Bech 176772ee3314SRyan Harkinhelp: 17687c4e1eeaSChris Kay $(s)echo "usage: ${MAKE} [PLAT=<platform>] [OPTIONS] [TARGET]" 17697c4e1eeaSChris Kay $(s)echo "" 17707c4e1eeaSChris Kay $(s)echo "PLAT is used to specify which platform you wish to build." 17717c4e1eeaSChris Kay $(s)echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}" 17727c4e1eeaSChris Kay $(s)echo "" 17737c4e1eeaSChris Kay $(s)echo "platform = ${PLATFORM_LIST}" 17747c4e1eeaSChris Kay $(s)echo "" 17757c4e1eeaSChris Kay $(s)echo "Please refer to the User Guide for a list of all supported options." 17767c4e1eeaSChris Kay $(s)echo "Note that the build system doesn't track dependencies for build " 17777c4e1eeaSChris Kay $(s)echo "options. Therefore, if any of the build options are changed " 17787c4e1eeaSChris Kay $(s)echo "from a previous build, a clean build must be performed." 17797c4e1eeaSChris Kay $(s)echo "" 17807c4e1eeaSChris Kay $(s)echo "Supported Targets:" 17817c4e1eeaSChris Kay $(s)echo " all Build all individual bootloader binaries" 17827c4e1eeaSChris Kay $(s)echo " bl1 Build the BL1 binary" 17837c4e1eeaSChris Kay $(s)echo " bl2 Build the BL2 binary" 17847c4e1eeaSChris Kay $(s)echo " bl2u Build the BL2U binary" 17857c4e1eeaSChris Kay $(s)echo " bl31 Build the BL31 binary" 17867c4e1eeaSChris Kay $(s)echo " bl32 Build the BL32 binary. If ARCH=aarch32, then " 17877c4e1eeaSChris Kay $(s)echo " this builds secure payload specified by AARCH32_SP" 17887c4e1eeaSChris Kay $(s)echo " certificates Build the certificates (requires 'GENERATE_COT=1')" 17897c4e1eeaSChris Kay $(s)echo " fip Build the Firmware Image Package (FIP)" 17907c4e1eeaSChris Kay $(s)echo " fwu_fip Build the FWU Firmware Image Package (FIP)" 17917c4e1eeaSChris Kay $(s)echo " checkcodebase Check the coding style of the entire source tree" 17927c4e1eeaSChris Kay $(s)echo " checkpatch Check the coding style on changes in the current" 17937c4e1eeaSChris Kay $(s)echo " branch against BASE_COMMIT (default origin/master)" 17947c4e1eeaSChris Kay $(s)echo " clean Clean the build for the selected platform" 17957c4e1eeaSChris Kay $(s)echo " cscope Generate cscope index" 17967c4e1eeaSChris Kay $(s)echo " distclean Remove all build artifacts for all platforms" 17977c4e1eeaSChris Kay $(s)echo " certtool Build the Certificate generation tool" 17987c4e1eeaSChris Kay $(s)echo " enctool Build the Firmware encryption tool" 17997c4e1eeaSChris Kay $(s)echo " fiptool Build the Firmware Image Package (FIP) creation tool" 18007c4e1eeaSChris Kay $(s)echo " sp Build the Secure Partition Packages" 18017c4e1eeaSChris Kay $(s)echo " sptool Build the Secure Partition Package creation tool" 18027c4e1eeaSChris Kay $(s)echo " dtbs Build the Device Tree Blobs (if required for the platform)" 18037c4e1eeaSChris Kay $(s)echo " memmap Print the memory map of the built binaries" 18047c4e1eeaSChris Kay $(s)echo " doc Build html based documentation using Sphinx tool" 18057c4e1eeaSChris Kay $(s)echo "" 18067c4e1eeaSChris Kay $(s)echo "Note: most build targets require PLAT to be set to a specific platform." 18077c4e1eeaSChris Kay $(s)echo "" 18087c4e1eeaSChris Kay $(s)echo "example: build all targets for the FVP platform:" 18097c4e1eeaSChris Kay $(s)echo " CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all" 1810a9812206SPali Rohár 1811a9812206SPali Rohár.PHONY: FORCE 1812a9812206SPali RohárFORCE:; 1813