blob: f487560812d12bcbe0e43e76fbbaf24361cea075 [file] [log] [blame]
Balint Dobszay1bf41f52022-05-30 12:56:38 +02001################################################################################
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:
Imre Kis874a2dd2023-01-09 17:01:22 +010017 rm -rf $(TS_INSTALL_PREFIX)/opteesp $(TS_INSTALL_PREFIX)/sp
Balint Dobszay1bf41f52022-05-30 12:56:38 +020018
19ifneq ($(COMPILE_S_USER),64)
20$(error Trusted Services SPs only support AArch64)
21endif
22
Imre Kis874a2dd2023-01-09 17:01:22 +010023SP_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
Balint Dobszay1bf41f52022-05-30 12:56:38 +020040# 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.)
Julian Hallb0c8fc22022-11-30 12:24:38 +000051# 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=<...>)
Balint Dobszay1bf41f52022-05-30 12:56:38 +020054define build-sp
Imre Kis874a2dd2023-01-09 17:01:22 +010055$(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
Balint Dobszay1bf41f52022-05-30 12:56:38 +020058.PHONY: ffa-$1-sp
59ffa-$1-sp:
60 CROSS_COMPILE=$(subst $(CCACHE),,$(CROSS_COMPILE_S_USER)) cmake -G"Unix Makefiles" \
Julian Hallb0c8fc22022-11-30 12:24:38 +000061 -S $(TS_PATH)/deployments/$1/$2 -B $(TS_BUILD_PATH)/$1 \
Balint Dobszay1bf41f52022-05-30 12:56:38 +020062 -DCMAKE_INSTALL_PREFIX=$(TS_INSTALL_PREFIX) \
Julian Hallb0c8fc22022-11-30 12:24:38 +000063 -DCMAKE_C_COMPILER_LAUNCHER=$(CCACHE) $(SP_COMMON_FLAGS) $4
Balint Dobszay1bf41f52022-05-30 12:56:38 +020064 $$(MAKE) -C $(TS_BUILD_PATH)/$1 install
Imre Kis874a2dd2023-01-09 17:01:22 +010065 dtc -I dts -O dtb -o $(TS_INSTALL_PREFIX)/$(SP_DIR)/manifest/$3.dtb \
66 $(TS_INSTALL_PREFIX)/$(SP_DIR)/manifest/$3.dts
Balint Dobszay1bf41f52022-05-30 12:56:38 +020067
68.PHONY: ffa-$1-sp-clean
69ffa-$1-sp-clean:
Gyorgy Szinga72ab362023-09-19 18:36:14 +000070 - $$(MAKE) -C $(TS_BUILD_PATH)/$1 clean
Balint Dobszay1bf41f52022-05-30 12:56:38 +020071
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
Imre Kis874a2dd2023-01-09 17:01:22 +010080optee_os_sp_paths += $(TS_INSTALL_PREFIX)/$(SP_DIR)/bin/$3.$(SP_EXT)
Imre Kisafa78002023-03-24 16:21:27 +010081fip_sp_json_paths += $(TS_INSTALL_PREFIX)/$(SP_DIR)/json/$1.json
Balint Dobszay1bf41f52022-05-30 12:56:38 +020082endef
83
Balint Dobszaydb9b8f02022-09-01 11:20:23 +020084ifeq ($(SP_PACKAGING_METHOD),embedded)
Balint Dobszay1bf41f52022-05-30 12:56:38 +020085# Add the list of SP paths to the optee_os config
86OPTEE_OS_COMMON_EXTRA_FLAGS += SP_PATHS="$(optee_os_sp_paths)"
Balint Dobszaydb9b8f02022-09-01 11:20:23 +020087else ifeq ($(SP_PACKAGING_METHOD),fip)
Imre Kisafa78002023-03-24 16:21:27 +010088$(TS_INSTALL_PREFIX)/sp_layout.json: ffa-sp-all
Imre Kisdc34f492023-04-11 16:53:06 +020089 $(PYTHON3) $(TS_PATH)/tools/python/merge_json.py $@ $(fip_sp_json_paths)
Imre Kisafa78002023-03-24 16:21:27 +010090
91optee-os-common: $(TS_INSTALL_PREFIX)/sp_layout.json
92
Balint Dobszaydb9b8f02022-09-01 11:20:23 +020093# Configure TF-A to load the SPs from FIP by BL2
Sudeep Holla68f7beb2024-05-23 17:21:55 +010094TF_A_FLAGS += ARM_BL2_SP_LIST_DTS=$(ROOT)/build/fvp/bl2_sp_list.dtsi \
Imre Kisafa78002023-03-24 16:21:27 +010095 SP_LAYOUT_FILE=$(TS_INSTALL_PREFIX)/sp_layout.json
Balint Dobszaydb9b8f02022-09-01 11:20:23 +020096endif
Balint Dobszayc3d34122022-05-30 13:28:06 +020097
98################################################################################
99# Linux FF-A user space drivers
100################################################################################
101.PHONY: linux-arm-ffa-tee linux-arm-ffa-tee-clean
102all: linux-arm-ffa-tee
103
104linux-arm-ffa-tee: linux
105 mkdir -p $(OUT_PATH)/linux-arm-ffa-tee
106 $(MAKE) -C $(ROOT)/linux-arm-ffa-tee $(LINUX_COMMON_FLAGS) install \
107 TARGET_DIR=$(OUT_PATH)/linux-arm-ffa-tee
108
109linux-arm-ffa-tee-clean:
110 $(MAKE) -C $(ROOT)/linux-arm-ffa-tee clean
111
Gabor Tothce8a7f42023-03-23 10:56:53 +0100112# This driver is only used by the uefi-test app or the spmc tests
113ifneq ($(filter y, $(TS_UEFI_TESTS) $(SPMC_TESTS)),)
Balint Dobszayc3d34122022-05-30 13:28:06 +0200114.PHONY: linux-arm-ffa-user linux-arm-ffa-user-clean
115all: linux-arm-ffa-user
116
117linux-arm-ffa-user: linux
118 mkdir -p $(OUT_PATH)/linux-arm-ffa-user
119 $(MAKE) -C $(ROOT)/linux-arm-ffa-user $(LINUX_COMMON_FLAGS) install \
120 TARGET_DIR=$(OUT_PATH)/linux-arm-ffa-user
Jelle Selsbb5a5362022-07-18 17:07:05 +0200121 echo "ed32d533-99e6-4209-9cc0-2d72cdd998a7,\
122 5c9edbc3-7b3a-4367-9f83-7c191ae86a37,\
123 7817164c-c40c-4d1a-867a-9bb2278cf41a,\
Jelle Sels3a937c52023-02-01 09:25:52 +0100124 23eb0100-e32a-4497-9052-2f11e584afa6,\
125 bdcd76d7-825e-4751-963b-86d4f84943ac" > \
Balint Dobszayc3d34122022-05-30 13:28:06 +0200126 $(OUT_PATH)/linux-arm-ffa-user/sp_uuid_list.txt
127
128linux-arm-ffa-user-clean:
129 $(MAKE) -C $(ROOT)/linux-arm-ffa-user clean
130
131# Disable CONFIG_STRICT_DEVMEM option in the Linux kernel config. This allows
132# userspace access to the whole NS physical address space through /dev/mem. It's
133# needed by the uefi-test app to communicate with the smm-gateway SP using a
134# static carveout. If changed, run "make linux-defconfig-clean" to take effect.
Balint Dobszay3730e012023-06-02 11:40:41 +0200135LINUX_DEFCONFIG_COMMON_FILES += $(CURDIR)/kconfigs/fvp_trusted-services_uefi.conf
Balint Dobszayc3d34122022-05-30 13:28:06 +0200136endif
Balint Dobszayc0b8fdf2022-06-02 14:41:54 +0200137
138################################################################################
139# Trusted Services test applications
140################################################################################
141.PHONY: ffa-test-all ffa-test-all-clean ffa-test-all-realclean
142all: ffa-test-all
143
144ffa-test-all-realclean:
145 rm -rf $(TS_INSTALL_PREFIX)/arm-linux
146
147ifneq ($(COMPILE_NS_USER),64)
148$(error Trusted Services test apps only support AArch64)
149endif
150
151# Helper macro to build and install Trusted Services test applications.
152# Invokes CMake to configure, and make to build and install the apps.
Gyorgy Szing0e2a1d92023-02-28 00:58:45 +0100153#
154# Parameter list:
155# 1 - SP deployment name (e.g. psa-api-test/internal-trusted-storage,
156# ts-demo, etc.)
Gabor Toth22d70632023-11-09 19:05:17 +0100157# 2 - Additional build flags
Gyorgy Szing0e2a1d92023-02-28 00:58:45 +0100158
Balint Dobszayc0b8fdf2022-06-02 14:41:54 +0200159define build-ts-app
160.PHONY: ffa-$1
161ffa-$1:
162 CROSS_COMPILE=$(subst $(CCACHE),,$(CROSS_COMPILE_NS_USER)) cmake -G"Unix Makefiles" \
163 -S $(TS_PATH)/deployments/$1/arm-linux -B $(TS_BUILD_PATH)/$1 \
164 -DCMAKE_INSTALL_PREFIX=$(TS_INSTALL_PREFIX) \
Gyorgy Szing27cd4172023-02-28 01:10:34 +0100165 -Dlibts_DIR=${TS_INSTALL_PREFIX}/arm-linux/lib/cmake/libts \
166 -DCFG_FORCE_PREBUILT_LIBTS=On \
Gabor Toth22d70632023-11-09 19:05:17 +0100167 -DCMAKE_C_COMPILER_LAUNCHER=$(CCACHE) $(TS_APP_COMMON_FLAGS) $2
Balint Dobszayc0b8fdf2022-06-02 14:41:54 +0200168 $$(MAKE) -C $(TS_BUILD_PATH)/$1 install
169
Gyorgy Szing27cd4172023-02-28 01:10:34 +0100170ifneq ($1,libts)
171ffa-$1: ffa-libts
172endif
173
Balint Dobszayc0b8fdf2022-06-02 14:41:54 +0200174.PHONY: ffa-$1-clean
175ffa-$1-clean:
Gyorgy Szinga72ab362023-09-19 18:36:14 +0000176 - $$(MAKE) -C $(TS_BUILD_PATH)/$1 clean
Balint Dobszayc0b8fdf2022-06-02 14:41:54 +0200177
178.PHONY: ffa-$1-realclean
179ffa-$1-realclean:
180 rm -rf $(TS_BUILD_PATH)/$1
181
182ffa-test-all: ffa-$1
183ffa-test-all-clean: ffa-$1-clean
184ffa-test-all-realclean: ffa-$1-realclean
185endef
Gyorgy Szing46fa5a42023-04-05 07:56:30 +0000186
187################################################################################
188# Trusted Services hot applications
189################################################################################
190.PHONY: ts-host-all ts-host-all-clean ts-host-all-realclean
191all: ts-host-all
192
193ts-host-all-realclean:
194 rm -rf $(TS_INSTALL_PREFIX)/linux-pc
195
196# Helper macro to build and install Trusted Services applications which
197# run on the host.
198# Invokes CMake to configure, and make to build and install the apps.
199#
200# Parameter list:
201# 1 - deployment name (e.g. fwu-app )
Gabor Toth22d70632023-11-09 19:05:17 +0100202# 2 - Additional build flags
Gyorgy Szing46fa5a42023-04-05 07:56:30 +0000203
204define build-ts-host-app
205.PHONY: ts-host-$1
206$(if $1, ,$(error build-ts-host-app: missing deployment name argument))
207
Gyorgy Szing46fa5a42023-04-05 07:56:30 +0000208ts-host-$1:
209 cmake -G"Unix Makefiles" \
210 -S $(TS_PATH)/deployments/$1/linux-pc -B $(TS_BUILD_PATH)/$1 \
211 -DCMAKE_INSTALL_PREFIX=$(TS_INSTALL_PREFIX) \
Gabor Toth22d70632023-11-09 19:05:17 +0100212 -DCMAKE_C_COMPILER_LAUNCHER=$(CCACHE) \
213 $(TS_HOST_COMMON_FLAGS) $2
Gyorgy Szing46fa5a42023-04-05 07:56:30 +0000214 $$(MAKE) -C $(TS_BUILD_PATH)/$1 install
215
216.PHONY: ts-host-$1-clean
217ts-host-$1-clean:
218 $$(MAKE) -C $(TS_BUILD_PATH)/$1 clean
219
220.PHONY: ts-host-$1-realclean
221ts-host-$1-realclean:
222 rm -rf $(TS_BUILD_PATH)/$1
223
224ts-host-all: ts-host-$1
225ts-host-all-clean: ts-host-$1-clean
226ts-host-all-realclean: ts-host-$1-realclean
227
228endef