Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 1 | #------------------------------------------------------------------------------- |
Sherry Zhang | f58f2bd | 2022-01-10 17:21:11 +0800 | [diff] [blame] | 2 | # Copyright (c) 2020-2022, Arm Limited. All rights reserved. |
Chris Brand | 56b4d0c | 2021-12-17 16:15:58 -0800 | [diff] [blame] | 3 | # Copyright (c) 2021, Cypress Semiconductor Corporation. All rights reserved. |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 4 | # |
| 5 | # SPDX-License-Identifier: BSD-3-Clause |
| 6 | # |
| 7 | #------------------------------------------------------------------------------- |
| 8 | |
Raef Coles | 6981732 | 2020-10-19 14:14:14 +0100 | [diff] [blame] | 9 | cmake_minimum_required(VERSION 3.15) |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 10 | |
| 11 | add_library(tfm_spm STATIC) |
| 12 | add_library(tfm_boot_status INTERFACE) |
| 13 | add_library(tfm_arch INTERFACE) |
| 14 | add_library(tfm_utilities INTERFACE) |
| 15 | |
| 16 | set(TFM_PARTITION_PLATFORM ON CACHE BOOL "Enable the TF-M Platform partition") |
| 17 | |
David Hu | f1841af | 2021-09-02 12:50:45 +0800 | [diff] [blame] | 18 | # Generate TF-M version |
| 19 | configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/tfm_version.h.in |
| 20 | ${CMAKE_BINARY_DIR}/generated/secure_fw/spm/include/tfm_version.h) |
| 21 | |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 22 | target_include_directories(tfm_spm |
| 23 | PUBLIC |
| 24 | ${CMAKE_CURRENT_SOURCE_DIR} |
| 25 | ${CMAKE_CURRENT_SOURCE_DIR}/include |
| 26 | $<$<BOOL:${TFM_PSA_API}>:${CMAKE_CURRENT_SOURCE_DIR}/cmsis_psa> |
| 27 | $<$<BOOL:${TFM_PSA_API}>:${CMAKE_CURRENT_SOURCE_DIR}/cmsis_psa/include> |
| 28 | $<$<NOT:$<BOOL:${TFM_PSA_API}>>:${CMAKE_CURRENT_SOURCE_DIR}/cmsis_func> |
| 29 | $<$<NOT:$<BOOL:${TFM_PSA_API}>>:${CMAKE_CURRENT_SOURCE_DIR}/cmsis_func/include> |
| 30 | PRIVATE |
| 31 | ${CMAKE_SOURCE_DIR} |
Ken Liu | e6f31e5 | 2021-08-16 13:42:25 +0800 | [diff] [blame] | 32 | ${CMAKE_SOURCE_DIR}/secure_fw/include |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 33 | ${CMAKE_BINARY_DIR}/generated |
David Hu | f1841af | 2021-09-02 12:50:45 +0800 | [diff] [blame] | 34 | ${CMAKE_BINARY_DIR}/generated/secure_fw/spm/include |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 35 | $<$<BOOL:${TFM_PSA_API}>:${CMAKE_BINARY_DIR}/generated/secure_fw/spm/cmsis_psa> |
| 36 | $<$<NOT:$<BOOL:${TFM_PSA_API}>>:${CMAKE_BINARY_DIR}/generated/secure_fw/spm/cmsis_func> |
| 37 | ) |
| 38 | |
| 39 | target_sources(tfm_spm |
| 40 | PRIVATE |
Ken Liu | 55ba01f | 2021-01-20 17:34:50 +0800 | [diff] [blame] | 41 | ffm/tfm_boot_data.c |
| 42 | ffm/tfm_core_utils.c |
| 43 | ffm/utilities.c |
Øyvind Rønningstad | f2c8dad | 2021-01-15 15:33:33 +0100 | [diff] [blame] | 44 | $<$<BOOL:${TFM_EXCEPTION_INFO_DUMP}>:cmsis_psa/exception_info.c> |
Shawn Shan | 90f102f | 2021-02-19 10:45:07 +0800 | [diff] [blame] | 45 | $<$<NOT:$<STREQUAL:${TFM_SPM_LOG_LEVEL},TFM_SPM_LOG_LEVEL_SILENCE>>:ffm/spm_log.c> |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 46 | $<$<BOOL:${TFM_MULTI_CORE_TOPOLOGY}>:cmsis_psa/tfm_multi_core_mem_check.c> |
Ken Liu | 55ba01f | 2021-01-20 17:34:50 +0800 | [diff] [blame] | 47 | $<$<NOT:$<BOOL:${TFM_PSA_API}>>:ffm/tfm_core_mem_check.c> |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 48 | $<$<BOOL:${TFM_PSA_API}>:cmsis_psa/arch/tfm_arch.c> |
| 49 | $<$<BOOL:${TFM_PSA_API}>:cmsis_psa/main.c> |
| 50 | $<$<BOOL:${TFM_PSA_API}>:cmsis_psa/spm_ipc.c> |
Sherry Zhang | f58f2bd | 2022-01-10 17:21:11 +0800 | [diff] [blame] | 51 | $<$<BOOL:${CONFIG_TFM_PSA_API_CROSS_CALL}>:cmsis_psa/spm_cross_call.c> |
Ken Liu | acd2a57 | 2021-05-12 16:19:04 +0800 | [diff] [blame] | 52 | $<$<BOOL:${TFM_PSA_API}>:cmsis_psa/static_load.c> |
Mingyang Sun | 133a792 | 2021-07-08 16:01:26 +0800 | [diff] [blame] | 53 | $<$<BOOL:${TFM_PSA_API}>:ffm/psa_api.c> |
Ken Liu | f39d8eb | 2021-10-07 12:55:33 +0800 | [diff] [blame] | 54 | $<$<BOOL:${TFM_PSA_API}>:ffm/backend.c> |
Kevin Peng | 3f67b2e | 2021-10-18 17:47:27 +0800 | [diff] [blame] | 55 | $<$<BOOL:${TFM_PSA_API}>:ffm/interrupt.c> |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 56 | $<$<BOOL:${TFM_PSA_API}>:cmsis_psa/tfm_core_svcalls_ipc.c> |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 57 | $<$<BOOL:${TFM_PSA_API}>:cmsis_psa/tfm_pools.c> |
Ken Liu | 5d73c87 | 2021-08-19 19:23:17 +0800 | [diff] [blame] | 58 | $<$<BOOL:${TFM_PSA_API}>:cmsis_psa/thread.c> |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 59 | $<$<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> |
Chris Brand | 56b4d0c | 2021-12-17 16:15:58 -0800 | [diff] [blame] | 63 | $<$<BOOL:${TFM_NS_MANAGE_NSID}>:ns_client_ext/tfm_ns_ctx.c> |
| 64 | ns_client_ext/tfm_spm_ns_ctx.c |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 65 | $<$<NOT:$<BOOL:${TFM_PSA_API}>>:cmsis_func/tfm_secure_api.c> |
| 66 | #TODO add other arches |
Gabor Abonyi | 866571c | 2021-10-07 13:56:19 +0200 | [diff] [blame] | 67 | $<$<AND:$<BOOL:${TFM_PSA_API}>,$<STREQUAL:${TFM_SYSTEM_ARCHITECTURE},armv8.1-m.main>>:cmsis_psa/arch/tfm_arch_v8m_main.c> |
| 68 | $<$<AND:$<BOOL:${TFM_PSA_API}>,$<STREQUAL:${TFM_SYSTEM_ARCHITECTURE},armv8-m.base>>:cmsis_psa/arch/tfm_arch_v8m_base.c> |
| 69 | $<$<AND:$<BOOL:${TFM_PSA_API}>,$<STREQUAL:${TFM_SYSTEM_ARCHITECTURE},armv8-m.main>>:cmsis_psa/arch/tfm_arch_v8m_main.c> |
| 70 | $<$<AND:$<BOOL:${TFM_PSA_API}>,$<STREQUAL:${TFM_SYSTEM_ARCHITECTURE},armv6-m>>:cmsis_psa/arch/tfm_arch_v6m_v7m.c> |
| 71 | $<$<AND:$<BOOL:${TFM_PSA_API}>,$<STREQUAL:${TFM_SYSTEM_ARCHITECTURE},armv7-m>>:cmsis_psa/arch/tfm_arch_v6m_v7m.c> |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 72 | ) |
| 73 | |
Ken Liu | ea45b0d | 2021-05-22 17:41:25 +0800 | [diff] [blame] | 74 | target_include_directories(tfm_partitions INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/cmsis_psa) |
| 75 | |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 76 | target_link_libraries(tfm_spm |
| 77 | PUBLIC |
| 78 | tfm_arch |
| 79 | PRIVATE |
| 80 | psa_interface |
| 81 | platform_s |
| 82 | tfm_boot_status |
| 83 | tfm_secure_api |
| 84 | tfm_partitions |
David Hu | f07e97d | 2021-02-15 22:05:40 +0800 | [diff] [blame] | 85 | tfm_fih |
Kevin Peng | 498c45b | 2021-08-31 17:57:15 +0800 | [diff] [blame] | 86 | tfm_sprt |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 87 | ) |
| 88 | |
| 89 | target_compile_definitions(tfm_spm |
| 90 | PRIVATE |
| 91 | $<$<CONFIG:Debug>:TFM_CORE_DEBUG> |
| 92 | $<$<AND:$<BOOL:${BL2}>,$<BOOL:${MCUBOOT_MEASURED_BOOT}>>:BOOT_DATA_AVAILABLE> |
Øyvind Rønningstad | f2c8dad | 2021-01-15 15:33:33 +0100 | [diff] [blame] | 93 | $<$<BOOL:${TFM_EXCEPTION_INFO_DUMP}>:TFM_EXCEPTION_INFO_DUMP> |
Sherry Zhnag | 482b88b | 2021-08-19 17:51:47 +0800 | [diff] [blame] | 94 | $<$<BOOL:${TFM_NS_MANAGE_NSID}>:TFM_NS_MANAGE_NSID> |
Sherry Zhang | f58f2bd | 2022-01-10 17:21:11 +0800 | [diff] [blame] | 95 | $<$<BOOL:${CONFIG_TFM_SPM_BACKEND_IPC}>:CONFIG_TFM_SPM_BACKEND_IPC> |
| 96 | $<$<BOOL:${CONFIG_TFM_SPM_BACKEND_SFN}>:CONFIG_TFM_SPM_BACKEND_SFN> |
Feder Liang | 5519438 | 2021-11-22 16:45:33 +0800 | [diff] [blame] | 97 | # CONFIG_TFM_FP |
| 98 | $<$<STREQUAL:${CONFIG_TFM_FP},hard>:CONFIG_TFM_FP=2> |
| 99 | $<$<STREQUAL:${CONFIG_TFM_FP},soft>:CONFIG_TFM_FP=0> |
Feder Liang | d4dbaa9 | 2021-09-07 15:34:46 +0800 | [diff] [blame] | 100 | ) |
| 101 | |
| 102 | target_compile_options(tfm_spm |
| 103 | PUBLIC |
| 104 | ${COMPILER_CP_FLAG} |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 105 | ) |
| 106 | |
| 107 | # The veneers give warnings about not being properly declared so they get hidden |
| 108 | # to not overshadow _real_ warnings. |
| 109 | set_source_files_properties(tfm_secure_api.c |
| 110 | PROPERTIES |
TTornblom | 611dba1 | 2021-09-30 12:09:38 +0200 | [diff] [blame] | 111 | COMPILE_FLAGS |
| 112 | $<$<C_COMPILER_ID:ARMClang>:-Wno-implicit-function-declaration> |
| 113 | $<$<C_COMPILER_ID:GNU>:-Wno-implicit-function-declaration> |
| 114 | $<$<C_COMPILER_ID:IAR>:> |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 115 | ) |
| 116 | |
Raef Coles | d8f6750 | 2020-10-13 10:45:33 +0100 | [diff] [blame] | 117 | ############################ Partition Defs #################################### |
| 118 | |
| 119 | target_compile_definitions(tfm_partition_defs |
| 120 | INTERFACE |
| 121 | $<$<STREQUAL:${TEST_PSA_API},IPC>:PSA_API_TEST_IPC> |
| 122 | ) |
| 123 | |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 124 | ############################ TFM arch ########################################## |
| 125 | |
| 126 | target_include_directories(tfm_arch |
| 127 | INTERFACE |
| 128 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/cmsis_psa/arch> |
| 129 | ) |
| 130 | |
| 131 | ############################ Boot Status ####################################### |
| 132 | |
| 133 | target_include_directories(tfm_boot_status |
| 134 | INTERFACE |
| 135 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> |
| 136 | ) |
| 137 | |
| 138 | ############################ TFM utilities ##################################### |
| 139 | |
| 140 | target_include_directories(tfm_utilities |
| 141 | INTERFACE |
| 142 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> |
| 143 | ) |
| 144 | |
| 145 | ############################ Secure API ######################################## |
| 146 | |
| 147 | target_link_libraries(tfm_secure_api |
Summer Qin | 5a212ec | 2020-11-19 15:48:57 +0800 | [diff] [blame] | 148 | INTERFACE |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 149 | tfm_partitions |
| 150 | ) |
| 151 | |
| 152 | target_include_directories(tfm_secure_api |
Summer Qin | 5a212ec | 2020-11-19 15:48:57 +0800 | [diff] [blame] | 153 | INTERFACE |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 154 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> |
Kevin Peng | fc7b771 | 2021-05-08 13:42:56 +0800 | [diff] [blame] | 155 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/interface> |
| 156 | $<$<NOT:$<BOOL:${TFM_PSA_API}>>:${CMAKE_CURRENT_SOURCE_DIR}/cmsis_func/include> |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 157 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/arch/include> |
| 158 | ) |
| 159 | |
| 160 | ############################# Secure veneers ################################### |
| 161 | |
| 162 | if(NOT TFM_MULTI_CORE_TOPOLOGY) |
| 163 | # If this is added to the spm, it is discarded as it is not used. Since the |
| 164 | # spm is a static library it can't generate veneers under all compilers so |
| 165 | # instead this single file is added to the tfm_s target. |
| 166 | target_sources(tfm_s |
| 167 | PRIVATE |
| 168 | $<$<NOT:$<BOOL:${TFM_PSA_API}>>:${CMAKE_BINARY_DIR}/generated/secure_fw/spm/cmsis_func/tfm_veneers.c> |
Sherry Zhnag | 482b88b | 2021-08-19 17:51:47 +0800 | [diff] [blame] | 169 | $<$<BOOL:${TFM_NS_MANAGE_NSID}>:${CMAKE_CURRENT_SOURCE_DIR}/ns_client_ext/tfm_ns_client_ext.c> |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 170 | ) |
| 171 | endif() |