1################################################################################ 2# Paths to Trusted Services source and output 3################################################################################ 4TS_PATH ?= $(ROOT)/trusted-services 5TS_BUILD_PATH ?= $(OUT_PATH)/ts-build 6TS_INSTALL_PREFIX ?= $(OUT_PATH)/ts-install 7 8################################################################################ 9# Secure Partitions 10################################################################################ 11.PHONY: ffa-sp-all ffa-sp-all-clean ffa-sp-all-realclean 12 13optee-os-common: ffa-sp-all 14optee-os-clean: ffa-sp-all-clean 15 16ffa-sp-all-realclean: 17 rm -rf $(TS_INSTALL_PREFIX)/opteesp $(TS_INSTALL_PREFIX)/sp 18 19ifneq ($(COMPILE_S_USER),64) 20$(error Trusted Services SPs only support AArch64) 21endif 22 23SP_EXT-opteesp := stripped.elf 24SP_EXT-sp := bin 25 26# The macro sets a variable if the source variable is defined, otherwise it 27# results in an error. 28# Parameter list: 29# 1 - Destination variable name 30# 2 - Source variable name 31# 3 - Error message 32define set_if_source_defined 33ifndef $(2) 34$$(error $(3)) 35else 36$(1) := $($(2)) 37endif 38endef 39 40# Helper macro to build and install Trusted Services Secure Partitions (SPs). 41# Invokes CMake to configure, and make to build and install the SP. (CMake's 42# Makefile generator backend is used, we can run make in the build directory). 43# Adds the SP output image to the optee_os_sp_paths list and complies the SP 44# manifest dts to dtb. 45# 46# For information about the additional dependencies of the project, please see 47# https://trusted-services.readthedocs.io/en/latest/developer/software-requirements.html 48# 49# Parameter list: 50# 1 - SP deployment name (e.g. internal-trusted-storage, crypto, etc.) 51# 2 - Build configuration name (e.g. config/shared-flash) 52# 3 - SP canonical UUID (e.g. dc1eef48-b17a-4ccf-ac8b-dfcff7711b14) 53# 4 - SP additional build flags (e.g. -DTS_PLATFORM=<...>) 54define build-sp 55$(eval SP_DIR := $(lastword $(subst -, ,$(2)))) 56$(eval $(call set_if_source_defined,SP_EXT,SP_EXT-$(lastword $(subst -, ,$(2))),Invalid $(1) SP configuration: $(2))) 57 58.PHONY: ffa-$1-sp 59ffa-$1-sp: 60 CROSS_COMPILE=$(subst $(CCACHE),,$(CROSS_COMPILE_S_USER)) cmake -G"Unix Makefiles" \ 61 -S $(TS_PATH)/deployments/$1/$2 -B $(TS_BUILD_PATH)/$1 \ 62 -DCMAKE_INSTALL_PREFIX=$(TS_INSTALL_PREFIX) \ 63 -DCMAKE_C_COMPILER_LAUNCHER=$(CCACHE) $(SP_COMMON_FLAGS) $4 64 $$(MAKE) -C $(TS_BUILD_PATH)/$1 install 65 dtc -I dts -O dtb -o $(TS_INSTALL_PREFIX)/$(SP_DIR)/manifest/$3.dtb \ 66 $(TS_INSTALL_PREFIX)/$(SP_DIR)/manifest/$3.dts 67 68.PHONY: ffa-$1-sp-clean 69ffa-$1-sp-clean: 70 - $$(MAKE) -C $(TS_BUILD_PATH)/$1 clean 71 72.PHONY: ffa-$1-sp-realclean 73ffa-$1-sp-realclean: 74 rm -rf $(TS_BUILD_PATH)/$1 75 76ffa-sp-all: ffa-$1-sp 77ffa-sp-all-clean: ffa-$1-sp-clean 78ffa-sp-all-realclean: ffa-$1-sp-realclean 79 80optee_os_sp_paths += $(TS_INSTALL_PREFIX)/$(SP_DIR)/bin/$3.$(SP_EXT) 81fip_sp_json_paths += $(TS_INSTALL_PREFIX)/$(SP_DIR)/json/$1.json 82endef 83 84ifeq ($(SP_PACKAGING_METHOD),embedded) 85# Add the list of SP paths to the optee_os config 86OPTEE_OS_COMMON_EXTRA_FLAGS += SP_PATHS="$(optee_os_sp_paths)" 87else ifeq ($(SP_PACKAGING_METHOD),fip) 88$(TS_INSTALL_PREFIX)/sp_layout.json: ffa-sp-all 89 $(PYTHON3) $(TS_PATH)/tools/python/merge_json.py $@ $(fip_sp_json_paths) 90 91optee-os-common: $(TS_INSTALL_PREFIX)/sp_layout.json 92 93# Configure TF-A to load the SPs from FIP by BL2 94TF_A_FLAGS += ARM_BL2_SP_LIST_DTS=$(ROOT)/build/fvp/bl2_sp_list.dtsi \ 95 SP_LAYOUT_FILE=$(TS_INSTALL_PREFIX)/sp_layout.json 96endif 97 98################################################################################ 99# Linux FF-A user space driver 100################################################################################ 101# This driver is only used by the uefi-test app or the spmc tests 102ifneq ($(filter y, $(TS_UEFI_TESTS) $(SPMC_TESTS)),) 103.PHONY: linux-arm-ffa-user linux-arm-ffa-user-clean 104all: linux-arm-ffa-user 105 106linux-arm-ffa-user: linux 107 mkdir -p $(OUT_PATH)/linux-arm-ffa-user 108 $(MAKE) -C $(ROOT)/linux-arm-ffa-user $(LINUX_COMMON_FLAGS) install \ 109 TARGET_DIR=$(OUT_PATH)/linux-arm-ffa-user 110 echo "ed32d533-99e6-4209-9cc0-2d72cdd998a7,\ 111 5c9edbc3-7b3a-4367-9f83-7c191ae86a37,\ 112 7817164c-c40c-4d1a-867a-9bb2278cf41a,\ 113 23eb0100-e32a-4497-9052-2f11e584afa6,\ 114 bdcd76d7-825e-4751-963b-86d4f84943ac" > \ 115 $(OUT_PATH)/linux-arm-ffa-user/sp_uuid_list.txt 116 117linux-arm-ffa-user-clean: 118 $(MAKE) -C $(ROOT)/linux-arm-ffa-user clean 119 120# Disable CONFIG_STRICT_DEVMEM option in the Linux kernel config. This allows 121# userspace access to the whole NS physical address space through /dev/mem. It's 122# needed by the uefi-test app to communicate with the smm-gateway SP using a 123# static carveout. If changed, run "make linux-defconfig-clean" to take effect. 124LINUX_DEFCONFIG_COMMON_FILES += $(CURDIR)/kconfigs/fvp_trusted-services_uefi.conf 125endif 126 127################################################################################ 128# Trusted Services test applications 129################################################################################ 130.PHONY: ffa-test-all ffa-test-all-clean ffa-test-all-realclean 131all: ffa-test-all 132 133ffa-test-all-realclean: 134 rm -rf $(TS_INSTALL_PREFIX)/arm-linux 135 136ifneq ($(COMPILE_NS_USER),64) 137$(error Trusted Services test apps only support AArch64) 138endif 139 140# Helper macro to build and install Trusted Services test applications. 141# Invokes CMake to configure, and make to build and install the apps. 142# 143# Parameter list: 144# 1 - SP deployment name (e.g. psa-api-test/internal-trusted-storage, 145# ts-demo, etc.) 146# 2 - Additional build flags 147 148define build-ts-app 149.PHONY: ffa-$1 150ffa-$1: 151 CROSS_COMPILE=$(subst $(CCACHE),,$(CROSS_COMPILE_NS_USER)) cmake -G"Unix Makefiles" \ 152 -S $(TS_PATH)/deployments/$1/arm-linux -B $(TS_BUILD_PATH)/$1 \ 153 -DCMAKE_INSTALL_PREFIX=$(TS_INSTALL_PREFIX) \ 154 -Dlibts_DIR=${TS_INSTALL_PREFIX}/arm-linux/lib/cmake/libts \ 155 -DCFG_FORCE_PREBUILT_LIBTS=On \ 156 -Dlibpsats_DIR=${TS_INSTALL_PREFIX}/arm-linux/lib/cmake/libpsats \ 157 -DCFG_FORCE_PREBUILT_LIBPSATS=On \ 158 -DCMAKE_C_COMPILER_LAUNCHER=$(CCACHE) $(TS_APP_COMMON_FLAGS) $2 159 $$(MAKE) -C $(TS_BUILD_PATH)/$1 install 160 161ifneq ($1,libts) 162 163ifeq ($1,libpsats) 164ffa-libpsats: ffa-libts 165else 166ffa-$1: ffa-libpsats 167endif 168 169endif 170 171.PHONY: ffa-$1-clean 172ffa-$1-clean: 173 - $$(MAKE) -C $(TS_BUILD_PATH)/$1 clean 174 175.PHONY: ffa-$1-realclean 176ffa-$1-realclean: 177 rm -rf $(TS_BUILD_PATH)/$1 178 179ffa-test-all: ffa-$1 180ffa-test-all-clean: ffa-$1-clean 181ffa-test-all-realclean: ffa-$1-realclean 182endef 183 184################################################################################ 185# Trusted Services hot applications 186################################################################################ 187.PHONY: ts-host-all ts-host-all-clean ts-host-all-realclean 188all: ts-host-all 189 190ts-host-all-realclean: 191 rm -rf $(TS_INSTALL_PREFIX)/linux-pc 192 193# Helper macro to build and install Trusted Services applications which 194# run on the host. 195# Invokes CMake to configure, and make to build and install the apps. 196# 197# Parameter list: 198# 1 - deployment name (e.g. fwu-app ) 199# 2 - Additional build flags 200 201define build-ts-host-app 202.PHONY: ts-host-$1 203$(if $1, ,$(error build-ts-host-app: missing deployment name argument)) 204 205ts-host-$1: 206 cmake -G"Unix Makefiles" \ 207 -S $(TS_PATH)/deployments/$1/linux-pc -B $(TS_BUILD_PATH)/$1 \ 208 -DCMAKE_INSTALL_PREFIX=$(TS_INSTALL_PREFIX) \ 209 -DCMAKE_C_COMPILER_LAUNCHER=$(CCACHE) \ 210 $(TS_HOST_COMMON_FLAGS) $2 211 $$(MAKE) -C $(TS_BUILD_PATH)/$1 install 212 213.PHONY: ts-host-$1-clean 214ts-host-$1-clean: 215 $$(MAKE) -C $(TS_BUILD_PATH)/$1 clean 216 217.PHONY: ts-host-$1-realclean 218ts-host-$1-realclean: 219 rm -rf $(TS_BUILD_PATH)/$1 220 221ts-host-all: ts-host-$1 222ts-host-all-clean: ts-host-$1-clean 223ts-host-all-realclean: ts-host-$1-realclean 224 225endef 226