blob: 8831f4028c6409e83379d203a2d7568fcf4d9eda [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>
Mingyang Sundeae45d2021-09-06 15:31:07 +080055 $<$<BOOL:${TFM_PSA_API}>:ffm/backend_ipc.c>
Raef Colesabfe81a2020-07-10 09:52:34 +010056 $<$<BOOL:${TFM_PSA_API}>:cmsis_psa/tfm_core_svcalls_ipc.c>
57 $<$<AND:$<BOOL:${TFM_PSA_API}>,$<NOT:$<BOOL:${TFM_MULTI_CORE_TOPOLOGY}>>>:cmsis_psa/tfm_nspm_ipc.c>
58 $<$<BOOL:${TFM_PSA_API}>:cmsis_psa/tfm_pools.c>
Ken Liu5d73c872021-08-19 19:23:17 +080059 $<$<BOOL:${TFM_PSA_API}>:cmsis_psa/thread.c>
Raef Colesabfe81a2020-07-10 09:52:34 +010060 $<$<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>
Sherry Zhnag482b88b2021-08-19 17:51:47 +080065 $<$<AND:$<NOT:$<BOOL:${TFM_MULTI_CORE_TOPOLOGY}>>,$<BOOL:${TFM_NS_MANAGE_NSID}>>:ns_client_ext/tfm_ns_ctx.c>
66 $<$<NOT:$<BOOL:${TFM_MULTI_CORE_TOPOLOGY}>>:ns_client_ext/tfm_spm_ns_ctx.c>
Raef Colesabfe81a2020-07-10 09:52:34 +010067 $<$<NOT:$<BOOL:${TFM_PSA_API}>>:cmsis_func/tfm_secure_api.c>
68 #TODO add other arches
Raef Coles600a4632020-10-15 16:42:35 +010069 $<$<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 +010070 $<$<AND:$<BOOL:${TFM_PSA_API}>,$<STREQUAL:${CMAKE_SYSTEM_ARCHITECTURE},armv8-m.base>>:cmsis_psa/arch/tfm_arch_v8m_base.c>
71 $<$<AND:$<BOOL:${TFM_PSA_API}>,$<STREQUAL:${CMAKE_SYSTEM_ARCHITECTURE},armv8-m.main>>:cmsis_psa/arch/tfm_arch_v8m_main.c>
72 $<$<AND:$<BOOL:${TFM_PSA_API}>,$<STREQUAL:${CMAKE_SYSTEM_ARCHITECTURE},armv6-m>>:cmsis_psa/arch/tfm_arch_v6m_v7m.c>
73 $<$<AND:$<BOOL:${TFM_PSA_API}>,$<STREQUAL:${CMAKE_SYSTEM_ARCHITECTURE},armv7-m>>:cmsis_psa/arch/tfm_arch_v6m_v7m.c>
74)
75
Ken Liuea45b0d2021-05-22 17:41:25 +080076target_include_directories(tfm_partitions INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/cmsis_psa)
77
Mingyang Sund20999f2020-10-15 14:53:12 +080078#workaround for arch-test
79if (TEST_PSA_API STREQUAL IPC)
Mingyang Sunca27cf02021-05-11 11:02:50 +080080 target_include_directories(tfm_partitions INTERFACE ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests)
Shawn Shan781ef732021-03-10 14:05:57 +080081 target_sources(tfm_psa_rot_partition_driver_partition PRIVATE
Mingyang Sund20999f2020-10-15 14:53:12 +080082 ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/intermedia_driver_partition_psa.c)
Ken Liubd9a19b2021-10-21 16:22:39 +080083 target_compile_definitions(tfm_psa_rot_partition_driver_partition PRIVATE CONFIG_TFM_BUILDING_SPE=1)
Shawn Shan781ef732021-03-10 14:05:57 +080084 target_sources(tfm_app_rot_partition_client_partition PRIVATE
Mingyang Sund20999f2020-10-15 14:53:12 +080085 ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/intermedia_client_partition_psa.c)
Ken Liubd9a19b2021-10-21 16:22:39 +080086 target_compile_definitions(tfm_app_rot_partition_client_partition PRIVATE CONFIG_TFM_BUILDING_SPE=1)
Shawn Shan781ef732021-03-10 14:05:57 +080087 target_sources(tfm_app_rot_partition_server_partition PRIVATE
Mingyang Sund20999f2020-10-15 14:53:12 +080088 ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/intermedia_server_partition_psa.c)
Ken Liubd9a19b2021-10-21 16:22:39 +080089 target_compile_definitions(tfm_app_rot_partition_server_partition PRIVATE CONFIG_TFM_BUILDING_SPE=1)
Mingyang Sunca27cf02021-05-11 11:02:50 +080090 target_sources(tfm_partitions INTERFACE
Ken Liu4520ce32021-05-11 22:49:10 +080091 ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/load_info_driver_partition_psa.c
92 ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/load_info_client_partition_psa.c
93 ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/load_info_server_partition_psa.c
Mingyang Sunca27cf02021-05-11 11:02:50 +080094 )
Mingyang Sund20999f2020-10-15 14:53:12 +080095endif()
96
Raef Colesabfe81a2020-07-10 09:52:34 +010097target_link_libraries(tfm_spm
98 PUBLIC
99 tfm_arch
100 PRIVATE
101 psa_interface
102 platform_s
103 tfm_boot_status
104 tfm_secure_api
105 tfm_partitions
Shawn Shan781ef732021-03-10 14:05:57 +0800106 $<$<STREQUAL:${TEST_PSA_API},IPC>:tfm_psa_rot_partition_driver_partition>
107 $<$<STREQUAL:${TEST_PSA_API},IPC>:tfm_app_rot_partition_client_partition>
108 $<$<STREQUAL:${TEST_PSA_API},IPC>:tfm_app_rot_partition_server_partition>
David Huf07e97d2021-02-15 22:05:40 +0800109 tfm_fih
Kevin Peng498c45b2021-08-31 17:57:15 +0800110 tfm_sprt
Raef Colesabfe81a2020-07-10 09:52:34 +0100111)
112
113target_compile_definitions(tfm_spm
114 PRIVATE
115 $<$<CONFIG:Debug>:TFM_CORE_DEBUG>
116 $<$<AND:$<BOOL:${BL2}>,$<BOOL:${MCUBOOT_MEASURED_BOOT}>>:BOOT_DATA_AVAILABLE>
Øyvind Rønningstadf2c8dad2021-01-15 15:33:33 +0100117 $<$<BOOL:${TFM_EXCEPTION_INFO_DUMP}>:TFM_EXCEPTION_INFO_DUMP>
Sherry Zhnag482b88b2021-08-19 17:51:47 +0800118 $<$<BOOL:${TFM_NS_MANAGE_NSID}>:TFM_NS_MANAGE_NSID>
Raef Colesabfe81a2020-07-10 09:52:34 +0100119)
120
121# The veneers give warnings about not being properly declared so they get hidden
122# to not overshadow _real_ warnings.
123set_source_files_properties(tfm_secure_api.c
124 PROPERTIES
TTornblom611dba12021-09-30 12:09:38 +0200125 COMPILE_FLAGS
126 $<$<C_COMPILER_ID:ARMClang>:-Wno-implicit-function-declaration>
127 $<$<C_COMPILER_ID:GNU>:-Wno-implicit-function-declaration>
128 $<$<C_COMPILER_ID:IAR>:>
Raef Colesabfe81a2020-07-10 09:52:34 +0100129)
130
Raef Colesd8f67502020-10-13 10:45:33 +0100131############################ Partition Defs ####################################
132
133target_compile_definitions(tfm_partition_defs
134 INTERFACE
135 $<$<STREQUAL:${TEST_PSA_API},IPC>:PSA_API_TEST_IPC>
136)
137
Raef Colesabfe81a2020-07-10 09:52:34 +0100138############################ TFM arch ##########################################
139
140target_include_directories(tfm_arch
141 INTERFACE
142 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/cmsis_psa/arch>
143)
144
145############################ Boot Status #######################################
146
147target_include_directories(tfm_boot_status
148 INTERFACE
149 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
150)
151
152############################ TFM utilities #####################################
153
154target_include_directories(tfm_utilities
155 INTERFACE
156 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
157)
158
159############################ Secure API ########################################
160
161target_link_libraries(tfm_secure_api
Summer Qin5a212ec2020-11-19 15:48:57 +0800162 INTERFACE
Raef Colesabfe81a2020-07-10 09:52:34 +0100163 tfm_partitions
164)
165
166target_include_directories(tfm_secure_api
Summer Qin5a212ec2020-11-19 15:48:57 +0800167 INTERFACE
Raef Colesabfe81a2020-07-10 09:52:34 +0100168 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
Kevin Pengfc7b7712021-05-08 13:42:56 +0800169 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/interface>
170 $<$<NOT:$<BOOL:${TFM_PSA_API}>>:${CMAKE_CURRENT_SOURCE_DIR}/cmsis_func/include>
Raef Colesabfe81a2020-07-10 09:52:34 +0100171 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/arch/include>
172)
173
174############################# Secure veneers ###################################
175
176if(NOT TFM_MULTI_CORE_TOPOLOGY)
177 # If this is added to the spm, it is discarded as it is not used. Since the
178 # spm is a static library it can't generate veneers under all compilers so
179 # instead this single file is added to the tfm_s target.
180 target_sources(tfm_s
181 PRIVATE
182 $<$<NOT:$<BOOL:${TFM_PSA_API}>>:${CMAKE_BINARY_DIR}/generated/secure_fw/spm/cmsis_func/tfm_veneers.c>
183 $<$<BOOL:${TFM_PSA_API}>:${CMAKE_CURRENT_SOURCE_DIR}/cmsis_psa/tfm_psa_api_veneers.c>
Sherry Zhnag482b88b2021-08-19 17:51:47 +0800184 $<$<BOOL:${TFM_NS_MANAGE_NSID}>:${CMAKE_CURRENT_SOURCE_DIR}/ns_client_ext/tfm_ns_client_ext.c>
Raef Colesabfe81a2020-07-10 09:52:34 +0100185 )
186endif()