blob: 2caf429a0a9697f108dcb48b792413b552275537 [file] [log] [blame]
Raef Colesabfe81a2020-07-10 09:52:34 +01001#-------------------------------------------------------------------------------
2# Copyright (c) 2020, Arm Limited. All rights reserved.
3#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6#-------------------------------------------------------------------------------
7
8cmake_minimum_required(VERSION 3.13)
9
10add_library(tfm_spm STATIC)
11add_library(tfm_boot_status INTERFACE)
12add_library(tfm_arch INTERFACE)
13add_library(tfm_utilities INTERFACE)
14
15set(TFM_PARTITION_PLATFORM ON CACHE BOOL "Enable the TF-M Platform partition")
16
17target_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
32target_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
37 $<$<BOOL:${TFM_MULTI_CORE_TOPOLOGY}>:cmsis_psa/tfm_multi_core.c>
38 $<$<BOOL:${TFM_MULTI_CORE_TOPOLOGY}>:cmsis_psa/tfm_multi_core_mem_check.c>
39 $<$<BOOL:${TFM_MULTI_CORE_TOPOLOGY}>:cmsis_psa/tfm_rpc.c>
40 $<$<BOOL:${TFM_MULTI_CORE_TOPOLOGY}>:cmsis_psa/tfm_spe_mailbox.c>
41 $<$<NOT:$<BOOL:${TFM_MULTI_CORE_TOPOLOGY}>>:common/tfm_core_mem_check.c>
42 $<$<BOOL:${TFM_PSA_API}>:cmsis_psa/arch/tfm_arch.c>
43 $<$<BOOL:${TFM_PSA_API}>:cmsis_psa/main.c>
44 $<$<BOOL:${TFM_PSA_API}>:cmsis_psa/spm_ipc.c>
45 $<$<BOOL:${TFM_PSA_API}>:common/spm_psa_client_call.c>
46 $<$<BOOL:${TFM_PSA_API}>:common/psa_client_service_apis.c>
47 $<$<BOOL:${TFM_PSA_API}>:cmsis_psa/tfm_core_svcalls_ipc.c>
48 $<$<AND:$<BOOL:${TFM_PSA_API}>,$<NOT:$<BOOL:${TFM_MULTI_CORE_TOPOLOGY}>>>:cmsis_psa/tfm_nspm_ipc.c>
49 $<$<BOOL:${TFM_PSA_API}>:cmsis_psa/tfm_pools.c>
50 $<$<BOOL:${TFM_PSA_API}>:cmsis_psa/tfm_thread.c>
51 $<$<BOOL:${TFM_PSA_API}>:cmsis_psa/tfm_wait.c>
52 $<$<NOT:$<BOOL:${TFM_PSA_API}>>:cmsis_func/main.c>
53 $<$<NOT:$<BOOL:${TFM_PSA_API}>>:cmsis_func/arch.c>
54 $<$<NOT:$<BOOL:${TFM_PSA_API}>>:cmsis_func/spm_func.c>
55 $<$<NOT:$<BOOL:${TFM_PSA_API}>>:cmsis_func/tfm_core_svcalls_func.c>
56 $<$<NOT:$<BOOL:${TFM_PSA_API}>>:cmsis_func/tfm_nspm_func.c>
57 $<$<NOT:$<BOOL:${TFM_PSA_API}>>:cmsis_func/tfm_secure_api.c>
58 #TODO add other arches
59 $<$<AND:$<BOOL:${TFM_PSA_API}>,$<STREQUAL:${CMAKE_SYSTEM_ARCHITECTURE},armv8-m.base>>:cmsis_psa/arch/tfm_arch_v8m_base.c>
60 $<$<AND:$<BOOL:${TFM_PSA_API}>,$<STREQUAL:${CMAKE_SYSTEM_ARCHITECTURE},armv8-m.main>>:cmsis_psa/arch/tfm_arch_v8m_main.c>
61 $<$<AND:$<BOOL:${TFM_PSA_API}>,$<STREQUAL:${CMAKE_SYSTEM_ARCHITECTURE},armv6-m>>:cmsis_psa/arch/tfm_arch_v6m_v7m.c>
62 $<$<AND:$<BOOL:${TFM_PSA_API}>,$<STREQUAL:${CMAKE_SYSTEM_ARCHITECTURE},armv7-m>>:cmsis_psa/arch/tfm_arch_v6m_v7m.c>
63)
64
65target_link_libraries(tfm_spm
66 PUBLIC
67 tfm_arch
68 PRIVATE
69 psa_interface
70 platform_s
71 tfm_boot_status
72 tfm_secure_api
73 tfm_partitions
74)
75
76target_compile_definitions(tfm_spm
77 PRIVATE
78 $<$<CONFIG:Debug>:TFM_CORE_DEBUG>
79 $<$<AND:$<BOOL:${BL2}>,$<BOOL:${MCUBOOT_MEASURED_BOOT}>>:BOOT_DATA_AVAILABLE>
80 $<$<BOOL:${TFM_INTERNAL_MCUBOOT}>:LEGACY_TFM_TLV_HEADER>
81)
82
83# With constant optimizations on tfm_nspc_func emits a symbol that the linker
84# doesn't like. It's unclear why this is, so I'll put a TODO here, but for the
85# moment this fixes it with mimimal impact.
86set_source_files_properties(tfm_nspm_func.c
87 PROPERTIES
88 COMPILE_FLAGS -fno-ipa-cp
89)
90
91# The veneers give warnings about not being properly declared so they get hidden
92# to not overshadow _real_ warnings.
93set_source_files_properties(tfm_secure_api.c
94 PROPERTIES
95 COMPILE_FLAGS -Wno-implicit-function-declaration
96)
97
98############################ TFM arch ##########################################
99
100target_include_directories(tfm_arch
101 INTERFACE
102 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/cmsis_psa/arch>
103)
104
105############################ Boot Status #######################################
106
107target_include_directories(tfm_boot_status
108 INTERFACE
109 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
110)
111
112############################ TFM utilities #####################################
113
114target_include_directories(tfm_utilities
115 INTERFACE
116 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
117)
118
119############################ Secure API ########################################
120
121target_link_libraries(tfm_secure_api
122 PRIVATE
123 tfm_partitions
124)
125
126target_include_directories(tfm_secure_api
127 PUBLIC
128 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
129 $<$<BOOL:${TFM_PSA_API}>:${CMAKE_CURRENT_SOURCE_DIR}/model_ipc/include>
130 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/arch/include>
131)
132
133############################# Secure veneers ###################################
134
135if(NOT TFM_MULTI_CORE_TOPOLOGY)
136 # If this is added to the spm, it is discarded as it is not used. Since the
137 # spm is a static library it can't generate veneers under all compilers so
138 # instead this single file is added to the tfm_s target.
139 target_sources(tfm_s
140 PRIVATE
141 $<$<NOT:$<BOOL:${TFM_PSA_API}>>:${CMAKE_BINARY_DIR}/generated/secure_fw/spm/cmsis_func/tfm_veneers.c>
142 $<$<BOOL:${TFM_PSA_API}>:${CMAKE_CURRENT_SOURCE_DIR}/cmsis_psa/tfm_psa_api_veneers.c>
143 )
144endif()