xref: /rk3399_ARM-atf/plat/qemu/qemu/platform.mk (revision 90ce8b8718d079b9e906d06bdd6a72da6cc5b636)
1#
2# Copyright (c) 2013-2022, 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    AUTH_SOURCES	:=	drivers/auth/auth_mod.c			\
61				drivers/auth/img_parser_mod.c		\
62				drivers/auth/tbbr/tbbr_cot_common.c
63
64    BL1_SOURCES		+=	${AUTH_SOURCES}				\
65				bl1/tbbr/tbbr_img_desc.c		\
66				plat/common/tbbr/plat_tbbr.c		\
67				${PLAT_QEMU_COMMON_PATH}/qemu_trusted_boot.c	     	\
68				$(PLAT_QEMU_COMMON_PATH)/qemu_rotpk.S	\
69				drivers/auth/tbbr/tbbr_cot_bl1.c
70
71    BL2_SOURCES		+=	${AUTH_SOURCES}				\
72				plat/common/tbbr/plat_tbbr.c		\
73				${PLAT_QEMU_COMMON_PATH}/qemu_trusted_boot.c	     	\
74				$(PLAT_QEMU_COMMON_PATH)/qemu_rotpk.S	\
75				drivers/auth/tbbr/tbbr_cot_bl2.c
76
77    include drivers/auth/mbedtls/mbedtls_x509.mk
78
79    ROT_KEY             = $(BUILD_PLAT)/rot_key.pem
80    ROTPK_HASH          = $(BUILD_PLAT)/rotpk_sha256.bin
81
82    $(eval $(call add_define_val,ROTPK_HASH,'"$(ROTPK_HASH)"'))
83
84    $(BUILD_PLAT)/bl1/qemu_rotpk.o: $(ROTPK_HASH)
85    $(BUILD_PLAT)/bl2/qemu_rotpk.o: $(ROTPK_HASH)
86
87    certificates: $(ROT_KEY)
88
89    $(ROT_KEY): | $(BUILD_PLAT)
90	@echo "  OPENSSL $@"
91	$(Q)${OPENSSL_BIN_PATH}/openssl genrsa 2048 > $@ 2>/dev/null
92
93    $(ROTPK_HASH): $(ROT_KEY)
94	@echo "  OPENSSL $@"
95	$(Q)${OPENSSL_BIN_PATH}/openssl rsa -in $< -pubout -outform DER 2>/dev/null |\
96	${OPENSSL_BIN_PATH}/openssl dgst -sha256 -binary > $@ 2>/dev/null
97endif
98
99# Include Measured Boot makefile before any Crypto library makefile.
100# Crypto library makefile may need default definitions of Measured Boot build
101# flags present in Measured Boot makefile.
102ifeq (${MEASURED_BOOT},1)
103    MEASURED_BOOT_MK := drivers/measured_boot/event_log/event_log.mk
104    $(info Including ${MEASURED_BOOT_MK})
105    include ${MEASURED_BOOT_MK}
106
107    ifneq (${MBOOT_EL_HASH_ALG}, sha256)
108        $(eval $(call add_define,TF_MBEDTLS_MBOOT_USE_SHA512))
109    endif
110
111    BL2_SOURCES		+=	plat/qemu/qemu/qemu_measured_boot.c	\
112				plat/qemu/qemu/qemu_helpers.c		\
113				${EVENT_LOG_SOURCES}
114
115     BL1_SOURCES	+=      plat/qemu/qemu/qemu_bl1_measured_boot.c
116
117endif
118
119ifneq ($(filter 1,${MEASURED_BOOT} ${TRUSTED_BOARD_BOOT}),)
120    CRYPTO_SOURCES	:=	drivers/auth/crypto_mod.c
121
122    BL1_SOURCES		+=	${CRYPTO_SOURCES}
123    BL2_SOURCES		+=	${CRYPTO_SOURCES}
124
125    # We expect to locate the *.mk files under the directories specified below
126    #
127    include drivers/auth/mbedtls/mbedtls_crypto.mk
128endif
129
130BL1_SOURCES		+=	drivers/io/io_semihosting.c		\
131				drivers/io/io_storage.c			\
132				drivers/io/io_fip.c			\
133				drivers/io/io_memmap.c			\
134				lib/semihosting/semihosting.c		\
135				lib/semihosting/${ARCH}/semihosting_call.S \
136				${PLAT_QEMU_COMMON_PATH}/qemu_io_storage.c		\
137				${PLAT_QEMU_COMMON_PATH}/${ARCH}/plat_helpers.S	\
138				${PLAT_QEMU_COMMON_PATH}/qemu_bl1_setup.c
139
140ifeq (${ARM_ARCH_MAJOR},8)
141BL1_SOURCES		+=	lib/cpus/aarch64/aem_generic.S		\
142				lib/cpus/aarch64/cortex_a53.S		\
143				lib/cpus/aarch64/cortex_a57.S		\
144				lib/cpus/aarch64/cortex_a72.S		\
145				lib/cpus/aarch64/qemu_max.S		\
146
147else
148BL1_SOURCES		+=	lib/cpus/${ARCH}/cortex_a15.S
149endif
150
151BL2_SOURCES		+=	drivers/io/io_semihosting.c		\
152				drivers/io/io_storage.c			\
153				drivers/io/io_fip.c			\
154				drivers/io/io_memmap.c			\
155				lib/semihosting/semihosting.c		\
156				lib/semihosting/${ARCH}/semihosting_call.S		\
157				${PLAT_QEMU_COMMON_PATH}/qemu_io_storage.c		\
158				${PLAT_QEMU_COMMON_PATH}/${ARCH}/plat_helpers.S		\
159				${PLAT_QEMU_COMMON_PATH}/qemu_bl2_setup.c		\
160				${PLAT_QEMU_COMMON_PATH}/qemu_bl2_mem_params_desc.c	\
161				${PLAT_QEMU_COMMON_PATH}/qemu_image_load.c		\
162				common/fdt_fixup.c					\
163				common/fdt_wrappers.c					\
164				common/desc_image_load.c				\
165				common/uuid.c
166
167ifeq ($(add-lib-optee),yes)
168BL2_SOURCES		+=	lib/optee/optee_utils.c
169endif
170
171ifneq (${DECRYPTION_SUPPORT},none)
172BL1_SOURCES		+=	drivers/io/io_encrypted.c
173BL2_SOURCES		+=	drivers/io/io_encrypted.c
174endif
175
176# Include GICv2 driver files
177include drivers/arm/gic/v2/gicv2.mk
178QEMU_GICV2_SOURCES	:=	${GICV2_SOURCES}			\
179				plat/common/plat_gicv2.c		\
180				${PLAT_QEMU_COMMON_PATH}/qemu_gicv2.c
181
182# Include GICv3 driver files
183include drivers/arm/gic/v3/gicv3.mk
184
185QEMU_GICV3_SOURCES	:=	${GICV3_SOURCES}			\
186				plat/common/plat_gicv3.c		\
187				${PLAT_QEMU_COMMON_PATH}/qemu_gicv3.c
188
189ifeq (${QEMU_USE_GIC_DRIVER}, QEMU_GICV2)
190QEMU_GIC_SOURCES	:=	${QEMU_GICV2_SOURCES}
191else ifeq (${QEMU_USE_GIC_DRIVER}, QEMU_GICV3)
192QEMU_GIC_SOURCES	:=	${QEMU_GICV3_SOURCES}
193else
194$(error "Incorrect GIC driver chosen for QEMU platform")
195endif
196
197ifeq (${ARM_ARCH_MAJOR},8)
198BL31_SOURCES		+=	lib/cpus/aarch64/aem_generic.S		\
199				lib/cpus/aarch64/cortex_a53.S		\
200				lib/cpus/aarch64/cortex_a57.S		\
201				lib/cpus/aarch64/cortex_a72.S		\
202				lib/cpus/aarch64/qemu_max.S		\
203				lib/semihosting/semihosting.c		\
204				lib/semihosting/${ARCH}/semihosting_call.S \
205				plat/common/plat_psci_common.c		\
206				drivers/arm/pl061/pl061_gpio.c		\
207				drivers/gpio/gpio.c			\
208				${PLAT_QEMU_COMMON_PATH}/qemu_pm.c			\
209				${PLAT_QEMU_COMMON_PATH}/topology.c			\
210				${PLAT_QEMU_COMMON_PATH}/aarch64/plat_helpers.S	\
211				${PLAT_QEMU_COMMON_PATH}/qemu_bl31_setup.c		\
212				${QEMU_GIC_SOURCES}
213
214# Pointer Authentication sources
215ifeq (${ENABLE_PAUTH}, 1)
216PLAT_BL_COMMON_SOURCES	+=	plat/arm/common/aarch64/arm_pauth.c
217endif
218
219ifeq (${SPD},spmd)
220BL31_SOURCES		+=	plat/common/plat_spmd_manifest.c	\
221				common/uuid.c				\
222				${LIBFDT_SRCS} 				\
223				${FDT_WRAPPERS_SOURCES}
224endif
225endif
226
227# Add the build options to pack Trusted OS Extra1 and Trusted OS Extra2 images
228# in the FIP if the platform requires.
229ifneq ($(BL32_EXTRA1),)
230ifneq (${DECRYPTION_SUPPORT},none)
231$(eval $(call TOOL_ADD_IMG,bl32_extra1,--tos-fw-extra1,,$(ENCRYPT_BL32)))
232else
233$(eval $(call TOOL_ADD_IMG,bl32_extra1,--tos-fw-extra1))
234endif
235endif
236ifneq ($(BL32_EXTRA2),)
237ifneq (${DECRYPTION_SUPPORT},none)
238$(eval $(call TOOL_ADD_IMG,bl32_extra2,--tos-fw-extra2,,$(ENCRYPT_BL32)))
239else
240$(eval $(call TOOL_ADD_IMG,bl32_extra2,--tos-fw-extra2))
241endif
242endif
243
244ifneq ($(QEMU_TB_FW_CONFIG_DTS),)
245FDT_SOURCES		+=	${QEMU_TB_FW_CONFIG_DTS}
246QEMU_TB_FW_CONFIG	:=	${BUILD_PLAT}/fdts/$(notdir $(basename ${QEMU_TB_FW_CONFIG_DTS})).dtb
247# Add the TB_FW_CONFIG to FIP
248$(eval $(call TOOL_ADD_PAYLOAD,${QEMU_TB_FW_CONFIG},--tb-fw-config,${QEMU_TB_FW_CONFIG}))
249endif
250
251ifneq ($(QEMU_TOS_FW_CONFIG_DTS),)
252FDT_SOURCES		+=	${QEMU_TOS_FW_CONFIG_DTS}
253QEMU_TOS_FW_CONFIG	:=	${BUILD_PLAT}/fdts/$(notdir $(basename ${QEMU_TOS_FW_CONFIG_DTS})).dtb
254# Add the TOS_FW_CONFIG to FIP
255$(eval $(call TOOL_ADD_PAYLOAD,${QEMU_TOS_FW_CONFIG},--tos-fw-config,${QEMU_TOS_FW_CONFIG}))
256endif
257
258SEPARATE_CODE_AND_RODATA := 1
259ENABLE_STACK_PROTECTOR	 := 0
260ifneq ($(ENABLE_STACK_PROTECTOR), 0)
261	PLAT_BL_COMMON_SOURCES += ${PLAT_QEMU_COMMON_PATH}/qemu_stack_protector.c
262endif
263
264BL32_RAM_LOCATION	:=	tdram
265ifeq (${BL32_RAM_LOCATION}, tsram)
266  BL32_RAM_LOCATION_ID = SEC_SRAM_ID
267else ifeq (${BL32_RAM_LOCATION}, tdram)
268  BL32_RAM_LOCATION_ID = SEC_DRAM_ID
269else
270  $(error "Unsupported BL32_RAM_LOCATION value")
271endif
272
273# Process flags
274$(eval $(call add_define,BL32_RAM_LOCATION_ID))
275
276# Don't have the Linux kernel as a BL33 image by default
277ARM_LINUX_KERNEL_AS_BL33	:=	0
278$(eval $(call assert_boolean,ARM_LINUX_KERNEL_AS_BL33))
279$(eval $(call add_define,ARM_LINUX_KERNEL_AS_BL33))
280
281ARM_PRELOADED_DTB_BASE := PLAT_QEMU_DT_BASE
282$(eval $(call add_define,ARM_PRELOADED_DTB_BASE))
283
284# Later QEMU versions support SME and SVE.
285ifneq (${ARCH},aarch32)
286	ENABLE_SVE_FOR_NS	:= 1
287	ENABLE_SME_FOR_NS	:= 1
288endif
289