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 | |
| 17 | target_include_directories(tfm_spm |
| 18 | PUBLIC |
| 19 | ${CMAKE_CURRENT_SOURCE_DIR} |
| 20 | ${CMAKE_CURRENT_SOURCE_DIR}/include |
| 21 | $<$<BOOL:${TFM_PSA_API}>:${CMAKE_CURRENT_SOURCE_DIR}/cmsis_psa> |
| 22 | $<$<BOOL:${TFM_PSA_API}>:${CMAKE_CURRENT_SOURCE_DIR}/cmsis_psa/include> |
| 23 | $<$<NOT:$<BOOL:${TFM_PSA_API}>>:${CMAKE_CURRENT_SOURCE_DIR}/cmsis_func> |
| 24 | $<$<NOT:$<BOOL:${TFM_PSA_API}>>:${CMAKE_CURRENT_SOURCE_DIR}/cmsis_func/include> |
| 25 | PRIVATE |
| 26 | ${CMAKE_SOURCE_DIR} |
| 27 | ${CMAKE_BINARY_DIR}/generated |
| 28 | $<$<BOOL:${TFM_PSA_API}>:${CMAKE_BINARY_DIR}/generated/secure_fw/spm/cmsis_psa> |
| 29 | $<$<NOT:$<BOOL:${TFM_PSA_API}>>:${CMAKE_BINARY_DIR}/generated/secure_fw/spm/cmsis_func> |
| 30 | ) |
| 31 | |
| 32 | target_sources(tfm_spm |
| 33 | PRIVATE |
Ken Liu | 55ba01f | 2021-01-20 17:34:50 +0800 | [diff] [blame] | 34 | ffm/tfm_boot_data.c |
| 35 | ffm/tfm_core_utils.c |
| 36 | ffm/utilities.c |
Shawn Shan | 90f102f | 2021-02-19 10:45:07 +0800 | [diff] [blame] | 37 | $<$<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] | 38 | $<$<BOOL:${TFM_MULTI_CORE_TOPOLOGY}>:cmsis_psa/tfm_multi_core.c> |
| 39 | $<$<BOOL:${TFM_MULTI_CORE_TOPOLOGY}>:cmsis_psa/tfm_multi_core_mem_check.c> |
| 40 | $<$<BOOL:${TFM_MULTI_CORE_TOPOLOGY}>:cmsis_psa/tfm_rpc.c> |
| 41 | $<$<BOOL:${TFM_MULTI_CORE_TOPOLOGY}>:cmsis_psa/tfm_spe_mailbox.c> |
Ken Liu | 55ba01f | 2021-01-20 17:34:50 +0800 | [diff] [blame] | 42 | $<$<NOT:$<BOOL:${TFM_PSA_API}>>:ffm/tfm_core_mem_check.c> |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 43 | $<$<BOOL:${TFM_PSA_API}>:cmsis_psa/arch/tfm_arch.c> |
| 44 | $<$<BOOL:${TFM_PSA_API}>:cmsis_psa/main.c> |
| 45 | $<$<BOOL:${TFM_PSA_API}>:cmsis_psa/spm_ipc.c> |
Ken Liu | 55ba01f | 2021-01-20 17:34:50 +0800 | [diff] [blame] | 46 | $<$<BOOL:${TFM_PSA_API}>:ffm/spm_psa_client_call.c> |
| 47 | $<$<BOOL:${TFM_PSA_API}>:ffm/psa_client_service_apis.c> |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 48 | $<$<BOOL:${TFM_PSA_API}>:cmsis_psa/tfm_core_svcalls_ipc.c> |
| 49 | $<$<AND:$<BOOL:${TFM_PSA_API}>,$<NOT:$<BOOL:${TFM_MULTI_CORE_TOPOLOGY}>>>:cmsis_psa/tfm_nspm_ipc.c> |
| 50 | $<$<BOOL:${TFM_PSA_API}>:cmsis_psa/tfm_pools.c> |
| 51 | $<$<BOOL:${TFM_PSA_API}>:cmsis_psa/tfm_thread.c> |
| 52 | $<$<BOOL:${TFM_PSA_API}>:cmsis_psa/tfm_wait.c> |
| 53 | $<$<NOT:$<BOOL:${TFM_PSA_API}>>:cmsis_func/main.c> |
| 54 | $<$<NOT:$<BOOL:${TFM_PSA_API}>>:cmsis_func/arch.c> |
| 55 | $<$<NOT:$<BOOL:${TFM_PSA_API}>>:cmsis_func/spm_func.c> |
| 56 | $<$<NOT:$<BOOL:${TFM_PSA_API}>>:cmsis_func/tfm_core_svcalls_func.c> |
| 57 | $<$<NOT:$<BOOL:${TFM_PSA_API}>>:cmsis_func/tfm_nspm_func.c> |
| 58 | $<$<NOT:$<BOOL:${TFM_PSA_API}>>:cmsis_func/tfm_secure_api.c> |
| 59 | #TODO add other arches |
Raef Coles | 600a463 | 2020-10-15 16:42:35 +0100 | [diff] [blame] | 60 | $<$<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] | 61 | $<$<AND:$<BOOL:${TFM_PSA_API}>,$<STREQUAL:${CMAKE_SYSTEM_ARCHITECTURE},armv8-m.base>>:cmsis_psa/arch/tfm_arch_v8m_base.c> |
| 62 | $<$<AND:$<BOOL:${TFM_PSA_API}>,$<STREQUAL:${CMAKE_SYSTEM_ARCHITECTURE},armv8-m.main>>:cmsis_psa/arch/tfm_arch_v8m_main.c> |
| 63 | $<$<AND:$<BOOL:${TFM_PSA_API}>,$<STREQUAL:${CMAKE_SYSTEM_ARCHITECTURE},armv6-m>>:cmsis_psa/arch/tfm_arch_v6m_v7m.c> |
| 64 | $<$<AND:$<BOOL:${TFM_PSA_API}>,$<STREQUAL:${CMAKE_SYSTEM_ARCHITECTURE},armv7-m>>:cmsis_psa/arch/tfm_arch_v6m_v7m.c> |
| 65 | ) |
| 66 | |
Mingyang Sun | d20999f | 2020-10-15 14:53:12 +0800 | [diff] [blame] | 67 | #workaround for arch-test |
| 68 | if (TEST_PSA_API STREQUAL IPC) |
| 69 | target_sources(driver_partition PRIVATE |
| 70 | ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/intermedia_driver_partition_psa.c) |
| 71 | target_sources(client_partition PRIVATE |
| 72 | ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/intermedia_client_partition_psa.c) |
| 73 | target_sources(server_partition PRIVATE |
| 74 | ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/intermedia_server_partition_psa.c) |
| 75 | endif() |
| 76 | |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 77 | target_link_libraries(tfm_spm |
| 78 | PUBLIC |
| 79 | tfm_arch |
| 80 | PRIVATE |
| 81 | psa_interface |
| 82 | platform_s |
| 83 | tfm_boot_status |
| 84 | tfm_secure_api |
| 85 | tfm_partitions |
Raef Coles | d8f6750 | 2020-10-13 10:45:33 +0100 | [diff] [blame] | 86 | $<$<STREQUAL:${TEST_PSA_API},IPC>:driver_partition> |
| 87 | $<$<STREQUAL:${TEST_PSA_API},IPC>:client_partition> |
| 88 | $<$<STREQUAL:${TEST_PSA_API},IPC>:server_partition> |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 89 | ) |
| 90 | |
| 91 | target_compile_definitions(tfm_spm |
| 92 | PRIVATE |
| 93 | $<$<CONFIG:Debug>:TFM_CORE_DEBUG> |
| 94 | $<$<AND:$<BOOL:${BL2}>,$<BOOL:${MCUBOOT_MEASURED_BOOT}>>:BOOT_DATA_AVAILABLE> |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 95 | ) |
| 96 | |
| 97 | # With constant optimizations on tfm_nspc_func emits a symbol that the linker |
| 98 | # doesn't like. It's unclear why this is, so I'll put a TODO here, but for the |
| 99 | # moment this fixes it with mimimal impact. |
| 100 | set_source_files_properties(tfm_nspm_func.c |
| 101 | PROPERTIES |
| 102 | COMPILE_FLAGS -fno-ipa-cp |
| 103 | ) |
| 104 | |
| 105 | # The veneers give warnings about not being properly declared so they get hidden |
| 106 | # to not overshadow _real_ warnings. |
| 107 | set_source_files_properties(tfm_secure_api.c |
| 108 | PROPERTIES |
| 109 | COMPILE_FLAGS -Wno-implicit-function-declaration |
| 110 | ) |
| 111 | |
Raef Coles | d8f6750 | 2020-10-13 10:45:33 +0100 | [diff] [blame] | 112 | ############################ Partition Defs #################################### |
| 113 | |
| 114 | target_compile_definitions(tfm_partition_defs |
| 115 | INTERFACE |
| 116 | $<$<STREQUAL:${TEST_PSA_API},IPC>:PSA_API_TEST_IPC> |
| 117 | ) |
| 118 | |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 119 | ############################ TFM arch ########################################## |
| 120 | |
| 121 | target_include_directories(tfm_arch |
| 122 | INTERFACE |
| 123 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/cmsis_psa/arch> |
| 124 | ) |
| 125 | |
| 126 | ############################ Boot Status ####################################### |
| 127 | |
| 128 | target_include_directories(tfm_boot_status |
| 129 | INTERFACE |
| 130 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> |
| 131 | ) |
| 132 | |
| 133 | ############################ TFM utilities ##################################### |
| 134 | |
| 135 | target_include_directories(tfm_utilities |
| 136 | INTERFACE |
| 137 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> |
| 138 | ) |
| 139 | |
| 140 | ############################ Secure API ######################################## |
| 141 | |
| 142 | target_link_libraries(tfm_secure_api |
Summer Qin | 5a212ec | 2020-11-19 15:48:57 +0800 | [diff] [blame] | 143 | INTERFACE |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 144 | tfm_partitions |
| 145 | ) |
| 146 | |
| 147 | target_include_directories(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 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> |
| 150 | $<$<BOOL:${TFM_PSA_API}>:${CMAKE_CURRENT_SOURCE_DIR}/model_ipc/include> |
| 151 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/arch/include> |
| 152 | ) |
| 153 | |
| 154 | ############################# Secure veneers ################################### |
| 155 | |
| 156 | if(NOT TFM_MULTI_CORE_TOPOLOGY) |
| 157 | # If this is added to the spm, it is discarded as it is not used. Since the |
| 158 | # spm is a static library it can't generate veneers under all compilers so |
| 159 | # instead this single file is added to the tfm_s target. |
| 160 | target_sources(tfm_s |
| 161 | PRIVATE |
| 162 | $<$<NOT:$<BOOL:${TFM_PSA_API}>>:${CMAKE_BINARY_DIR}/generated/secure_fw/spm/cmsis_func/tfm_veneers.c> |
| 163 | $<$<BOOL:${TFM_PSA_API}>:${CMAKE_CURRENT_SOURCE_DIR}/cmsis_psa/tfm_psa_api_veneers.c> |
| 164 | ) |
| 165 | endif() |