blob: 7ce15e39cdc349a47b207e7f896ff858759b98a3 [file] [log] [blame]
Raef Colesabfe81a2020-07-10 09:52:34 +01001#-------------------------------------------------------------------------------
Ken Liu55ba01f2021-01-20 17:34:50 +08002# Copyright (c) 2020-2021, Arm Limited. All rights reserved.
Raef Colesabfe81a2020-07-10 09:52:34 +01003#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6#-------------------------------------------------------------------------------
7
Raef Coles69817322020-10-19 14:14:14 +01008cmake_minimum_required(VERSION 3.15)
Raef Colesabfe81a2020-07-10 09:52:34 +01009
10add_library(tfm_spm STATIC)
11add_library(tfm_boot_status INTERFACE)
12add_library(tfm_arch INTERFACE)
13add_library(tfm_utilities INTERFACE)
14
15set(TFM_PARTITION_PLATFORM ON CACHE BOOL "Enable the TF-M Platform partition")
16
David Huf1841af2021-09-02 12:50:45 +080017# Generate TF-M version
18configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/tfm_version.h.in
19 ${CMAKE_BINARY_DIR}/generated/secure_fw/spm/include/tfm_version.h)
20
Raef Colesabfe81a2020-07-10 09:52:34 +010021target_include_directories(tfm_spm
22 PUBLIC
23 ${CMAKE_CURRENT_SOURCE_DIR}
24 ${CMAKE_CURRENT_SOURCE_DIR}/include
25 $<$<BOOL:${TFM_PSA_API}>:${CMAKE_CURRENT_SOURCE_DIR}/cmsis_psa>
26 $<$<BOOL:${TFM_PSA_API}>:${CMAKE_CURRENT_SOURCE_DIR}/cmsis_psa/include>
27 $<$<NOT:$<BOOL:${TFM_PSA_API}>>:${CMAKE_CURRENT_SOURCE_DIR}/cmsis_func>
28 $<$<NOT:$<BOOL:${TFM_PSA_API}>>:${CMAKE_CURRENT_SOURCE_DIR}/cmsis_func/include>
29 PRIVATE
30 ${CMAKE_SOURCE_DIR}
Ken Liue6f31e52021-08-16 13:42:25 +080031 ${CMAKE_SOURCE_DIR}/secure_fw/include
Raef Colesabfe81a2020-07-10 09:52:34 +010032 ${CMAKE_BINARY_DIR}/generated
David Huf1841af2021-09-02 12:50:45 +080033 ${CMAKE_BINARY_DIR}/generated/secure_fw/spm/include
Raef Colesabfe81a2020-07-10 09:52:34 +010034 $<$<BOOL:${TFM_PSA_API}>:${CMAKE_BINARY_DIR}/generated/secure_fw/spm/cmsis_psa>
35 $<$<NOT:$<BOOL:${TFM_PSA_API}>>:${CMAKE_BINARY_DIR}/generated/secure_fw/spm/cmsis_func>
36)
37
38target_sources(tfm_spm
39 PRIVATE
Ken Liu55ba01f2021-01-20 17:34:50 +080040 ffm/tfm_boot_data.c
41 ffm/tfm_core_utils.c
42 ffm/utilities.c
Øyvind Rønningstadf2c8dad2021-01-15 15:33:33 +010043 $<$<BOOL:${TFM_EXCEPTION_INFO_DUMP}>:cmsis_psa/exception_info.c>
Shawn Shan90f102f2021-02-19 10:45:07 +080044 $<$<NOT:$<STREQUAL:${TFM_SPM_LOG_LEVEL},TFM_SPM_LOG_LEVEL_SILENCE>>:ffm/spm_log.c>
Raef Colesabfe81a2020-07-10 09:52:34 +010045 $<$<BOOL:${TFM_MULTI_CORE_TOPOLOGY}>:cmsis_psa/tfm_multi_core.c>
46 $<$<BOOL:${TFM_MULTI_CORE_TOPOLOGY}>:cmsis_psa/tfm_multi_core_mem_check.c>
47 $<$<BOOL:${TFM_MULTI_CORE_TOPOLOGY}>:cmsis_psa/tfm_rpc.c>
Mark Horvathdadc1ea2021-03-12 15:39:25 +010048 $<$<AND:$<BOOL:${TFM_MULTI_CORE_TOPOLOGY}>,$<NOT:$<BOOL:${TFM_PLAT_SPECIFIC_MULTI_CORE_COMM}>>>:cmsis_psa/tfm_spe_mailbox.c>
Ken Liu55ba01f2021-01-20 17:34:50 +080049 $<$<NOT:$<BOOL:${TFM_PSA_API}>>:ffm/tfm_core_mem_check.c>
Raef Colesabfe81a2020-07-10 09:52:34 +010050 $<$<BOOL:${TFM_PSA_API}>:cmsis_psa/arch/tfm_arch.c>
51 $<$<BOOL:${TFM_PSA_API}>:cmsis_psa/main.c>
52 $<$<BOOL:${TFM_PSA_API}>:cmsis_psa/spm_ipc.c>
Ken Liuacd2a572021-05-12 16:19:04 +080053 $<$<BOOL:${TFM_PSA_API}>:cmsis_psa/static_load.c>
Mingyang Sun133a7922021-07-08 16:01:26 +080054 $<$<BOOL:${TFM_PSA_API}>:ffm/psa_api.c>
Raef Colesabfe81a2020-07-10 09:52:34 +010055 $<$<BOOL:${TFM_PSA_API}>:cmsis_psa/tfm_core_svcalls_ipc.c>
56 $<$<AND:$<BOOL:${TFM_PSA_API}>,$<NOT:$<BOOL:${TFM_MULTI_CORE_TOPOLOGY}>>>:cmsis_psa/tfm_nspm_ipc.c>
57 $<$<BOOL:${TFM_PSA_API}>:cmsis_psa/tfm_pools.c>
58 $<$<BOOL:${TFM_PSA_API}>:cmsis_psa/tfm_thread.c>
59 $<$<BOOL:${TFM_PSA_API}>:cmsis_psa/tfm_wait.c>
60 $<$<NOT:$<BOOL:${TFM_PSA_API}>>:cmsis_func/main.c>
61 $<$<NOT:$<BOOL:${TFM_PSA_API}>>:cmsis_func/arch.c>
62 $<$<NOT:$<BOOL:${TFM_PSA_API}>>:cmsis_func/spm_func.c>
63 $<$<NOT:$<BOOL:${TFM_PSA_API}>>:cmsis_func/tfm_core_svcalls_func.c>
64 $<$<NOT:$<BOOL:${TFM_PSA_API}>>:cmsis_func/tfm_nspm_func.c>
65 $<$<NOT:$<BOOL:${TFM_PSA_API}>>:cmsis_func/tfm_secure_api.c>
66 #TODO add other arches
Raef Coles600a4632020-10-15 16:42:35 +010067 $<$<AND:$<BOOL:${TFM_PSA_API}>,$<STREQUAL:${CMAKE_SYSTEM_ARCHITECTURE},armv8.1-m.main>>:cmsis_psa/arch/tfm_arch_v8m_main.c>
Raef Colesabfe81a2020-07-10 09:52:34 +010068 $<$<AND:$<BOOL:${TFM_PSA_API}>,$<STREQUAL:${CMAKE_SYSTEM_ARCHITECTURE},armv8-m.base>>:cmsis_psa/arch/tfm_arch_v8m_base.c>
69 $<$<AND:$<BOOL:${TFM_PSA_API}>,$<STREQUAL:${CMAKE_SYSTEM_ARCHITECTURE},armv8-m.main>>:cmsis_psa/arch/tfm_arch_v8m_main.c>
70 $<$<AND:$<BOOL:${TFM_PSA_API}>,$<STREQUAL:${CMAKE_SYSTEM_ARCHITECTURE},armv6-m>>:cmsis_psa/arch/tfm_arch_v6m_v7m.c>
71 $<$<AND:$<BOOL:${TFM_PSA_API}>,$<STREQUAL:${CMAKE_SYSTEM_ARCHITECTURE},armv7-m>>:cmsis_psa/arch/tfm_arch_v6m_v7m.c>
72)
73
Ken Liuea45b0d2021-05-22 17:41:25 +080074target_include_directories(tfm_partitions INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/cmsis_psa)
75
Mingyang Sund20999f2020-10-15 14:53:12 +080076#workaround for arch-test
77if (TEST_PSA_API STREQUAL IPC)
Mingyang Sunca27cf02021-05-11 11:02:50 +080078 target_include_directories(tfm_partitions INTERFACE ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests)
Shawn Shan781ef732021-03-10 14:05:57 +080079 target_sources(tfm_psa_rot_partition_driver_partition PRIVATE
Mingyang Sund20999f2020-10-15 14:53:12 +080080 ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/intermedia_driver_partition_psa.c)
Shawn Shan781ef732021-03-10 14:05:57 +080081 target_sources(tfm_app_rot_partition_client_partition PRIVATE
Mingyang Sund20999f2020-10-15 14:53:12 +080082 ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/intermedia_client_partition_psa.c)
Shawn Shan781ef732021-03-10 14:05:57 +080083 target_sources(tfm_app_rot_partition_server_partition PRIVATE
Mingyang Sund20999f2020-10-15 14:53:12 +080084 ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/intermedia_server_partition_psa.c)
Mingyang Sunca27cf02021-05-11 11:02:50 +080085 target_sources(tfm_partitions INTERFACE
Ken Liu4520ce32021-05-11 22:49:10 +080086 ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/load_info_driver_partition_psa.c
87 ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/load_info_client_partition_psa.c
88 ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/load_info_server_partition_psa.c
Mingyang Sunca27cf02021-05-11 11:02:50 +080089 )
Mingyang Sund20999f2020-10-15 14:53:12 +080090endif()
91
Raef Colesabfe81a2020-07-10 09:52:34 +010092target_link_libraries(tfm_spm
93 PUBLIC
94 tfm_arch
95 PRIVATE
96 psa_interface
97 platform_s
98 tfm_boot_status
99 tfm_secure_api
100 tfm_partitions
Shawn Shan781ef732021-03-10 14:05:57 +0800101 $<$<STREQUAL:${TEST_PSA_API},IPC>:tfm_psa_rot_partition_driver_partition>
102 $<$<STREQUAL:${TEST_PSA_API},IPC>:tfm_app_rot_partition_client_partition>
103 $<$<STREQUAL:${TEST_PSA_API},IPC>:tfm_app_rot_partition_server_partition>
David Huf07e97d2021-02-15 22:05:40 +0800104 tfm_fih
Kevin Peng498c45b2021-08-31 17:57:15 +0800105 tfm_sprt
Raef Colesabfe81a2020-07-10 09:52:34 +0100106)
107
108target_compile_definitions(tfm_spm
109 PRIVATE
110 $<$<CONFIG:Debug>:TFM_CORE_DEBUG>
111 $<$<AND:$<BOOL:${BL2}>,$<BOOL:${MCUBOOT_MEASURED_BOOT}>>:BOOT_DATA_AVAILABLE>
Øyvind Rønningstadf2c8dad2021-01-15 15:33:33 +0100112 $<$<BOOL:${TFM_EXCEPTION_INFO_DUMP}>:TFM_EXCEPTION_INFO_DUMP>
Raef Colesabfe81a2020-07-10 09:52:34 +0100113)
114
115# With constant optimizations on tfm_nspc_func emits a symbol that the linker
116# doesn't like. It's unclear why this is, so I'll put a TODO here, but for the
117# moment this fixes it with mimimal impact.
118set_source_files_properties(tfm_nspm_func.c
119 PROPERTIES
120 COMPILE_FLAGS -fno-ipa-cp
121)
122
123# The veneers give warnings about not being properly declared so they get hidden
124# to not overshadow _real_ warnings.
125set_source_files_properties(tfm_secure_api.c
126 PROPERTIES
127 COMPILE_FLAGS -Wno-implicit-function-declaration
128)
129
Raef Colesd8f67502020-10-13 10:45:33 +0100130############################ Partition Defs ####################################
131
132target_compile_definitions(tfm_partition_defs
133 INTERFACE
134 $<$<STREQUAL:${TEST_PSA_API},IPC>:PSA_API_TEST_IPC>
135)
136
Raef Colesabfe81a2020-07-10 09:52:34 +0100137############################ TFM arch ##########################################
138
139target_include_directories(tfm_arch
140 INTERFACE
141 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/cmsis_psa/arch>
142)
143
144############################ Boot Status #######################################
145
146target_include_directories(tfm_boot_status
147 INTERFACE
148 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
149)
150
151############################ TFM utilities #####################################
152
153target_include_directories(tfm_utilities
154 INTERFACE
155 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
156)
157
158############################ Secure API ########################################
159
160target_link_libraries(tfm_secure_api
Summer Qin5a212ec2020-11-19 15:48:57 +0800161 INTERFACE
Raef Colesabfe81a2020-07-10 09:52:34 +0100162 tfm_partitions
163)
164
165target_include_directories(tfm_secure_api
Summer Qin5a212ec2020-11-19 15:48:57 +0800166 INTERFACE
Raef Colesabfe81a2020-07-10 09:52:34 +0100167 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
Kevin Pengfc7b7712021-05-08 13:42:56 +0800168 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/interface>
169 $<$<NOT:$<BOOL:${TFM_PSA_API}>>:${CMAKE_CURRENT_SOURCE_DIR}/cmsis_func/include>
Raef Colesabfe81a2020-07-10 09:52:34 +0100170 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/arch/include>
171)
172
173############################# Secure veneers ###################################
174
175if(NOT TFM_MULTI_CORE_TOPOLOGY)
176 # If this is added to the spm, it is discarded as it is not used. Since the
177 # spm is a static library it can't generate veneers under all compilers so
178 # instead this single file is added to the tfm_s target.
179 target_sources(tfm_s
180 PRIVATE
181 $<$<NOT:$<BOOL:${TFM_PSA_API}>>:${CMAKE_BINARY_DIR}/generated/secure_fw/spm/cmsis_func/tfm_veneers.c>
182 $<$<BOOL:${TFM_PSA_API}>:${CMAKE_CURRENT_SOURCE_DIR}/cmsis_psa/tfm_psa_api_veneers.c>
183 )
184endif()