1# 2# Copyright (c) 2013-2024, Arm Limited and Contributors. All rights reserved. 3# 4# SPDX-License-Identifier: BSD-3-Clause 5# 6 7# 8# Trusted Firmware Version 9# 10VERSION_MAJOR := 2 11VERSION_MINOR := 11 12# VERSION_PATCH is only used for LTS releases 13VERSION_PATCH := 0 14VERSION := ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH} 15 16# Default goal is build all images 17.DEFAULT_GOAL := all 18 19# Avoid any implicit propagation of command line variable definitions to 20# sub-Makefiles, like CFLAGS that we reserved for the firmware images' 21# usage. Other command line options like "-s" are still propagated as usual. 22MAKEOVERRIDES = 23 24MAKE_HELPERS_DIRECTORY := make_helpers/ 25include ${MAKE_HELPERS_DIRECTORY}build_macros.mk 26include ${MAKE_HELPERS_DIRECTORY}build_env.mk 27include ${MAKE_HELPERS_DIRECTORY}build-rules.mk 28include ${MAKE_HELPERS_DIRECTORY}common.mk 29 30################################################################################ 31# Default values for build configurations, and their dependencies 32################################################################################ 33 34include ${MAKE_HELPERS_DIRECTORY}defaults.mk 35 36################################################################################ 37# Configure the toolchains used to build TF-A and its tools 38################################################################################ 39 40# 41# The clean and check targets do not behave correctly if the user's environment 42# does not appropriately configure a toolchain. While we try to find a permanent 43# solution to this, do not try to detect any toolchains if we are building 44# exclusively with targets which do not use any toolchain tools. 45# 46 47ifeq ($(filter-out check% %clean doc %tool,$(or $(MAKECMDGOALS),all)),) 48 toolchains := 49endif 50 51include ${MAKE_HELPERS_DIRECTORY}toolchain.mk 52 53# Assertions enabled for DEBUG builds by default 54ENABLE_ASSERTIONS := ${DEBUG} 55ENABLE_PMF := ${ENABLE_RUNTIME_INSTRUMENTATION} 56PLAT := ${DEFAULT_PLAT} 57 58################################################################################ 59# Checkpatch script options 60################################################################################ 61 62CHECKCODE_ARGS := --no-patch 63# Do not check the coding style on imported library files or documentation files 64INC_DRV_DIRS_TO_CHECK := $(sort $(filter-out \ 65 include/drivers/arm, \ 66 $(wildcard include/drivers/*))) 67INC_LIB_DIRS_TO_CHECK := $(sort $(filter-out \ 68 include/lib/libfdt \ 69 include/lib/libc, \ 70 $(wildcard include/lib/*))) 71INC_DIRS_TO_CHECK := $(sort $(filter-out \ 72 include/lib \ 73 include/drivers, \ 74 $(wildcard include/*))) 75LIB_DIRS_TO_CHECK := $(sort $(filter-out \ 76 lib/compiler-rt \ 77 lib/libfdt% \ 78 lib/libc, \ 79 lib/zlib \ 80 $(wildcard lib/*))) 81ROOT_DIRS_TO_CHECK := $(sort $(filter-out \ 82 lib \ 83 include \ 84 docs \ 85 %.rst, \ 86 $(wildcard *))) 87CHECK_PATHS := ${ROOT_DIRS_TO_CHECK} \ 88 ${INC_DIRS_TO_CHECK} \ 89 ${INC_LIB_DIRS_TO_CHECK} \ 90 ${LIB_DIRS_TO_CHECK} \ 91 ${INC_DRV_DIRS_TO_CHECK} \ 92 ${INC_ARM_DIRS_TO_CHECK} 93 94################################################################################ 95# Process build options 96################################################################################ 97 98ifeq ($(verbose),) 99 CHECKCODE_ARGS += --no-summary --terse 100endif 101 102################################################################################ 103# Auxiliary tools (fiptool, cert_create, etc) 104################################################################################ 105 106# Variables for use with Certificate Generation Tool 107CRTTOOLPATH ?= tools/cert_create 108CRTTOOL ?= ${CRTTOOLPATH}/cert_create${BIN_EXT} 109 110# Variables for use with Firmware Encryption Tool 111ENCTOOLPATH ?= tools/encrypt_fw 112ENCTOOL ?= ${ENCTOOLPATH}/encrypt_fw${BIN_EXT} 113 114# Variables for use with Firmware Image Package 115FIPTOOLPATH ?= tools/fiptool 116FIPTOOL ?= ${FIPTOOLPATH}/fiptool${BIN_EXT} 117 118# Variables for use with sptool 119SPTOOLPATH ?= tools/sptool 120SPTOOL ?= ${SPTOOLPATH}/sptool.py 121SP_MK_GEN ?= ${SPTOOLPATH}/sp_mk_generator.py 122SP_DTS_LIST_FRAGMENT ?= ${BUILD_PLAT}/sp_list_fragment.dts 123 124# Variables for use with Certificate Conversion (cot-dt2c) Tool 125CERTCONVPATH ?= tools/cot_dt2c 126 127# Variables for use with ROMLIB 128ROMLIBPATH ?= lib/romlib 129 130# Variable for use with Python 131PYTHON ?= python3 132 133# Variables for use with documentation build using Sphinx tool 134DOCS_PATH ?= docs 135 136################################################################################ 137# Compiler Configuration based on ARCH_MAJOR and ARCH_MINOR flags 138################################################################################ 139ifeq (${ARM_ARCH_MAJOR},7) 140 target32-directive = -target arm-none-eabi 141# Will set march-directive from platform configuration 142else 143 target32-directive = -target armv8a-none-eabi 144endif #(ARM_ARCH_MAJOR) 145 146################################################################################ 147# Get Architecture Feature Modifiers 148################################################################################ 149arch-features = ${ARM_ARCH_FEATURE} 150 151ifneq ($(filter %-clang,$($(ARCH)-cc-id)),) 152 ifeq ($($(ARCH)-cc-id),arm-clang) 153 TF_CFLAGS_aarch32 := -target arm-arm-none-eabi 154 TF_CFLAGS_aarch64 := -target aarch64-arm-none-eabi 155 else 156 TF_CFLAGS_aarch32 = $(target32-directive) 157 TF_CFLAGS_aarch64 := -target aarch64-elf 158 endif 159 160else ifeq ($($(ARCH)-cc-id),gnu-gcc) 161 # Enable LTO only for aarch64 162 ifeq (${ARCH},aarch64) 163 LTO_CFLAGS = $(if $(filter-out 0,$(ENABLE_LTO)),-flto) 164 endif 165endif #(clang) 166 167# Process Debug flag 168$(eval $(call add_define,DEBUG)) 169ifneq (${DEBUG}, 0) 170 BUILD_TYPE := debug 171 TF_CFLAGS += -g -gdwarf-4 172 ASFLAGS += -g -Wa,-gdwarf-4 173 174 # Use LOG_LEVEL_INFO by default for debug builds 175 LOG_LEVEL := 40 176else 177 BUILD_TYPE := release 178 # Use LOG_LEVEL_NOTICE by default for release builds 179 LOG_LEVEL := 20 180endif #(Debug) 181 182# Default build string (git branch and commit) 183ifeq (${BUILD_STRING},) 184 BUILD_STRING := $(shell git describe --always --dirty --tags 2> /dev/null) 185endif 186VERSION_STRING := v${VERSION}(${BUILD_TYPE}):${BUILD_STRING} 187 188ifeq (${AARCH32_INSTRUCTION_SET},A32) 189 TF_CFLAGS_aarch32 += -marm 190else ifeq (${AARCH32_INSTRUCTION_SET},T32) 191 TF_CFLAGS_aarch32 += -mthumb 192else 193 $(error Error: Unknown AArch32 instruction set ${AARCH32_INSTRUCTION_SET}) 194endif #(AARCH32_INSTRUCTION_SET) 195 196TF_CFLAGS_aarch32 += -mno-unaligned-access 197TF_CFLAGS_aarch64 += -mgeneral-regs-only -mstrict-align 198 199############################################################################## 200# WARNINGS Configuration 201############################################################################### 202# General warnings 203WARNINGS := -Wall -Wmissing-include-dirs -Wunused \ 204 -Wdisabled-optimization -Wvla -Wshadow \ 205 -Wredundant-decls 206# stricter warnings 207WARNINGS += -Wextra -Wno-trigraphs 208# too verbose for generic build 209WARNINGS += -Wno-missing-field-initializers \ 210 -Wno-type-limits -Wno-sign-compare \ 211# on clang this flag gets reset if -Wextra is set after it. No difference on gcc 212WARNINGS += -Wno-unused-parameter 213 214# Additional warnings 215# Level 1 - infrequent warnings we should have none of 216# full -Wextra 217WARNING1 += -Wsign-compare 218WARNING1 += -Wtype-limits 219WARNING1 += -Wmissing-field-initializers 220 221# Level 2 - problematic warnings that we want 222# zlib, compiler-rt, coreboot, and mbdedtls blow up with these 223# TODO: disable just for them and move into default build 224WARNING2 += -Wold-style-definition 225WARNING2 += -Wmissing-prototypes 226WARNING2 += -Wmissing-format-attribute 227# TF-A aims to comply with this eventually. Effort too large at present 228WARNING2 += -Wundef 229# currently very involved and many platforms set this off 230WARNING2 += -Wunused-const-variable=2 231 232# Level 3 - very pedantic, frequently ignored 233WARNING3 := -Wbad-function-cast 234WARNING3 += -Waggregate-return 235WARNING3 += -Wnested-externs 236WARNING3 += -Wcast-align 237WARNING3 += -Wcast-qual 238WARNING3 += -Wconversion 239WARNING3 += -Wpacked 240WARNING3 += -Wpointer-arith 241WARNING3 += -Wswitch-default 242 243# Setting W is quite verbose and most warnings will be pre-existing issues 244# outside of the contributor's control. Don't fail the build on them so warnings 245# can be seen and hopefully addressed 246ifdef W 247 ifneq (${W},0) 248 E ?= 0 249 endif 250endif 251 252ifeq (${W},1) 253 WARNINGS += $(WARNING1) 254else ifeq (${W},2) 255 WARNINGS += $(WARNING1) $(WARNING2) 256else ifeq (${W},3) 257 WARNINGS += $(WARNING1) $(WARNING2) $(WARNING3) 258endif #(W) 259 260# Compiler specific warnings 261ifeq ($(filter %-clang,$($(ARCH)-cc-id)),) 262# not using clang 263WARNINGS += -Wunused-but-set-variable -Wmaybe-uninitialized \ 264 -Wpacked-bitfield-compat -Wshift-overflow=2 \ 265 -Wlogical-op 266 267# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105523 268TF_CFLAGS += $(call cc_option, --param=min-pagesize=0) 269 270ifeq ($(HARDEN_SLS), 1) 271 TF_CFLAGS_aarch64 += $(call cc_option, -mharden-sls=all) 272endif 273 274else 275# using clang 276WARNINGS += -Wshift-overflow -Wshift-sign-overflow \ 277 -Wlogical-op-parentheses 278endif #(Clang Warning) 279 280ifneq (${E},0) 281 ERRORS := -Werror 282endif #(E) 283 284################################################################################ 285# Compiler and Linker Directives 286################################################################################ 287CPPFLAGS = ${DEFINES} ${INCLUDES} ${MBEDTLS_INC} -nostdinc \ 288 $(ERRORS) $(WARNINGS) 289ASFLAGS += $(CPPFLAGS) \ 290 -ffreestanding -Wa,--fatal-warnings 291TF_CFLAGS += $(CPPFLAGS) $(TF_CFLAGS_$(ARCH)) \ 292 -ffunction-sections -fdata-sections \ 293 -ffreestanding -fno-builtin -fno-common \ 294 -Os -std=gnu99 295 296ifeq (${SANITIZE_UB},on) 297 TF_CFLAGS += -fsanitize=undefined -fno-sanitize-recover 298endif #(${SANITIZE_UB},on) 299 300ifeq (${SANITIZE_UB},trap) 301 TF_CFLAGS += -fsanitize=undefined -fno-sanitize-recover \ 302 -fsanitize-undefined-trap-on-error 303endif #(${SANITIZE_UB},trap) 304 305GCC_V_OUTPUT := $(if $($(ARCH)-cc),$(shell $($(ARCH)-cc) -v 2>&1)) 306 307TF_LDFLAGS += -z noexecstack 308 309# LD = armlink 310ifeq ($($(ARCH)-ld-id),arm-link) 311 TF_LDFLAGS += --diag_error=warning --lto_level=O1 312 TF_LDFLAGS += --remove --info=unused,unusedsymbols 313 TF_LDFLAGS += $(TF_LDFLAGS_$(ARCH)) 314 315# LD = gcc (used when GCC LTO is enabled) 316else ifeq ($($(ARCH)-ld-id),gnu-gcc) 317 # Pass ld options with Wl or Xlinker switches 318 TF_LDFLAGS += $(call ld_option,-Xlinker --no-warn-rwx-segments) 319 TF_LDFLAGS += -Wl,--fatal-warnings -O1 320 TF_LDFLAGS += -Wl,--gc-sections 321 322 TF_LDFLAGS += -Wl,-z,common-page-size=4096 #Configure page size constants 323 TF_LDFLAGS += -Wl,-z,max-page-size=4096 324 TF_LDFLAGS += -Wl,--build-id=none 325 326 ifeq ($(ENABLE_LTO),1) 327 ifeq (${ARCH},aarch64) 328 TF_LDFLAGS += -flto -fuse-linker-plugin 329 TF_LDFLAGS += -flto-partition=one 330 endif 331 endif #(ENABLE_LTO) 332 333# GCC automatically adds fix-cortex-a53-843419 flag when used to link 334# which breaks some builds, so disable if errata fix is not explicitly enabled 335 ifeq (${ARCH},aarch64) 336 ifneq (${ERRATA_A53_843419},1) 337 TF_LDFLAGS += -mno-fix-cortex-a53-843419 338 endif 339 endif 340 TF_LDFLAGS += -nostdlib 341 TF_LDFLAGS += $(subst --,-Xlinker --,$(TF_LDFLAGS_$(ARCH))) 342 343# LD = gcc-ld (ld) or llvm-ld (ld.lld) or other 344else 345# With ld.bfd version 2.39 and newer new warnings are added. Skip those since we 346# are not loaded by a elf loader. 347 TF_LDFLAGS += $(call ld_option, --no-warn-rwx-segments) 348 TF_LDFLAGS += -O1 349 TF_LDFLAGS += --gc-sections 350 351 TF_LDFLAGS += -z common-page-size=4096 # Configure page size constants 352 TF_LDFLAGS += -z max-page-size=4096 353 TF_LDFLAGS += --build-id=none 354 355# ld.lld doesn't recognize the errata flags, 356# therefore don't add those in that case. 357# ld.lld reports section type mismatch warnings, 358# therefore don't add --fatal-warnings to it. 359 ifneq ($($(ARCH)-ld-id),llvm-lld) 360 TF_LDFLAGS += $(TF_LDFLAGS_$(ARCH)) --fatal-warnings 361 endif 362 363endif #(LD = armlink) 364 365################################################################################ 366# Setup ARCH_MAJOR/MINOR before parsing arch_features. 367################################################################################ 368ifeq (${ENABLE_RME},1) 369 ARM_ARCH_MAJOR := 9 370 ARM_ARCH_MINOR := 2 371endif 372 373################################################################################ 374# Common sources and include directories 375################################################################################ 376include lib/compiler-rt/compiler-rt.mk 377 378# Allow overriding the timestamp, for example for reproducible builds, or to 379# synchronize timestamps across multiple projects. 380# This must be set to a C string (including quotes where applicable). 381BUILD_MESSAGE_TIMESTAMP ?= __TIME__", "__DATE__ 382 383DEFINES += -DBUILD_MESSAGE_TIMESTAMP='$(BUILD_MESSAGE_TIMESTAMP)' 384DEFINES += -DBUILD_MESSAGE_VERSION_STRING='"$(VERSION_STRING)"' 385DEFINES += -DBUILD_MESSAGE_VERSION='"$(VERSION)"' 386 387BL_COMMON_SOURCES += common/bl_common.c \ 388 common/tf_log.c \ 389 common/${ARCH}/debug.S \ 390 drivers/console/multi_console.c \ 391 lib/${ARCH}/cache_helpers.S \ 392 lib/${ARCH}/misc_helpers.S \ 393 lib/extensions/pmuv3/${ARCH}/pmuv3.c \ 394 plat/common/plat_bl_common.c \ 395 plat/common/plat_log_common.c \ 396 plat/common/${ARCH}/plat_common.c \ 397 plat/common/${ARCH}/platform_helpers.S \ 398 ${COMPILER_RT_SRCS} 399 400ifeq ($($(ARCH)-cc-id),arm-clang) 401 BL_COMMON_SOURCES += lib/${ARCH}/armclang_printf.S 402endif 403 404ifeq (${SANITIZE_UB},on) 405 BL_COMMON_SOURCES += plat/common/ubsan.c 406endif 407 408INCLUDES += -Iinclude \ 409 -Iinclude/arch/${ARCH} \ 410 -Iinclude/lib/cpus/${ARCH} \ 411 -Iinclude/lib/el3_runtime/${ARCH} \ 412 ${PLAT_INCLUDES} \ 413 ${SPD_INCLUDES} 414 415DTC_FLAGS += -I dts -O dtb 416DTC_CPPFLAGS += -P -nostdinc $(INCLUDES) -Ifdts -undef \ 417 -x assembler-with-cpp $(DEFINES) 418 419include common/backtrace/backtrace.mk 420 421################################################################################ 422# Generic definitions 423################################################################################ 424include ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk 425 426ifeq (${BUILD_BASE},) 427 BUILD_BASE := ./build 428endif 429BUILD_PLAT := $(abspath ${BUILD_BASE})/${PLAT}/${BUILD_TYPE} 430 431SPDS := $(sort $(filter-out none, $(patsubst services/spd/%,%,$(wildcard services/spd/*)))) 432 433# Platforms providing their own TBB makefile may override this value 434INCLUDE_TBBR_MK := 1 435 436################################################################################ 437# Include SPD Makefile if one has been specified 438################################################################################ 439 440ifneq (${SPD},none) 441 ifeq (${ARCH},aarch32) 442 $(error "Error: SPD is incompatible with AArch32.") 443 endif 444 445 ifdef EL3_PAYLOAD_BASE 446 $(warning "SPD and EL3_PAYLOAD_BASE are incompatible build options.") 447 $(warning "The SPD and its BL32 companion will be present but \ 448 ignored.") 449 endif 450 451 ifeq (${SPD},spmd) 452 # SPMD is located in std_svc directory 453 SPD_DIR := std_svc 454 455 ifeq ($(SPMD_SPM_AT_SEL2),1) 456 CTX_INCLUDE_EL2_REGS := 1 457 ifeq ($(SPMC_AT_EL3),1) 458 $(error SPM cannot be enabled in both S-EL2 and EL3.) 459 endif 460 ifeq ($(CTX_INCLUDE_SVE_REGS),1) 461 $(error SVE context management not needed with Hafnium SPMC.) 462 endif 463 endif 464 465 ifeq ($(findstring optee_sp,$(ARM_SPMC_MANIFEST_DTS)),optee_sp) 466 DTC_CPPFLAGS += -DOPTEE_SP_FW_CONFIG 467 endif 468 469 ifeq ($(findstring trusty_sp,$(ARM_SPMC_MANIFEST_DTS)),trusty_sp) 470 DTC_CPPFLAGS += -DTRUSTY_SP_FW_CONFIG 471 endif 472 473 ifeq ($(TS_SP_FW_CONFIG),1) 474 DTC_CPPFLAGS += -DTS_SP_FW_CONFIG 475 endif 476 477 ifneq ($(ARM_BL2_SP_LIST_DTS),) 478 DTC_CPPFLAGS += -DARM_BL2_SP_LIST_DTS=$(ARM_BL2_SP_LIST_DTS) 479 endif 480 481 ifneq ($(SP_LAYOUT_FILE),) 482 BL2_ENABLE_SP_LOAD := 1 483 endif 484 485 ifeq ($(SPMC_AT_EL3_SEL0_SP),1) 486 ifneq ($(SPMC_AT_EL3),1) 487 $(error SEL0 SP cannot be enabled without SPMC at EL3) 488 endif 489 endif 490 else 491 # All other SPDs in spd directory 492 SPD_DIR := spd 493 endif #(SPD) 494 495 # We expect to locate an spd.mk under the specified SPD directory 496 SPD_MAKE := $(wildcard services/${SPD_DIR}/${SPD}/${SPD}.mk) 497 498 ifeq (${SPD_MAKE},) 499 $(error Error: No services/${SPD_DIR}/${SPD}/${SPD}.mk located) 500 endif 501 $(info Including ${SPD_MAKE}) 502 include ${SPD_MAKE} 503 504 # If there's BL32 companion for the chosen SPD, we expect that the SPD's 505 # Makefile would set NEED_BL32 to "yes". In this case, the build system 506 # supports two mutually exclusive options: 507 # * BL32 is built from source: then BL32_SOURCES must contain the list 508 # of source files to build BL32 509 # * BL32 is a prebuilt binary: then BL32 must point to the image file 510 # that will be included in the FIP 511 # If both BL32_SOURCES and BL32 are defined, the binary takes precedence 512 # over the sources. 513endif #(SPD=none) 514 515ifeq (${ENABLE_SPMD_LP}, 1) 516ifneq (${SPD},spmd) 517 $(error Error: ENABLE_SPMD_LP requires SPD=spmd.) 518endif 519ifeq ($(SPMC_AT_EL3),1) 520 $(error SPMC at EL3 not supported when enabling SPMD Logical partitions.) 521endif 522endif 523 524################################################################################ 525# Process BRANCH_PROTECTION value and set 526# Pointer Authentication and Branch Target Identification flags 527################################################################################ 528ifeq (${BRANCH_PROTECTION},0) 529 # Default value turns off all types of branch protection 530 BP_OPTION := none 531else ifneq (${ARCH},aarch64) 532 $(error BRANCH_PROTECTION requires AArch64) 533else ifeq (${BRANCH_PROTECTION},1) 534 # Enables all types of branch protection features 535 BP_OPTION := standard 536 ENABLE_BTI := 1 537 ENABLE_PAUTH := 1 538else ifeq (${BRANCH_PROTECTION},2) 539 # Return address signing to its standard level 540 BP_OPTION := pac-ret 541 ENABLE_PAUTH := 1 542else ifeq (${BRANCH_PROTECTION},3) 543 # Extend the signing to include leaf functions 544 BP_OPTION := pac-ret+leaf 545 ENABLE_PAUTH := 1 546else ifeq (${BRANCH_PROTECTION},4) 547 # Turn on branch target identification mechanism 548 BP_OPTION := bti 549 ENABLE_BTI := 1 550else 551 $(error Unknown BRANCH_PROTECTION value ${BRANCH_PROTECTION}) 552endif #(BRANCH_PROTECTION) 553 554ifeq ($(ENABLE_PAUTH),1) 555 CTX_INCLUDE_PAUTH_REGS := 1 556endif 557ifneq (${BP_OPTION},none) 558 TF_CFLAGS_aarch64 += -mbranch-protection=${BP_OPTION} 559endif #(BP_OPTION) 560 561# Pointer Authentication sources 562ifeq (${ENABLE_PAUTH}, 1) 563# arm/common/aarch64/arm_pauth.c contains a sample platform hook to complete the 564# Pauth support. As it's not secure, it must be reimplemented for real platforms 565 BL_COMMON_SOURCES += lib/extensions/pauth/pauth_helpers.S 566endif 567 568################################################################################ 569# Include the platform specific Makefile after the SPD Makefile (the platform 570# makefile may use all previous definitions in this file) 571################################################################################ 572include ${PLAT_MAKEFILE_FULL} 573 574################################################################################ 575# Setup arch_features based on ARM_ARCH_MAJOR, ARM_ARCH_MINOR provided from 576# platform. 577################################################################################ 578include ${MAKE_HELPERS_DIRECTORY}arch_features.mk 579 580#################################################### 581# Enable required options for Memory Stack Tagging. 582#################################################### 583 584# Currently, these options are enabled only for clang and armclang compiler. 585ifeq (${SUPPORT_STACK_MEMTAG},yes) 586 ifdef mem_tag_arch_support 587 # Check for armclang and clang compilers 588 ifneq ($(filter %-clang,$($(ARCH)-cc-id)),) 589 # Add "memtag" architecture feature modifier if not specified 590 ifeq ( ,$(findstring memtag,$(arch-features))) 591 arch-features := $(arch-features)+memtag 592 endif # memtag 593 ifeq ($($(ARCH)-cc-id),arm-clang) 594 TF_CFLAGS += -mmemtag-stack 595 else ifeq ($($(ARCH)-cc-id),llvm-clang) 596 TF_CFLAGS += -fsanitize=memtag 597 endif # armclang 598 endif 599 else 600 $(error "Error: stack memory tagging is not supported for \ 601 architecture ${ARCH},armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a") 602 endif #(mem_tag_arch_support) 603endif #(SUPPORT_STACK_MEMTAG) 604 605################################################################################ 606# RME dependent flags configuration, Enable optional features for RME. 607################################################################################ 608# FEAT_RME 609ifeq (${ENABLE_RME},1) 610 # RME doesn't support BRBE 611 ENABLE_BRBE_FOR_NS := 0 612 613 # RME doesn't support PIE 614 ifneq (${ENABLE_PIE},0) 615 $(error ENABLE_RME does not support PIE) 616 endif 617 618 # RME doesn't support BRBE 619 ifneq (${ENABLE_BRBE_FOR_NS},0) 620 $(error ENABLE_RME does not support BRBE.) 621 endif 622 623 # RME requires AARCH64 624 ifneq (${ARCH},aarch64) 625 $(error ENABLE_RME requires AArch64) 626 endif 627 628 # RME requires el2 context to be saved for now. 629 CTX_INCLUDE_EL2_REGS := 1 630 CTX_INCLUDE_AARCH32_REGS := 0 631 CTX_INCLUDE_PAUTH_REGS := 1 632 633 # RME enables CSV2_2 extension by default. 634 ENABLE_FEAT_CSV2_2 = 1 635endif #(FEAT_RME) 636 637################################################################################ 638# Include rmmd Makefile if RME is enabled 639################################################################################ 640ifneq (${ENABLE_RME},0) 641 ifneq (${ARCH},aarch64) 642 $(error ENABLE_RME requires AArch64) 643 endif 644 ifeq ($(SPMC_AT_EL3),1) 645 $(error SPMC_AT_EL3 and ENABLE_RME cannot both be enabled.) 646 endif 647 648 ifneq (${SPD}, none) 649 ifneq (${SPD}, spmd) 650 $(error ENABLE_RME is incompatible with SPD=${SPD}. Use SPD=spmd) 651 endif 652 endif 653include services/std_svc/rmmd/rmmd.mk 654$(warning "RME is an experimental feature") 655endif 656 657ifeq (${CTX_INCLUDE_EL2_REGS}, 1) 658 ifeq (${SPD},none) 659 ifeq (${ENABLE_RME},0) 660 $(error CTX_INCLUDE_EL2_REGS is available only when SPD \ 661 or RME is enabled) 662 endif 663 endif 664endif 665 666################################################################################ 667# Platform specific Makefile might provide us ARCH_MAJOR/MINOR use that to come 668# up with appropriate march values for compiler. 669################################################################################ 670include ${MAKE_HELPERS_DIRECTORY}march.mk 671 672TF_CFLAGS += $(march-directive) 673ASFLAGS += $(march-directive) 674 675# This internal flag is common option which is set to 1 for scenarios 676# when the BL2 is running in EL3 level. This occurs in two scenarios - 677# 4 world system running BL2 at EL3 and two world system without BL1 running 678# BL2 in EL3 679 680ifeq (${RESET_TO_BL2},1) 681 BL2_RUNS_AT_EL3 := 1 682 ifeq (${ENABLE_RME},1) 683 $(error RESET_TO_BL2=1 and ENABLE_RME=1 configuration is not \ 684 supported at the moment.) 685 endif 686else ifeq (${ENABLE_RME},1) 687 BL2_RUNS_AT_EL3 := 1 688else 689 BL2_RUNS_AT_EL3 := 0 690endif 691 692# This internal flag is set to 1 when Firmware First handling of External aborts 693# is required by lowe ELs. Currently only NS requires this support. 694ifeq ($(HANDLE_EA_EL3_FIRST_NS),1) 695 FFH_SUPPORT := 1 696else 697 FFH_SUPPORT := 0 698endif 699 700ifeq (${ARM_ARCH_MAJOR},7) 701include make_helpers/armv7-a-cpus.mk 702endif 703 704PIE_FOUND := $(findstring --enable-default-pie,${GCC_V_OUTPUT}) 705ifneq ($(PIE_FOUND),) 706 TF_CFLAGS += -fno-PIE 707ifeq ($($(ARCH)-ld-id),gnu-gcc) 708 TF_LDFLAGS += -no-pie 709endif 710endif #(PIE_FOUND) 711 712ifeq ($($(ARCH)-ld-id),gnu-gcc) 713 PIE_LDFLAGS += -Wl,-pie -Wl,--no-dynamic-linker 714else 715 PIE_LDFLAGS += -pie --no-dynamic-linker 716endif 717 718ifeq ($(ENABLE_PIE),1) 719 ifeq ($(RESET_TO_BL2),1) 720 ifneq ($(BL2_IN_XIP_MEM),1) 721 BL2_CPPFLAGS += -fpie 722 BL2_CFLAGS += -fpie 723 BL2_LDFLAGS += $(PIE_LDFLAGS) 724 endif #(BL2_IN_XIP_MEM) 725 endif #(RESET_TO_BL2) 726 BL31_CPPFLAGS += -fpie 727 BL31_CFLAGS += -fpie 728 BL31_LDFLAGS += $(PIE_LDFLAGS) 729 730 BL32_CPPFLAGS += -fpie 731 BL32_CFLAGS += -fpie 732 BL32_LDFLAGS += $(PIE_LDFLAGS) 733endif #(ENABLE_PIE) 734 735BL1_CPPFLAGS += -DREPORT_ERRATA=${DEBUG} 736BL31_CPPFLAGS += -DREPORT_ERRATA=${DEBUG} 737BL32_CPPFLAGS += -DREPORT_ERRATA=${DEBUG} 738 739BL1_CPPFLAGS += -DIMAGE_AT_EL3 740ifeq ($(RESET_TO_BL2),1) 741 BL2_CPPFLAGS += -DIMAGE_AT_EL3 742else 743 BL2_CPPFLAGS += -DIMAGE_AT_EL1 744endif #(RESET_TO_BL2) 745 746ifeq (${ARCH},aarch64) 747 BL2U_CPPFLAGS += -DIMAGE_AT_EL1 748 BL31_CPPFLAGS += -DIMAGE_AT_EL3 749 BL32_CPPFLAGS += -DIMAGE_AT_EL1 750else 751 BL32_CPPFLAGS += -DIMAGE_AT_EL3 752endif 753 754# Include the CPU specific operations makefile, which provides default 755# values for all CPU errata workarounds and CPU specific optimisations. 756# This can be overridden by the platform. 757include lib/cpus/cpu-ops.mk 758 759################################################################################ 760# Build `AARCH32_SP` as BL32 image for AArch32 761################################################################################ 762ifeq (${ARCH},aarch32) 763 NEED_BL32 := yes 764 765 ifneq (${AARCH32_SP},none) 766 # We expect to locate an sp.mk under the specified AARCH32_SP directory 767 AARCH32_SP_MAKE := $(wildcard bl32/${AARCH32_SP}/${AARCH32_SP}.mk) 768 769 ifeq (${AARCH32_SP_MAKE},) 770 $(error Error: No bl32/${AARCH32_SP}/${AARCH32_SP}.mk located) 771 endif 772 $(info Including ${AARCH32_SP_MAKE}) 773 include ${AARCH32_SP_MAKE} 774 endif 775endif #(ARCH=aarch32) 776 777################################################################################ 778# Include libc if not overridden 779################################################################################ 780ifeq (${OVERRIDE_LIBC},0) 781include lib/libc/libc.mk 782endif 783 784################################################################################ 785# Check incompatible options and dependencies 786################################################################################ 787 788# USE_DEBUGFS experimental feature recommended only in debug builds 789ifeq (${USE_DEBUGFS},1) 790 ifeq (${DEBUG},1) 791 $(warning DEBUGFS experimental feature is enabled.) 792 else 793 $(warning DEBUGFS experimental, recommended in DEBUG builds ONLY) 794 endif 795endif #(USE_DEBUGFS) 796 797# USE_SPINLOCK_CAS requires AArch64 build 798ifeq (${USE_SPINLOCK_CAS},1) 799 ifneq (${ARCH},aarch64) 800 $(error USE_SPINLOCK_CAS requires AArch64) 801 endif 802endif #(USE_SPINLOCK_CAS) 803 804# The cert_create tool cannot generate certificates individually, so we use the 805# target 'certificates' to create them all 806ifneq (${GENERATE_COT},0) 807 FIP_DEPS += certificates 808 FWU_FIP_DEPS += fwu_certificates 809endif 810 811ifneq (${DECRYPTION_SUPPORT},none) 812 ENC_ARGS += -f ${FW_ENC_STATUS} 813 ENC_ARGS += -k ${ENC_KEY} 814 ENC_ARGS += -n ${ENC_NONCE} 815 FIP_DEPS += enctool 816 FWU_FIP_DEPS += enctool 817endif #(DECRYPTION_SUPPORT) 818 819ifdef EL3_PAYLOAD_BASE 820 ifdef PRELOADED_BL33_BASE 821 $(warning "PRELOADED_BL33_BASE and EL3_PAYLOAD_BASE are \ 822 incompatible build options. EL3_PAYLOAD_BASE has priority.") 823 endif 824 ifneq (${GENERATE_COT},0) 825 $(error "GENERATE_COT and EL3_PAYLOAD_BASE are incompatible \ 826 build options.") 827 endif 828 ifneq (${TRUSTED_BOARD_BOOT},0) 829 $(error "TRUSTED_BOARD_BOOT and EL3_PAYLOAD_BASE are \ 830 incompatible \ build options.") 831 endif 832endif #(EL3_PAYLOAD_BASE) 833 834ifeq (${NEED_BL33},yes) 835 ifdef EL3_PAYLOAD_BASE 836 $(warning "BL33 image is not needed when option \ 837 BL33_PAYLOAD_BASE is used and won't be added to the FIP file.") 838 endif 839 ifdef PRELOADED_BL33_BASE 840 $(warning "BL33 image is not needed when option \ 841 PRELOADED_BL33_BASE is used and won't be added to the FIP file.") 842 endif 843endif #(NEED_BL33) 844 845# When building for systems with hardware-assisted coherency, there's no need to 846# use USE_COHERENT_MEM. Require that USE_COHERENT_MEM must be set to 0 too. 847ifeq ($(HW_ASSISTED_COHERENCY)-$(USE_COHERENT_MEM),1-1) 848 $(error USE_COHERENT_MEM cannot be enabled with HW_ASSISTED_COHERENCY) 849endif 850 851#For now, BL2_IN_XIP_MEM is only supported when RESET_TO_BL2 is 1. 852ifeq ($(RESET_TO_BL2)-$(BL2_IN_XIP_MEM),0-1) 853 $(error "BL2_IN_XIP_MEM is only supported when RESET_TO_BL2 is enabled") 854endif 855 856# RAS_EXTENSION is deprecated, provide alternate build options 857ifeq ($(RAS_EXTENSION),1) 858 $(error "RAS_EXTENSION is now deprecated, please use ENABLE_FEAT_RAS \ 859 and HANDLE_EA_EL3_FIRST_NS instead") 860endif 861 862 863# When FAULT_INJECTION_SUPPORT is used, require that FEAT_RAS is enabled 864ifeq ($(FAULT_INJECTION_SUPPORT),1) 865 ifeq ($(ENABLE_FEAT_RAS),0) 866 $(error For FAULT_INJECTION_SUPPORT, ENABLE_FEAT_RAS must not be 0) 867 endif 868endif #(FAULT_INJECTION_SUPPORT) 869 870# DYN_DISABLE_AUTH can be set only when TRUSTED_BOARD_BOOT=1 871ifeq ($(DYN_DISABLE_AUTH), 1) 872 ifeq (${TRUSTED_BOARD_BOOT}, 0) 873 $(error "TRUSTED_BOARD_BOOT must be enabled for DYN_DISABLE_AUTH \ 874 to be set.") 875 endif 876endif #(DYN_DISABLE_AUTH) 877 878ifeq ($(MEASURED_BOOT)-$(TRUSTED_BOARD_BOOT),1-1) 879# Support authentication verification and hash calculation 880 CRYPTO_SUPPORT := 3 881else ifeq ($(DRTM_SUPPORT)-$(TRUSTED_BOARD_BOOT),1-1) 882# Support authentication verification and hash calculation 883 CRYPTO_SUPPORT := 3 884else ifneq ($(filter 1,${MEASURED_BOOT} ${DRTM_SUPPORT}),) 885# Support hash calculation only 886 CRYPTO_SUPPORT := 2 887else ifeq (${TRUSTED_BOARD_BOOT},1) 888# Support authentication verification only 889 CRYPTO_SUPPORT := 1 890else 891 CRYPTO_SUPPORT := 0 892endif #($(MEASURED_BOOT)-$(TRUSTED_BOARD_BOOT)) 893 894# SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled. 895ifeq ($(SDEI_SUPPORT)-$(SDEI_IN_FCONF),0-1) 896 $(error "SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled") 897endif 898 899# If pointer authentication is used in the firmware, make sure that all the 900# registers associated to it are also saved and restored. 901# Not doing it would leak the value of the keys used by EL3 to EL1 and S-EL1. 902ifeq ($(ENABLE_PAUTH),1) 903 ifeq ($(CTX_INCLUDE_PAUTH_REGS),0) 904 $(error Pointer Authentication requires CTX_INCLUDE_PAUTH_REGS=1) 905 endif 906endif #(ENABLE_PAUTH) 907 908ifeq ($(CTX_INCLUDE_PAUTH_REGS),1) 909 ifneq (${ARCH},aarch64) 910 $(error CTX_INCLUDE_PAUTH_REGS requires AArch64) 911 endif 912endif #(CTX_INCLUDE_PAUTH_REGS) 913 914ifeq ($(FEATURE_DETECTION),1) 915 $(info FEATURE_DETECTION is an experimental feature) 916endif #(FEATURE_DETECTION) 917 918ifneq ($(ENABLE_SME2_FOR_NS), 0) 919 ifeq (${ENABLE_SME_FOR_NS}, 0) 920 $(warning "ENABLE_SME2_FOR_NS requires ENABLE_SME_FOR_NS also \ 921 to be set") 922 $(warning "Forced ENABLE_SME_FOR_NS=1") 923 override ENABLE_SME_FOR_NS := 1 924 endif 925endif #(ENABLE_SME2_FOR_NS) 926 927ifeq (${ARM_XLAT_TABLES_LIB_V1}, 1) 928 ifeq (${ALLOW_RO_XLAT_TABLES}, 1) 929 $(error "ALLOW_RO_XLAT_TABLES requires translation tables \ 930 library v2") 931 endif 932endif #(ARM_XLAT_TABLES_LIB_V1) 933 934ifneq (${DECRYPTION_SUPPORT},none) 935 ifeq (${TRUSTED_BOARD_BOOT}, 0) 936 $(error TRUSTED_BOARD_BOOT must be enabled for DECRYPTION_SUPPORT \ 937 to be set) 938 endif 939endif #(DECRYPTION_SUPPORT) 940 941# Ensure that no Aarch64-only features are enabled in Aarch32 build 942ifeq (${ARCH},aarch32) 943 944 # SME/SVE only supported on AArch64 945 ifneq (${ENABLE_SME_FOR_NS},0) 946 $(error "ENABLE_SME_FOR_NS cannot be used with ARCH=aarch32") 947 endif 948 949 ifeq (${ENABLE_SVE_FOR_NS},1) 950 # Warning instead of error due to CI dependency on this 951 $(error "ENABLE_SVE_FOR_NS cannot be used with ARCH=aarch32") 952 endif 953 954 # BRBE is not supported in AArch32 955 ifeq (${ENABLE_BRBE_FOR_NS},1) 956 $(error "ENABLE_BRBE_FOR_NS cannot be used with ARCH=aarch32") 957 endif 958 959 # FEAT_RNG_TRAP is not supported in AArch32 960 ifeq (${ENABLE_FEAT_RNG_TRAP},1) 961 $(error "ENABLE_FEAT_RNG_TRAP cannot be used with ARCH=aarch32") 962 endif 963endif #(ARCH=aarch32) 964 965ifneq (${ENABLE_SME_FOR_NS},0) 966 ifeq (${ENABLE_SVE_FOR_NS},0) 967 $(error "ENABLE_SME_FOR_NS requires ENABLE_SVE_FOR_NS") 968 endif 969endif #(ENABLE_SME_FOR_NS) 970 971# Secure SME/SVE requires the non-secure component as well 972ifeq (${ENABLE_SME_FOR_SWD},1) 973 ifeq (${ENABLE_SME_FOR_NS},0) 974 $(error "ENABLE_SME_FOR_SWD requires ENABLE_SME_FOR_NS") 975 endif 976 ifeq (${ENABLE_SVE_FOR_SWD},0) 977 $(error "ENABLE_SME_FOR_SWD requires ENABLE_SVE_FOR_SWD") 978 endif 979endif #(ENABLE_SME_FOR_SWD) 980 981# Enabling SVE for SWD requires enabling SVE for NWD due to ENABLE_FEAT 982# mechanism. 983ifeq (${ENABLE_SVE_FOR_SWD},1) 984 ifeq (${ENABLE_SVE_FOR_NS},0) 985 $(error "ENABLE_SVE_FOR_SWD requires ENABLE_SVE_FOR_NS") 986 endif 987endif 988 989# Enabling SVE for both the worlds typically requires the context 990# management of SVE registers. The only exception being SPMC at S-EL2. 991ifeq (${ENABLE_SVE_FOR_SWD}, 1) 992 ifneq (${ENABLE_SVE_FOR_NS}, 0) 993 ifeq (${CTX_INCLUDE_SVE_REGS}-$(SPMD_SPM_AT_SEL2),0-0) 994 $(warning "ENABLE_SVE_FOR_SWD and ENABLE_SVE_FOR_NS together require CTX_INCLUDE_SVE_REGS") 995 endif 996 endif 997endif 998 999# Enabling SVE in either world while enabling CTX_INCLUDE_FPREGS requires 1000# CTX_INCLUDE_SVE_REGS to be enabled due to architectural dependency between FP 1001# and SVE registers. 1002ifeq (${CTX_INCLUDE_FPREGS}, 1) 1003 ifneq (${ENABLE_SVE_FOR_NS},0) 1004 ifeq (${CTX_INCLUDE_SVE_REGS},0) 1005 # Warning instead of error due to CI dependency on this 1006 $(warning "CTX_INCLUDE_FPREGS and ENABLE_SVE_FOR_NS together require CTX_INCLUDE_SVE_REGS") 1007 $(warning "Forced ENABLE_SVE_FOR_NS=0") 1008 override ENABLE_SVE_FOR_NS := 0 1009 endif 1010 endif 1011endif #(CTX_INCLUDE_FPREGS) 1012 1013# SVE context management is only required if secure world has access to SVE/FP 1014# functionality. 1015ifeq (${CTX_INCLUDE_SVE_REGS},1) 1016 ifeq (${ENABLE_SVE_FOR_SWD},0) 1017 $(error "CTX_INCLUDE_SVE_REGS requires ENABLE_SVE_FOR_SWD to also be enabled") 1018 endif 1019endif 1020 1021# SME cannot be used with CTX_INCLUDE_FPREGS since SPM does its own context 1022# management including FPU registers. 1023ifeq (${CTX_INCLUDE_FPREGS},1) 1024 ifneq (${ENABLE_SME_FOR_NS},0) 1025 $(error "ENABLE_SME_FOR_NS cannot be used with CTX_INCLUDE_FPREGS") 1026 endif 1027endif #(CTX_INCLUDE_FPREGS) 1028 1029ifeq ($(DRTM_SUPPORT),1) 1030 $(info DRTM_SUPPORT is an experimental feature) 1031endif 1032 1033ifeq (${TRANSFER_LIST},1) 1034 $(info TRANSFER_LIST is an experimental feature) 1035endif 1036 1037ifeq (${ENABLE_RME},1) 1038 ifneq (${SEPARATE_CODE_AND_RODATA},1) 1039 $(error `ENABLE_RME=1` requires `SEPARATE_CODE_AND_RODATA=1`) 1040 endif 1041endif 1042 1043ifeq ($(PSA_CRYPTO),1) 1044 $(info PSA_CRYPTO is an experimental feature) 1045endif 1046 1047ifeq ($(DICE_PROTECTION_ENVIRONMENT),1) 1048 $(info DICE_PROTECTION_ENVIRONMENT is an experimental feature) 1049endif 1050 1051################################################################################ 1052# Process platform overrideable behaviour 1053################################################################################ 1054 1055ifdef BL1_SOURCES 1056 NEED_BL1 := yes 1057endif #(BL1_SOURCES) 1058 1059ifdef BL2_SOURCES 1060 NEED_BL2 := yes 1061 1062 # Using BL2 implies that a BL33 image also needs to be supplied for the FIP and 1063 # Certificate generation tools. This flag can be overridden by the platform. 1064 ifdef EL3_PAYLOAD_BASE 1065 # If booting an EL3 payload there is no need for a BL33 image 1066 # in the FIP file. 1067 NEED_BL33 := no 1068 else 1069 ifdef PRELOADED_BL33_BASE 1070 # If booting a BL33 preloaded image there is no need of 1071 # another one in the FIP file. 1072 NEED_BL33 := no 1073 else 1074 NEED_BL33 ?= yes 1075 endif 1076 endif 1077endif #(BL2_SOURCES) 1078 1079ifdef BL2U_SOURCES 1080 NEED_BL2U := yes 1081endif #(BL2U_SOURCES) 1082 1083# If SCP_BL2 is given, we always want FIP to include it. 1084ifdef SCP_BL2 1085 NEED_SCP_BL2 := yes 1086endif #(SCP_BL2) 1087 1088# For AArch32, BL31 is not currently supported. 1089ifneq (${ARCH},aarch32) 1090 ifdef BL31_SOURCES 1091 # When booting an EL3 payload, there is no need to compile the BL31 1092 # image nor put it in the FIP. 1093 ifndef EL3_PAYLOAD_BASE 1094 NEED_BL31 := yes 1095 endif 1096 endif 1097endif #(ARCH=aarch64) 1098 1099# Process TBB related flags 1100ifneq (${GENERATE_COT},0) 1101 # Common cert_create options 1102 ifneq (${CREATE_KEYS},0) 1103 $(eval CRT_ARGS += -n) 1104 $(eval FWU_CRT_ARGS += -n) 1105 ifneq (${SAVE_KEYS},0) 1106 $(eval CRT_ARGS += -k) 1107 $(eval FWU_CRT_ARGS += -k) 1108 endif 1109 endif 1110 # Include TBBR makefile (unless the platform indicates otherwise) 1111 ifeq (${INCLUDE_TBBR_MK},1) 1112 include make_helpers/tbbr/tbbr_tools.mk 1113 endif 1114endif #(GENERATE_COT) 1115 1116ifneq (${FIP_ALIGN},0) 1117 FIP_ARGS += --align ${FIP_ALIGN} 1118endif #(FIP_ALIGN) 1119 1120ifdef FDT_SOURCES 1121 NEED_FDT := yes 1122endif #(FDT_SOURCES) 1123 1124################################################################################ 1125# Include libraries' Makefile that are used in all BL 1126################################################################################ 1127 1128include lib/stack_protector/stack_protector.mk 1129 1130################################################################################ 1131# Include BL specific makefiles 1132################################################################################ 1133 1134ifeq (${NEED_BL1},yes) 1135include bl1/bl1.mk 1136endif 1137 1138ifeq (${NEED_BL2},yes) 1139include bl2/bl2.mk 1140endif 1141 1142ifeq (${NEED_BL2U},yes) 1143include bl2u/bl2u.mk 1144endif 1145 1146ifeq (${NEED_BL31},yes) 1147include bl31/bl31.mk 1148endif 1149 1150################################################################################ 1151# Build options checks 1152################################################################################ 1153 1154# Boolean_Flags 1155$(eval $(call assert_booleans,\ 1156 $(sort \ 1157 ALLOW_RO_XLAT_TABLES \ 1158 BL2_ENABLE_SP_LOAD \ 1159 COLD_BOOT_SINGLE_CPU \ 1160 CREATE_KEYS \ 1161 CTX_INCLUDE_AARCH32_REGS \ 1162 CTX_INCLUDE_FPREGS \ 1163 CTX_INCLUDE_SVE_REGS \ 1164 CTX_INCLUDE_EL2_REGS \ 1165 CTX_INCLUDE_MPAM_REGS \ 1166 DEBUG \ 1167 DYN_DISABLE_AUTH \ 1168 EL3_EXCEPTION_HANDLING \ 1169 ENABLE_AMU_AUXILIARY_COUNTERS \ 1170 ENABLE_AMU_FCONF \ 1171 AMU_RESTRICT_COUNTERS \ 1172 ENABLE_ASSERTIONS \ 1173 ENABLE_PIE \ 1174 ENABLE_PMF \ 1175 ENABLE_PSCI_STAT \ 1176 ENABLE_RUNTIME_INSTRUMENTATION \ 1177 ENABLE_SME_FOR_SWD \ 1178 ENABLE_SVE_FOR_SWD \ 1179 ENABLE_FEAT_RAS \ 1180 FFH_SUPPORT \ 1181 ERROR_DEPRECATED \ 1182 FAULT_INJECTION_SUPPORT \ 1183 GENERATE_COT \ 1184 GICV2_G0_FOR_EL3 \ 1185 HANDLE_EA_EL3_FIRST_NS \ 1186 HARDEN_SLS \ 1187 HW_ASSISTED_COHERENCY \ 1188 MEASURED_BOOT \ 1189 DICE_PROTECTION_ENVIRONMENT \ 1190 DRTM_SUPPORT \ 1191 NS_TIMER_SWITCH \ 1192 OVERRIDE_LIBC \ 1193 PL011_GENERIC_UART \ 1194 PROGRAMMABLE_RESET_ADDRESS \ 1195 PSCI_EXTENDED_STATE_ID \ 1196 PSCI_OS_INIT_MODE \ 1197 RESET_TO_BL31 \ 1198 SAVE_KEYS \ 1199 SEPARATE_CODE_AND_RODATA \ 1200 SEPARATE_BL2_NOLOAD_REGION \ 1201 SEPARATE_NOBITS_REGION \ 1202 SEPARATE_SIMD_SECTION \ 1203 SPIN_ON_BL1_EXIT \ 1204 SPM_MM \ 1205 SPMC_AT_EL3 \ 1206 SPMC_AT_EL3_SEL0_SP \ 1207 SPMD_SPM_AT_SEL2 \ 1208 ENABLE_SPMD_LP \ 1209 TRANSFER_LIST \ 1210 TRUSTED_BOARD_BOOT \ 1211 USE_COHERENT_MEM \ 1212 USE_DEBUGFS \ 1213 ARM_IO_IN_DTB \ 1214 SDEI_IN_FCONF \ 1215 SEC_INT_DESC_IN_FCONF \ 1216 USE_ROMLIB \ 1217 USE_TBBR_DEFS \ 1218 WARMBOOT_ENABLE_DCACHE_EARLY \ 1219 RESET_TO_BL2 \ 1220 BL2_IN_XIP_MEM \ 1221 BL2_INV_DCACHE \ 1222 USE_SPINLOCK_CAS \ 1223 ENCRYPT_BL31 \ 1224 ENCRYPT_BL32 \ 1225 ERRATA_SPECULATIVE_AT \ 1226 RAS_TRAP_NS_ERR_REC_ACCESS \ 1227 COT_DESC_IN_DTB \ 1228 USE_SP804_TIMER \ 1229 PSA_FWU_SUPPORT \ 1230 PSA_FWU_METADATA_FW_STORE_DESC \ 1231 ENABLE_MPMM \ 1232 ENABLE_MPMM_FCONF \ 1233 FEATURE_DETECTION \ 1234 TRNG_SUPPORT \ 1235 ERRATA_ABI_SUPPORT \ 1236 ERRATA_NON_ARM_INTERCONNECT \ 1237 CONDITIONAL_CMO \ 1238 PSA_CRYPTO \ 1239 ENABLE_CONSOLE_GETC \ 1240 INIT_UNUSED_NS_EL2 \ 1241 PLATFORM_REPORT_CTX_MEM_USE \ 1242 EARLY_CONSOLE \ 1243 PRESERVE_DSU_PMU_REGS \ 1244))) 1245 1246# Numeric_Flags 1247$(eval $(call assert_numerics,\ 1248 $(sort \ 1249 ARM_ARCH_MAJOR \ 1250 ARM_ARCH_MINOR \ 1251 BRANCH_PROTECTION \ 1252 CTX_INCLUDE_PAUTH_REGS \ 1253 CTX_INCLUDE_NEVE_REGS \ 1254 CRYPTO_SUPPORT \ 1255 DISABLE_MTPMU \ 1256 ENABLE_BRBE_FOR_NS \ 1257 ENABLE_TRBE_FOR_NS \ 1258 ENABLE_BTI \ 1259 ENABLE_PAUTH \ 1260 ENABLE_FEAT_AMU \ 1261 ENABLE_FEAT_AMUv1p1 \ 1262 ENABLE_FEAT_CSV2_2 \ 1263 ENABLE_FEAT_CSV2_3 \ 1264 ENABLE_FEAT_DEBUGV8P9 \ 1265 ENABLE_FEAT_DIT \ 1266 ENABLE_FEAT_ECV \ 1267 ENABLE_FEAT_FGT \ 1268 ENABLE_FEAT_FGT2 \ 1269 ENABLE_FEAT_HCX \ 1270 ENABLE_FEAT_MTE2 \ 1271 ENABLE_FEAT_PAN \ 1272 ENABLE_FEAT_RNG \ 1273 ENABLE_FEAT_RNG_TRAP \ 1274 ENABLE_FEAT_SEL2 \ 1275 ENABLE_FEAT_TCR2 \ 1276 ENABLE_FEAT_SB \ 1277 ENABLE_FEAT_S2PIE \ 1278 ENABLE_FEAT_S1PIE \ 1279 ENABLE_FEAT_S2POE \ 1280 ENABLE_FEAT_S1POE \ 1281 ENABLE_FEAT_GCS \ 1282 ENABLE_FEAT_VHE \ 1283 ENABLE_FEAT_MPAM \ 1284 ENABLE_RME \ 1285 ENABLE_SPE_FOR_NS \ 1286 ENABLE_SYS_REG_TRACE_FOR_NS \ 1287 ENABLE_SME_FOR_NS \ 1288 ENABLE_SME2_FOR_NS \ 1289 ENABLE_SVE_FOR_NS \ 1290 ENABLE_TRF_FOR_NS \ 1291 FW_ENC_STATUS \ 1292 NR_OF_FW_BANKS \ 1293 NR_OF_IMAGES_IN_FW_BANK \ 1294 TWED_DELAY \ 1295 ENABLE_FEAT_TWED \ 1296 SVE_VECTOR_LEN \ 1297 IMPDEF_SYSREG_TRAP \ 1298))) 1299 1300ifdef KEY_SIZE 1301 $(eval $(call assert_numeric,KEY_SIZE)) 1302endif 1303 1304ifeq ($(filter $(SANITIZE_UB), on off trap),) 1305 $(error "Invalid value for SANITIZE_UB: can be one of on, off, trap") 1306endif 1307 1308################################################################################ 1309# Add definitions to the cpp preprocessor based on the current build options. 1310# This is done after including the platform specific makefile to allow the 1311# platform to overwrite the default options 1312################################################################################ 1313 1314$(eval $(call add_defines,\ 1315 $(sort \ 1316 ALLOW_RO_XLAT_TABLES \ 1317 ARM_ARCH_MAJOR \ 1318 ARM_ARCH_MINOR \ 1319 BL2_ENABLE_SP_LOAD \ 1320 COLD_BOOT_SINGLE_CPU \ 1321 CTX_INCLUDE_AARCH32_REGS \ 1322 CTX_INCLUDE_FPREGS \ 1323 CTX_INCLUDE_SVE_REGS \ 1324 CTX_INCLUDE_PAUTH_REGS \ 1325 CTX_INCLUDE_MPAM_REGS \ 1326 EL3_EXCEPTION_HANDLING \ 1327 CTX_INCLUDE_EL2_REGS \ 1328 CTX_INCLUDE_NEVE_REGS \ 1329 DECRYPTION_SUPPORT_${DECRYPTION_SUPPORT} \ 1330 DISABLE_MTPMU \ 1331 ENABLE_FEAT_AMU \ 1332 ENABLE_AMU_AUXILIARY_COUNTERS \ 1333 ENABLE_AMU_FCONF \ 1334 AMU_RESTRICT_COUNTERS \ 1335 ENABLE_ASSERTIONS \ 1336 ENABLE_BTI \ 1337 ENABLE_FEAT_DEBUGV8P9 \ 1338 ENABLE_FEAT_MPAM \ 1339 ENABLE_PAUTH \ 1340 ENABLE_PIE \ 1341 ENABLE_PMF \ 1342 ENABLE_PSCI_STAT \ 1343 ENABLE_RME \ 1344 ENABLE_RUNTIME_INSTRUMENTATION \ 1345 ENABLE_SME_FOR_NS \ 1346 ENABLE_SME2_FOR_NS \ 1347 ENABLE_SME_FOR_SWD \ 1348 ENABLE_SPE_FOR_NS \ 1349 ENABLE_SVE_FOR_NS \ 1350 ENABLE_SVE_FOR_SWD \ 1351 ENABLE_FEAT_RAS \ 1352 FFH_SUPPORT \ 1353 ENCRYPT_BL31 \ 1354 ENCRYPT_BL32 \ 1355 ERROR_DEPRECATED \ 1356 FAULT_INJECTION_SUPPORT \ 1357 GICV2_G0_FOR_EL3 \ 1358 HANDLE_EA_EL3_FIRST_NS \ 1359 HW_ASSISTED_COHERENCY \ 1360 LOG_LEVEL \ 1361 MEASURED_BOOT \ 1362 DICE_PROTECTION_ENVIRONMENT \ 1363 DRTM_SUPPORT \ 1364 NS_TIMER_SWITCH \ 1365 PL011_GENERIC_UART \ 1366 PLAT_${PLAT} \ 1367 PROGRAMMABLE_RESET_ADDRESS \ 1368 PSCI_EXTENDED_STATE_ID \ 1369 PSCI_OS_INIT_MODE \ 1370 RESET_TO_BL31 \ 1371 RME_GPT_BITLOCK_BLOCK \ 1372 RME_GPT_MAX_BLOCK \ 1373 SEPARATE_CODE_AND_RODATA \ 1374 SEPARATE_BL2_NOLOAD_REGION \ 1375 SEPARATE_NOBITS_REGION \ 1376 SEPARATE_SIMD_SECTION \ 1377 RECLAIM_INIT_CODE \ 1378 SPD_${SPD} \ 1379 SPIN_ON_BL1_EXIT \ 1380 SPM_MM \ 1381 SPMC_AT_EL3 \ 1382 SPMC_AT_EL3_SEL0_SP \ 1383 SPMD_SPM_AT_SEL2 \ 1384 TRANSFER_LIST \ 1385 TRUSTED_BOARD_BOOT \ 1386 CRYPTO_SUPPORT \ 1387 TRNG_SUPPORT \ 1388 ERRATA_ABI_SUPPORT \ 1389 ERRATA_NON_ARM_INTERCONNECT \ 1390 USE_COHERENT_MEM \ 1391 USE_DEBUGFS \ 1392 ARM_IO_IN_DTB \ 1393 SDEI_IN_FCONF \ 1394 SEC_INT_DESC_IN_FCONF \ 1395 USE_ROMLIB \ 1396 USE_TBBR_DEFS \ 1397 WARMBOOT_ENABLE_DCACHE_EARLY \ 1398 RESET_TO_BL2 \ 1399 BL2_RUNS_AT_EL3 \ 1400 BL2_IN_XIP_MEM \ 1401 BL2_INV_DCACHE \ 1402 USE_SPINLOCK_CAS \ 1403 ERRATA_SPECULATIVE_AT \ 1404 RAS_TRAP_NS_ERR_REC_ACCESS \ 1405 COT_DESC_IN_DTB \ 1406 USE_SP804_TIMER \ 1407 ENABLE_FEAT_RNG \ 1408 ENABLE_FEAT_RNG_TRAP \ 1409 ENABLE_FEAT_SB \ 1410 ENABLE_FEAT_DIT \ 1411 NR_OF_FW_BANKS \ 1412 NR_OF_IMAGES_IN_FW_BANK \ 1413 PSA_FWU_SUPPORT \ 1414 PSA_FWU_METADATA_FW_STORE_DESC \ 1415 ENABLE_BRBE_FOR_NS \ 1416 ENABLE_TRBE_FOR_NS \ 1417 ENABLE_SYS_REG_TRACE_FOR_NS \ 1418 ENABLE_TRF_FOR_NS \ 1419 ENABLE_FEAT_HCX \ 1420 ENABLE_MPMM \ 1421 ENABLE_MPMM_FCONF \ 1422 ENABLE_FEAT_FGT \ 1423 ENABLE_FEAT_FGT2 \ 1424 ENABLE_FEAT_ECV \ 1425 ENABLE_FEAT_AMUv1p1 \ 1426 ENABLE_FEAT_SEL2 \ 1427 ENABLE_FEAT_VHE \ 1428 ENABLE_FEAT_CSV2_2 \ 1429 ENABLE_FEAT_CSV2_3 \ 1430 ENABLE_FEAT_PAN \ 1431 ENABLE_FEAT_TCR2 \ 1432 ENABLE_FEAT_S2PIE \ 1433 ENABLE_FEAT_S1PIE \ 1434 ENABLE_FEAT_S2POE \ 1435 ENABLE_FEAT_S1POE \ 1436 ENABLE_FEAT_GCS \ 1437 ENABLE_FEAT_MTE2 \ 1438 FEATURE_DETECTION \ 1439 TWED_DELAY \ 1440 ENABLE_FEAT_TWED \ 1441 CONDITIONAL_CMO \ 1442 IMPDEF_SYSREG_TRAP \ 1443 SVE_VECTOR_LEN \ 1444 ENABLE_SPMD_LP \ 1445 PSA_CRYPTO \ 1446 ENABLE_CONSOLE_GETC \ 1447 INIT_UNUSED_NS_EL2 \ 1448 PLATFORM_REPORT_CTX_MEM_USE \ 1449 EARLY_CONSOLE \ 1450 PRESERVE_DSU_PMU_REGS \ 1451))) 1452 1453ifeq (${PLATFORM_REPORT_CTX_MEM_USE}, 1) 1454ifeq (${DEBUG}, 0) 1455 $(warning "PLATFORM_REPORT_CTX_MEM_USE can be applied when DEBUG=1 only") 1456 override PLATFORM_REPORT_CTX_MEM_USE := 0 1457endif 1458endif 1459 1460ifeq (${SANITIZE_UB},trap) 1461 $(eval $(call add_define,MONITOR_TRAPS)) 1462endif #(SANITIZE_UB) 1463 1464# Define the EL3_PAYLOAD_BASE flag only if it is provided. 1465ifdef EL3_PAYLOAD_BASE 1466 $(eval $(call add_define,EL3_PAYLOAD_BASE)) 1467else 1468# Define the PRELOADED_BL33_BASE flag only if it is provided and 1469# EL3_PAYLOAD_BASE is not defined, as it has priority. 1470 ifdef PRELOADED_BL33_BASE 1471 $(eval $(call add_define,PRELOADED_BL33_BASE)) 1472 endif 1473endif #(EL3_PAYLOAD_BASE) 1474 1475# Define the DYN_DISABLE_AUTH flag only if set. 1476ifeq (${DYN_DISABLE_AUTH},1) 1477 $(eval $(call add_define,DYN_DISABLE_AUTH)) 1478endif 1479 1480ifeq ($($(ARCH)-ld-id),arm-link) 1481 $(eval $(call add_define,USE_ARM_LINK)) 1482endif 1483 1484# Generate and include sp_gen.mk if SPD is spmd and SP_LAYOUT_FILE is defined 1485ifeq (${SPD},spmd) 1486ifdef SP_LAYOUT_FILE 1487 -include $(BUILD_PLAT)/sp_gen.mk 1488 FIP_DEPS += sp 1489 CRT_DEPS += sp 1490 NEED_SP_PKG := yes 1491else 1492 ifeq (${SPMD_SPM_AT_SEL2},1) 1493 $(error "SPMD with SPM at S-EL2 require SP_LAYOUT_FILE") 1494 endif 1495endif #(SP_LAYOUT_FILE) 1496endif #(SPD) 1497 1498################################################################################ 1499# Build targets 1500################################################################################ 1501 1502.PHONY: all msg_start clean realclean distclean cscope locate-checkpatch checkcodebase checkpatch fiptool sptool fip sp fwu_fip certtool dtbs memmap doc enctool 1503.SUFFIXES: 1504 1505all: msg_start 1506 1507msg_start: 1508 $(s)echo "Building ${PLAT}" 1509 1510ifeq (${ERROR_DEPRECATED},0) 1511# Check if deprecated declarations and cpp warnings should be treated as error or not. 1512ifneq ($(filter %-clang,$($(ARCH)-cc-id)),) 1513 CPPFLAGS += -Wno-error=deprecated-declarations 1514else 1515 CPPFLAGS += -Wno-error=deprecated-declarations -Wno-error=cpp 1516endif 1517endif #(!ERROR_DEPRECATED) 1518 1519$(eval $(call MAKE_LIB,c)) 1520 1521# Expand build macros for the different images 1522ifeq (${NEED_BL1},yes) 1523BL1_SOURCES := $(sort ${BL1_SOURCES}) 1524$(eval $(call MAKE_BL,bl1)) 1525endif #(NEED_BL1) 1526 1527ifeq (${NEED_BL2},yes) 1528 1529ifeq (${RESET_TO_BL2}, 0) 1530FIP_BL2_ARGS := tb-fw 1531endif 1532 1533BL2_SOURCES := $(sort ${BL2_SOURCES}) 1534 1535$(if ${BL2}, $(eval $(call TOOL_ADD_IMG,bl2,--${FIP_BL2_ARGS})),\ 1536 $(eval $(call MAKE_BL,bl2,${FIP_BL2_ARGS}))) 1537 1538endif #(NEED_BL2) 1539 1540ifeq (${NEED_SCP_BL2},yes) 1541$(eval $(call TOOL_ADD_IMG,scp_bl2,--scp-fw)) 1542endif #(NEED_SCP_BL2) 1543 1544ifeq (${NEED_BL31},yes) 1545BL31_SOURCES += ${SPD_SOURCES} 1546# Sort BL31 source files to remove duplicates 1547BL31_SOURCES := $(sort ${BL31_SOURCES}) 1548ifneq (${DECRYPTION_SUPPORT},none) 1549$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw,,$(ENCRYPT_BL31))),\ 1550 $(eval $(call MAKE_BL,bl31,soc-fw,,$(ENCRYPT_BL31)))) 1551else 1552$(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw)),\ 1553 $(eval $(call MAKE_BL,bl31,soc-fw))) 1554endif #(DECRYPTION_SUPPORT) 1555endif #(NEED_BL31) 1556 1557# If a BL32 image is needed but neither BL32 nor BL32_SOURCES is defined, the 1558# build system will call TOOL_ADD_IMG to print a warning message and abort the 1559# process. Note that the dependency on BL32 applies to the FIP only. 1560ifeq (${NEED_BL32},yes) 1561# Sort BL32 source files to remove duplicates 1562BL32_SOURCES := $(sort ${BL32_SOURCES}) 1563BUILD_BL32 := $(if $(BL32),,$(if $(BL32_SOURCES),1)) 1564 1565ifneq (${DECRYPTION_SUPPORT},none) 1566$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw,,$(ENCRYPT_BL32))),\ 1567 $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw,,$(ENCRYPT_BL32)))) 1568else 1569$(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw)),\ 1570 $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw))) 1571endif #(DECRYPTION_SUPPORT) 1572endif #(NEED_BL32) 1573 1574# If RMM image is needed but RMM is not defined, Test Realm Payload (TRP) 1575# needs to be built from RMM_SOURCES. 1576ifeq (${NEED_RMM},yes) 1577# Sort RMM source files to remove duplicates 1578RMM_SOURCES := $(sort ${RMM_SOURCES}) 1579BUILD_RMM := $(if $(RMM),,$(if $(RMM_SOURCES),1)) 1580 1581$(if ${BUILD_RMM}, $(eval $(call MAKE_BL,rmm,rmm-fw)),\ 1582 $(eval $(call TOOL_ADD_IMG,rmm,--rmm-fw))) 1583endif #(NEED_RMM) 1584 1585# Add the BL33 image if required by the platform 1586ifeq (${NEED_BL33},yes) 1587$(eval $(call TOOL_ADD_IMG,bl33,--nt-fw)) 1588endif #(NEED_BL33) 1589 1590ifeq (${NEED_BL2U},yes) 1591$(if ${BL2U}, $(eval $(call TOOL_ADD_IMG,bl2u,--ap-fwu-cfg,FWU_)),\ 1592 $(eval $(call MAKE_BL,bl2u,ap-fwu-cfg,FWU_))) 1593endif #(NEED_BL2U) 1594 1595# Expand build macros for the different images 1596ifeq (${NEED_FDT},yes) 1597 $(eval $(call MAKE_DTBS,$(BUILD_PLAT)/fdts,$(FDT_SOURCES))) 1598endif #(NEED_FDT) 1599 1600# Add Secure Partition packages 1601ifeq (${NEED_SP_PKG},yes) 1602$(BUILD_PLAT)/sp_gen.mk: ${SP_MK_GEN} ${SP_LAYOUT_FILE} | $$(@D)/ 1603 $(q)${PYTHON} "$<" "$@" $(filter-out $<,$^) $(BUILD_PLAT) ${COT} ${SP_DTS_LIST_FRAGMENT} 1604sp: $(DTBS) $(BUILD_PLAT)/sp_gen.mk $(SP_PKGS) 1605 $(s)echo 1606 $(s)echo "Built SP Images successfully" 1607 $(s)echo 1608endif #(NEED_SP_PKG) 1609 1610locate-checkpatch: 1611ifndef CHECKPATCH 1612 $(error "Please set CHECKPATCH to point to the Linux checkpatch.pl file, eg: CHECKPATCH=../linux/scripts/checkpatch.pl") 1613else 1614ifeq (,$(wildcard ${CHECKPATCH})) 1615 $(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/scripts/checkpatch.pl") 1616endif 1617endif #(CHECKPATCH) 1618 1619clean: 1620 $(s)echo " CLEAN" 1621 $(call SHELL_REMOVE_DIR,${BUILD_PLAT}) 1622 $(q)${MAKE} -C ${CERTCONVPATH} clean 1623ifdef UNIX_MK 1624 $(q)${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean 1625else 1626# Clear the MAKEFLAGS as we do not want 1627# to pass the gnumake flags to nmake. 1628 $(q)set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) clean 1629endif #(UNIX_MK) 1630 $(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean 1631 $(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} clean 1632 $(q)${MAKE} --no-print-directory -C ${ROMLIBPATH} clean 1633 1634realclean distclean: 1635 $(s)echo " REALCLEAN" 1636 $(call SHELL_REMOVE_DIR,${BUILD_BASE}) 1637 $(call SHELL_DELETE_ALL, ${CURDIR}/cscope.*) 1638 $(q)${MAKE} -C ${CERTCONVPATH} clean 1639ifdef UNIX_MK 1640 $(q)${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean 1641else 1642# Clear the MAKEFLAGS as we do not want 1643# to pass the gnumake flags to nmake. 1644 $(q)set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) realclean 1645endif #(UNIX_MK) 1646 $(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} realclean 1647 $(q)${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} realclean 1648 $(q)${MAKE} --no-print-directory -C ${ROMLIBPATH} clean 1649 1650checkcodebase: locate-checkpatch 1651 $(s)echo " CHECKING STYLE" 1652 $(q)if test -d .git ; then \ 1653 git ls-files | grep -E -v 'libfdt|libc|docs|\.rst' | \ 1654 while read GIT_FILE ; \ 1655 do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ; \ 1656 done ; \ 1657 else \ 1658 find . -type f -not -iwholename "*.git*" \ 1659 -not -iwholename "*build*" \ 1660 -not -iwholename "*libfdt*" \ 1661 -not -iwholename "*libc*" \ 1662 -not -iwholename "*docs*" \ 1663 -not -iwholename "*.rst" \ 1664 -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ; \ 1665 fi 1666 1667checkpatch: locate-checkpatch 1668 $(s)echo " CHECKING STYLE" 1669 $(q)if test -n "${CHECKPATCH_OPTS}"; then \ 1670 echo " with ${CHECKPATCH_OPTS} option(s)"; \ 1671 fi 1672 $(q)COMMON_COMMIT=$$(git merge-base HEAD ${BASE_COMMIT}); \ 1673 for commit in `git rev-list --no-merges $$COMMON_COMMIT..HEAD`; \ 1674 do \ 1675 printf "\n[*] Checking style of '$$commit'\n\n"; \ 1676 git log --format=email "$$commit~..$$commit" \ 1677 -- ${CHECK_PATHS} | \ 1678 ${CHECKPATCH} ${CHECKPATCH_OPTS} - || true; \ 1679 git diff --format=email "$$commit~..$$commit" \ 1680 -- ${CHECK_PATHS} | \ 1681 ${CHECKPATCH} ${CHECKPATCH_OPTS} - || true; \ 1682 done 1683 1684certtool: ${CRTTOOL} 1685 1686${CRTTOOL}: FORCE 1687 $(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 1688 $(s)echo 1689 $(s)echo "Built $@ successfully" 1690 $(s)echo 1691 1692ifneq (${GENERATE_COT},0) 1693certificates: ${CRT_DEPS} ${CRTTOOL} 1694 $(q)${CRTTOOL} ${CRT_ARGS} 1695 $(s)echo 1696 $(s)echo "Built $@ successfully" 1697 $(s)echo "Certificates can be found in ${BUILD_PLAT}" 1698 $(s)echo 1699endif #(GENERATE_COT) 1700 1701${BUILD_PLAT}/${FIP_NAME}: ${FIP_DEPS} ${FIPTOOL} 1702 $(eval ${CHECK_FIP_CMD}) 1703 $(q)${FIPTOOL} create ${FIP_ARGS} $@ 1704 $(q)${FIPTOOL} info $@ 1705 $(s)echo 1706 $(s)echo "Built $@ successfully" 1707 $(s)echo 1708 1709ifneq (${GENERATE_COT},0) 1710fwu_certificates: ${FWU_CRT_DEPS} ${CRTTOOL} 1711 $(q)${CRTTOOL} ${FWU_CRT_ARGS} 1712 $(s)echo 1713 $(s)echo "Built $@ successfully" 1714 $(s)echo "FWU certificates can be found in ${BUILD_PLAT}" 1715 $(s)echo 1716endif #(GENERATE_COT) 1717 1718${BUILD_PLAT}/${FWU_FIP_NAME}: ${FWU_FIP_DEPS} ${FIPTOOL} 1719 $(eval ${CHECK_FWU_FIP_CMD}) 1720 $(q)${FIPTOOL} create ${FWU_FIP_ARGS} $@ 1721 $(q)${FIPTOOL} info $@ 1722 $(s)echo 1723 $(s)echo "Built $@ successfully" 1724 $(s)echo 1725 1726fiptool: ${FIPTOOL} 1727fip: ${BUILD_PLAT}/${FIP_NAME} 1728fwu_fip: ${BUILD_PLAT}/${FWU_FIP_NAME} 1729 1730${FIPTOOL}: FORCE 1731ifdef UNIX_MK 1732 $(q)${MAKE} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" FIPTOOL=${FIPTOOL} OPENSSL_DIR=${OPENSSL_DIR} DEBUG=${DEBUG} --no-print-directory -C ${FIPTOOLPATH} all 1733else 1734# Clear the MAKEFLAGS as we do not want 1735# to pass the gnumake flags to nmake. 1736 $(q)set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) 1737endif #(UNIX_MK) 1738 1739romlib.bin: libraries FORCE 1740 $(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 1741 1742memmap: all 1743ifdef UNIX_MK 1744 $(q)PYTHONPATH=${CURDIR}/tools/memory \ 1745 ${PYTHON} -m memory.memmap -sr ${BUILD_PLAT} 1746else 1747 $(q)set PYTHONPATH=${CURDIR}/tools/memory && \ 1748 ${PYTHON} -m memory.memmap -sr ${BUILD_PLAT} 1749endif 1750 1751doc: 1752 $(s)echo " BUILD DOCUMENTATION" 1753 $(q)${MAKE} --no-print-directory -C ${DOCS_PATH} html 1754 1755enctool: ${ENCTOOL} 1756 1757${ENCTOOL}: FORCE 1758 $(q)${MAKE} PLAT=${PLAT} BUILD_INFO=0 OPENSSL_DIR=${OPENSSL_DIR} ENCTOOL=${ENCTOOL} DEBUG=${DEBUG} --no-print-directory -C ${ENCTOOLPATH} all 1759 $(s)echo 1760 $(s)echo "Built $@ successfully" 1761 $(s)echo 1762 1763cscope: 1764 $(s)echo " CSCOPE" 1765 $(q)find ${CURDIR} -name "*.[chsS]" > cscope.files 1766 $(q)cscope -b -q -k 1767 1768help: 1769 $(s)echo "usage: ${MAKE} [PLAT=<platform>] [OPTIONS] [TARGET]" 1770 $(s)echo "" 1771 $(s)echo "PLAT is used to specify which platform you wish to build." 1772 $(s)echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}" 1773 $(s)echo "" 1774 $(s)echo "platform = ${PLATFORM_LIST}" 1775 $(s)echo "" 1776 $(s)echo "Please refer to the User Guide for a list of all supported options." 1777 $(s)echo "Note that the build system doesn't track dependencies for build " 1778 $(s)echo "options. Therefore, if any of the build options are changed " 1779 $(s)echo "from a previous build, a clean build must be performed." 1780 $(s)echo "" 1781 $(s)echo "Supported Targets:" 1782 $(s)echo " all Build all individual bootloader binaries" 1783 $(s)echo " bl1 Build the BL1 binary" 1784 $(s)echo " bl2 Build the BL2 binary" 1785 $(s)echo " bl2u Build the BL2U binary" 1786 $(s)echo " bl31 Build the BL31 binary" 1787 $(s)echo " bl32 Build the BL32 binary. If ARCH=aarch32, then " 1788 $(s)echo " this builds secure payload specified by AARCH32_SP" 1789 $(s)echo " certificates Build the certificates (requires 'GENERATE_COT=1')" 1790 $(s)echo " fip Build the Firmware Image Package (FIP)" 1791 $(s)echo " fwu_fip Build the FWU Firmware Image Package (FIP)" 1792 $(s)echo " checkcodebase Check the coding style of the entire source tree" 1793 $(s)echo " checkpatch Check the coding style on changes in the current" 1794 $(s)echo " branch against BASE_COMMIT (default origin/master)" 1795 $(s)echo " clean Clean the build for the selected platform" 1796 $(s)echo " cscope Generate cscope index" 1797 $(s)echo " distclean Remove all build artifacts for all platforms" 1798 $(s)echo " certtool Build the Certificate generation tool" 1799 $(s)echo " enctool Build the Firmware encryption tool" 1800 $(s)echo " fiptool Build the Firmware Image Package (FIP) creation tool" 1801 $(s)echo " sp Build the Secure Partition Packages" 1802 $(s)echo " sptool Build the Secure Partition Package creation tool" 1803 $(s)echo " dtbs Build the Device Tree Blobs (if required for the platform)" 1804 $(s)echo " memmap Print the memory map of the built binaries" 1805 $(s)echo " doc Build html based documentation using Sphinx tool" 1806 $(s)echo "" 1807 $(s)echo "Note: most build targets require PLAT to be set to a specific platform." 1808 $(s)echo "" 1809 $(s)echo "example: build all targets for the FVP platform:" 1810 $(s)echo " CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all" 1811 1812.PHONY: FORCE 1813FORCE:; 1814