1# 2# Copyright (c) 2013-2021, ARM Limited and Contributors. All rights reserved. 3# 4# SPDX-License-Identifier: BSD-3-Clause 5# 6 7# Use the GICv2 driver on QEMU by default 8QEMU_USE_GIC_DRIVER := QEMU_GICV2 9 10ifeq (${ARM_ARCH_MAJOR},7) 11# ARMv7 Qemu support in trusted firmware expects the Cortex-A15 model. 12# Qemu Cortex-A15 model does not implement the virtualization extension. 13# For this reason, we cannot set ARM_CORTEX_A15=yes and must define all 14# the ARMv7 build directives. 15MARCH32_DIRECTIVE := -mcpu=cortex-a15 16$(eval $(call add_define,ARMV7_SUPPORTS_LARGE_PAGE_ADDRESSING)) 17$(eval $(call add_define,ARMV7_SUPPORTS_GENERIC_TIMER)) 18$(eval $(call add_define,ARMV7_SUPPORTS_VFP)) 19# Qemu expects a BL32 boot stage. 20NEED_BL32 := yes 21endif # ARMv7 22 23ifeq (${SPD},opteed) 24add-lib-optee := yes 25endif 26ifeq ($(AARCH32_SP),optee) 27add-lib-optee := yes 28endif 29ifeq ($(SPMC_OPTEE),1) 30$(eval $(call add_define,SPMC_OPTEE)) 31add-lib-optee := yes 32endif 33 34include lib/libfdt/libfdt.mk 35 36ifeq ($(NEED_BL32),yes) 37$(eval $(call add_define,QEMU_LOAD_BL32)) 38endif 39 40PLAT_QEMU_PATH := plat/qemu/qemu 41PLAT_QEMU_COMMON_PATH := plat/qemu/common 42PLAT_INCLUDES := -Iinclude/plat/arm/common/ \ 43 -I${PLAT_QEMU_COMMON_PATH}/include \ 44 -I${PLAT_QEMU_PATH}/include \ 45 -Iinclude/common/tbbr 46 47ifeq (${ARM_ARCH_MAJOR},8) 48PLAT_INCLUDES += -Iinclude/plat/arm/common/${ARCH} 49endif 50 51PLAT_BL_COMMON_SOURCES := ${PLAT_QEMU_COMMON_PATH}/qemu_common.c \ 52 ${PLAT_QEMU_COMMON_PATH}/qemu_console.c \ 53 drivers/arm/pl011/${ARCH}/pl011_console.S 54 55include lib/xlat_tables_v2/xlat_tables.mk 56PLAT_BL_COMMON_SOURCES += ${XLAT_TABLES_LIB_SRCS} 57 58ifneq (${TRUSTED_BOARD_BOOT},0) 59 60 include drivers/auth/mbedtls/mbedtls_crypto.mk 61 include drivers/auth/mbedtls/mbedtls_x509.mk 62 63 AUTH_SOURCES := drivers/auth/auth_mod.c \ 64 drivers/auth/crypto_mod.c \ 65 drivers/auth/img_parser_mod.c \ 66 drivers/auth/tbbr/tbbr_cot_common.c 67 68 BL1_SOURCES += ${AUTH_SOURCES} \ 69 bl1/tbbr/tbbr_img_desc.c \ 70 plat/common/tbbr/plat_tbbr.c \ 71 ${PLAT_QEMU_COMMON_PATH}/qemu_trusted_boot.c \ 72 $(PLAT_QEMU_COMMON_PATH)/qemu_rotpk.S \ 73 drivers/auth/tbbr/tbbr_cot_bl1.c 74 75 BL2_SOURCES += ${AUTH_SOURCES} \ 76 plat/common/tbbr/plat_tbbr.c \ 77 ${PLAT_QEMU_COMMON_PATH}/qemu_trusted_boot.c \ 78 $(PLAT_QEMU_COMMON_PATH)/qemu_rotpk.S \ 79 drivers/auth/tbbr/tbbr_cot_bl2.c 80 81 ROT_KEY = $(BUILD_PLAT)/rot_key.pem 82 ROTPK_HASH = $(BUILD_PLAT)/rotpk_sha256.bin 83 84 $(eval $(call add_define_val,ROTPK_HASH,'"$(ROTPK_HASH)"')) 85 86 $(BUILD_PLAT)/bl1/qemu_rotpk.o: $(ROTPK_HASH) 87 $(BUILD_PLAT)/bl2/qemu_rotpk.o: $(ROTPK_HASH) 88 89 certificates: $(ROT_KEY) 90 91 $(ROT_KEY): | $(BUILD_PLAT) 92 @echo " OPENSSL $@" 93 $(Q)openssl genrsa 2048 > $@ 2>/dev/null 94 95 $(ROTPK_HASH): $(ROT_KEY) 96 @echo " OPENSSL $@" 97 $(Q)openssl rsa -in $< -pubout -outform DER 2>/dev/null |\ 98 openssl dgst -sha256 -binary > $@ 2>/dev/null 99endif 100 101BL1_SOURCES += drivers/io/io_semihosting.c \ 102 drivers/io/io_storage.c \ 103 drivers/io/io_fip.c \ 104 drivers/io/io_memmap.c \ 105 lib/semihosting/semihosting.c \ 106 lib/semihosting/${ARCH}/semihosting_call.S \ 107 ${PLAT_QEMU_COMMON_PATH}/qemu_io_storage.c \ 108 ${PLAT_QEMU_COMMON_PATH}/${ARCH}/plat_helpers.S \ 109 ${PLAT_QEMU_COMMON_PATH}/qemu_bl1_setup.c 110 111ifeq (${ARM_ARCH_MAJOR},8) 112BL1_SOURCES += lib/cpus/aarch64/aem_generic.S \ 113 lib/cpus/aarch64/cortex_a53.S \ 114 lib/cpus/aarch64/cortex_a57.S \ 115 lib/cpus/aarch64/cortex_a72.S \ 116 lib/cpus/aarch64/qemu_max.S \ 117 118else 119BL1_SOURCES += lib/cpus/${ARCH}/cortex_a15.S 120endif 121 122BL2_SOURCES += drivers/io/io_semihosting.c \ 123 drivers/io/io_storage.c \ 124 drivers/io/io_fip.c \ 125 drivers/io/io_memmap.c \ 126 lib/semihosting/semihosting.c \ 127 lib/semihosting/${ARCH}/semihosting_call.S \ 128 ${PLAT_QEMU_COMMON_PATH}/qemu_io_storage.c \ 129 ${PLAT_QEMU_COMMON_PATH}/${ARCH}/plat_helpers.S \ 130 ${PLAT_QEMU_COMMON_PATH}/qemu_bl2_setup.c \ 131 ${PLAT_QEMU_COMMON_PATH}/qemu_bl2_mem_params_desc.c \ 132 ${PLAT_QEMU_COMMON_PATH}/qemu_image_load.c \ 133 common/fdt_fixup.c \ 134 common/desc_image_load.c 135 136ifeq ($(add-lib-optee),yes) 137BL2_SOURCES += lib/optee/optee_utils.c 138endif 139 140ifneq (${DECRYPTION_SUPPORT},none) 141BL1_SOURCES += drivers/io/io_encrypted.c 142BL2_SOURCES += drivers/io/io_encrypted.c 143endif 144 145# Include GICv2 driver files 146include drivers/arm/gic/v2/gicv2.mk 147QEMU_GICV2_SOURCES := ${GICV2_SOURCES} \ 148 plat/common/plat_gicv2.c \ 149 ${PLAT_QEMU_COMMON_PATH}/qemu_gicv2.c 150 151# Include GICv3 driver files 152include drivers/arm/gic/v3/gicv3.mk 153 154QEMU_GICV3_SOURCES := ${GICV3_SOURCES} \ 155 plat/common/plat_gicv3.c \ 156 ${PLAT_QEMU_COMMON_PATH}/qemu_gicv3.c 157 158ifeq (${QEMU_USE_GIC_DRIVER}, QEMU_GICV2) 159QEMU_GIC_SOURCES := ${QEMU_GICV2_SOURCES} 160else ifeq (${QEMU_USE_GIC_DRIVER}, QEMU_GICV3) 161QEMU_GIC_SOURCES := ${QEMU_GICV3_SOURCES} 162else 163$(error "Incorrect GIC driver chosen for QEMU platform") 164endif 165 166ifeq (${ARM_ARCH_MAJOR},8) 167BL31_SOURCES += lib/cpus/aarch64/aem_generic.S \ 168 lib/cpus/aarch64/cortex_a53.S \ 169 lib/cpus/aarch64/cortex_a57.S \ 170 lib/cpus/aarch64/cortex_a72.S \ 171 lib/cpus/aarch64/qemu_max.S \ 172 lib/semihosting/semihosting.c \ 173 lib/semihosting/${ARCH}/semihosting_call.S \ 174 plat/common/plat_psci_common.c \ 175 drivers/arm/pl061/pl061_gpio.c \ 176 drivers/gpio/gpio.c \ 177 ${PLAT_QEMU_COMMON_PATH}/qemu_pm.c \ 178 ${PLAT_QEMU_COMMON_PATH}/topology.c \ 179 ${PLAT_QEMU_COMMON_PATH}/aarch64/plat_helpers.S \ 180 ${PLAT_QEMU_COMMON_PATH}/qemu_bl31_setup.c \ 181 ${QEMU_GIC_SOURCES} 182 183ifeq (${SPD},spmd) 184BL31_SOURCES += plat/qemu/common/qemu_spmd_manifest.c 185endif 186endif 187 188# Add the build options to pack Trusted OS Extra1 and Trusted OS Extra2 images 189# in the FIP if the platform requires. 190ifneq ($(BL32_EXTRA1),) 191ifneq (${DECRYPTION_SUPPORT},none) 192$(eval $(call TOOL_ADD_IMG,bl32_extra1,--tos-fw-extra1,,$(ENCRYPT_BL32))) 193else 194$(eval $(call TOOL_ADD_IMG,bl32_extra1,--tos-fw-extra1)) 195endif 196endif 197ifneq ($(BL32_EXTRA2),) 198ifneq (${DECRYPTION_SUPPORT},none) 199$(eval $(call TOOL_ADD_IMG,bl32_extra2,--tos-fw-extra2,,$(ENCRYPT_BL32))) 200else 201$(eval $(call TOOL_ADD_IMG,bl32_extra2,--tos-fw-extra2)) 202endif 203endif 204 205SEPARATE_CODE_AND_RODATA := 1 206ENABLE_STACK_PROTECTOR := 0 207ifneq ($(ENABLE_STACK_PROTECTOR), 0) 208 PLAT_BL_COMMON_SOURCES += ${PLAT_QEMU_COMMON_PATH}/qemu_stack_protector.c 209endif 210 211BL32_RAM_LOCATION := tdram 212ifeq (${BL32_RAM_LOCATION}, tsram) 213 BL32_RAM_LOCATION_ID = SEC_SRAM_ID 214else ifeq (${BL32_RAM_LOCATION}, tdram) 215 BL32_RAM_LOCATION_ID = SEC_DRAM_ID 216else 217 $(error "Unsupported BL32_RAM_LOCATION value") 218endif 219 220# Process flags 221$(eval $(call add_define,BL32_RAM_LOCATION_ID)) 222 223# Don't have the Linux kernel as a BL33 image by default 224ARM_LINUX_KERNEL_AS_BL33 := 0 225$(eval $(call assert_boolean,ARM_LINUX_KERNEL_AS_BL33)) 226$(eval $(call add_define,ARM_LINUX_KERNEL_AS_BL33)) 227 228ARM_PRELOADED_DTB_BASE := PLAT_QEMU_DT_BASE 229$(eval $(call add_define,ARM_PRELOADED_DTB_BASE)) 230 231# Do not enable SVE 232ENABLE_SVE_FOR_NS := 0 233