blob: 144fc4c5f81f492e0311f63b824da321f440302d [file] [log] [blame]
Kevin Peng62a87112020-07-07 15:07:46 +08001#-------------------------------------------------------------------------------
Raef Colesb8f0c312021-05-26 14:17:37 +01002# Copyright (c) 2020-2022, Arm Limited. All rights reserved.
Chris Brandddcf5292021-10-27 13:50:35 -07003# Copyright (c) 2022, Cypress Semiconductor Corp. All rights reserved.
Kevin Peng62a87112020-07-07 15:07:46 +08004#
5# SPDX-License-Identifier: BSD-3-Clause
6#
7#-------------------------------------------------------------------------------
8
Raef Coles5ee45ed2020-09-24 11:25:44 +01009cmake_minimum_required(VERSION 3.13)
Kevin Peng62a87112020-07-07 15:07:46 +080010project(tfm_ns LANGUAGES ASM C)
Kevin Peng62a87112020-07-07 15:07:46 +080011
Raef Coles5ee45ed2020-09-24 11:25:44 +010012# For multi-core projects, the NS app can be run on a different CPU to the
13# Secure code. To facilitate this, we once again reload the compiler to load the
14# setting for the NS CPU. Cmake settings are directory scoped so this affects
15# anything loaded from or declared in this dir.
16if (TFM_MULTI_CORE_TOPOLOGY)
17 include(${CMAKE_SOURCE_DIR}/platform/ext/target/${TFM_PLATFORM}/preload_ns.cmake)
Raef Coles34cffa72020-10-28 10:27:19 +000018 tfm_toolchain_reload_compiler()
David Hu402a2982020-12-17 22:31:04 +080019
20 # Enable TFM_MULTI_CORE_NS_OS when building with tf-m-tests NS App.
21 set(TFM_MULTI_CORE_NS_OS ON CACHE BOOL "Enable NS RTOS support in NS mailbox")
Kevin Peng62a87112020-07-07 15:07:46 +080022endif()
23
David Hu73f259b2020-12-07 10:58:41 +080024# In actual NS integration, NS side build should include the source files
25# exported by TF-M build.
26# Directly include interface folder to simplify the NS build in this demo, since
27# install always occurs at the end of build.
28set(INTERFACE_SRC_DIR ${CMAKE_SOURCE_DIR}/interface/src)
29set(INTERFACE_INC_DIR ${CMAKE_SOURCE_DIR}/interface/include)
30
David Hucdc51fb2021-04-06 18:10:46 +080031# NS interface implemented by NSPE
32set(NS_INTERFACE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../ns_interface)
33
Xinyu Zhangeebbea32021-09-01 15:26:39 +080034# nsid_manager
35set(NSID_MGR_DIR ${NS_INTERFACE_DIR}/ns_client_ext)
36
David Hu73f259b2020-12-07 10:58:41 +080037#################### TF-M NS interface (header only) ###########################
38
39add_library(tfm_ns_interface INTERFACE)
40
David Hucdc51fb2021-04-06 18:10:46 +080041# Include interface headers exported by TF-M
David Hu73f259b2020-12-07 10:58:41 +080042target_include_directories(tfm_ns_interface
43 INTERFACE
44 ${INTERFACE_INC_DIR}
45 ${CMAKE_BINARY_DIR}/generated/interface/include
David Hu8e683252020-12-17 18:02:32 +080046 $<$<BOOL:${TFM_MULTI_CORE_TOPOLOGY}>:${INTERFACE_INC_DIR}/multi_core>
David Hu98adf322020-09-01 16:18:46 +080047 $<$<BOOL:${TFM_MULTI_CORE_TOPOLOGY}>:${CMAKE_SOURCE_DIR}/platform/ext/cmsis>
David Hu73f259b2020-12-07 10:58:41 +080048)
49
David Hucdc51fb2021-04-06 18:10:46 +080050# Include NS local interface headers
51target_include_directories(tfm_ns_interface
52 INTERFACE
53 ${NS_INTERFACE_DIR}
Xinyu Zhangeebbea32021-09-01 15:26:39 +080054 ${NSID_MGR_DIR}
David Hucdc51fb2021-04-06 18:10:46 +080055)
56
David Hu73f259b2020-12-07 10:58:41 +080057# PSA interface files are generated from a template
58add_dependencies(tfm_ns_interface
59 tfm_generated_files
60)
61
62# Include selection of Secure Partitions from TF-M build.
63# It can be replaced by NS side configurations later.
64target_link_libraries(tfm_ns_interface
65 INTERFACE
66 tfm_partition_defs
67)
68
69target_compile_definitions(tfm_ns_interface
70 INTERFACE
71 $<$<BOOL:${TFM_PSA_API}>:TFM_PSA_API>
72 $<$<STREQUAL:${TEST_PSA_API},IPC>:PSA_API_TEST_IPC>
Xinyu Zhangeebbea32021-09-01 15:26:39 +080073 $<$<BOOL:${TFM_NS_MANAGE_NSID}>:TFM_NS_MANAGE_NSID>
Xinyu Zhang92fe7582021-09-24 17:11:49 +080074 $<$<BOOL:${TEST_NS_MANAGE_NSID}>:TEST_NS_MANAGE_NSID>
David Hu73f259b2020-12-07 10:58:41 +080075 $<$<BOOL:${TFM_MULTI_CORE_TOPOLOGY}>:TFM_MULTI_CORE_TOPOLOGY>
David Hu402a2982020-12-17 22:31:04 +080076 $<$<BOOL:${TFM_MULTI_CORE_NS_OS}>:TFM_MULTI_CORE_NS_OS>
David Hu98adf322020-09-01 16:18:46 +080077 $<$<AND:$<BOOL:${TFM_MULTI_CORE_NS_OS_MAILBOX_THREAD}>,$<BOOL:${TFM_MULTI_CORE_NS_OS}>>:TFM_MULTI_CORE_NS_OS_MAILBOX_THREAD>
David Hu73f259b2020-12-07 10:58:41 +080078 $<$<BOOL:${FORWARD_PROT_MSG}>:FORWARD_PROT_MSG>
79)
80
81###################### TF-M NS interface api (NS lib) ##########################
82
83add_library(tfm_api_ns STATIC)
84
Xinyu Zhangeebbea32021-09-01 15:26:39 +080085target_sources(tfm_api_ns
86 PRIVATE
87 $<$<BOOL:${TFM_NS_MANAGE_NSID}>:${NSID_MGR_DIR}/tfm_nsid_manager.c>
88)
89
David Hu73f259b2020-12-07 10:58:41 +080090if (${TFM_PSA_API})
91 target_sources(tfm_api_ns PRIVATE
Jianliang Shen7a814e42021-10-18 15:25:39 +080092 $<$<OR:$<BOOL:${FORWARD_PROT_MSG}>,$<BOOL:${TFM_PARTITION_PLATFORM}>>:${INTERFACE_SRC_DIR}/tfm_platform_ipc_api.c>
93 $<$<OR:$<BOOL:${FORWARD_PROT_MSG}>,$<BOOL:${TFM_PARTITION_PROTECTED_STORAGE}>>:${INTERFACE_SRC_DIR}/tfm_ps_ipc_api.c>
94 $<$<OR:$<BOOL:${FORWARD_PROT_MSG}>,$<BOOL:${TFM_PARTITION_INTERNAL_TRUSTED_STORAGE}>>:${INTERFACE_SRC_DIR}/tfm_its_ipc_api.c>
95 $<$<OR:$<BOOL:${FORWARD_PROT_MSG}>,$<BOOL:${TFM_PARTITION_CRYPTO}>>:${INTERFACE_SRC_DIR}/tfm_crypto_ipc_api.c>
96 $<$<OR:$<BOOL:${FORWARD_PROT_MSG}>,$<BOOL:${TFM_PARTITION_INITIAL_ATTESTATION}>>:${INTERFACE_SRC_DIR}/tfm_initial_attestation_ipc_api.c>
Sherry Zhang92c499a2021-03-08 18:14:15 +080097 $<$<BOOL:${TFM_PARTITION_FIRMWARE_UPDATE}>:${INTERFACE_SRC_DIR}/tfm_firmware_update_ipc_api.c>
98 )
David Hu73f259b2020-12-07 10:58:41 +080099
100 if (TFM_MULTI_CORE_TOPOLOGY)
101 target_sources(tfm_api_ns PRIVATE
David Hu8e683252020-12-17 18:02:32 +0800102 ${INTERFACE_SRC_DIR}/multi_core/tfm_multi_core_ns_api.c
103 ${INTERFACE_SRC_DIR}/multi_core/tfm_multi_core_psa_ns_api.c
David Hu98adf322020-09-01 16:18:46 +0800104 $<$<NOT:$<BOOL:${TFM_MULTI_CORE_NS_OS_MAILBOX_THREAD}>>:${INTERFACE_SRC_DIR}/multi_core/tfm_ns_mailbox.c>
105 $<$<AND:$<BOOL:${TFM_MULTI_CORE_NS_OS}>,$<BOOL:${TFM_MULTI_CORE_NS_OS_MAILBOX_THREAD}>>:${INTERFACE_SRC_DIR}/multi_core/tfm_ns_mailbox_thread.c>
David Hu73f259b2020-12-07 10:58:41 +0800106 )
David Hucdc51fb2021-04-06 18:10:46 +0800107
108 # NS RTOS specific implementation of NS mailbox
109 target_sources(tfm_api_ns PRIVATE
110 $<$<BOOL:${TFM_MULTI_CORE_NS_OS}>:${NS_INTERFACE_DIR}/multi_core/tfm_ns_mailbox_rtos_api.c>
shejia01e0dd80a2021-07-12 17:47:50 +0800111 $<$<BOOL:${TEST_NS_MULTI_CORE}>:${NS_INTERFACE_DIR}/multi_core/tfm_ns_mailbox_test.c>
David Hucdc51fb2021-04-06 18:10:46 +0800112 )
David Hu73f259b2020-12-07 10:58:41 +0800113 else()
114 target_sources(tfm_api_ns PRIVATE
David Hu73f259b2020-12-07 10:58:41 +0800115 ${INTERFACE_SRC_DIR}/tfm_psa_ns_api.c
116 )
David Hucdc51fb2021-04-06 18:10:46 +0800117
118 # NS specific implementation of NS interface dispacther
119 target_sources(tfm_api_ns PRIVATE
120 ${CMAKE_CURRENT_SOURCE_DIR}/tfm_ns_interface.c
121 )
David Hu73f259b2020-12-07 10:58:41 +0800122 endif()
123else()
124 target_sources(tfm_api_ns PRIVATE
125 $<$<BOOL:${TFM_PARTITION_PLATFORM}>:${INTERFACE_SRC_DIR}/tfm_platform_func_api.c>
126 $<$<BOOL:${TFM_PARTITION_AUDIT_LOG}>:${INTERFACE_SRC_DIR}/tfm_audit_func_api.c>
127 $<$<BOOL:${TFM_PARTITION_PROTECTED_STORAGE}>:${INTERFACE_SRC_DIR}/tfm_ps_func_api.c>
128 $<$<BOOL:${TFM_PARTITION_INTERNAL_TRUSTED_STORAGE}>:${INTERFACE_SRC_DIR}/tfm_its_func_api.c>
129 $<$<BOOL:${TFM_PARTITION_CRYPTO}>:${INTERFACE_SRC_DIR}/tfm_crypto_func_api.c>
130 $<$<BOOL:${TFM_PARTITION_INITIAL_ATTESTATION}>:${INTERFACE_SRC_DIR}/tfm_initial_attestation_func_api.c>
Sherry Zhang92c499a2021-03-08 18:14:15 +0800131 $<$<BOOL:${TFM_PARTITION_FIRMWARE_UPDATE}>:${INTERFACE_SRC_DIR}/tfm_firmware_update_func_api.c>
David Hucdc51fb2021-04-06 18:10:46 +0800132 )
133
134 # NS specific implementation of NS interface dispacther
135 target_sources(tfm_api_ns PRIVATE
136 ${CMAKE_CURRENT_SOURCE_DIR}/tfm_ns_interface.c
David Hu73f259b2020-12-07 10:58:41 +0800137 )
138endif()
139
140target_link_libraries(tfm_api_ns
141 PUBLIC
142 tfm_ns_interface
143 PRIVATE
Sherry Zhang8342d7d2021-10-14 17:57:26 +0800144 $<$<NOT:$<BOOL:${TFM_MULTI_CORE_TOPOLOGY}>>:tfm_s_veneers>
David Hu73f259b2020-12-07 10:58:41 +0800145 platform_ns
David Hu73f259b2020-12-07 10:58:41 +0800146)
147
Raef Coles5ee45ed2020-09-24 11:25:44 +0100148############################# PSA test integration #############################
149
Raef Colesc922f252020-10-05 10:49:30 +0100150if(TEST_PSA_API AND NOT PSA_ARCH_TESTS_BINARY_PATH)
151 if(NOT SUITE)
152 set(SUITE ${TEST_PSA_API})
153 endif()
Raef Coles5ee45ed2020-09-24 11:25:44 +0100154
Øyvind Rønningstad205a34a2020-10-02 10:31:23 +0200155 if (NOT DEFINED PSA_API_TEST_TARGET)
156 string(REGEX REPLACE ".*/" "" PSA_API_TEST_TARGET ${TFM_PLATFORM})
157 endif()
Raef Coles5ee45ed2020-09-24 11:25:44 +0100158
Raef Colesc922f252020-10-05 10:49:30 +0100159 if(NOT TARGET)
160 if (NOT "${TEST_PSA_API}" STREQUAL "IPC")
161 set(TARGET tgt_dev_apis_tfm_${PSA_API_TEST_TARGET})
162 else()
163 set(TARGET tgt_ff_tfm_${PSA_API_TEST_TARGET})
164 endif()
Raef Coles5ee45ed2020-09-24 11:25:44 +0100165 endif()
166
Raef Coles5ee45ed2020-09-24 11:25:44 +0100167
Raef Colesc922f252020-10-05 10:49:30 +0100168 if(NOT PSA_INCLUDE_PATHS)
David Hua1fee3d2020-12-30 11:06:37 +0800169 set(PSA_INCLUDE_PATHS ${INTERFACE_INC_DIR}/
Raef Coles23d6a192020-10-22 15:43:38 +0100170 ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/
Raef Colesc922f252020-10-05 10:49:30 +0100171 ${CMAKE_BINARY_DIR}/generated/interface/include
172 )
Raef Coles5ee45ed2020-09-24 11:25:44 +0100173 endif()
174
Raef Colesc922f252020-10-05 10:49:30 +0100175 if(NOT SP_HEAP_MEM_SUPP)
Raef Coles06e6f652020-10-20 16:10:38 +0100176 set(SP_HEAP_MEM_SUPP 0)
Raef Colesc922f252020-10-05 10:49:30 +0100177 endif()
178 if(NOT PLATFORM_PSA_ISOLATION_LEVEL)
179 set(PLATFORM_PSA_ISOLATION_LEVEL ${TFM_ISOLATION_LEVEL})
180 endif()
181
182 if (NOT TOOLCHAIN)
183 if (${CMAKE_C_COMPILER_ID} STREQUAL GNU)
184 set(TOOLCHAIN GNUARM)
185 elseif (${CMAKE_C_COMPILER_ID} STREQUAL ARMClang)
186 set(TOOLCHAIN ARMCLANG)
187 endif()
188 endif()
189
190 if (NOT CPU_ARCH)
Chris Brandddcf5292021-10-27 13:50:35 -0700191 if (${TFM_SYSTEM_ARCHITECTURE} STREQUAL armv8-m.main)
Raef Colesc922f252020-10-05 10:49:30 +0100192 set(CPU_ARCH armv8m_ml)
Chris Brandddcf5292021-10-27 13:50:35 -0700193 elseif (${TFM_SYSTEM_ARCHITECTURE} STREQUAL armv8-m.base)
Raef Colesc922f252020-10-05 10:49:30 +0100194 set(CPU_ARCH armv8m_bl)
Chris Brandddcf5292021-10-27 13:50:35 -0700195 elseif (${TFM_SYSTEM_ARCHITECTURE} STREQUAL armv7-m)
Raef Colesc922f252020-10-05 10:49:30 +0100196 set(CPU_ARCH armv7m)
197 endif()
Raef Coles5ee45ed2020-09-24 11:25:44 +0100198 endif()
199
200 add_subdirectory(${PSA_ARCH_TESTS_PATH}/api-tests ${CMAKE_CURRENT_BINARY_DIR}/psa_api_tests)
Raef Coles4817eb82022-01-18 12:33:24 +0000201
202 if (TEST_PSA_API STREQUAL IPC)
203 target_include_directories(tfm_partitions
204 INTERFACE
205 ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests
206 )
207
208 target_sources(tfm_psa_rot_partition_driver_partition
209 PRIVATE
210 ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/intermedia_driver_partition_psa.c
211 )
212 target_link_libraries(tfm_psa_rot_partition_driver_partition
213 PRIVATE
214 psa_interface
215 platform_s
216 )
217 target_compile_definitions(tfm_psa_rot_partition_driver_partition
218 PRIVATE
219 CONFIG_TFM_BUILDING_SPE=1
220 TFM_LVL=${TFM_ISOLATION_LEVEL}
221 )
222
223 target_sources(tfm_app_rot_partition_client_partition
224 PRIVATE
225 ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/intermedia_client_partition_psa.c
226 )
227 target_link_libraries(tfm_app_rot_partition_client_partition
228 PRIVATE
229 psa_interface
230 platform_s
231 )
232 target_compile_definitions(tfm_app_rot_partition_client_partition
233 PRIVATE
234 CONFIG_TFM_BUILDING_SPE=1
235 TFM_LVL=${TFM_ISOLATION_LEVEL}
236 )
237
238 target_sources(tfm_app_rot_partition_server_partition
239 PRIVATE
240 ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/intermedia_server_partition_psa.c
241 )
242 target_link_libraries(tfm_app_rot_partition_server_partition
243 PRIVATE
244 psa_interface
245 platform_s
246 )
247 target_compile_definitions(tfm_app_rot_partition_server_partition
248 PRIVATE
249 CONFIG_TFM_BUILDING_SPE=1
250 TFM_LVL=${TFM_ISOLATION_LEVEL}
251 )
252
253 target_sources(tfm_partitions
254 INTERFACE
255 ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/load_info_driver_partition_psa.c
256 ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/load_info_client_partition_psa.c
257 ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/load_info_server_partition_psa.c
258 )
259
260 target_link_libraries(tfm_partitions
261 INTERFACE
262 tfm_psa_rot_partition_driver_partition
263 tfm_app_rot_partition_client_partition
264 tfm_app_rot_partition_server_partition
265 )
266 endif()
Kevin Peng62a87112020-07-07 15:07:46 +0800267endif()
268
Raef Coles5ee45ed2020-09-24 11:25:44 +0100269############################# Test integration #################################
Kevin Peng62a87112020-07-07 15:07:46 +0800270
Raef Coles5ee45ed2020-09-24 11:25:44 +0100271add_library(tfm_ns_integration_test STATIC EXCLUDE_FROM_ALL)
Kevin Peng62a87112020-07-07 15:07:46 +0800272
Raef Coles5ee45ed2020-09-24 11:25:44 +0100273target_sources(tfm_ns_integration_test
274 PRIVATE
275 tfm_integ_test.c
276)
Kevin Peng62a87112020-07-07 15:07:46 +0800277
Raef Coles5ee45ed2020-09-24 11:25:44 +0100278target_include_directories(tfm_ns_integration_test
279 PUBLIC
280 .
281)
Kevin Peng62a87112020-07-07 15:07:46 +0800282
Raef Coles5ee45ed2020-09-24 11:25:44 +0100283target_link_libraries(tfm_ns_integration_test
Raef Coles5ee45ed2020-09-24 11:25:44 +0100284 PRIVATE
David Huacba69e2021-09-10 15:36:48 +0800285 $<$<BOOL:${TEST_FRAMEWORK_NS}>:tfm_ns_tests>
286 $<$<BOOL:${TEST_FRAMEWORK_S}>:tfm_ns_interface>
287 $<$<BOOL:${TEST_FRAMEWORK_S}>:tfm_api_ns>
Paul Sokolovsky5d7925e2022-03-15 12:13:53 +0300288 tfm_log
Raef Coles5ee45ed2020-09-24 11:25:44 +0100289)
Kevin Peng62a87112020-07-07 15:07:46 +0800290
Raef Coles5ee45ed2020-09-24 11:25:44 +0100291target_compile_definitions(tfm_ns_integration_test
292 PUBLIC
shejia01e0dd80a2021-07-12 17:47:50 +0800293 $<$<BOOL:${TEST_FRAMEWORK_NS}>:TEST_FRAMEWORK_NS>
294 $<$<BOOL:${TEST_FRAMEWORK_S}>:TEST_FRAMEWORK_S>
shejia0126b2d782021-08-19 17:08:24 +0800295 $<$<BOOL:${TFM_LIB_MODEL}>:TFM_LIB_MODEL>
Raef Coles5ee45ed2020-09-24 11:25:44 +0100296)
Kevin Peng62a87112020-07-07 15:07:46 +0800297
Raef Coles5ee45ed2020-09-24 11:25:44 +0100298############################# TFM NS app #######################################
Kevin Peng62a87112020-07-07 15:07:46 +0800299
Raef Coles5ee45ed2020-09-24 11:25:44 +0100300add_executable(tfm_ns)
Kevin Peng62a87112020-07-07 15:07:46 +0800301
Raef Coles5ee45ed2020-09-24 11:25:44 +0100302target_sources(tfm_ns
303 PRIVATE
304 main_ns.c
Kevin Peng0d3a3812020-12-23 02:17:57 +0000305 $<$<BOOL:${TEST_PSA_API}>:psa_api_test.c>
Raef Coles5ee45ed2020-09-24 11:25:44 +0100306)
Kevin Peng62a87112020-07-07 15:07:46 +0800307
Raef Coles5ee45ed2020-09-24 11:25:44 +0100308target_link_libraries(tfm_ns
309 PRIVATE
310 platform_ns
311 CMSIS_5_tfm_ns
shejia01e0dd80a2021-07-12 17:47:50 +0800312 $<$<OR:$<BOOL:${TEST_FRAMEWORK_NS}>,$<BOOL:${TEST_FRAMEWORK_S}>>:tfm_ns_integration_test>
Kevin Peng0d3a3812020-12-23 02:17:57 +0000313 $<$<BOOL:${TEST_PSA_API}>:val_nspe>
314 $<$<BOOL:${TEST_PSA_API}>:pal_nspe>
315 $<$<BOOL:${TEST_PSA_API}>:test_combine>
David Hu73f259b2020-12-07 10:58:41 +0800316 tfm_api_ns
Raef Colesb8f0c312021-05-26 14:17:37 +0100317 tfm_log
Raef Coles5ee45ed2020-09-24 11:25:44 +0100318)
Kevin Peng62a87112020-07-07 15:07:46 +0800319
Kevin Peng0d3a3812020-12-23 02:17:57 +0000320target_compile_definitions(tfm_ns
321 PUBLIC
322 $<$<BOOL:${TEST_PSA_API}>:PSA_API_TEST_NS>
323)
324
Raef Coles5ee45ed2020-09-24 11:25:44 +0100325set_target_properties(tfm_ns PROPERTIES
326 SUFFIX ".axf"
327 RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
328)
Kevin Peng62a87112020-07-07 15:07:46 +0800329
Raef Coles5ee45ed2020-09-24 11:25:44 +0100330target_link_options(tfm_ns
331 PRIVATE
332 $<$<C_COMPILER_ID:GNU>:-Wl,-Map=${CMAKE_BINARY_DIR}/bin/tfm_ns.map>
333 $<$<C_COMPILER_ID:ARMClang>:--map>
TTornblomd35ffa02020-09-29 13:31:31 +0200334 $<$<C_COMPILER_ID:IAR>:--map\;${CMAKE_BINARY_DIR}/bin/tfm_ns.map>
Raef Coles5ee45ed2020-09-24 11:25:44 +0100335)
Kevin Peng62a87112020-07-07 15:07:46 +0800336
Raef Coles5ee45ed2020-09-24 11:25:44 +0100337add_convert_to_bin_target(tfm_ns)
Kevin Peng62a87112020-07-07 15:07:46 +0800338
Raef Coles5ee45ed2020-09-24 11:25:44 +0100339############################# CMSIS ############################################
Kevin Peng62a87112020-07-07 15:07:46 +0800340
Raef Coles5ee45ed2020-09-24 11:25:44 +0100341include(FetchContent)
Kevin Peng62a87112020-07-07 15:07:46 +0800342
Raef Coles5ee45ed2020-09-24 11:25:44 +0100343set(FETCHCONTENT_QUIET FALSE)
344cmake_policy(SET CMP0079 NEW)
Kevin Peng62a87112020-07-07 15:07:46 +0800345
Raef Coles5ee45ed2020-09-24 11:25:44 +0100346add_library(CMSIS_5_tfm_ns INTERFACE)
Kevin Peng62a87112020-07-07 15:07:46 +0800347
Raef Coles5ee45ed2020-09-24 11:25:44 +0100348target_sources(CMSIS_5_tfm_ns
349 INTERFACE
Xinyu Zhangeebbea32021-09-01 15:26:39 +0800350 ${NSID_MGR_DIR}/tz_shim_layer.c
Raef Coles5ee45ed2020-09-24 11:25:44 +0100351 ${CMSIS_5_PATH}/RTOS2/RTX/Config/RTX_Config.c
352 ${CMSIS_5_PATH}/RTOS2/RTX/Source/rtx_lib.c
353 ${CMAKE_CURRENT_SOURCE_DIR}/os_wrapper_cmsis_rtos_v2.c
Xinyu Zhangeebbea32021-09-01 15:26:39 +0800354 $<$<BOOL:${TFM_NS_MANAGE_NSID}>:${CMAKE_CURRENT_SOURCE_DIR}/tfm_nsid_map_table.c>
Raef Coles5ee45ed2020-09-24 11:25:44 +0100355)
Kevin Peng62a87112020-07-07 15:07:46 +0800356
Raef Coles5ee45ed2020-09-24 11:25:44 +0100357target_include_directories(CMSIS_5_tfm_ns
358 INTERFACE
359 ${CMSIS_5_PATH}/Core/Include
360 ${CMSIS_5_PATH}/RTOS2/Include
361 ${CMSIS_5_PATH}/RTOS2/RTX/Include
362 ${CMSIS_5_PATH}/RTOS2/RTX/Config
Xinyu Zhangeebbea32021-09-01 15:26:39 +0800363 $<$<BOOL:${TFM_NS_MANAGE_NSID}>:${CMAKE_CURRENT_SOURCE_DIR}>
Raef Coles5ee45ed2020-09-24 11:25:44 +0100364)
Kevin Peng62a87112020-07-07 15:07:46 +0800365
Raef Coles5ee45ed2020-09-24 11:25:44 +0100366target_link_libraries(CMSIS_5_tfm_ns
367 INTERFACE
368 platform_ns
369)
Xinyu Zhangeebbea32021-09-01 15:26:39 +0800370
371target_compile_definitions(CMSIS_5_tfm_ns
372 INTERFACE
373 $<$<BOOL:${TFM_NS_MANAGE_NSID}>:TFM_NS_MANAGE_NSID>
374)