Balint Dobszay | 1bf41f5 | 2022-05-30 12:56:38 +0200 | [diff] [blame] | 1 | ################################################################################ |
| 2 | # Paths to Trusted Services source and output |
| 3 | ################################################################################ |
| 4 | TS_PATH ?= $(ROOT)/trusted-services |
| 5 | TS_BUILD_PATH ?= $(OUT_PATH)/ts-build |
| 6 | TS_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 | |
| 13 | optee-os-common: ffa-sp-all |
| 14 | optee-os-clean: ffa-sp-all-clean |
| 15 | |
| 16 | ffa-sp-all-realclean: |
Imre Kis | 874a2dd | 2023-01-09 17:01:22 +0100 | [diff] [blame] | 17 | rm -rf $(TS_INSTALL_PREFIX)/opteesp $(TS_INSTALL_PREFIX)/sp |
Balint Dobszay | 1bf41f5 | 2022-05-30 12:56:38 +0200 | [diff] [blame] | 18 | |
| 19 | ifneq ($(COMPILE_S_USER),64) |
| 20 | $(error Trusted Services SPs only support AArch64) |
| 21 | endif |
| 22 | |
Imre Kis | 874a2dd | 2023-01-09 17:01:22 +0100 | [diff] [blame] | 23 | SP_EXT-opteesp := stripped.elf |
| 24 | SP_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 |
| 32 | define set_if_source_defined |
| 33 | ifndef $(2) |
| 34 | $$(error $(3)) |
| 35 | else |
| 36 | $(1) := $($(2)) |
| 37 | endif |
| 38 | endef |
| 39 | |
Balint Dobszay | 1bf41f5 | 2022-05-30 12:56:38 +0200 | [diff] [blame] | 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.) |
Julian Hall | b0c8fc2 | 2022-11-30 12:24:38 +0000 | [diff] [blame] | 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=<...>) |
Balint Dobszay | 1bf41f5 | 2022-05-30 12:56:38 +0200 | [diff] [blame] | 54 | define build-sp |
Imre Kis | 874a2dd | 2023-01-09 17:01:22 +0100 | [diff] [blame] | 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 | |
Balint Dobszay | 1bf41f5 | 2022-05-30 12:56:38 +0200 | [diff] [blame] | 58 | .PHONY: ffa-$1-sp |
| 59 | ffa-$1-sp: |
| 60 | CROSS_COMPILE=$(subst $(CCACHE),,$(CROSS_COMPILE_S_USER)) cmake -G"Unix Makefiles" \ |
Julian Hall | b0c8fc2 | 2022-11-30 12:24:38 +0000 | [diff] [blame] | 61 | -S $(TS_PATH)/deployments/$1/$2 -B $(TS_BUILD_PATH)/$1 \ |
Balint Dobszay | 1bf41f5 | 2022-05-30 12:56:38 +0200 | [diff] [blame] | 62 | -DCMAKE_INSTALL_PREFIX=$(TS_INSTALL_PREFIX) \ |
Julian Hall | b0c8fc2 | 2022-11-30 12:24:38 +0000 | [diff] [blame] | 63 | -DCMAKE_C_COMPILER_LAUNCHER=$(CCACHE) $(SP_COMMON_FLAGS) $4 |
Balint Dobszay | 1bf41f5 | 2022-05-30 12:56:38 +0200 | [diff] [blame] | 64 | $$(MAKE) -C $(TS_BUILD_PATH)/$1 install |
Imre Kis | 874a2dd | 2023-01-09 17:01:22 +0100 | [diff] [blame] | 65 | dtc -I dts -O dtb -o $(TS_INSTALL_PREFIX)/$(SP_DIR)/manifest/$3.dtb \ |
| 66 | $(TS_INSTALL_PREFIX)/$(SP_DIR)/manifest/$3.dts |
Balint Dobszay | 1bf41f5 | 2022-05-30 12:56:38 +0200 | [diff] [blame] | 67 | |
| 68 | .PHONY: ffa-$1-sp-clean |
| 69 | ffa-$1-sp-clean: |
Gyorgy Szing | a72ab36 | 2023-09-19 18:36:14 +0000 | [diff] [blame] | 70 | - $$(MAKE) -C $(TS_BUILD_PATH)/$1 clean |
Balint Dobszay | 1bf41f5 | 2022-05-30 12:56:38 +0200 | [diff] [blame] | 71 | |
| 72 | .PHONY: ffa-$1-sp-realclean |
| 73 | ffa-$1-sp-realclean: |
| 74 | rm -rf $(TS_BUILD_PATH)/$1 |
| 75 | |
| 76 | ffa-sp-all: ffa-$1-sp |
| 77 | ffa-sp-all-clean: ffa-$1-sp-clean |
| 78 | ffa-sp-all-realclean: ffa-$1-sp-realclean |
| 79 | |
Imre Kis | 874a2dd | 2023-01-09 17:01:22 +0100 | [diff] [blame] | 80 | optee_os_sp_paths += $(TS_INSTALL_PREFIX)/$(SP_DIR)/bin/$3.$(SP_EXT) |
Imre Kis | afa7800 | 2023-03-24 16:21:27 +0100 | [diff] [blame] | 81 | fip_sp_json_paths += $(TS_INSTALL_PREFIX)/$(SP_DIR)/json/$1.json |
Balint Dobszay | 1bf41f5 | 2022-05-30 12:56:38 +0200 | [diff] [blame] | 82 | endef |
| 83 | |
Balint Dobszay | db9b8f0 | 2022-09-01 11:20:23 +0200 | [diff] [blame] | 84 | ifeq ($(SP_PACKAGING_METHOD),embedded) |
Balint Dobszay | 1bf41f5 | 2022-05-30 12:56:38 +0200 | [diff] [blame] | 85 | # Add the list of SP paths to the optee_os config |
| 86 | OPTEE_OS_COMMON_EXTRA_FLAGS += SP_PATHS="$(optee_os_sp_paths)" |
Balint Dobszay | db9b8f0 | 2022-09-01 11:20:23 +0200 | [diff] [blame] | 87 | else ifeq ($(SP_PACKAGING_METHOD),fip) |
Imre Kis | afa7800 | 2023-03-24 16:21:27 +0100 | [diff] [blame] | 88 | $(TS_INSTALL_PREFIX)/sp_layout.json: ffa-sp-all |
Imre Kis | dc34f49 | 2023-04-11 16:53:06 +0200 | [diff] [blame] | 89 | $(PYTHON3) $(TS_PATH)/tools/python/merge_json.py $@ $(fip_sp_json_paths) |
Imre Kis | afa7800 | 2023-03-24 16:21:27 +0100 | [diff] [blame] | 90 | |
| 91 | optee-os-common: $(TS_INSTALL_PREFIX)/sp_layout.json |
| 92 | |
Balint Dobszay | db9b8f0 | 2022-09-01 11:20:23 +0200 | [diff] [blame] | 93 | # Configure TF-A to load the SPs from FIP by BL2 |
Sudeep Holla | 68f7beb | 2024-05-23 17:21:55 +0100 | [diff] [blame] | 94 | TF_A_FLAGS += ARM_BL2_SP_LIST_DTS=$(ROOT)/build/fvp/bl2_sp_list.dtsi \ |
Imre Kis | afa7800 | 2023-03-24 16:21:27 +0100 | [diff] [blame] | 95 | SP_LAYOUT_FILE=$(TS_INSTALL_PREFIX)/sp_layout.json |
Balint Dobszay | db9b8f0 | 2022-09-01 11:20:23 +0200 | [diff] [blame] | 96 | endif |
Balint Dobszay | c3d3412 | 2022-05-30 13:28:06 +0200 | [diff] [blame] | 97 | |
| 98 | ################################################################################ |
Balint Dobszay | 58b2bf9 | 2024-07-10 12:51:17 +0200 | [diff] [blame] | 99 | # Linux FF-A user space driver |
Balint Dobszay | c3d3412 | 2022-05-30 13:28:06 +0200 | [diff] [blame] | 100 | ################################################################################ |
Gabor Toth | ce8a7f4 | 2023-03-23 10:56:53 +0100 | [diff] [blame] | 101 | # This driver is only used by the uefi-test app or the spmc tests |
| 102 | ifneq ($(filter y, $(TS_UEFI_TESTS) $(SPMC_TESTS)),) |
Balint Dobszay | c3d3412 | 2022-05-30 13:28:06 +0200 | [diff] [blame] | 103 | .PHONY: linux-arm-ffa-user linux-arm-ffa-user-clean |
| 104 | all: linux-arm-ffa-user |
| 105 | |
| 106 | linux-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 |
Jelle Sels | bb5a536 | 2022-07-18 17:07:05 +0200 | [diff] [blame] | 110 | echo "ed32d533-99e6-4209-9cc0-2d72cdd998a7,\ |
| 111 | 5c9edbc3-7b3a-4367-9f83-7c191ae86a37,\ |
| 112 | 7817164c-c40c-4d1a-867a-9bb2278cf41a,\ |
Jelle Sels | 3a937c5 | 2023-02-01 09:25:52 +0100 | [diff] [blame] | 113 | 23eb0100-e32a-4497-9052-2f11e584afa6,\ |
Jens Wiklander | 1320543 | 2025-04-17 16:23:53 +0200 | [diff] [blame] | 114 | bdcd76d7-825e-4751-963b-86d4f84943ac,\ |
| 115 | 54b5440e-a3d2-48d1-872a-7b6cbfc34855" > \ |
Balint Dobszay | c3d3412 | 2022-05-30 13:28:06 +0200 | [diff] [blame] | 116 | $(OUT_PATH)/linux-arm-ffa-user/sp_uuid_list.txt |
| 117 | |
| 118 | linux-arm-ffa-user-clean: |
| 119 | $(MAKE) -C $(ROOT)/linux-arm-ffa-user clean |
| 120 | |
| 121 | # Disable CONFIG_STRICT_DEVMEM option in the Linux kernel config. This allows |
| 122 | # userspace access to the whole NS physical address space through /dev/mem. It's |
| 123 | # needed by the uefi-test app to communicate with the smm-gateway SP using a |
| 124 | # static carveout. If changed, run "make linux-defconfig-clean" to take effect. |
Balint Dobszay | 3730e01 | 2023-06-02 11:40:41 +0200 | [diff] [blame] | 125 | LINUX_DEFCONFIG_COMMON_FILES += $(CURDIR)/kconfigs/fvp_trusted-services_uefi.conf |
Balint Dobszay | c3d3412 | 2022-05-30 13:28:06 +0200 | [diff] [blame] | 126 | endif |
Balint Dobszay | c0b8fdf | 2022-06-02 14:41:54 +0200 | [diff] [blame] | 127 | |
| 128 | ################################################################################ |
| 129 | # Trusted Services test applications |
| 130 | ################################################################################ |
| 131 | .PHONY: ffa-test-all ffa-test-all-clean ffa-test-all-realclean |
| 132 | all: ffa-test-all |
| 133 | |
| 134 | ffa-test-all-realclean: |
| 135 | rm -rf $(TS_INSTALL_PREFIX)/arm-linux |
| 136 | |
| 137 | ifneq ($(COMPILE_NS_USER),64) |
| 138 | $(error Trusted Services test apps only support AArch64) |
| 139 | endif |
| 140 | |
| 141 | # Helper macro to build and install Trusted Services test applications. |
| 142 | # Invokes CMake to configure, and make to build and install the apps. |
Gyorgy Szing | 0e2a1d9 | 2023-02-28 00:58:45 +0100 | [diff] [blame] | 143 | # |
| 144 | # Parameter list: |
| 145 | # 1 - SP deployment name (e.g. psa-api-test/internal-trusted-storage, |
| 146 | # ts-demo, etc.) |
Gabor Toth | 22d7063 | 2023-11-09 19:05:17 +0100 | [diff] [blame] | 147 | # 2 - Additional build flags |
Gyorgy Szing | 0e2a1d9 | 2023-02-28 00:58:45 +0100 | [diff] [blame] | 148 | |
Balint Dobszay | c0b8fdf | 2022-06-02 14:41:54 +0200 | [diff] [blame] | 149 | define build-ts-app |
| 150 | .PHONY: ffa-$1 |
| 151 | ffa-$1: |
| 152 | CROSS_COMPILE=$(subst $(CCACHE),,$(CROSS_COMPILE_NS_USER)) cmake -G"Unix Makefiles" \ |
| 153 | -S $(TS_PATH)/deployments/$1/arm-linux -B $(TS_BUILD_PATH)/$1 \ |
| 154 | -DCMAKE_INSTALL_PREFIX=$(TS_INSTALL_PREFIX) \ |
Gyorgy Szing | 27cd417 | 2023-02-28 01:10:34 +0100 | [diff] [blame] | 155 | -Dlibts_DIR=${TS_INSTALL_PREFIX}/arm-linux/lib/cmake/libts \ |
| 156 | -DCFG_FORCE_PREBUILT_LIBTS=On \ |
Gabor Toth | d014819 | 2024-03-05 11:38:58 +0100 | [diff] [blame] | 157 | -Dlibpsats_DIR=${TS_INSTALL_PREFIX}/arm-linux/lib/cmake/libpsats \ |
| 158 | -DCFG_FORCE_PREBUILT_LIBPSATS=On \ |
Gabor Toth | 22d7063 | 2023-11-09 19:05:17 +0100 | [diff] [blame] | 159 | -DCMAKE_C_COMPILER_LAUNCHER=$(CCACHE) $(TS_APP_COMMON_FLAGS) $2 |
Balint Dobszay | c0b8fdf | 2022-06-02 14:41:54 +0200 | [diff] [blame] | 160 | $$(MAKE) -C $(TS_BUILD_PATH)/$1 install |
| 161 | |
Gyorgy Szing | 27cd417 | 2023-02-28 01:10:34 +0100 | [diff] [blame] | 162 | ifneq ($1,libts) |
Gabor Toth | d014819 | 2024-03-05 11:38:58 +0100 | [diff] [blame] | 163 | |
| 164 | ifeq ($1,libpsats) |
| 165 | ffa-libpsats: ffa-libts |
| 166 | else |
| 167 | ffa-$1: ffa-libpsats |
| 168 | endif |
| 169 | |
Gyorgy Szing | 27cd417 | 2023-02-28 01:10:34 +0100 | [diff] [blame] | 170 | endif |
| 171 | |
Balint Dobszay | c0b8fdf | 2022-06-02 14:41:54 +0200 | [diff] [blame] | 172 | .PHONY: ffa-$1-clean |
| 173 | ffa-$1-clean: |
Gyorgy Szing | a72ab36 | 2023-09-19 18:36:14 +0000 | [diff] [blame] | 174 | - $$(MAKE) -C $(TS_BUILD_PATH)/$1 clean |
Balint Dobszay | c0b8fdf | 2022-06-02 14:41:54 +0200 | [diff] [blame] | 175 | |
| 176 | .PHONY: ffa-$1-realclean |
| 177 | ffa-$1-realclean: |
| 178 | rm -rf $(TS_BUILD_PATH)/$1 |
| 179 | |
| 180 | ffa-test-all: ffa-$1 |
| 181 | ffa-test-all-clean: ffa-$1-clean |
| 182 | ffa-test-all-realclean: ffa-$1-realclean |
| 183 | endef |
Gyorgy Szing | 46fa5a4 | 2023-04-05 07:56:30 +0000 | [diff] [blame] | 184 | |
| 185 | ################################################################################ |
| 186 | # Trusted Services hot applications |
| 187 | ################################################################################ |
| 188 | .PHONY: ts-host-all ts-host-all-clean ts-host-all-realclean |
| 189 | all: ts-host-all |
| 190 | |
| 191 | ts-host-all-realclean: |
| 192 | rm -rf $(TS_INSTALL_PREFIX)/linux-pc |
| 193 | |
| 194 | # Helper macro to build and install Trusted Services applications which |
| 195 | # run on the host. |
| 196 | # Invokes CMake to configure, and make to build and install the apps. |
| 197 | # |
| 198 | # Parameter list: |
| 199 | # 1 - deployment name (e.g. fwu-app ) |
Gabor Toth | 22d7063 | 2023-11-09 19:05:17 +0100 | [diff] [blame] | 200 | # 2 - Additional build flags |
Gyorgy Szing | 46fa5a4 | 2023-04-05 07:56:30 +0000 | [diff] [blame] | 201 | |
| 202 | define build-ts-host-app |
| 203 | .PHONY: ts-host-$1 |
| 204 | $(if $1, ,$(error build-ts-host-app: missing deployment name argument)) |
| 205 | |
Gyorgy Szing | 46fa5a4 | 2023-04-05 07:56:30 +0000 | [diff] [blame] | 206 | ts-host-$1: |
| 207 | cmake -G"Unix Makefiles" \ |
| 208 | -S $(TS_PATH)/deployments/$1/linux-pc -B $(TS_BUILD_PATH)/$1 \ |
| 209 | -DCMAKE_INSTALL_PREFIX=$(TS_INSTALL_PREFIX) \ |
Gabor Toth | 22d7063 | 2023-11-09 19:05:17 +0100 | [diff] [blame] | 210 | -DCMAKE_C_COMPILER_LAUNCHER=$(CCACHE) \ |
| 211 | $(TS_HOST_COMMON_FLAGS) $2 |
Gyorgy Szing | 46fa5a4 | 2023-04-05 07:56:30 +0000 | [diff] [blame] | 212 | $$(MAKE) -C $(TS_BUILD_PATH)/$1 install |
| 213 | |
| 214 | .PHONY: ts-host-$1-clean |
| 215 | ts-host-$1-clean: |
| 216 | $$(MAKE) -C $(TS_BUILD_PATH)/$1 clean |
| 217 | |
| 218 | .PHONY: ts-host-$1-realclean |
| 219 | ts-host-$1-realclean: |
| 220 | rm -rf $(TS_BUILD_PATH)/$1 |
| 221 | |
| 222 | ts-host-all: ts-host-$1 |
| 223 | ts-host-all-clean: ts-host-$1-clean |
| 224 | ts-host-all-realclean: ts-host-$1-realclean |
| 225 | |
| 226 | endef |