blob: c5571f4046db32d8e3d9e294080c3e988469a564 [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 Brand592c98e2022-05-20 14:46:54 -07003# Copyright (c) 2022 Cypress Semiconductor Corporation (an Infineon company)
4# or an affiliate of Cypress Semiconductor Corporation. All rights reserved.
Kevin Peng62a87112020-07-07 15:07:46 +08005#
6# SPDX-License-Identifier: BSD-3-Clause
7#
8#-------------------------------------------------------------------------------
9
Raef Coles5ee45ed2020-09-24 11:25:44 +010010cmake_minimum_required(VERSION 3.13)
Kevin Peng62a87112020-07-07 15:07:46 +080011project(tfm_ns LANGUAGES ASM C)
Kevin Peng62a87112020-07-07 15:07:46 +080012
Raef Coles5ee45ed2020-09-24 11:25:44 +010013# For multi-core projects, the NS app can be run on a different CPU to the
14# Secure code. To facilitate this, we once again reload the compiler to load the
15# setting for the NS CPU. Cmake settings are directory scoped so this affects
16# anything loaded from or declared in this dir.
Chris Brand592c98e2022-05-20 14:46:54 -070017if (EXISTS ${CMAKE_SOURCE_DIR}/platform/ext/target/${TFM_PLATFORM}/preload_ns.cmake)
Raef Coles5ee45ed2020-09-24 11:25:44 +010018 include(${CMAKE_SOURCE_DIR}/platform/ext/target/${TFM_PLATFORM}/preload_ns.cmake)
Raef Coles34cffa72020-10-28 10:27:19 +000019 tfm_toolchain_reload_compiler()
Chris Brand592c98e2022-05-20 14:46:54 -070020endif()
David Hu402a2982020-12-17 22:31:04 +080021
Chris Brand592c98e2022-05-20 14:46:54 -070022if (TFM_MULTI_CORE_TOPOLOGY)
David Hu402a2982020-12-17 22:31:04 +080023 # Enable TFM_MULTI_CORE_NS_OS when building with tf-m-tests NS App.
24 set(TFM_MULTI_CORE_NS_OS ON CACHE BOOL "Enable NS RTOS support in NS mailbox")
Kevin Peng62a87112020-07-07 15:07:46 +080025endif()
26
David Hu73f259b2020-12-07 10:58:41 +080027# In actual NS integration, NS side build should include the source files
28# exported by TF-M build.
29# Directly include interface folder to simplify the NS build in this demo, since
30# install always occurs at the end of build.
31set(INTERFACE_SRC_DIR ${CMAKE_SOURCE_DIR}/interface/src)
32set(INTERFACE_INC_DIR ${CMAKE_SOURCE_DIR}/interface/include)
33
David Hucdc51fb2021-04-06 18:10:46 +080034# NS interface implemented by NSPE
35set(NS_INTERFACE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../ns_interface)
36
Xinyu Zhangeebbea32021-09-01 15:26:39 +080037# nsid_manager
38set(NSID_MGR_DIR ${NS_INTERFACE_DIR}/ns_client_ext)
39
David Hu73f259b2020-12-07 10:58:41 +080040#################### TF-M NS interface (header only) ###########################
41
42add_library(tfm_ns_interface INTERFACE)
43
David Hucdc51fb2021-04-06 18:10:46 +080044# Include interface headers exported by TF-M
David Hu73f259b2020-12-07 10:58:41 +080045target_include_directories(tfm_ns_interface
46 INTERFACE
47 ${INTERFACE_INC_DIR}
48 ${CMAKE_BINARY_DIR}/generated/interface/include
Chris Brand5c8b6392022-05-20 14:46:12 -070049 $<$<BOOL:${TFM_PARTITION_NS_AGENT_MAILBOX}>:${INTERFACE_INC_DIR}/multi_core>
David Hu73f259b2020-12-07 10:58:41 +080050)
51
David Hucdc51fb2021-04-06 18:10:46 +080052# Include NS local interface headers
53target_include_directories(tfm_ns_interface
54 INTERFACE
55 ${NS_INTERFACE_DIR}
Xinyu Zhangeebbea32021-09-01 15:26:39 +080056 ${NSID_MGR_DIR}
David Hucdc51fb2021-04-06 18:10:46 +080057)
58
David Hu73f259b2020-12-07 10:58:41 +080059# PSA interface files are generated from a template
60add_dependencies(tfm_ns_interface
61 tfm_generated_files
62)
63
64# Include selection of Secure Partitions from TF-M build.
65# It can be replaced by NS side configurations later.
66target_link_libraries(tfm_ns_interface
67 INTERFACE
68 tfm_partition_defs
69)
70
71target_compile_definitions(tfm_ns_interface
72 INTERFACE
73 $<$<BOOL:${TFM_PSA_API}>:TFM_PSA_API>
74 $<$<STREQUAL:${TEST_PSA_API},IPC>:PSA_API_TEST_IPC>
Xinyu Zhangeebbea32021-09-01 15:26:39 +080075 $<$<BOOL:${TFM_NS_MANAGE_NSID}>:TFM_NS_MANAGE_NSID>
Xinyu Zhang92fe7582021-09-24 17:11:49 +080076 $<$<BOOL:${TEST_NS_MANAGE_NSID}>:TEST_NS_MANAGE_NSID>
Chris Brand5c8b6392022-05-20 14:46:12 -070077 $<$<BOOL:${CONFIG_TFM_USE_TRUSTZONE}>:CONFIG_TFM_USE_TRUSTZONE>
David Hu73f259b2020-12-07 10:58:41 +080078 $<$<BOOL:${TFM_MULTI_CORE_TOPOLOGY}>:TFM_MULTI_CORE_TOPOLOGY>
David Hu402a2982020-12-17 22:31:04 +080079 $<$<BOOL:${TFM_MULTI_CORE_NS_OS}>:TFM_MULTI_CORE_NS_OS>
David Hu98adf322020-09-01 16:18:46 +080080 $<$<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 +080081)
82
Kevin Peng06108cd2022-06-09 11:37:39 +080083target_compile_options(tfm_ns_interface
84 INTERFACE
85 ${COMPILER_CP_FLAG}
86)
87
David Hu73f259b2020-12-07 10:58:41 +080088###################### TF-M NS interface api (NS lib) ##########################
89
90add_library(tfm_api_ns STATIC)
91
Xinyu Zhangeebbea32021-09-01 15:26:39 +080092target_sources(tfm_api_ns
93 PRIVATE
94 $<$<BOOL:${TFM_NS_MANAGE_NSID}>:${NSID_MGR_DIR}/tfm_nsid_manager.c>
95)
96
Chris Brand5c8b6392022-05-20 14:46:12 -070097if (TFM_PSA_API)
David Hu73f259b2020-12-07 10:58:41 +080098 target_sources(tfm_api_ns PRIVATE
Mark Horvath2f072582022-09-09 16:15:30 +020099 $<$<BOOL:${TFM_PARTITION_PLATFORM}>:${INTERFACE_SRC_DIR}/tfm_platform_ipc_api.c>
100 $<$<BOOL:${TFM_PARTITION_PROTECTED_STORAGE}>:${INTERFACE_SRC_DIR}/tfm_ps_ipc_api.c>
101 $<$<BOOL:${TFM_PARTITION_INTERNAL_TRUSTED_STORAGE}>:${INTERFACE_SRC_DIR}/tfm_its_ipc_api.c>
102 $<$<BOOL:${TFM_PARTITION_CRYPTO}>:${INTERFACE_SRC_DIR}/tfm_crypto_ipc_api.c>
103 $<$<BOOL:${TFM_PARTITION_INITIAL_ATTESTATION}>:${INTERFACE_SRC_DIR}/tfm_initial_attestation_ipc_api.c>
Sherry Zhang92c499a2021-03-08 18:14:15 +0800104 $<$<BOOL:${TFM_PARTITION_FIRMWARE_UPDATE}>:${INTERFACE_SRC_DIR}/tfm_firmware_update_ipc_api.c>
105 )
David Hu73f259b2020-12-07 10:58:41 +0800106
Chris Brand5c8b6392022-05-20 14:46:12 -0700107 if (TFM_PARTITION_NS_AGENT_MAILBOX)
David Hu73f259b2020-12-07 10:58:41 +0800108 target_sources(tfm_api_ns PRIVATE
David Hu8e683252020-12-17 18:02:32 +0800109 ${INTERFACE_SRC_DIR}/multi_core/tfm_multi_core_ns_api.c
110 ${INTERFACE_SRC_DIR}/multi_core/tfm_multi_core_psa_ns_api.c
David Hu98adf322020-09-01 16:18:46 +0800111 $<$<NOT:$<BOOL:${TFM_MULTI_CORE_NS_OS_MAILBOX_THREAD}>>:${INTERFACE_SRC_DIR}/multi_core/tfm_ns_mailbox.c>
112 $<$<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 +0800113 )
David Hucdc51fb2021-04-06 18:10:46 +0800114
115 # NS RTOS specific implementation of NS mailbox
116 target_sources(tfm_api_ns PRIVATE
117 $<$<BOOL:${TFM_MULTI_CORE_NS_OS}>:${NS_INTERFACE_DIR}/multi_core/tfm_ns_mailbox_rtos_api.c>
shejia01e0dd80a2021-07-12 17:47:50 +0800118 $<$<BOOL:${TEST_NS_MULTI_CORE}>:${NS_INTERFACE_DIR}/multi_core/tfm_ns_mailbox_test.c>
David Hucdc51fb2021-04-06 18:10:46 +0800119 )
David Hu73f259b2020-12-07 10:58:41 +0800120 endif()
121else()
122 target_sources(tfm_api_ns PRIVATE
123 $<$<BOOL:${TFM_PARTITION_PLATFORM}>:${INTERFACE_SRC_DIR}/tfm_platform_func_api.c>
124 $<$<BOOL:${TFM_PARTITION_AUDIT_LOG}>:${INTERFACE_SRC_DIR}/tfm_audit_func_api.c>
125 $<$<BOOL:${TFM_PARTITION_PROTECTED_STORAGE}>:${INTERFACE_SRC_DIR}/tfm_ps_func_api.c>
126 $<$<BOOL:${TFM_PARTITION_INTERNAL_TRUSTED_STORAGE}>:${INTERFACE_SRC_DIR}/tfm_its_func_api.c>
127 $<$<BOOL:${TFM_PARTITION_CRYPTO}>:${INTERFACE_SRC_DIR}/tfm_crypto_func_api.c>
128 $<$<BOOL:${TFM_PARTITION_INITIAL_ATTESTATION}>:${INTERFACE_SRC_DIR}/tfm_initial_attestation_func_api.c>
Sherry Zhang92c499a2021-03-08 18:14:15 +0800129 $<$<BOOL:${TFM_PARTITION_FIRMWARE_UPDATE}>:${INTERFACE_SRC_DIR}/tfm_firmware_update_func_api.c>
David Hucdc51fb2021-04-06 18:10:46 +0800130 )
David Hu73f259b2020-12-07 10:58:41 +0800131endif()
132
Chris Brand5c8b6392022-05-20 14:46:12 -0700133target_sources(tfm_api_ns PRIVATE
134 $<$<AND:$<BOOL:${TFM_PSA_API}>,$<BOOL:${CONFIG_TFM_USE_TRUSTZONE}>>:${INTERFACE_SRC_DIR}/tfm_psa_ns_api.c>
135 # NS specific implementation of NS interface dispacther
136 $<$<BOOL:${CONFIG_TFM_USE_TRUSTZONE}>:${CMAKE_CURRENT_SOURCE_DIR}/tfm_ns_interface.c>
137)
138
David Hu73f259b2020-12-07 10:58:41 +0800139target_link_libraries(tfm_api_ns
140 PUBLIC
141 tfm_ns_interface
142 PRIVATE
Chris Brand5c8b6392022-05-20 14:46:12 -0700143 $<$<BOOL:${CONFIG_TFM_USE_TRUSTZONE}>:tfm_s_veneers>
David Hu73f259b2020-12-07 10:58:41 +0800144 platform_ns
David Hu73f259b2020-12-07 10:58:41 +0800145)
146
Raef Coles5ee45ed2020-09-24 11:25:44 +0100147############################# PSA test integration #############################
148
Raef Colesc922f252020-10-05 10:49:30 +0100149if(TEST_PSA_API AND NOT PSA_ARCH_TESTS_BINARY_PATH)
150 if(NOT SUITE)
151 set(SUITE ${TEST_PSA_API})
152 endif()
Raef Coles5ee45ed2020-09-24 11:25:44 +0100153
Øyvind Rønningstad205a34a2020-10-02 10:31:23 +0200154 if (NOT DEFINED PSA_API_TEST_TARGET)
155 string(REGEX REPLACE ".*/" "" PSA_API_TEST_TARGET ${TFM_PLATFORM})
156 endif()
Raef Coles5ee45ed2020-09-24 11:25:44 +0100157
Raef Colesc922f252020-10-05 10:49:30 +0100158 if(NOT TARGET)
159 if (NOT "${TEST_PSA_API}" STREQUAL "IPC")
160 set(TARGET tgt_dev_apis_tfm_${PSA_API_TEST_TARGET})
161 else()
162 set(TARGET tgt_ff_tfm_${PSA_API_TEST_TARGET})
163 endif()
Raef Coles5ee45ed2020-09-24 11:25:44 +0100164 endif()
165
Raef Coles5ee45ed2020-09-24 11:25:44 +0100166
Raef Colesc922f252020-10-05 10:49:30 +0100167 if(NOT PSA_INCLUDE_PATHS)
David Hua1fee3d2020-12-30 11:06:37 +0800168 set(PSA_INCLUDE_PATHS ${INTERFACE_INC_DIR}/
Raef Coles23d6a192020-10-22 15:43:38 +0100169 ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/
Raef Colesc922f252020-10-05 10:49:30 +0100170 ${CMAKE_BINARY_DIR}/generated/interface/include
171 )
Raef Coles5ee45ed2020-09-24 11:25:44 +0100172 endif()
173
Raef Colesc922f252020-10-05 10:49:30 +0100174 if(NOT SP_HEAP_MEM_SUPP)
Raef Coles06e6f652020-10-20 16:10:38 +0100175 set(SP_HEAP_MEM_SUPP 0)
Raef Colesc922f252020-10-05 10:49:30 +0100176 endif()
177 if(NOT PLATFORM_PSA_ISOLATION_LEVEL)
178 set(PLATFORM_PSA_ISOLATION_LEVEL ${TFM_ISOLATION_LEVEL})
179 endif()
180
181 if (NOT TOOLCHAIN)
182 if (${CMAKE_C_COMPILER_ID} STREQUAL GNU)
183 set(TOOLCHAIN GNUARM)
184 elseif (${CMAKE_C_COMPILER_ID} STREQUAL ARMClang)
185 set(TOOLCHAIN ARMCLANG)
186 endif()
187 endif()
188
189 if (NOT CPU_ARCH)
Chris Brandddcf5292021-10-27 13:50:35 -0700190 if (${TFM_SYSTEM_ARCHITECTURE} STREQUAL armv8-m.main)
Raef Colesc922f252020-10-05 10:49:30 +0100191 set(CPU_ARCH armv8m_ml)
Chris Brandddcf5292021-10-27 13:50:35 -0700192 elseif (${TFM_SYSTEM_ARCHITECTURE} STREQUAL armv8-m.base)
Raef Colesc922f252020-10-05 10:49:30 +0100193 set(CPU_ARCH armv8m_bl)
Chris Brandddcf5292021-10-27 13:50:35 -0700194 elseif (${TFM_SYSTEM_ARCHITECTURE} STREQUAL armv7-m)
Raef Colesc922f252020-10-05 10:49:30 +0100195 set(CPU_ARCH armv7m)
196 endif()
Raef Coles5ee45ed2020-09-24 11:25:44 +0100197 endif()
198
199 add_subdirectory(${PSA_ARCH_TESTS_PATH}/api-tests ${CMAKE_CURRENT_BINARY_DIR}/psa_api_tests)
Raef Coles4817eb82022-01-18 12:33:24 +0000200
201 if (TEST_PSA_API STREQUAL IPC)
202 target_include_directories(tfm_partitions
203 INTERFACE
204 ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests
205 )
206
207 target_sources(tfm_psa_rot_partition_driver_partition
208 PRIVATE
209 ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/intermedia_driver_partition_psa.c
210 )
211 target_link_libraries(tfm_psa_rot_partition_driver_partition
212 PRIVATE
213 psa_interface
214 platform_s
215 )
216 target_compile_definitions(tfm_psa_rot_partition_driver_partition
217 PRIVATE
218 CONFIG_TFM_BUILDING_SPE=1
219 TFM_LVL=${TFM_ISOLATION_LEVEL}
220 )
221
222 target_sources(tfm_app_rot_partition_client_partition
223 PRIVATE
224 ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/intermedia_client_partition_psa.c
225 )
226 target_link_libraries(tfm_app_rot_partition_client_partition
227 PRIVATE
228 psa_interface
229 platform_s
230 )
231 target_compile_definitions(tfm_app_rot_partition_client_partition
232 PRIVATE
233 CONFIG_TFM_BUILDING_SPE=1
234 TFM_LVL=${TFM_ISOLATION_LEVEL}
235 )
236
237 target_sources(tfm_app_rot_partition_server_partition
238 PRIVATE
239 ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/intermedia_server_partition_psa.c
240 )
241 target_link_libraries(tfm_app_rot_partition_server_partition
242 PRIVATE
243 psa_interface
244 platform_s
245 )
246 target_compile_definitions(tfm_app_rot_partition_server_partition
247 PRIVATE
248 CONFIG_TFM_BUILDING_SPE=1
249 TFM_LVL=${TFM_ISOLATION_LEVEL}
250 )
251
252 target_sources(tfm_partitions
253 INTERFACE
254 ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/load_info_driver_partition_psa.c
255 ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/load_info_client_partition_psa.c
256 ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/load_info_server_partition_psa.c
257 )
258
259 target_link_libraries(tfm_partitions
260 INTERFACE
261 tfm_psa_rot_partition_driver_partition
262 tfm_app_rot_partition_client_partition
263 tfm_app_rot_partition_server_partition
264 )
265 endif()
Kevin Peng62a87112020-07-07 15:07:46 +0800266endif()
267
Raef Coles5ee45ed2020-09-24 11:25:44 +0100268############################# Test integration #################################
Kevin Peng62a87112020-07-07 15:07:46 +0800269
Kevin Peng342ec682022-04-29 10:36:58 +0800270add_library(tfm_test_app STATIC EXCLUDE_FROM_ALL)
Kevin Peng62a87112020-07-07 15:07:46 +0800271
Kevin Peng342ec682022-04-29 10:36:58 +0800272target_sources(tfm_test_app
Raef Coles5ee45ed2020-09-24 11:25:44 +0100273 PRIVATE
Kevin Peng342ec682022-04-29 10:36:58 +0800274 test_app.c
Raef Coles5ee45ed2020-09-24 11:25:44 +0100275)
Kevin Peng62a87112020-07-07 15:07:46 +0800276
Kevin Peng342ec682022-04-29 10:36:58 +0800277target_include_directories(tfm_test_app
Raef Coles5ee45ed2020-09-24 11:25:44 +0100278 PUBLIC
279 .
280)
Kevin Peng62a87112020-07-07 15:07:46 +0800281
Kevin Peng342ec682022-04-29 10:36:58 +0800282target_link_libraries(tfm_test_app
Raef Coles5ee45ed2020-09-24 11:25:44 +0100283 PRIVATE
David Huacba69e2021-09-10 15:36:48 +0800284 $<$<BOOL:${TEST_FRAMEWORK_NS}>:tfm_ns_tests>
Kevin Peng342ec682022-04-29 10:36:58 +0800285 $<$<BOOL:${TEST_PSA_API}>:val_nspe>
286 $<$<BOOL:${TEST_PSA_API}>:pal_nspe>
287 $<$<BOOL:${TEST_PSA_API}>:test_combine>
Kevin Peng6e2e4352022-05-11 11:18:54 +0800288 tfm_api_ns
Paul Sokolovsky5d7925e2022-03-15 12:13:53 +0300289 tfm_log
Raef Coles5ee45ed2020-09-24 11:25:44 +0100290)
Kevin Peng62a87112020-07-07 15:07:46 +0800291
Kevin Peng342ec682022-04-29 10:36:58 +0800292target_compile_definitions(tfm_test_app
293 PRIVATE
shejia01e0dd80a2021-07-12 17:47:50 +0800294 $<$<BOOL:${TEST_FRAMEWORK_NS}>:TEST_FRAMEWORK_NS>
295 $<$<BOOL:${TEST_FRAMEWORK_S}>:TEST_FRAMEWORK_S>
shejia0126b2d782021-08-19 17:08:24 +0800296 $<$<BOOL:${TFM_LIB_MODEL}>:TFM_LIB_MODEL>
Kevin Peng342ec682022-04-29 10:36:58 +0800297 $<$<BOOL:${TEST_PSA_API}>:PSA_API_TEST_NS>
Raef Coles5ee45ed2020-09-24 11:25:44 +0100298)
Kevin Peng62a87112020-07-07 15:07:46 +0800299
Raef Coles5ee45ed2020-09-24 11:25:44 +0100300############################# TFM NS app #######################################
Kevin Peng62a87112020-07-07 15:07:46 +0800301
Raef Coles5ee45ed2020-09-24 11:25:44 +0100302add_executable(tfm_ns)
Kevin Peng62a87112020-07-07 15:07:46 +0800303
Raef Coles5ee45ed2020-09-24 11:25:44 +0100304target_sources(tfm_ns
305 PRIVATE
306 main_ns.c
Raef Coles5ee45ed2020-09-24 11:25:44 +0100307)
Kevin Peng62a87112020-07-07 15:07:46 +0800308
Raef Coles5ee45ed2020-09-24 11:25:44 +0100309target_link_libraries(tfm_ns
310 PRIVATE
311 platform_ns
312 CMSIS_5_tfm_ns
Kevin Peng342ec682022-04-29 10:36:58 +0800313 tfm_test_app
Raef Colesb8f0c312021-05-26 14:17:37 +0100314 tfm_log
Raef Coles5ee45ed2020-09-24 11:25:44 +0100315)
Kevin Peng62a87112020-07-07 15:07:46 +0800316
Raef Coles5ee45ed2020-09-24 11:25:44 +0100317set_target_properties(tfm_ns PROPERTIES
318 SUFFIX ".axf"
319 RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
320)
Kevin Peng62a87112020-07-07 15:07:46 +0800321
Raef Coles5ee45ed2020-09-24 11:25:44 +0100322target_link_options(tfm_ns
323 PRIVATE
324 $<$<C_COMPILER_ID:GNU>:-Wl,-Map=${CMAKE_BINARY_DIR}/bin/tfm_ns.map>
325 $<$<C_COMPILER_ID:ARMClang>:--map>
TTornblomd35ffa02020-09-29 13:31:31 +0200326 $<$<C_COMPILER_ID:IAR>:--map\;${CMAKE_BINARY_DIR}/bin/tfm_ns.map>
Raef Coles5ee45ed2020-09-24 11:25:44 +0100327)
Kevin Peng62a87112020-07-07 15:07:46 +0800328
Raef Coles5ee45ed2020-09-24 11:25:44 +0100329add_convert_to_bin_target(tfm_ns)
Kevin Peng62a87112020-07-07 15:07:46 +0800330
Raef Coles5ee45ed2020-09-24 11:25:44 +0100331############################# CMSIS ############################################
Kevin Peng62a87112020-07-07 15:07:46 +0800332
Raef Coles5ee45ed2020-09-24 11:25:44 +0100333include(FetchContent)
Kevin Peng62a87112020-07-07 15:07:46 +0800334
Raef Coles5ee45ed2020-09-24 11:25:44 +0100335set(FETCHCONTENT_QUIET FALSE)
336cmake_policy(SET CMP0079 NEW)
Kevin Peng62a87112020-07-07 15:07:46 +0800337
Raef Coles5ee45ed2020-09-24 11:25:44 +0100338add_library(CMSIS_5_tfm_ns INTERFACE)
Kevin Peng62a87112020-07-07 15:07:46 +0800339
Raef Coles5ee45ed2020-09-24 11:25:44 +0100340target_sources(CMSIS_5_tfm_ns
341 INTERFACE
Xinyu Zhangeebbea32021-09-01 15:26:39 +0800342 ${NSID_MGR_DIR}/tz_shim_layer.c
Raef Coles5ee45ed2020-09-24 11:25:44 +0100343 ${CMSIS_5_PATH}/RTOS2/RTX/Config/RTX_Config.c
344 ${CMSIS_5_PATH}/RTOS2/RTX/Source/rtx_lib.c
345 ${CMAKE_CURRENT_SOURCE_DIR}/os_wrapper_cmsis_rtos_v2.c
Xinyu Zhangeebbea32021-09-01 15:26:39 +0800346 $<$<BOOL:${TFM_NS_MANAGE_NSID}>:${CMAKE_CURRENT_SOURCE_DIR}/tfm_nsid_map_table.c>
Raef Coles5ee45ed2020-09-24 11:25:44 +0100347)
Kevin Peng62a87112020-07-07 15:07:46 +0800348
Raef Coles5ee45ed2020-09-24 11:25:44 +0100349target_include_directories(CMSIS_5_tfm_ns
350 INTERFACE
351 ${CMSIS_5_PATH}/Core/Include
352 ${CMSIS_5_PATH}/RTOS2/Include
353 ${CMSIS_5_PATH}/RTOS2/RTX/Include
354 ${CMSIS_5_PATH}/RTOS2/RTX/Config
Xinyu Zhangeebbea32021-09-01 15:26:39 +0800355 $<$<BOOL:${TFM_NS_MANAGE_NSID}>:${CMAKE_CURRENT_SOURCE_DIR}>
Raef Coles5ee45ed2020-09-24 11:25:44 +0100356)
Kevin Peng62a87112020-07-07 15:07:46 +0800357
Raef Coles5ee45ed2020-09-24 11:25:44 +0100358target_link_libraries(CMSIS_5_tfm_ns
359 INTERFACE
360 platform_ns
361)
Xinyu Zhangeebbea32021-09-01 15:26:39 +0800362
363target_compile_definitions(CMSIS_5_tfm_ns
364 INTERFACE
365 $<$<BOOL:${TFM_NS_MANAGE_NSID}>:TFM_NS_MANAGE_NSID>
366)