blob: f4a98cf3dbfef08fa3fd1b0a79aac3e0b41d73b8 [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 Liue07c3b72021-10-14 16:19:13 +080053 $<$<BOOL:${TFM_PSA_API}>:cmsis_psa/spm_thread_call.c>
Ken Liuacd2a572021-05-12 16:19:04 +080054 $<$<BOOL:${TFM_PSA_API}>:cmsis_psa/static_load.c>
Mingyang Sun133a7922021-07-08 16:01:26 +080055 $<$<BOOL:${TFM_PSA_API}>:ffm/psa_api.c>
Mingyang Sundeae45d2021-09-06 15:31:07 +080056 $<$<BOOL:${TFM_PSA_API}>:ffm/backend_ipc.c>
Raef Colesabfe81a2020-07-10 09:52:34 +010057 $<$<BOOL:${TFM_PSA_API}>:cmsis_psa/tfm_core_svcalls_ipc.c>
58 $<$<AND:$<BOOL:${TFM_PSA_API}>,$<NOT:$<BOOL:${TFM_MULTI_CORE_TOPOLOGY}>>>:cmsis_psa/tfm_nspm_ipc.c>
59 $<$<BOOL:${TFM_PSA_API}>:cmsis_psa/tfm_pools.c>
Ken Liu5d73c872021-08-19 19:23:17 +080060 $<$<BOOL:${TFM_PSA_API}>:cmsis_psa/thread.c>
Raef Colesabfe81a2020-07-10 09:52:34 +010061 $<$<NOT:$<BOOL:${TFM_PSA_API}>>:cmsis_func/main.c>
62 $<$<NOT:$<BOOL:${TFM_PSA_API}>>:cmsis_func/arch.c>
63 $<$<NOT:$<BOOL:${TFM_PSA_API}>>:cmsis_func/spm_func.c>
64 $<$<NOT:$<BOOL:${TFM_PSA_API}>>:cmsis_func/tfm_core_svcalls_func.c>
65 $<$<NOT:$<BOOL:${TFM_PSA_API}>>:cmsis_func/tfm_nspm_func.c>
Sherry Zhnag482b88b2021-08-19 17:51:47 +080066 $<$<AND:$<NOT:$<BOOL:${TFM_MULTI_CORE_TOPOLOGY}>>,$<BOOL:${TFM_NS_MANAGE_NSID}>>:ns_client_ext/tfm_ns_ctx.c>
67 $<$<NOT:$<BOOL:${TFM_MULTI_CORE_TOPOLOGY}>>:ns_client_ext/tfm_spm_ns_ctx.c>
Raef Colesabfe81a2020-07-10 09:52:34 +010068 $<$<NOT:$<BOOL:${TFM_PSA_API}>>:cmsis_func/tfm_secure_api.c>
69 #TODO add other arches
Gabor Abonyi866571c2021-10-07 13:56:19 +020070 $<$<AND:$<BOOL:${TFM_PSA_API}>,$<STREQUAL:${TFM_SYSTEM_ARCHITECTURE},armv8.1-m.main>>:cmsis_psa/arch/tfm_arch_v8m_main.c>
71 $<$<AND:$<BOOL:${TFM_PSA_API}>,$<STREQUAL:${TFM_SYSTEM_ARCHITECTURE},armv8-m.base>>:cmsis_psa/arch/tfm_arch_v8m_base.c>
72 $<$<AND:$<BOOL:${TFM_PSA_API}>,$<STREQUAL:${TFM_SYSTEM_ARCHITECTURE},armv8-m.main>>:cmsis_psa/arch/tfm_arch_v8m_main.c>
73 $<$<AND:$<BOOL:${TFM_PSA_API}>,$<STREQUAL:${TFM_SYSTEM_ARCHITECTURE},armv6-m>>:cmsis_psa/arch/tfm_arch_v6m_v7m.c>
74 $<$<AND:$<BOOL:${TFM_PSA_API}>,$<STREQUAL:${TFM_SYSTEM_ARCHITECTURE},armv7-m>>:cmsis_psa/arch/tfm_arch_v6m_v7m.c>
Raef Colesabfe81a2020-07-10 09:52:34 +010075)
76
Ken Liuea45b0d2021-05-22 17:41:25 +080077target_include_directories(tfm_partitions INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/cmsis_psa)
78
Mingyang Sund20999f2020-10-15 14:53:12 +080079#workaround for arch-test
80if (TEST_PSA_API STREQUAL IPC)
Mingyang Sunca27cf02021-05-11 11:02:50 +080081 target_include_directories(tfm_partitions INTERFACE ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests)
Shawn Shan781ef732021-03-10 14:05:57 +080082 target_sources(tfm_psa_rot_partition_driver_partition PRIVATE
Mingyang Sund20999f2020-10-15 14:53:12 +080083 ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/intermedia_driver_partition_psa.c)
Ken Liubd9a19b2021-10-21 16:22:39 +080084 target_compile_definitions(tfm_psa_rot_partition_driver_partition PRIVATE CONFIG_TFM_BUILDING_SPE=1)
Shawn Shan781ef732021-03-10 14:05:57 +080085 target_sources(tfm_app_rot_partition_client_partition PRIVATE
Mingyang Sund20999f2020-10-15 14:53:12 +080086 ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/intermedia_client_partition_psa.c)
Ken Liubd9a19b2021-10-21 16:22:39 +080087 target_compile_definitions(tfm_app_rot_partition_client_partition PRIVATE CONFIG_TFM_BUILDING_SPE=1)
Shawn Shan781ef732021-03-10 14:05:57 +080088 target_sources(tfm_app_rot_partition_server_partition PRIVATE
Mingyang Sund20999f2020-10-15 14:53:12 +080089 ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/intermedia_server_partition_psa.c)
Ken Liubd9a19b2021-10-21 16:22:39 +080090 target_compile_definitions(tfm_app_rot_partition_server_partition PRIVATE CONFIG_TFM_BUILDING_SPE=1)
Mingyang Sunca27cf02021-05-11 11:02:50 +080091 target_sources(tfm_partitions INTERFACE
Ken Liu4520ce32021-05-11 22:49:10 +080092 ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/load_info_driver_partition_psa.c
93 ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/load_info_client_partition_psa.c
94 ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/load_info_server_partition_psa.c
Mingyang Sunca27cf02021-05-11 11:02:50 +080095 )
Mingyang Sund20999f2020-10-15 14:53:12 +080096endif()
97
Raef Colesabfe81a2020-07-10 09:52:34 +010098target_link_libraries(tfm_spm
99 PUBLIC
100 tfm_arch
101 PRIVATE
102 psa_interface
103 platform_s
104 tfm_boot_status
105 tfm_secure_api
106 tfm_partitions
Shawn Shan781ef732021-03-10 14:05:57 +0800107 $<$<STREQUAL:${TEST_PSA_API},IPC>:tfm_psa_rot_partition_driver_partition>
108 $<$<STREQUAL:${TEST_PSA_API},IPC>:tfm_app_rot_partition_client_partition>
109 $<$<STREQUAL:${TEST_PSA_API},IPC>:tfm_app_rot_partition_server_partition>
David Huf07e97d2021-02-15 22:05:40 +0800110 tfm_fih
Kevin Peng498c45b2021-08-31 17:57:15 +0800111 tfm_sprt
Raef Colesabfe81a2020-07-10 09:52:34 +0100112)
113
114target_compile_definitions(tfm_spm
115 PRIVATE
116 $<$<CONFIG:Debug>:TFM_CORE_DEBUG>
117 $<$<AND:$<BOOL:${BL2}>,$<BOOL:${MCUBOOT_MEASURED_BOOT}>>:BOOT_DATA_AVAILABLE>
Øyvind Rønningstadf2c8dad2021-01-15 15:33:33 +0100118 $<$<BOOL:${TFM_EXCEPTION_INFO_DUMP}>:TFM_EXCEPTION_INFO_DUMP>
Sherry Zhnag482b88b2021-08-19 17:51:47 +0800119 $<$<BOOL:${TFM_NS_MANAGE_NSID}>:TFM_NS_MANAGE_NSID>
Raef Colesabfe81a2020-07-10 09:52:34 +0100120)
121
122# The veneers give warnings about not being properly declared so they get hidden
123# to not overshadow _real_ warnings.
124set_source_files_properties(tfm_secure_api.c
125 PROPERTIES
TTornblom611dba12021-09-30 12:09:38 +0200126 COMPILE_FLAGS
127 $<$<C_COMPILER_ID:ARMClang>:-Wno-implicit-function-declaration>
128 $<$<C_COMPILER_ID:GNU>:-Wno-implicit-function-declaration>
129 $<$<C_COMPILER_ID:IAR>:>
Raef Colesabfe81a2020-07-10 09:52:34 +0100130)
131
Raef Colesd8f67502020-10-13 10:45:33 +0100132############################ Partition Defs ####################################
133
134target_compile_definitions(tfm_partition_defs
135 INTERFACE
136 $<$<STREQUAL:${TEST_PSA_API},IPC>:PSA_API_TEST_IPC>
137)
138
Raef Colesabfe81a2020-07-10 09:52:34 +0100139############################ TFM arch ##########################################
140
141target_include_directories(tfm_arch
142 INTERFACE
143 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/cmsis_psa/arch>
144)
145
146############################ Boot Status #######################################
147
148target_include_directories(tfm_boot_status
149 INTERFACE
150 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
151)
152
153############################ TFM utilities #####################################
154
155target_include_directories(tfm_utilities
156 INTERFACE
157 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
158)
159
160############################ Secure API ########################################
161
162target_link_libraries(tfm_secure_api
Summer Qin5a212ec2020-11-19 15:48:57 +0800163 INTERFACE
Raef Colesabfe81a2020-07-10 09:52:34 +0100164 tfm_partitions
165)
166
167target_include_directories(tfm_secure_api
Summer Qin5a212ec2020-11-19 15:48:57 +0800168 INTERFACE
Raef Colesabfe81a2020-07-10 09:52:34 +0100169 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
Kevin Pengfc7b7712021-05-08 13:42:56 +0800170 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/interface>
171 $<$<NOT:$<BOOL:${TFM_PSA_API}>>:${CMAKE_CURRENT_SOURCE_DIR}/cmsis_func/include>
Raef Colesabfe81a2020-07-10 09:52:34 +0100172 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/arch/include>
173)
174
175############################# Secure veneers ###################################
176
177if(NOT TFM_MULTI_CORE_TOPOLOGY)
178 # If this is added to the spm, it is discarded as it is not used. Since the
179 # spm is a static library it can't generate veneers under all compilers so
180 # instead this single file is added to the tfm_s target.
181 target_sources(tfm_s
182 PRIVATE
183 $<$<NOT:$<BOOL:${TFM_PSA_API}>>:${CMAKE_BINARY_DIR}/generated/secure_fw/spm/cmsis_func/tfm_veneers.c>
184 $<$<BOOL:${TFM_PSA_API}>:${CMAKE_CURRENT_SOURCE_DIR}/cmsis_psa/tfm_psa_api_veneers.c>
Sherry Zhnag482b88b2021-08-19 17:51:47 +0800185 $<$<BOOL:${TFM_NS_MANAGE_NSID}>:${CMAKE_CURRENT_SOURCE_DIR}/ns_client_ext/tfm_ns_client_ext.c>
Raef Colesabfe81a2020-07-10 09:52:34 +0100186 )
187endif()