Jens Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 1 | # |
Hongbo Zhang | 32338ec | 2018-04-19 13:06:07 +0800 | [diff] [blame] | 2 | # Copyright (c) 2013-2019, ARM Limited and Contributors. All rights reserved. |
Jens Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 3 | # |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | # SPDX-License-Identifier: BSD-3-Clause |
Jens Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 5 | # |
| 6 | |
Hongbo Zhang | bdcbf2a | 2018-04-19 14:42:23 +0800 | [diff] [blame] | 7 | # Use the GICv2 driver on QEMU by default |
| 8 | QEMU_USE_GIC_DRIVER := QEMU_GICV2 |
| 9 | |
Etienne Carriere | 911de8c | 2018-02-02 13:23:22 +0100 | [diff] [blame] | 10 | ifeq (${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. |
| 15 | MARCH32_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. |
| 19 | NEED_BL32 := yes |
| 20 | endif # ARMv7 |
| 21 | |
| 22 | ifeq (${SPD},opteed) |
| 23 | add-lib-optee := yes |
| 24 | endif |
| 25 | ifeq ($(AARCH32_SP),optee) |
| 26 | add-lib-optee := yes |
| 27 | endif |
| 28 | |
Jens Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 29 | include lib/libfdt/libfdt.mk |
| 30 | |
Fu Wei | c2f7844 | 2017-05-27 21:21:42 +0800 | [diff] [blame] | 31 | ifeq ($(NEED_BL32),yes) |
| 32 | $(eval $(call add_define,QEMU_LOAD_BL32)) |
| 33 | endif |
| 34 | |
Michalis Pappas | 3469cd0 | 2017-10-18 09:43:37 +0800 | [diff] [blame] | 35 | PLAT_PATH := plat/qemu/ |
Antonio Nino Diaz | 50a4d1a | 2019-02-01 12:22:22 +0000 | [diff] [blame] | 36 | PLAT_INCLUDES := -Iplat/qemu/include |
Jens Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 37 | |
Etienne Carriere | 911de8c | 2018-02-02 13:23:22 +0100 | [diff] [blame] | 38 | ifeq (${ARM_ARCH_MAJOR},8) |
| 39 | PLAT_INCLUDES += -Iinclude/plat/arm/common/${ARCH} |
| 40 | endif |
| 41 | |
Michalis Pappas | cca6cb7 | 2018-03-04 15:43:38 +0800 | [diff] [blame] | 42 | PLAT_BL_COMMON_SOURCES := plat/qemu/qemu_common.c \ |
| 43 | plat/qemu/qemu_console.c \ |
| 44 | drivers/arm/pl011/${ARCH}/pl011_console.S \ |
Fu Wei | 77ecd46 | 2017-07-31 18:28:32 +0800 | [diff] [blame] | 45 | |
Fu Wei | 77ecd46 | 2017-07-31 18:28:32 +0800 | [diff] [blame] | 46 | include lib/xlat_tables_v2/xlat_tables.mk |
Fu Wei | 77ecd46 | 2017-07-31 18:28:32 +0800 | [diff] [blame] | 47 | PLAT_BL_COMMON_SOURCES += ${XLAT_TABLES_LIB_SRCS} |
Jens Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 48 | |
Michalis Pappas | 3469cd0 | 2017-10-18 09:43:37 +0800 | [diff] [blame] | 49 | ifneq (${TRUSTED_BOARD_BOOT},0) |
| 50 | |
| 51 | include drivers/auth/mbedtls/mbedtls_crypto.mk |
| 52 | include drivers/auth/mbedtls/mbedtls_x509.mk |
| 53 | |
Michalis Pappas | 3469cd0 | 2017-10-18 09:43:37 +0800 | [diff] [blame] | 54 | 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 Pappas | 3469cd0 | 2017-10-18 09:43:37 +0800 | [diff] [blame] | 59 | 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 |
| 88 | endif |
| 89 | |
Jens Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 90 | BL1_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 Carriere | 911de8c | 2018-02-02 13:23:22 +0100 | [diff] [blame] | 95 | lib/semihosting/${ARCH}/semihosting_call.S \ |
Jens Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 96 | plat/qemu/qemu_io_storage.c \ |
Etienne Carriere | 911de8c | 2018-02-02 13:23:22 +0100 | [diff] [blame] | 97 | plat/qemu/${ARCH}/plat_helpers.S \ |
Jens Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 98 | plat/qemu/qemu_bl1_setup.c |
| 99 | |
Etienne Carriere | 911de8c | 2018-02-02 13:23:22 +0100 | [diff] [blame] | 100 | ifeq (${ARM_ARCH_MAJOR},8) |
| 101 | BL1_SOURCES += lib/cpus/aarch64/aem_generic.S \ |
| 102 | lib/cpus/aarch64/cortex_a53.S \ |
| 103 | lib/cpus/aarch64/cortex_a57.S |
| 104 | else |
| 105 | BL1_SOURCES += lib/cpus/${ARCH}/cortex_a15.S |
| 106 | endif |
| 107 | |
Jens Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 108 | BL2_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 Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 112 | lib/semihosting/semihosting.c \ |
Etienne Carriere | 911de8c | 2018-02-02 13:23:22 +0100 | [diff] [blame] | 113 | lib/semihosting/${ARCH}/semihosting_call.S\ |
Jens Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 114 | plat/qemu/qemu_io_storage.c \ |
Etienne Carriere | 911de8c | 2018-02-02 13:23:22 +0100 | [diff] [blame] | 115 | plat/qemu/${ARCH}/plat_helpers.S \ |
Jens Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 116 | plat/qemu/qemu_bl2_setup.c \ |
Jens Wiklander | 6335a97 | 2018-09-04 15:08:48 +0200 | [diff] [blame] | 117 | plat/qemu/dt.c \ |
| 118 | plat/qemu/qemu_bl2_mem_params_desc.c \ |
Fu Wei | c2f7844 | 2017-05-27 21:21:42 +0800 | [diff] [blame] | 119 | plat/qemu/qemu_image_load.c \ |
| 120 | common/desc_image_load.c |
Jens Wiklander | 6335a97 | 2018-09-04 15:08:48 +0200 | [diff] [blame] | 121 | |
Etienne Carriere | 911de8c | 2018-02-02 13:23:22 +0100 | [diff] [blame] | 122 | ifeq ($(add-lib-optee),yes) |
Jens Wiklander | 0acbaaa | 2017-08-24 13:16:26 +0200 | [diff] [blame] | 123 | BL2_SOURCES += lib/optee/optee_utils.c |
| 124 | endif |
| 125 | |
Hongbo Zhang | bdcbf2a | 2018-04-19 14:42:23 +0800 | [diff] [blame] | 126 | QEMU_GICV2_SOURCES := drivers/arm/gic/v2/gicv2_helpers.c \ |
Hongbo Zhang | 32338ec | 2018-04-19 13:06:07 +0800 | [diff] [blame] | 127 | 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 Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 131 | |
Hongbo Zhang | bdcbf2a | 2018-04-19 14:42:23 +0800 | [diff] [blame] | 132 | QEMU_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 | |
| 138 | ifeq (${QEMU_USE_GIC_DRIVER}, QEMU_GICV2) |
| 139 | QEMU_GIC_SOURCES := ${QEMU_GICV2_SOURCES} |
| 140 | else ifeq (${QEMU_USE_GIC_DRIVER}, QEMU_GICV3) |
| 141 | QEMU_GIC_SOURCES := ${QEMU_GICV3_SOURCES} |
| 142 | else |
| 143 | $(error "Incorrect GIC driver chosen for QEMU platform") |
| 144 | endif |
| 145 | |
Etienne Carriere | 911de8c | 2018-02-02 13:23:22 +0100 | [diff] [blame] | 146 | ifeq (${ARM_ARCH_MAJOR},8) |
Jens Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 147 | BL31_SOURCES += lib/cpus/aarch64/aem_generic.S \ |
| 148 | lib/cpus/aarch64/cortex_a53.S \ |
| 149 | lib/cpus/aarch64/cortex_a57.S \ |
Jens Wiklander | 1017a6e | 2017-08-24 13:16:20 +0200 | [diff] [blame] | 150 | plat/common/plat_psci_common.c \ |
Jens Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 151 | plat/qemu/qemu_pm.c \ |
| 152 | plat/qemu/topology.c \ |
| 153 | plat/qemu/aarch64/plat_helpers.S \ |
Hongbo Zhang | 32338ec | 2018-04-19 13:06:07 +0800 | [diff] [blame] | 154 | plat/qemu/qemu_bl31_setup.c \ |
| 155 | ${QEMU_GIC_SOURCES} |
Etienne Carriere | 911de8c | 2018-02-02 13:23:22 +0100 | [diff] [blame] | 156 | endif |
Jens Wiklander | 0acbaaa | 2017-08-24 13:16:26 +0200 | [diff] [blame] | 157 | |
| 158 | # Add the build options to pack Trusted OS Extra1 and Trusted OS Extra2 images |
| 159 | # in the FIP if the platform requires. |
| 160 | ifneq ($(BL32_EXTRA1),) |
Masahiro Yamada | 9c5ca52 | 2018-01-26 11:42:01 +0900 | [diff] [blame] | 161 | $(eval $(call TOOL_ADD_IMG,bl32_extra1,--tos-fw-extra1)) |
Jens Wiklander | 0acbaaa | 2017-08-24 13:16:26 +0200 | [diff] [blame] | 162 | endif |
| 163 | ifneq ($(BL32_EXTRA2),) |
Masahiro Yamada | 9c5ca52 | 2018-01-26 11:42:01 +0900 | [diff] [blame] | 164 | $(eval $(call TOOL_ADD_IMG,bl32_extra2,--tos-fw-extra2)) |
Jens Wiklander | 0acbaaa | 2017-08-24 13:16:26 +0200 | [diff] [blame] | 165 | endif |
| 166 | |
Michalis Pappas | ba86112 | 2018-02-28 14:36:03 +0800 | [diff] [blame] | 167 | SEPARATE_CODE_AND_RODATA := 1 |
Michalis Pappas | e4c00bb | 2018-03-20 14:30:00 +0800 | [diff] [blame] | 168 | ENABLE_STACK_PROTECTOR := 0 |
| 169 | ifneq ($(ENABLE_STACK_PROTECTOR), 0) |
| 170 | PLAT_BL_COMMON_SOURCES += plat/qemu/qemu_stack_protector.c |
| 171 | endif |
Michalis Pappas | a0bb5ac | 2018-03-24 12:38:31 +0800 | [diff] [blame] | 172 | |
Jens Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 173 | BL32_RAM_LOCATION := tdram |
| 174 | ifeq (${BL32_RAM_LOCATION}, tsram) |
| 175 | BL32_RAM_LOCATION_ID = SEC_SRAM_ID |
| 176 | else ifeq (${BL32_RAM_LOCATION}, tdram) |
| 177 | BL32_RAM_LOCATION_ID = SEC_DRAM_ID |
| 178 | else |
| 179 | $(error "Unsupported BL32_RAM_LOCATION value") |
| 180 | endif |
| 181 | |
| 182 | # Process flags |
| 183 | $(eval $(call add_define,BL32_RAM_LOCATION_ID)) |
David Cunado | c5b0c0f | 2017-10-31 23:19:21 +0000 | [diff] [blame] | 184 | |
| 185 | # Do not enable SVE |
| 186 | ENABLE_SVE_FOR_NS := 0 |