blob: 6b9749c79a1d05260fd9bc1fd09c3c5da5fd2230 [file] [log] [blame]
Jens Wiklander52c798e2015-12-07 14:37:10 +01001#
Hongbo Zhang32338ec2018-04-19 13:06:07 +08002# Copyright (c) 2013-2019, ARM Limited and Contributors. All rights reserved.
Jens Wiklander52c798e2015-12-07 14:37:10 +01003#
dp-armfa3cf0b2017-05-03 09:38:09 +01004# SPDX-License-Identifier: BSD-3-Clause
Jens Wiklander52c798e2015-12-07 14:37:10 +01005#
6
Hongbo Zhangbdcbf2a2018-04-19 14:42:23 +08007# Use the GICv2 driver on QEMU by default
8QEMU_USE_GIC_DRIVER := QEMU_GICV2
9
Etienne Carriere911de8c2018-02-02 13:23:22 +010010ifeq (${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# Qemu expects a BL32 boot stage.
19NEED_BL32 := yes
20endif # ARMv7
21
22ifeq (${SPD},opteed)
23add-lib-optee := yes
24endif
25ifeq ($(AARCH32_SP),optee)
26add-lib-optee := yes
27endif
28
Jens Wiklander52c798e2015-12-07 14:37:10 +010029include lib/libfdt/libfdt.mk
30
Fu Weic2f78442017-05-27 21:21:42 +080031ifeq ($(NEED_BL32),yes)
32$(eval $(call add_define,QEMU_LOAD_BL32))
33endif
34
Michalis Pappas3469cd02017-10-18 09:43:37 +080035PLAT_PATH := plat/qemu/
Antonio Nino Diaz50a4d1a2019-02-01 12:22:22 +000036PLAT_INCLUDES := -Iplat/qemu/include
Jens Wiklander52c798e2015-12-07 14:37:10 +010037
Etienne Carriere911de8c2018-02-02 13:23:22 +010038ifeq (${ARM_ARCH_MAJOR},8)
39PLAT_INCLUDES += -Iinclude/plat/arm/common/${ARCH}
40endif
41
Michalis Pappascca6cb72018-03-04 15:43:38 +080042PLAT_BL_COMMON_SOURCES := plat/qemu/qemu_common.c \
43 plat/qemu/qemu_console.c \
44 drivers/arm/pl011/${ARCH}/pl011_console.S \
Fu Wei77ecd462017-07-31 18:28:32 +080045
Fu Wei77ecd462017-07-31 18:28:32 +080046include lib/xlat_tables_v2/xlat_tables.mk
Fu Wei77ecd462017-07-31 18:28:32 +080047PLAT_BL_COMMON_SOURCES += ${XLAT_TABLES_LIB_SRCS}
Jens Wiklander52c798e2015-12-07 14:37:10 +010048
Michalis Pappas3469cd02017-10-18 09:43:37 +080049ifneq (${TRUSTED_BOARD_BOOT},0)
50
51 include drivers/auth/mbedtls/mbedtls_crypto.mk
52 include drivers/auth/mbedtls/mbedtls_x509.mk
53
Michalis Pappas3469cd02017-10-18 09:43:37 +080054 AUTH_SOURCES := drivers/auth/auth_mod.c \
55 drivers/auth/crypto_mod.c \
56 drivers/auth/img_parser_mod.c \
57 drivers/auth/tbbr/tbbr_cot.c
58
Michalis Pappas3469cd02017-10-18 09:43:37 +080059 BL1_SOURCES += ${AUTH_SOURCES} \
60 bl1/tbbr/tbbr_img_desc.c \
61 plat/common/tbbr/plat_tbbr.c \
62 plat/qemu/qemu_trusted_boot.c \
63 $(PLAT_PATH)/qemu_rotpk.S
64
65 BL2_SOURCES += ${AUTH_SOURCES} \
66 plat/common/tbbr/plat_tbbr.c \
67 plat/qemu/qemu_trusted_boot.c \
68 $(PLAT_PATH)/qemu_rotpk.S
69
70 ROT_KEY = $(BUILD_PLAT)/rot_key.pem
71 ROTPK_HASH = $(BUILD_PLAT)/rotpk_sha256.bin
72
73 $(eval $(call add_define_val,ROTPK_HASH,'"$(ROTPK_HASH)"'))
74
75 $(BUILD_PLAT)/bl1/qemu_rotpk.o: $(ROTPK_HASH)
76 $(BUILD_PLAT)/bl2/qemu_rotpk.o: $(ROTPK_HASH)
77
78 certificates: $(ROT_KEY)
79
80 $(ROT_KEY):
81 @echo " OPENSSL $@"
82 $(Q)openssl genrsa 2048 > $@ 2>/dev/null
83
84 $(ROTPK_HASH): $(ROT_KEY)
85 @echo " OPENSSL $@"
86 $(Q)openssl rsa -in $< -pubout -outform DER 2>/dev/null |\
87 openssl dgst -sha256 -binary > $@ 2>/dev/null
88endif
89
Jens Wiklander52c798e2015-12-07 14:37:10 +010090BL1_SOURCES += drivers/io/io_semihosting.c \
91 drivers/io/io_storage.c \
92 drivers/io/io_fip.c \
93 drivers/io/io_memmap.c \
94 lib/semihosting/semihosting.c \
Etienne Carriere911de8c2018-02-02 13:23:22 +010095 lib/semihosting/${ARCH}/semihosting_call.S \
Jens Wiklander52c798e2015-12-07 14:37:10 +010096 plat/qemu/qemu_io_storage.c \
Etienne Carriere911de8c2018-02-02 13:23:22 +010097 plat/qemu/${ARCH}/plat_helpers.S \
Jens Wiklander52c798e2015-12-07 14:37:10 +010098 plat/qemu/qemu_bl1_setup.c
99
Etienne Carriere911de8c2018-02-02 13:23:22 +0100100ifeq (${ARM_ARCH_MAJOR},8)
101BL1_SOURCES += lib/cpus/aarch64/aem_generic.S \
102 lib/cpus/aarch64/cortex_a53.S \
103 lib/cpus/aarch64/cortex_a57.S
104else
105BL1_SOURCES += lib/cpus/${ARCH}/cortex_a15.S
106endif
107
Jens Wiklander52c798e2015-12-07 14:37:10 +0100108BL2_SOURCES += drivers/io/io_semihosting.c \
109 drivers/io/io_storage.c \
110 drivers/io/io_fip.c \
111 drivers/io/io_memmap.c \
Jens Wiklander52c798e2015-12-07 14:37:10 +0100112 lib/semihosting/semihosting.c \
Etienne Carriere911de8c2018-02-02 13:23:22 +0100113 lib/semihosting/${ARCH}/semihosting_call.S\
Jens Wiklander52c798e2015-12-07 14:37:10 +0100114 plat/qemu/qemu_io_storage.c \
Etienne Carriere911de8c2018-02-02 13:23:22 +0100115 plat/qemu/${ARCH}/plat_helpers.S \
Jens Wiklander52c798e2015-12-07 14:37:10 +0100116 plat/qemu/qemu_bl2_setup.c \
Jens Wiklander6335a972018-09-04 15:08:48 +0200117 plat/qemu/dt.c \
118 plat/qemu/qemu_bl2_mem_params_desc.c \
Fu Weic2f78442017-05-27 21:21:42 +0800119 plat/qemu/qemu_image_load.c \
120 common/desc_image_load.c
Jens Wiklander6335a972018-09-04 15:08:48 +0200121
Etienne Carriere911de8c2018-02-02 13:23:22 +0100122ifeq ($(add-lib-optee),yes)
Jens Wiklander0acbaaa2017-08-24 13:16:26 +0200123BL2_SOURCES += lib/optee/optee_utils.c
124endif
125
Hongbo Zhangbdcbf2a2018-04-19 14:42:23 +0800126QEMU_GICV2_SOURCES := drivers/arm/gic/v2/gicv2_helpers.c \
Hongbo Zhang32338ec2018-04-19 13:06:07 +0800127 drivers/arm/gic/v2/gicv2_main.c \
128 drivers/arm/gic/common/gic_common.c \
129 plat/common/plat_gicv2.c \
130 plat/qemu/qemu_gicv2.c
Jens Wiklander52c798e2015-12-07 14:37:10 +0100131
Hongbo Zhangbdcbf2a2018-04-19 14:42:23 +0800132QEMU_GICV3_SOURCES := drivers/arm/gic/v3/gicv3_helpers.c \
133 drivers/arm/gic/v3/gicv3_main.c \
134 drivers/arm/gic/common/gic_common.c \
135 plat/common/plat_gicv3.c \
136 plat/qemu/qemu_gicv3.c
137
138ifeq (${QEMU_USE_GIC_DRIVER}, QEMU_GICV2)
139QEMU_GIC_SOURCES := ${QEMU_GICV2_SOURCES}
140else ifeq (${QEMU_USE_GIC_DRIVER}, QEMU_GICV3)
141QEMU_GIC_SOURCES := ${QEMU_GICV3_SOURCES}
142else
143$(error "Incorrect GIC driver chosen for QEMU platform")
144endif
145
Etienne Carriere911de8c2018-02-02 13:23:22 +0100146ifeq (${ARM_ARCH_MAJOR},8)
Jens Wiklander52c798e2015-12-07 14:37:10 +0100147BL31_SOURCES += lib/cpus/aarch64/aem_generic.S \
148 lib/cpus/aarch64/cortex_a53.S \
149 lib/cpus/aarch64/cortex_a57.S \
Jens Wiklander1017a6e2017-08-24 13:16:20 +0200150 plat/common/plat_psci_common.c \
Jens Wiklander52c798e2015-12-07 14:37:10 +0100151 plat/qemu/qemu_pm.c \
152 plat/qemu/topology.c \
153 plat/qemu/aarch64/plat_helpers.S \
Hongbo Zhang32338ec2018-04-19 13:06:07 +0800154 plat/qemu/qemu_bl31_setup.c \
155 ${QEMU_GIC_SOURCES}
Etienne Carriere911de8c2018-02-02 13:23:22 +0100156endif
Jens Wiklander0acbaaa2017-08-24 13:16:26 +0200157
158# Add the build options to pack Trusted OS Extra1 and Trusted OS Extra2 images
159# in the FIP if the platform requires.
160ifneq ($(BL32_EXTRA1),)
Masahiro Yamada9c5ca522018-01-26 11:42:01 +0900161$(eval $(call TOOL_ADD_IMG,bl32_extra1,--tos-fw-extra1))
Jens Wiklander0acbaaa2017-08-24 13:16:26 +0200162endif
163ifneq ($(BL32_EXTRA2),)
Masahiro Yamada9c5ca522018-01-26 11:42:01 +0900164$(eval $(call TOOL_ADD_IMG,bl32_extra2,--tos-fw-extra2))
Jens Wiklander0acbaaa2017-08-24 13:16:26 +0200165endif
166
Michalis Pappasba861122018-02-28 14:36:03 +0800167SEPARATE_CODE_AND_RODATA := 1
Michalis Pappase4c00bb2018-03-20 14:30:00 +0800168ENABLE_STACK_PROTECTOR := 0
169ifneq ($(ENABLE_STACK_PROTECTOR), 0)
170 PLAT_BL_COMMON_SOURCES += plat/qemu/qemu_stack_protector.c
171endif
Michalis Pappasa0bb5ac2018-03-24 12:38:31 +0800172
Jens Wiklander52c798e2015-12-07 14:37:10 +0100173BL32_RAM_LOCATION := tdram
174ifeq (${BL32_RAM_LOCATION}, tsram)
175 BL32_RAM_LOCATION_ID = SEC_SRAM_ID
176else ifeq (${BL32_RAM_LOCATION}, tdram)
177 BL32_RAM_LOCATION_ID = SEC_DRAM_ID
178else
179 $(error "Unsupported BL32_RAM_LOCATION value")
180endif
181
182# Process flags
183$(eval $(call add_define,BL32_RAM_LOCATION_ID))
David Cunadoc5b0c0f2017-10-31 23:19:21 +0000184
185# Do not enable SVE
186ENABLE_SVE_FOR_NS := 0