Kevin Peng | 62a8711 | 2020-07-07 15:07:46 +0800 | [diff] [blame] | 1 | #------------------------------------------------------------------------------- |
Raef Coles | b8f0c31 | 2021-05-26 14:17:37 +0100 | [diff] [blame] | 2 | # Copyright (c) 2020-2022, Arm Limited. All rights reserved. |
Chris Brand | 592c98e | 2022-05-20 14:46:54 -0700 | [diff] [blame^] | 3 | # Copyright (c) 2022 Cypress Semiconductor Corporation (an Infineon company) |
| 4 | # or an affiliate of Cypress Semiconductor Corporation. All rights reserved. |
Kevin Peng | 62a8711 | 2020-07-07 15:07:46 +0800 | [diff] [blame] | 5 | # |
| 6 | # SPDX-License-Identifier: BSD-3-Clause |
| 7 | # |
| 8 | #------------------------------------------------------------------------------- |
| 9 | |
Raef Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 10 | cmake_minimum_required(VERSION 3.13) |
Kevin Peng | 62a8711 | 2020-07-07 15:07:46 +0800 | [diff] [blame] | 11 | project(tfm_ns LANGUAGES ASM C) |
Kevin Peng | 62a8711 | 2020-07-07 15:07:46 +0800 | [diff] [blame] | 12 | |
Raef Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 13 | # 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 Brand | 592c98e | 2022-05-20 14:46:54 -0700 | [diff] [blame^] | 17 | if (EXISTS ${CMAKE_SOURCE_DIR}/platform/ext/target/${TFM_PLATFORM}/preload_ns.cmake) |
Raef Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 18 | include(${CMAKE_SOURCE_DIR}/platform/ext/target/${TFM_PLATFORM}/preload_ns.cmake) |
Raef Coles | 34cffa7 | 2020-10-28 10:27:19 +0000 | [diff] [blame] | 19 | tfm_toolchain_reload_compiler() |
Chris Brand | 592c98e | 2022-05-20 14:46:54 -0700 | [diff] [blame^] | 20 | endif() |
David Hu | 402a298 | 2020-12-17 22:31:04 +0800 | [diff] [blame] | 21 | |
Chris Brand | 592c98e | 2022-05-20 14:46:54 -0700 | [diff] [blame^] | 22 | if (TFM_MULTI_CORE_TOPOLOGY) |
David Hu | 402a298 | 2020-12-17 22:31:04 +0800 | [diff] [blame] | 23 | # 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 Peng | 62a8711 | 2020-07-07 15:07:46 +0800 | [diff] [blame] | 25 | endif() |
| 26 | |
David Hu | 73f259b | 2020-12-07 10:58:41 +0800 | [diff] [blame] | 27 | # 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. |
| 31 | set(INTERFACE_SRC_DIR ${CMAKE_SOURCE_DIR}/interface/src) |
| 32 | set(INTERFACE_INC_DIR ${CMAKE_SOURCE_DIR}/interface/include) |
| 33 | |
David Hu | cdc51fb | 2021-04-06 18:10:46 +0800 | [diff] [blame] | 34 | # NS interface implemented by NSPE |
| 35 | set(NS_INTERFACE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../ns_interface) |
| 36 | |
Xinyu Zhang | eebbea3 | 2021-09-01 15:26:39 +0800 | [diff] [blame] | 37 | # nsid_manager |
| 38 | set(NSID_MGR_DIR ${NS_INTERFACE_DIR}/ns_client_ext) |
| 39 | |
David Hu | 73f259b | 2020-12-07 10:58:41 +0800 | [diff] [blame] | 40 | #################### TF-M NS interface (header only) ########################### |
| 41 | |
| 42 | add_library(tfm_ns_interface INTERFACE) |
| 43 | |
David Hu | cdc51fb | 2021-04-06 18:10:46 +0800 | [diff] [blame] | 44 | # Include interface headers exported by TF-M |
David Hu | 73f259b | 2020-12-07 10:58:41 +0800 | [diff] [blame] | 45 | target_include_directories(tfm_ns_interface |
| 46 | INTERFACE |
| 47 | ${INTERFACE_INC_DIR} |
| 48 | ${CMAKE_BINARY_DIR}/generated/interface/include |
David Hu | 8e68325 | 2020-12-17 18:02:32 +0800 | [diff] [blame] | 49 | $<$<BOOL:${TFM_MULTI_CORE_TOPOLOGY}>:${INTERFACE_INC_DIR}/multi_core> |
David Hu | 98adf32 | 2020-09-01 16:18:46 +0800 | [diff] [blame] | 50 | $<$<BOOL:${TFM_MULTI_CORE_TOPOLOGY}>:${CMAKE_SOURCE_DIR}/platform/ext/cmsis> |
David Hu | 73f259b | 2020-12-07 10:58:41 +0800 | [diff] [blame] | 51 | ) |
| 52 | |
David Hu | cdc51fb | 2021-04-06 18:10:46 +0800 | [diff] [blame] | 53 | # Include NS local interface headers |
| 54 | target_include_directories(tfm_ns_interface |
| 55 | INTERFACE |
| 56 | ${NS_INTERFACE_DIR} |
Xinyu Zhang | eebbea3 | 2021-09-01 15:26:39 +0800 | [diff] [blame] | 57 | ${NSID_MGR_DIR} |
David Hu | cdc51fb | 2021-04-06 18:10:46 +0800 | [diff] [blame] | 58 | ) |
| 59 | |
David Hu | 73f259b | 2020-12-07 10:58:41 +0800 | [diff] [blame] | 60 | # PSA interface files are generated from a template |
| 61 | add_dependencies(tfm_ns_interface |
| 62 | tfm_generated_files |
| 63 | ) |
| 64 | |
| 65 | # Include selection of Secure Partitions from TF-M build. |
| 66 | # It can be replaced by NS side configurations later. |
| 67 | target_link_libraries(tfm_ns_interface |
| 68 | INTERFACE |
| 69 | tfm_partition_defs |
| 70 | ) |
| 71 | |
| 72 | target_compile_definitions(tfm_ns_interface |
| 73 | INTERFACE |
| 74 | $<$<BOOL:${TFM_PSA_API}>:TFM_PSA_API> |
| 75 | $<$<STREQUAL:${TEST_PSA_API},IPC>:PSA_API_TEST_IPC> |
Xinyu Zhang | eebbea3 | 2021-09-01 15:26:39 +0800 | [diff] [blame] | 76 | $<$<BOOL:${TFM_NS_MANAGE_NSID}>:TFM_NS_MANAGE_NSID> |
Xinyu Zhang | 92fe758 | 2021-09-24 17:11:49 +0800 | [diff] [blame] | 77 | $<$<BOOL:${TEST_NS_MANAGE_NSID}>:TEST_NS_MANAGE_NSID> |
David Hu | 73f259b | 2020-12-07 10:58:41 +0800 | [diff] [blame] | 78 | $<$<BOOL:${TFM_MULTI_CORE_TOPOLOGY}>:TFM_MULTI_CORE_TOPOLOGY> |
David Hu | 402a298 | 2020-12-17 22:31:04 +0800 | [diff] [blame] | 79 | $<$<BOOL:${TFM_MULTI_CORE_NS_OS}>:TFM_MULTI_CORE_NS_OS> |
David Hu | 98adf32 | 2020-09-01 16:18:46 +0800 | [diff] [blame] | 80 | $<$<AND:$<BOOL:${TFM_MULTI_CORE_NS_OS_MAILBOX_THREAD}>,$<BOOL:${TFM_MULTI_CORE_NS_OS}>>:TFM_MULTI_CORE_NS_OS_MAILBOX_THREAD> |
David Hu | 73f259b | 2020-12-07 10:58:41 +0800 | [diff] [blame] | 81 | $<$<BOOL:${FORWARD_PROT_MSG}>:FORWARD_PROT_MSG> |
| 82 | ) |
| 83 | |
Kevin Peng | 06108cd | 2022-06-09 11:37:39 +0800 | [diff] [blame] | 84 | target_compile_options(tfm_ns_interface |
| 85 | INTERFACE |
| 86 | ${COMPILER_CP_FLAG} |
| 87 | ) |
| 88 | |
David Hu | 73f259b | 2020-12-07 10:58:41 +0800 | [diff] [blame] | 89 | ###################### TF-M NS interface api (NS lib) ########################## |
| 90 | |
| 91 | add_library(tfm_api_ns STATIC) |
| 92 | |
Xinyu Zhang | eebbea3 | 2021-09-01 15:26:39 +0800 | [diff] [blame] | 93 | target_sources(tfm_api_ns |
| 94 | PRIVATE |
| 95 | $<$<BOOL:${TFM_NS_MANAGE_NSID}>:${NSID_MGR_DIR}/tfm_nsid_manager.c> |
| 96 | ) |
| 97 | |
David Hu | 73f259b | 2020-12-07 10:58:41 +0800 | [diff] [blame] | 98 | if (${TFM_PSA_API}) |
| 99 | target_sources(tfm_api_ns PRIVATE |
Jianliang Shen | 7a814e4 | 2021-10-18 15:25:39 +0800 | [diff] [blame] | 100 | $<$<OR:$<BOOL:${FORWARD_PROT_MSG}>,$<BOOL:${TFM_PARTITION_PLATFORM}>>:${INTERFACE_SRC_DIR}/tfm_platform_ipc_api.c> |
| 101 | $<$<OR:$<BOOL:${FORWARD_PROT_MSG}>,$<BOOL:${TFM_PARTITION_PROTECTED_STORAGE}>>:${INTERFACE_SRC_DIR}/tfm_ps_ipc_api.c> |
| 102 | $<$<OR:$<BOOL:${FORWARD_PROT_MSG}>,$<BOOL:${TFM_PARTITION_INTERNAL_TRUSTED_STORAGE}>>:${INTERFACE_SRC_DIR}/tfm_its_ipc_api.c> |
| 103 | $<$<OR:$<BOOL:${FORWARD_PROT_MSG}>,$<BOOL:${TFM_PARTITION_CRYPTO}>>:${INTERFACE_SRC_DIR}/tfm_crypto_ipc_api.c> |
| 104 | $<$<OR:$<BOOL:${FORWARD_PROT_MSG}>,$<BOOL:${TFM_PARTITION_INITIAL_ATTESTATION}>>:${INTERFACE_SRC_DIR}/tfm_initial_attestation_ipc_api.c> |
Sherry Zhang | 92c499a | 2021-03-08 18:14:15 +0800 | [diff] [blame] | 105 | $<$<BOOL:${TFM_PARTITION_FIRMWARE_UPDATE}>:${INTERFACE_SRC_DIR}/tfm_firmware_update_ipc_api.c> |
| 106 | ) |
David Hu | 73f259b | 2020-12-07 10:58:41 +0800 | [diff] [blame] | 107 | |
| 108 | if (TFM_MULTI_CORE_TOPOLOGY) |
| 109 | target_sources(tfm_api_ns PRIVATE |
David Hu | 8e68325 | 2020-12-17 18:02:32 +0800 | [diff] [blame] | 110 | ${INTERFACE_SRC_DIR}/multi_core/tfm_multi_core_ns_api.c |
| 111 | ${INTERFACE_SRC_DIR}/multi_core/tfm_multi_core_psa_ns_api.c |
David Hu | 98adf32 | 2020-09-01 16:18:46 +0800 | [diff] [blame] | 112 | $<$<NOT:$<BOOL:${TFM_MULTI_CORE_NS_OS_MAILBOX_THREAD}>>:${INTERFACE_SRC_DIR}/multi_core/tfm_ns_mailbox.c> |
| 113 | $<$<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 Hu | 73f259b | 2020-12-07 10:58:41 +0800 | [diff] [blame] | 114 | ) |
David Hu | cdc51fb | 2021-04-06 18:10:46 +0800 | [diff] [blame] | 115 | |
| 116 | # NS RTOS specific implementation of NS mailbox |
| 117 | target_sources(tfm_api_ns PRIVATE |
| 118 | $<$<BOOL:${TFM_MULTI_CORE_NS_OS}>:${NS_INTERFACE_DIR}/multi_core/tfm_ns_mailbox_rtos_api.c> |
shejia01 | e0dd80a | 2021-07-12 17:47:50 +0800 | [diff] [blame] | 119 | $<$<BOOL:${TEST_NS_MULTI_CORE}>:${NS_INTERFACE_DIR}/multi_core/tfm_ns_mailbox_test.c> |
David Hu | cdc51fb | 2021-04-06 18:10:46 +0800 | [diff] [blame] | 120 | ) |
David Hu | 73f259b | 2020-12-07 10:58:41 +0800 | [diff] [blame] | 121 | else() |
| 122 | target_sources(tfm_api_ns PRIVATE |
David Hu | 73f259b | 2020-12-07 10:58:41 +0800 | [diff] [blame] | 123 | ${INTERFACE_SRC_DIR}/tfm_psa_ns_api.c |
| 124 | ) |
David Hu | cdc51fb | 2021-04-06 18:10:46 +0800 | [diff] [blame] | 125 | |
| 126 | # NS specific implementation of NS interface dispacther |
| 127 | target_sources(tfm_api_ns PRIVATE |
| 128 | ${CMAKE_CURRENT_SOURCE_DIR}/tfm_ns_interface.c |
| 129 | ) |
David Hu | 73f259b | 2020-12-07 10:58:41 +0800 | [diff] [blame] | 130 | endif() |
| 131 | else() |
| 132 | target_sources(tfm_api_ns PRIVATE |
| 133 | $<$<BOOL:${TFM_PARTITION_PLATFORM}>:${INTERFACE_SRC_DIR}/tfm_platform_func_api.c> |
| 134 | $<$<BOOL:${TFM_PARTITION_AUDIT_LOG}>:${INTERFACE_SRC_DIR}/tfm_audit_func_api.c> |
| 135 | $<$<BOOL:${TFM_PARTITION_PROTECTED_STORAGE}>:${INTERFACE_SRC_DIR}/tfm_ps_func_api.c> |
| 136 | $<$<BOOL:${TFM_PARTITION_INTERNAL_TRUSTED_STORAGE}>:${INTERFACE_SRC_DIR}/tfm_its_func_api.c> |
| 137 | $<$<BOOL:${TFM_PARTITION_CRYPTO}>:${INTERFACE_SRC_DIR}/tfm_crypto_func_api.c> |
| 138 | $<$<BOOL:${TFM_PARTITION_INITIAL_ATTESTATION}>:${INTERFACE_SRC_DIR}/tfm_initial_attestation_func_api.c> |
Sherry Zhang | 92c499a | 2021-03-08 18:14:15 +0800 | [diff] [blame] | 139 | $<$<BOOL:${TFM_PARTITION_FIRMWARE_UPDATE}>:${INTERFACE_SRC_DIR}/tfm_firmware_update_func_api.c> |
David Hu | cdc51fb | 2021-04-06 18:10:46 +0800 | [diff] [blame] | 140 | ) |
| 141 | |
| 142 | # NS specific implementation of NS interface dispacther |
| 143 | target_sources(tfm_api_ns PRIVATE |
| 144 | ${CMAKE_CURRENT_SOURCE_DIR}/tfm_ns_interface.c |
David Hu | 73f259b | 2020-12-07 10:58:41 +0800 | [diff] [blame] | 145 | ) |
| 146 | endif() |
| 147 | |
| 148 | target_link_libraries(tfm_api_ns |
| 149 | PUBLIC |
| 150 | tfm_ns_interface |
| 151 | PRIVATE |
Sherry Zhang | 8342d7d | 2021-10-14 17:57:26 +0800 | [diff] [blame] | 152 | $<$<NOT:$<BOOL:${TFM_MULTI_CORE_TOPOLOGY}>>:tfm_s_veneers> |
David Hu | 73f259b | 2020-12-07 10:58:41 +0800 | [diff] [blame] | 153 | platform_ns |
David Hu | 73f259b | 2020-12-07 10:58:41 +0800 | [diff] [blame] | 154 | ) |
| 155 | |
Raef Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 156 | ############################# PSA test integration ############################# |
| 157 | |
Raef Coles | c922f25 | 2020-10-05 10:49:30 +0100 | [diff] [blame] | 158 | if(TEST_PSA_API AND NOT PSA_ARCH_TESTS_BINARY_PATH) |
| 159 | if(NOT SUITE) |
| 160 | set(SUITE ${TEST_PSA_API}) |
| 161 | endif() |
Raef Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 162 | |
Øyvind Rønningstad | 205a34a | 2020-10-02 10:31:23 +0200 | [diff] [blame] | 163 | if (NOT DEFINED PSA_API_TEST_TARGET) |
| 164 | string(REGEX REPLACE ".*/" "" PSA_API_TEST_TARGET ${TFM_PLATFORM}) |
| 165 | endif() |
Raef Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 166 | |
Raef Coles | c922f25 | 2020-10-05 10:49:30 +0100 | [diff] [blame] | 167 | if(NOT TARGET) |
| 168 | if (NOT "${TEST_PSA_API}" STREQUAL "IPC") |
| 169 | set(TARGET tgt_dev_apis_tfm_${PSA_API_TEST_TARGET}) |
| 170 | else() |
| 171 | set(TARGET tgt_ff_tfm_${PSA_API_TEST_TARGET}) |
| 172 | endif() |
Raef Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 173 | endif() |
| 174 | |
Raef Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 175 | |
Raef Coles | c922f25 | 2020-10-05 10:49:30 +0100 | [diff] [blame] | 176 | if(NOT PSA_INCLUDE_PATHS) |
David Hu | a1fee3d | 2020-12-30 11:06:37 +0800 | [diff] [blame] | 177 | set(PSA_INCLUDE_PATHS ${INTERFACE_INC_DIR}/ |
Raef Coles | 23d6a19 | 2020-10-22 15:43:38 +0100 | [diff] [blame] | 178 | ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/ |
Raef Coles | c922f25 | 2020-10-05 10:49:30 +0100 | [diff] [blame] | 179 | ${CMAKE_BINARY_DIR}/generated/interface/include |
| 180 | ) |
Raef Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 181 | endif() |
| 182 | |
Raef Coles | c922f25 | 2020-10-05 10:49:30 +0100 | [diff] [blame] | 183 | if(NOT SP_HEAP_MEM_SUPP) |
Raef Coles | 06e6f65 | 2020-10-20 16:10:38 +0100 | [diff] [blame] | 184 | set(SP_HEAP_MEM_SUPP 0) |
Raef Coles | c922f25 | 2020-10-05 10:49:30 +0100 | [diff] [blame] | 185 | endif() |
| 186 | if(NOT PLATFORM_PSA_ISOLATION_LEVEL) |
| 187 | set(PLATFORM_PSA_ISOLATION_LEVEL ${TFM_ISOLATION_LEVEL}) |
| 188 | endif() |
| 189 | |
| 190 | if (NOT TOOLCHAIN) |
| 191 | if (${CMAKE_C_COMPILER_ID} STREQUAL GNU) |
| 192 | set(TOOLCHAIN GNUARM) |
| 193 | elseif (${CMAKE_C_COMPILER_ID} STREQUAL ARMClang) |
| 194 | set(TOOLCHAIN ARMCLANG) |
| 195 | endif() |
| 196 | endif() |
| 197 | |
| 198 | if (NOT CPU_ARCH) |
Chris Brand | ddcf529 | 2021-10-27 13:50:35 -0700 | [diff] [blame] | 199 | if (${TFM_SYSTEM_ARCHITECTURE} STREQUAL armv8-m.main) |
Raef Coles | c922f25 | 2020-10-05 10:49:30 +0100 | [diff] [blame] | 200 | set(CPU_ARCH armv8m_ml) |
Chris Brand | ddcf529 | 2021-10-27 13:50:35 -0700 | [diff] [blame] | 201 | elseif (${TFM_SYSTEM_ARCHITECTURE} STREQUAL armv8-m.base) |
Raef Coles | c922f25 | 2020-10-05 10:49:30 +0100 | [diff] [blame] | 202 | set(CPU_ARCH armv8m_bl) |
Chris Brand | ddcf529 | 2021-10-27 13:50:35 -0700 | [diff] [blame] | 203 | elseif (${TFM_SYSTEM_ARCHITECTURE} STREQUAL armv7-m) |
Raef Coles | c922f25 | 2020-10-05 10:49:30 +0100 | [diff] [blame] | 204 | set(CPU_ARCH armv7m) |
| 205 | endif() |
Raef Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 206 | endif() |
| 207 | |
| 208 | add_subdirectory(${PSA_ARCH_TESTS_PATH}/api-tests ${CMAKE_CURRENT_BINARY_DIR}/psa_api_tests) |
Raef Coles | 4817eb8 | 2022-01-18 12:33:24 +0000 | [diff] [blame] | 209 | |
| 210 | if (TEST_PSA_API STREQUAL IPC) |
| 211 | target_include_directories(tfm_partitions |
| 212 | INTERFACE |
| 213 | ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests |
| 214 | ) |
| 215 | |
| 216 | target_sources(tfm_psa_rot_partition_driver_partition |
| 217 | PRIVATE |
| 218 | ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/intermedia_driver_partition_psa.c |
| 219 | ) |
| 220 | target_link_libraries(tfm_psa_rot_partition_driver_partition |
| 221 | PRIVATE |
| 222 | psa_interface |
| 223 | platform_s |
| 224 | ) |
| 225 | target_compile_definitions(tfm_psa_rot_partition_driver_partition |
| 226 | PRIVATE |
| 227 | CONFIG_TFM_BUILDING_SPE=1 |
| 228 | TFM_LVL=${TFM_ISOLATION_LEVEL} |
| 229 | ) |
| 230 | |
| 231 | target_sources(tfm_app_rot_partition_client_partition |
| 232 | PRIVATE |
| 233 | ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/intermedia_client_partition_psa.c |
| 234 | ) |
| 235 | target_link_libraries(tfm_app_rot_partition_client_partition |
| 236 | PRIVATE |
| 237 | psa_interface |
| 238 | platform_s |
| 239 | ) |
| 240 | target_compile_definitions(tfm_app_rot_partition_client_partition |
| 241 | PRIVATE |
| 242 | CONFIG_TFM_BUILDING_SPE=1 |
| 243 | TFM_LVL=${TFM_ISOLATION_LEVEL} |
| 244 | ) |
| 245 | |
| 246 | target_sources(tfm_app_rot_partition_server_partition |
| 247 | PRIVATE |
| 248 | ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/intermedia_server_partition_psa.c |
| 249 | ) |
| 250 | target_link_libraries(tfm_app_rot_partition_server_partition |
| 251 | PRIVATE |
| 252 | psa_interface |
| 253 | platform_s |
| 254 | ) |
| 255 | target_compile_definitions(tfm_app_rot_partition_server_partition |
| 256 | PRIVATE |
| 257 | CONFIG_TFM_BUILDING_SPE=1 |
| 258 | TFM_LVL=${TFM_ISOLATION_LEVEL} |
| 259 | ) |
| 260 | |
| 261 | target_sources(tfm_partitions |
| 262 | INTERFACE |
| 263 | ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/load_info_driver_partition_psa.c |
| 264 | ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/load_info_client_partition_psa.c |
| 265 | ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/load_info_server_partition_psa.c |
| 266 | ) |
| 267 | |
| 268 | target_link_libraries(tfm_partitions |
| 269 | INTERFACE |
| 270 | tfm_psa_rot_partition_driver_partition |
| 271 | tfm_app_rot_partition_client_partition |
| 272 | tfm_app_rot_partition_server_partition |
| 273 | ) |
| 274 | endif() |
Kevin Peng | 62a8711 | 2020-07-07 15:07:46 +0800 | [diff] [blame] | 275 | endif() |
| 276 | |
Raef Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 277 | ############################# Test integration ################################# |
Kevin Peng | 62a8711 | 2020-07-07 15:07:46 +0800 | [diff] [blame] | 278 | |
Kevin Peng | 342ec68 | 2022-04-29 10:36:58 +0800 | [diff] [blame] | 279 | add_library(tfm_test_app STATIC EXCLUDE_FROM_ALL) |
Kevin Peng | 62a8711 | 2020-07-07 15:07:46 +0800 | [diff] [blame] | 280 | |
Kevin Peng | 342ec68 | 2022-04-29 10:36:58 +0800 | [diff] [blame] | 281 | target_sources(tfm_test_app |
Raef Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 282 | PRIVATE |
Kevin Peng | 342ec68 | 2022-04-29 10:36:58 +0800 | [diff] [blame] | 283 | test_app.c |
Raef Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 284 | ) |
Kevin Peng | 62a8711 | 2020-07-07 15:07:46 +0800 | [diff] [blame] | 285 | |
Kevin Peng | 342ec68 | 2022-04-29 10:36:58 +0800 | [diff] [blame] | 286 | target_include_directories(tfm_test_app |
Raef Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 287 | PUBLIC |
| 288 | . |
| 289 | ) |
Kevin Peng | 62a8711 | 2020-07-07 15:07:46 +0800 | [diff] [blame] | 290 | |
Kevin Peng | 342ec68 | 2022-04-29 10:36:58 +0800 | [diff] [blame] | 291 | target_link_libraries(tfm_test_app |
Raef Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 292 | PRIVATE |
David Hu | acba69e | 2021-09-10 15:36:48 +0800 | [diff] [blame] | 293 | $<$<BOOL:${TEST_FRAMEWORK_NS}>:tfm_ns_tests> |
Kevin Peng | 342ec68 | 2022-04-29 10:36:58 +0800 | [diff] [blame] | 294 | $<$<BOOL:${TEST_PSA_API}>:val_nspe> |
| 295 | $<$<BOOL:${TEST_PSA_API}>:pal_nspe> |
| 296 | $<$<BOOL:${TEST_PSA_API}>:test_combine> |
Kevin Peng | 6e2e435 | 2022-05-11 11:18:54 +0800 | [diff] [blame] | 297 | tfm_api_ns |
Paul Sokolovsky | 5d7925e | 2022-03-15 12:13:53 +0300 | [diff] [blame] | 298 | tfm_log |
Raef Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 299 | ) |
Kevin Peng | 62a8711 | 2020-07-07 15:07:46 +0800 | [diff] [blame] | 300 | |
Kevin Peng | 342ec68 | 2022-04-29 10:36:58 +0800 | [diff] [blame] | 301 | target_compile_definitions(tfm_test_app |
| 302 | PRIVATE |
shejia01 | e0dd80a | 2021-07-12 17:47:50 +0800 | [diff] [blame] | 303 | $<$<BOOL:${TEST_FRAMEWORK_NS}>:TEST_FRAMEWORK_NS> |
| 304 | $<$<BOOL:${TEST_FRAMEWORK_S}>:TEST_FRAMEWORK_S> |
shejia01 | 26b2d78 | 2021-08-19 17:08:24 +0800 | [diff] [blame] | 305 | $<$<BOOL:${TFM_LIB_MODEL}>:TFM_LIB_MODEL> |
Kevin Peng | 342ec68 | 2022-04-29 10:36:58 +0800 | [diff] [blame] | 306 | $<$<BOOL:${TEST_PSA_API}>:PSA_API_TEST_NS> |
Raef Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 307 | ) |
Kevin Peng | 62a8711 | 2020-07-07 15:07:46 +0800 | [diff] [blame] | 308 | |
Raef Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 309 | ############################# TFM NS app ####################################### |
Kevin Peng | 62a8711 | 2020-07-07 15:07:46 +0800 | [diff] [blame] | 310 | |
Raef Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 311 | add_executable(tfm_ns) |
Kevin Peng | 62a8711 | 2020-07-07 15:07:46 +0800 | [diff] [blame] | 312 | |
Raef Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 313 | target_sources(tfm_ns |
| 314 | PRIVATE |
| 315 | main_ns.c |
Raef Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 316 | ) |
Kevin Peng | 62a8711 | 2020-07-07 15:07:46 +0800 | [diff] [blame] | 317 | |
Raef Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 318 | target_link_libraries(tfm_ns |
| 319 | PRIVATE |
| 320 | platform_ns |
| 321 | CMSIS_5_tfm_ns |
Kevin Peng | 342ec68 | 2022-04-29 10:36:58 +0800 | [diff] [blame] | 322 | tfm_test_app |
Raef Coles | b8f0c31 | 2021-05-26 14:17:37 +0100 | [diff] [blame] | 323 | tfm_log |
Raef Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 324 | ) |
Kevin Peng | 62a8711 | 2020-07-07 15:07:46 +0800 | [diff] [blame] | 325 | |
Raef Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 326 | set_target_properties(tfm_ns PROPERTIES |
| 327 | SUFFIX ".axf" |
| 328 | RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin" |
| 329 | ) |
Kevin Peng | 62a8711 | 2020-07-07 15:07:46 +0800 | [diff] [blame] | 330 | |
Raef Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 331 | target_link_options(tfm_ns |
| 332 | PRIVATE |
| 333 | $<$<C_COMPILER_ID:GNU>:-Wl,-Map=${CMAKE_BINARY_DIR}/bin/tfm_ns.map> |
| 334 | $<$<C_COMPILER_ID:ARMClang>:--map> |
TTornblom | d35ffa0 | 2020-09-29 13:31:31 +0200 | [diff] [blame] | 335 | $<$<C_COMPILER_ID:IAR>:--map\;${CMAKE_BINARY_DIR}/bin/tfm_ns.map> |
Raef Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 336 | ) |
Kevin Peng | 62a8711 | 2020-07-07 15:07:46 +0800 | [diff] [blame] | 337 | |
Raef Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 338 | add_convert_to_bin_target(tfm_ns) |
Kevin Peng | 62a8711 | 2020-07-07 15:07:46 +0800 | [diff] [blame] | 339 | |
Raef Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 340 | ############################# CMSIS ############################################ |
Kevin Peng | 62a8711 | 2020-07-07 15:07:46 +0800 | [diff] [blame] | 341 | |
Raef Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 342 | include(FetchContent) |
Kevin Peng | 62a8711 | 2020-07-07 15:07:46 +0800 | [diff] [blame] | 343 | |
Raef Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 344 | set(FETCHCONTENT_QUIET FALSE) |
| 345 | cmake_policy(SET CMP0079 NEW) |
Kevin Peng | 62a8711 | 2020-07-07 15:07:46 +0800 | [diff] [blame] | 346 | |
Raef Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 347 | add_library(CMSIS_5_tfm_ns INTERFACE) |
Kevin Peng | 62a8711 | 2020-07-07 15:07:46 +0800 | [diff] [blame] | 348 | |
Raef Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 349 | target_sources(CMSIS_5_tfm_ns |
| 350 | INTERFACE |
Xinyu Zhang | eebbea3 | 2021-09-01 15:26:39 +0800 | [diff] [blame] | 351 | ${NSID_MGR_DIR}/tz_shim_layer.c |
Raef Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 352 | ${CMSIS_5_PATH}/RTOS2/RTX/Config/RTX_Config.c |
| 353 | ${CMSIS_5_PATH}/RTOS2/RTX/Source/rtx_lib.c |
| 354 | ${CMAKE_CURRENT_SOURCE_DIR}/os_wrapper_cmsis_rtos_v2.c |
Xinyu Zhang | eebbea3 | 2021-09-01 15:26:39 +0800 | [diff] [blame] | 355 | $<$<BOOL:${TFM_NS_MANAGE_NSID}>:${CMAKE_CURRENT_SOURCE_DIR}/tfm_nsid_map_table.c> |
Raef Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 356 | ) |
Kevin Peng | 62a8711 | 2020-07-07 15:07:46 +0800 | [diff] [blame] | 357 | |
Raef Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 358 | target_include_directories(CMSIS_5_tfm_ns |
| 359 | INTERFACE |
| 360 | ${CMSIS_5_PATH}/Core/Include |
| 361 | ${CMSIS_5_PATH}/RTOS2/Include |
| 362 | ${CMSIS_5_PATH}/RTOS2/RTX/Include |
| 363 | ${CMSIS_5_PATH}/RTOS2/RTX/Config |
Xinyu Zhang | eebbea3 | 2021-09-01 15:26:39 +0800 | [diff] [blame] | 364 | $<$<BOOL:${TFM_NS_MANAGE_NSID}>:${CMAKE_CURRENT_SOURCE_DIR}> |
Raef Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 365 | ) |
Kevin Peng | 62a8711 | 2020-07-07 15:07:46 +0800 | [diff] [blame] | 366 | |
Raef Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 367 | target_link_libraries(CMSIS_5_tfm_ns |
| 368 | INTERFACE |
| 369 | platform_ns |
| 370 | ) |
Xinyu Zhang | eebbea3 | 2021-09-01 15:26:39 +0800 | [diff] [blame] | 371 | |
| 372 | target_compile_definitions(CMSIS_5_tfm_ns |
| 373 | INTERFACE |
| 374 | $<$<BOOL:${TFM_NS_MANAGE_NSID}>:TFM_NS_MANAGE_NSID> |
| 375 | ) |