blob: 443279f034ad468f3f878e4bd4de62b24045e565 [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>
Ken Liu5d73c872021-08-19 19:23:17 +080058 $<$<BOOL:${TFM_PSA_API}>:cmsis_psa/thread.c>
Raef Colesabfe81a2020-07-10 09:52:34 +010059 $<$<NOT:$<BOOL:${TFM_PSA_API}>>:cmsis_func/main.c>
60 $<$<NOT:$<BOOL:${TFM_PSA_API}>>:cmsis_func/arch.c>
61 $<$<NOT:$<BOOL:${TFM_PSA_API}>>:cmsis_func/spm_func.c>
62 $<$<NOT:$<BOOL:${TFM_PSA_API}>>:cmsis_func/tfm_core_svcalls_func.c>
63 $<$<NOT:$<BOOL:${TFM_PSA_API}>>:cmsis_func/tfm_nspm_func.c>
64 $<$<NOT:$<BOOL:${TFM_PSA_API}>>:cmsis_func/tfm_secure_api.c>
65 #TODO add other arches
Raef Coles600a4632020-10-15 16:42:35 +010066 $<$<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 +010067 $<$<AND:$<BOOL:${TFM_PSA_API}>,$<STREQUAL:${CMAKE_SYSTEM_ARCHITECTURE},armv8-m.base>>:cmsis_psa/arch/tfm_arch_v8m_base.c>
68 $<$<AND:$<BOOL:${TFM_PSA_API}>,$<STREQUAL:${CMAKE_SYSTEM_ARCHITECTURE},armv8-m.main>>:cmsis_psa/arch/tfm_arch_v8m_main.c>
69 $<$<AND:$<BOOL:${TFM_PSA_API}>,$<STREQUAL:${CMAKE_SYSTEM_ARCHITECTURE},armv6-m>>:cmsis_psa/arch/tfm_arch_v6m_v7m.c>
70 $<$<AND:$<BOOL:${TFM_PSA_API}>,$<STREQUAL:${CMAKE_SYSTEM_ARCHITECTURE},armv7-m>>:cmsis_psa/arch/tfm_arch_v6m_v7m.c>
71)
72
Ken Liuea45b0d2021-05-22 17:41:25 +080073target_include_directories(tfm_partitions INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/cmsis_psa)
74
Mingyang Sund20999f2020-10-15 14:53:12 +080075#workaround for arch-test
76if (TEST_PSA_API STREQUAL IPC)
Mingyang Sunca27cf02021-05-11 11:02:50 +080077 target_include_directories(tfm_partitions INTERFACE ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests)
Shawn Shan781ef732021-03-10 14:05:57 +080078 target_sources(tfm_psa_rot_partition_driver_partition PRIVATE
Mingyang Sund20999f2020-10-15 14:53:12 +080079 ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/intermedia_driver_partition_psa.c)
Shawn Shan781ef732021-03-10 14:05:57 +080080 target_sources(tfm_app_rot_partition_client_partition PRIVATE
Mingyang Sund20999f2020-10-15 14:53:12 +080081 ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/intermedia_client_partition_psa.c)
Shawn Shan781ef732021-03-10 14:05:57 +080082 target_sources(tfm_app_rot_partition_server_partition PRIVATE
Mingyang Sund20999f2020-10-15 14:53:12 +080083 ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/intermedia_server_partition_psa.c)
Mingyang Sunca27cf02021-05-11 11:02:50 +080084 target_sources(tfm_partitions INTERFACE
Ken Liu4520ce32021-05-11 22:49:10 +080085 ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/load_info_driver_partition_psa.c
86 ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/load_info_client_partition_psa.c
87 ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/load_info_server_partition_psa.c
Mingyang Sunca27cf02021-05-11 11:02:50 +080088 )
Mingyang Sund20999f2020-10-15 14:53:12 +080089endif()
90
Raef Colesabfe81a2020-07-10 09:52:34 +010091target_link_libraries(tfm_spm
92 PUBLIC
93 tfm_arch
94 PRIVATE
95 psa_interface
96 platform_s
97 tfm_boot_status
98 tfm_secure_api
99 tfm_partitions
Shawn Shan781ef732021-03-10 14:05:57 +0800100 $<$<STREQUAL:${TEST_PSA_API},IPC>:tfm_psa_rot_partition_driver_partition>
101 $<$<STREQUAL:${TEST_PSA_API},IPC>:tfm_app_rot_partition_client_partition>
102 $<$<STREQUAL:${TEST_PSA_API},IPC>:tfm_app_rot_partition_server_partition>
David Huf07e97d2021-02-15 22:05:40 +0800103 tfm_fih
Kevin Peng498c45b2021-08-31 17:57:15 +0800104 tfm_sprt
Raef Colesabfe81a2020-07-10 09:52:34 +0100105)
106
107target_compile_definitions(tfm_spm
108 PRIVATE
109 $<$<CONFIG:Debug>:TFM_CORE_DEBUG>
110 $<$<AND:$<BOOL:${BL2}>,$<BOOL:${MCUBOOT_MEASURED_BOOT}>>:BOOT_DATA_AVAILABLE>
Øyvind Rønningstadf2c8dad2021-01-15 15:33:33 +0100111 $<$<BOOL:${TFM_EXCEPTION_INFO_DUMP}>:TFM_EXCEPTION_INFO_DUMP>
Raef Colesabfe81a2020-07-10 09:52:34 +0100112)
113
114# With constant optimizations on tfm_nspc_func emits a symbol that the linker
115# doesn't like. It's unclear why this is, so I'll put a TODO here, but for the
116# moment this fixes it with mimimal impact.
117set_source_files_properties(tfm_nspm_func.c
118 PROPERTIES
119 COMPILE_FLAGS -fno-ipa-cp
120)
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>
185 )
186endif()