Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 1 | #------------------------------------------------------------------------------- |
| 2 | # Copyright (c) 2020, Arm Limited. All rights reserved. |
| 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 |
| 34 | $<$<BOOL:${TFM_PARTITION_INITIAL_ATTESTATION}>:common/tfm_boot_data.c> |
| 35 | common/tfm_core_utils.c |
| 36 | common/utilities.c |
Shawn Shan | 6f33aad | 2020-10-16 15:30:17 +0800 | [diff] [blame] | 37 | common/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> |
Mingyang Sun | d1ed673 | 2020-08-26 15:52:21 +0800 | [diff] [blame^] | 42 | $<$<NOT:$<BOOL:${TFM_PSA_API}>>:common/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> |
| 46 | $<$<BOOL:${TFM_PSA_API}>:common/spm_psa_client_call.c> |
| 47 | $<$<BOOL:${TFM_PSA_API}>:common/psa_client_service_apis.c> |
| 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 | |
| 67 | target_link_libraries(tfm_spm |
| 68 | PUBLIC |
| 69 | tfm_arch |
| 70 | PRIVATE |
| 71 | psa_interface |
| 72 | platform_s |
| 73 | tfm_boot_status |
| 74 | tfm_secure_api |
| 75 | tfm_partitions |
Raef Coles | d8f6750 | 2020-10-13 10:45:33 +0100 | [diff] [blame] | 76 | $<$<STREQUAL:${TEST_PSA_API},IPC>:driver_partition> |
| 77 | $<$<STREQUAL:${TEST_PSA_API},IPC>:client_partition> |
| 78 | $<$<STREQUAL:${TEST_PSA_API},IPC>:server_partition> |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 79 | ) |
| 80 | |
| 81 | target_compile_definitions(tfm_spm |
| 82 | PRIVATE |
| 83 | $<$<CONFIG:Debug>:TFM_CORE_DEBUG> |
| 84 | $<$<AND:$<BOOL:${BL2}>,$<BOOL:${MCUBOOT_MEASURED_BOOT}>>:BOOT_DATA_AVAILABLE> |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 85 | ) |
| 86 | |
| 87 | # With constant optimizations on tfm_nspc_func emits a symbol that the linker |
| 88 | # doesn't like. It's unclear why this is, so I'll put a TODO here, but for the |
| 89 | # moment this fixes it with mimimal impact. |
| 90 | set_source_files_properties(tfm_nspm_func.c |
| 91 | PROPERTIES |
| 92 | COMPILE_FLAGS -fno-ipa-cp |
| 93 | ) |
| 94 | |
| 95 | # The veneers give warnings about not being properly declared so they get hidden |
| 96 | # to not overshadow _real_ warnings. |
| 97 | set_source_files_properties(tfm_secure_api.c |
| 98 | PROPERTIES |
| 99 | COMPILE_FLAGS -Wno-implicit-function-declaration |
| 100 | ) |
| 101 | |
Raef Coles | d8f6750 | 2020-10-13 10:45:33 +0100 | [diff] [blame] | 102 | ############################ Partition Defs #################################### |
| 103 | |
| 104 | target_compile_definitions(tfm_partition_defs |
| 105 | INTERFACE |
| 106 | $<$<STREQUAL:${TEST_PSA_API},IPC>:PSA_API_TEST_IPC> |
| 107 | ) |
| 108 | |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 109 | ############################ TFM arch ########################################## |
| 110 | |
| 111 | target_include_directories(tfm_arch |
| 112 | INTERFACE |
| 113 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/cmsis_psa/arch> |
| 114 | ) |
| 115 | |
| 116 | ############################ Boot Status ####################################### |
| 117 | |
| 118 | target_include_directories(tfm_boot_status |
| 119 | INTERFACE |
| 120 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> |
| 121 | ) |
| 122 | |
| 123 | ############################ TFM utilities ##################################### |
| 124 | |
| 125 | target_include_directories(tfm_utilities |
| 126 | INTERFACE |
| 127 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> |
| 128 | ) |
| 129 | |
| 130 | ############################ Secure API ######################################## |
| 131 | |
| 132 | target_link_libraries(tfm_secure_api |
| 133 | PRIVATE |
| 134 | tfm_partitions |
| 135 | ) |
| 136 | |
| 137 | target_include_directories(tfm_secure_api |
| 138 | PUBLIC |
| 139 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> |
| 140 | $<$<BOOL:${TFM_PSA_API}>:${CMAKE_CURRENT_SOURCE_DIR}/model_ipc/include> |
| 141 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/arch/include> |
| 142 | ) |
| 143 | |
| 144 | ############################# Secure veneers ################################### |
| 145 | |
| 146 | if(NOT TFM_MULTI_CORE_TOPOLOGY) |
| 147 | # If this is added to the spm, it is discarded as it is not used. Since the |
| 148 | # spm is a static library it can't generate veneers under all compilers so |
| 149 | # instead this single file is added to the tfm_s target. |
| 150 | target_sources(tfm_s |
| 151 | PRIVATE |
| 152 | $<$<NOT:$<BOOL:${TFM_PSA_API}>>:${CMAKE_BINARY_DIR}/generated/secure_fw/spm/cmsis_func/tfm_veneers.c> |
| 153 | $<$<BOOL:${TFM_PSA_API}>:${CMAKE_CURRENT_SOURCE_DIR}/cmsis_psa/tfm_psa_api_veneers.c> |
| 154 | ) |
| 155 | endif() |