1# 2# Copyright (c) 2015-2018, Google, Inc. All rights reserved 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15# 16 17# 18# This makefile containts rules for building ATF image for Trusty. 19# It is expected that it will be included by the project that requres ATF 20# support and the caller will configure the following variables: 21# 22# ATF_ROOT - Root of arm-trusted-firmware project 23# ATF_BUILD_BASE - location that will be used to store temp files and 24# build results. 25# ATF_PLAT - ATF platform to build 26# ATF_DEBUG - ATF debug level 27# ATF_WITH_TRUSTY_GENERIC_SERVICES - Add Trusty generic services 28# ATF_TOOLCHAIN_PREFIX - AArch64 toolchain to use for building ATF 29# 30# The following variable is returned to the caller: 31# ATF_OUT_DIR - Directory containing ATF images 32# ATF_BUILD_BASE - location that will be used to store temp files and 33# build results. 34# 35# 36 37# set location of resulting ATF image 38ifneq ($(ATF_DEBUG), 0) 39ATF_OUT_DIR := $(ATF_BUILD_BASE)/$(ATF_PLAT)/debug 40else 41ATF_OUT_DIR:=$(ATF_BUILD_BASE)/$(ATF_PLAT)/release 42endif 43ATF_BIN := $(ATF_OUT_DIR)/bl31.bin 44 45ATF_WITH_TRUSTY_GENERIC_SERVICES ?= false 46 47ifeq (true,$(call TOBOOL,$(HAFNIUM))) 48ATF_MAKE_ARGS := SPD=spmd 49ATF_MAKE_ARGS += SPMD_SPM_AT_SEL2=1 50ATF_MAKE_ARGS += BL32=$(BL32_BIN) 51ATF_MAKE_ARGS += BL33=$(TEST_RUNNER_BIN) 52ATF_MAKE_ARGS += SP_LAYOUT_FILE=$(HAFNIUM_OUT_DIR)/sp_layout.json 53ATF_MAKE_ARGS += QEMU_TOS_FW_CONFIG_DTS=$(HAFNIUM_OUT_DIR)/tos_fw_config.dts 54ATF_MAKE_ARGS += QEMU_TB_FW_CONFIG_DTS=$(HAFNIUM_OUT_DIR)/tb_fw_config.dts 55# Symlink the Hafnium DTBs to where ATF will look for them. 56HAFNIUM_DTBS := tb_fw_config.dtb tos_fw_config.dtb 57HAFNIUM_DTBS_SRCS := $(addprefix $(ATF_OUT_DIR)/fdts/, $(HAFNIUM_DTBS)) 58$(HAFNIUM_DTBS_SRCS): $(ATF_BIN) 59HAFNIUM_DTBS_OUT := $(addprefix $(ATF_OUT_DIR)/, $(HAFNIUM_DTBS)) 60$(HAFNIUM_DTBS_OUT): $(ATF_OUT_DIR)/%.dtb: $(ATF_OUT_DIR)/fdts/%.dtb 61 ln -sf $< $@ 62EXTRA_BUILDDEPS += $(HAFNIUM_DTBS_OUT) 63else 64ATF_MAKE_ARGS := SPD=trusty 65ATF_MAKE_ARGS += SPMD_SPM_AT_SEL2=0 66endif 67ATF_MAKE_ARGS += CC=$(CLANG_BINDIR)/clang 68ATF_MAKE_ARGS += DTC=$(TRUSTY_TOP)/prebuilts/misc/linux-x86/dtc/dtc 69ATF_MAKE_ARGS += CROSS_COMPILE=$(ATF_TOOLCHAIN_PREFIX) 70ATF_MAKE_ARGS += PLAT=$(ATF_PLAT) 71ATF_MAKE_ARGS += DEBUG=$(ATF_DEBUG) 72ATF_MAKE_ARGS += BUILD_BASE=$(ATF_BUILD_BASE) 73ATF_MAKE_ARGS += QEMU_USE_GIC_DRIVER=QEMU_GICV$(GIC_VERSION) 74# On aarch32, we skip EL2, see 27d8e1e75a2f45d7c23 75ifeq (true,$(call TOBOOL,$(KERNEL_32BIT))) 76ATF_MAKE_ARGS += INIT_UNUSED_NS_EL2=1 77endif 78 79ifeq (true,$(call TOBOOL,$(ATF_WITH_TRUSTY_GENERIC_SERVICES))) 80ATF_MAKE_ARGS += TRUSTY_SPD_WITH_GENERIC_SERVICES=1 81endif 82 83$(ATF_BIN): ATF_ROOT:=$(ATF_ROOT) 84$(ATF_BIN): ATF_MAKE_ARGS:=$(ATF_MAKE_ARGS) 85$(ATF_BIN): .PHONY 86 $(MAKE) -C $(ATF_ROOT) $(ATF_MAKE_ARGS) all sp 87 88# Add ATF_BIN to the list of project dependencies 89EXTRA_BUILDDEPS += $(ATF_BIN) 90 91ATF_ROOT:= 92ATF_PLAT:= 93ATF_DEBUG:= 94ATF_WITH_TRUSTY_GENERIC_SERVICES:= 95ATF_TOOLCHAIN_PREFIX:= 96ATF_BIN:= 97ATF_MAKE_ARGS:= 98