Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 1 | #------------------------------------------------------------------------------- |
Ken Liu | 55ba01f | 2021-01-20 17:34:50 +0800 | [diff] [blame] | 2 | # Copyright (c) 2020-2021, Arm Limited. All rights reserved. |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 3 | # |
| 4 | # SPDX-License-Identifier: BSD-3-Clause |
| 5 | # |
| 6 | #------------------------------------------------------------------------------- |
| 7 | |
Raef Coles | 6981732 | 2020-10-19 14:14:14 +0100 | [diff] [blame] | 8 | cmake_minimum_required(VERSION 3.15) |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 9 | |
| 10 | add_library(tfm_spm STATIC) |
| 11 | add_library(tfm_boot_status INTERFACE) |
| 12 | add_library(tfm_arch INTERFACE) |
| 13 | add_library(tfm_utilities INTERFACE) |
| 14 | |
| 15 | set(TFM_PARTITION_PLATFORM ON CACHE BOOL "Enable the TF-M Platform partition") |
| 16 | |
David Hu | f1841af | 2021-09-02 12:50:45 +0800 | [diff] [blame] | 17 | # Generate TF-M version |
| 18 | configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/tfm_version.h.in |
| 19 | ${CMAKE_BINARY_DIR}/generated/secure_fw/spm/include/tfm_version.h) |
| 20 | |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 21 | target_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 Liu | e6f31e5 | 2021-08-16 13:42:25 +0800 | [diff] [blame] | 31 | ${CMAKE_SOURCE_DIR}/secure_fw/include |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 32 | ${CMAKE_BINARY_DIR}/generated |
David Hu | f1841af | 2021-09-02 12:50:45 +0800 | [diff] [blame] | 33 | ${CMAKE_BINARY_DIR}/generated/secure_fw/spm/include |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 34 | $<$<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 | |
| 38 | target_sources(tfm_spm |
| 39 | PRIVATE |
Ken Liu | 55ba01f | 2021-01-20 17:34:50 +0800 | [diff] [blame] | 40 | ffm/tfm_boot_data.c |
| 41 | ffm/tfm_core_utils.c |
| 42 | ffm/utilities.c |
Øyvind Rønningstad | f2c8dad | 2021-01-15 15:33:33 +0100 | [diff] [blame] | 43 | $<$<BOOL:${TFM_EXCEPTION_INFO_DUMP}>:cmsis_psa/exception_info.c> |
Shawn Shan | 90f102f | 2021-02-19 10:45:07 +0800 | [diff] [blame] | 44 | $<$<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] | 45 | $<$<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 Horvath | dadc1ea | 2021-03-12 15:39:25 +0100 | [diff] [blame] | 48 | $<$<AND:$<BOOL:${TFM_MULTI_CORE_TOPOLOGY}>,$<NOT:$<BOOL:${TFM_PLAT_SPECIFIC_MULTI_CORE_COMM}>>>:cmsis_psa/tfm_spe_mailbox.c> |
Ken Liu | 55ba01f | 2021-01-20 17:34:50 +0800 | [diff] [blame] | 49 | $<$<NOT:$<BOOL:${TFM_PSA_API}>>:ffm/tfm_core_mem_check.c> |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 50 | $<$<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 Liu | acd2a57 | 2021-05-12 16:19:04 +0800 | [diff] [blame] | 53 | $<$<BOOL:${TFM_PSA_API}>:cmsis_psa/static_load.c> |
Mingyang Sun | 133a792 | 2021-07-08 16:01:26 +0800 | [diff] [blame] | 54 | $<$<BOOL:${TFM_PSA_API}>:ffm/psa_api.c> |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 55 | $<$<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 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> |
| 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 Coles | 600a463 | 2020-10-15 16:42:35 +0100 | [diff] [blame] | 66 | $<$<AND:$<BOOL:${TFM_PSA_API}>,$<STREQUAL:${CMAKE_SYSTEM_ARCHITECTURE},armv8.1-m.main>>:cmsis_psa/arch/tfm_arch_v8m_main.c> |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 67 | $<$<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 Liu | ea45b0d | 2021-05-22 17:41:25 +0800 | [diff] [blame] | 73 | target_include_directories(tfm_partitions INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/cmsis_psa) |
| 74 | |
Mingyang Sun | d20999f | 2020-10-15 14:53:12 +0800 | [diff] [blame] | 75 | #workaround for arch-test |
| 76 | if (TEST_PSA_API STREQUAL IPC) |
Mingyang Sun | ca27cf0 | 2021-05-11 11:02:50 +0800 | [diff] [blame] | 77 | target_include_directories(tfm_partitions INTERFACE ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests) |
Shawn Shan | 781ef73 | 2021-03-10 14:05:57 +0800 | [diff] [blame] | 78 | target_sources(tfm_psa_rot_partition_driver_partition PRIVATE |
Mingyang Sun | d20999f | 2020-10-15 14:53:12 +0800 | [diff] [blame] | 79 | ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/intermedia_driver_partition_psa.c) |
Shawn Shan | 781ef73 | 2021-03-10 14:05:57 +0800 | [diff] [blame] | 80 | target_sources(tfm_app_rot_partition_client_partition PRIVATE |
Mingyang Sun | d20999f | 2020-10-15 14:53:12 +0800 | [diff] [blame] | 81 | ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/intermedia_client_partition_psa.c) |
Shawn Shan | 781ef73 | 2021-03-10 14:05:57 +0800 | [diff] [blame] | 82 | target_sources(tfm_app_rot_partition_server_partition PRIVATE |
Mingyang Sun | d20999f | 2020-10-15 14:53:12 +0800 | [diff] [blame] | 83 | ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/intermedia_server_partition_psa.c) |
Mingyang Sun | ca27cf0 | 2021-05-11 11:02:50 +0800 | [diff] [blame] | 84 | target_sources(tfm_partitions INTERFACE |
Ken Liu | 4520ce3 | 2021-05-11 22:49:10 +0800 | [diff] [blame] | 85 | ${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 Sun | ca27cf0 | 2021-05-11 11:02:50 +0800 | [diff] [blame] | 88 | ) |
Mingyang Sun | d20999f | 2020-10-15 14:53:12 +0800 | [diff] [blame] | 89 | endif() |
| 90 | |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 91 | target_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 Shan | 781ef73 | 2021-03-10 14:05:57 +0800 | [diff] [blame] | 100 | $<$<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 Hu | f07e97d | 2021-02-15 22:05:40 +0800 | [diff] [blame] | 103 | tfm_fih |
Kevin Peng | 498c45b | 2021-08-31 17:57:15 +0800 | [diff] [blame] | 104 | tfm_sprt |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 105 | ) |
| 106 | |
| 107 | target_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ønningstad | f2c8dad | 2021-01-15 15:33:33 +0100 | [diff] [blame] | 111 | $<$<BOOL:${TFM_EXCEPTION_INFO_DUMP}>:TFM_EXCEPTION_INFO_DUMP> |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 112 | ) |
| 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. |
| 117 | set_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. |
| 124 | set_source_files_properties(tfm_secure_api.c |
| 125 | PROPERTIES |
TTornblom | 611dba1 | 2021-09-30 12:09:38 +0200 | [diff] [blame^] | 126 | 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 Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 130 | ) |
| 131 | |
Raef Coles | d8f6750 | 2020-10-13 10:45:33 +0100 | [diff] [blame] | 132 | ############################ Partition Defs #################################### |
| 133 | |
| 134 | target_compile_definitions(tfm_partition_defs |
| 135 | INTERFACE |
| 136 | $<$<STREQUAL:${TEST_PSA_API},IPC>:PSA_API_TEST_IPC> |
| 137 | ) |
| 138 | |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 139 | ############################ TFM arch ########################################## |
| 140 | |
| 141 | target_include_directories(tfm_arch |
| 142 | INTERFACE |
| 143 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/cmsis_psa/arch> |
| 144 | ) |
| 145 | |
| 146 | ############################ Boot Status ####################################### |
| 147 | |
| 148 | target_include_directories(tfm_boot_status |
| 149 | INTERFACE |
| 150 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> |
| 151 | ) |
| 152 | |
| 153 | ############################ TFM utilities ##################################### |
| 154 | |
| 155 | target_include_directories(tfm_utilities |
| 156 | INTERFACE |
| 157 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> |
| 158 | ) |
| 159 | |
| 160 | ############################ Secure API ######################################## |
| 161 | |
| 162 | target_link_libraries(tfm_secure_api |
Summer Qin | 5a212ec | 2020-11-19 15:48:57 +0800 | [diff] [blame] | 163 | INTERFACE |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 164 | tfm_partitions |
| 165 | ) |
| 166 | |
| 167 | target_include_directories(tfm_secure_api |
Summer Qin | 5a212ec | 2020-11-19 15:48:57 +0800 | [diff] [blame] | 168 | INTERFACE |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 169 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> |
Kevin Peng | fc7b771 | 2021-05-08 13:42:56 +0800 | [diff] [blame] | 170 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/interface> |
| 171 | $<$<NOT:$<BOOL:${TFM_PSA_API}>>:${CMAKE_CURRENT_SOURCE_DIR}/cmsis_func/include> |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 172 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/arch/include> |
| 173 | ) |
| 174 | |
| 175 | ############################# Secure veneers ################################### |
| 176 | |
| 177 | if(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 | ) |
| 186 | endif() |