blob: 28b02ce26800f97011986cf9d9bbb408634d35fc [file] [log] [blame]
Raef Colesabfe81a2020-07-10 09:52:34 +01001#-------------------------------------------------------------------------------
Ken Liu55ba01f2021-01-20 17:34:50 +08002# Copyright (c) 2020-2021, Arm Limited. All rights reserved.
Raef Colesabfe81a2020-07-10 09:52:34 +01003#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6#-------------------------------------------------------------------------------
7
Raef Coles69817322020-10-19 14:14:14 +01008cmake_minimum_required(VERSION 3.15)
Raef Colesabfe81a2020-07-10 09:52:34 +01009
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
Ken Liu55ba01f2021-01-20 17:34:50 +080034 ffm/tfm_boot_data.c
35 ffm/tfm_core_utils.c
36 ffm/utilities.c
Shawn Shan90f102f2021-02-19 10:45:07 +080037 $<$<NOT:$<STREQUAL:${TFM_SPM_LOG_LEVEL},TFM_SPM_LOG_LEVEL_SILENCE>>:ffm/spm_log.c>
Raef Colesabfe81a2020-07-10 09:52:34 +010038 $<$<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 Liu55ba01f2021-01-20 17:34:50 +080042 $<$<NOT:$<BOOL:${TFM_PSA_API}>>:ffm/tfm_core_mem_check.c>
Raef Colesabfe81a2020-07-10 09:52:34 +010043 $<$<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 Liu55ba01f2021-01-20 17:34:50 +080046 $<$<BOOL:${TFM_PSA_API}>:ffm/spm_psa_client_call.c>
47 $<$<BOOL:${TFM_PSA_API}>:ffm/psa_client_service_apis.c>
Raef Colesabfe81a2020-07-10 09:52:34 +010048 $<$<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 Coles600a4632020-10-15 16:42:35 +010060 $<$<AND:$<BOOL:${TFM_PSA_API}>,$<STREQUAL:${CMAKE_SYSTEM_ARCHITECTURE},armv8.1-m.main>>:cmsis_psa/arch/tfm_arch_v8m_main.c>
Raef Colesabfe81a2020-07-10 09:52:34 +010061 $<$<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 Sund20999f2020-10-15 14:53:12 +080067#workaround for arch-test
68if (TEST_PSA_API STREQUAL IPC)
Shawn Shan781ef732021-03-10 14:05:57 +080069 target_sources(tfm_psa_rot_partition_driver_partition PRIVATE
Mingyang Sund20999f2020-10-15 14:53:12 +080070 ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/intermedia_driver_partition_psa.c)
Shawn Shan781ef732021-03-10 14:05:57 +080071 target_sources(tfm_app_rot_partition_client_partition PRIVATE
Mingyang Sund20999f2020-10-15 14:53:12 +080072 ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/intermedia_client_partition_psa.c)
Shawn Shan781ef732021-03-10 14:05:57 +080073 target_sources(tfm_app_rot_partition_server_partition PRIVATE
Mingyang Sund20999f2020-10-15 14:53:12 +080074 ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/intermedia_server_partition_psa.c)
75endif()
76
Raef Colesabfe81a2020-07-10 09:52:34 +010077target_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
Shawn Shan781ef732021-03-10 14:05:57 +080086 $<$<STREQUAL:${TEST_PSA_API},IPC>:tfm_psa_rot_partition_driver_partition>
87 $<$<STREQUAL:${TEST_PSA_API},IPC>:tfm_app_rot_partition_client_partition>
88 $<$<STREQUAL:${TEST_PSA_API},IPC>:tfm_app_rot_partition_server_partition>
David Huf07e97d2021-02-15 22:05:40 +080089 tfm_fih
Raef Colesabfe81a2020-07-10 09:52:34 +010090)
91
92target_compile_definitions(tfm_spm
93 PRIVATE
94 $<$<CONFIG:Debug>:TFM_CORE_DEBUG>
95 $<$<AND:$<BOOL:${BL2}>,$<BOOL:${MCUBOOT_MEASURED_BOOT}>>:BOOT_DATA_AVAILABLE>
Raef Colesabfe81a2020-07-10 09:52:34 +010096)
97
98# With constant optimizations on tfm_nspc_func emits a symbol that the linker
99# doesn't like. It's unclear why this is, so I'll put a TODO here, but for the
100# moment this fixes it with mimimal impact.
101set_source_files_properties(tfm_nspm_func.c
102 PROPERTIES
103 COMPILE_FLAGS -fno-ipa-cp
104)
105
106# The veneers give warnings about not being properly declared so they get hidden
107# to not overshadow _real_ warnings.
108set_source_files_properties(tfm_secure_api.c
109 PROPERTIES
110 COMPILE_FLAGS -Wno-implicit-function-declaration
111)
112
Raef Colesd8f67502020-10-13 10:45:33 +0100113############################ Partition Defs ####################################
114
115target_compile_definitions(tfm_partition_defs
116 INTERFACE
117 $<$<STREQUAL:${TEST_PSA_API},IPC>:PSA_API_TEST_IPC>
118)
119
Raef Colesabfe81a2020-07-10 09:52:34 +0100120############################ TFM arch ##########################################
121
122target_include_directories(tfm_arch
123 INTERFACE
124 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/cmsis_psa/arch>
125)
126
127############################ Boot Status #######################################
128
129target_include_directories(tfm_boot_status
130 INTERFACE
131 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
132)
133
134############################ TFM utilities #####################################
135
136target_include_directories(tfm_utilities
137 INTERFACE
138 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
139)
140
141############################ Secure API ########################################
142
143target_link_libraries(tfm_secure_api
Summer Qin5a212ec2020-11-19 15:48:57 +0800144 INTERFACE
Raef Colesabfe81a2020-07-10 09:52:34 +0100145 tfm_partitions
146)
147
148target_include_directories(tfm_secure_api
Summer Qin5a212ec2020-11-19 15:48:57 +0800149 INTERFACE
Raef Colesabfe81a2020-07-10 09:52:34 +0100150 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
151 $<$<BOOL:${TFM_PSA_API}>:${CMAKE_CURRENT_SOURCE_DIR}/model_ipc/include>
152 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/arch/include>
153)
154
155############################# Secure veneers ###################################
156
157if(NOT TFM_MULTI_CORE_TOPOLOGY)
158 # If this is added to the spm, it is discarded as it is not used. Since the
159 # spm is a static library it can't generate veneers under all compilers so
160 # instead this single file is added to the tfm_s target.
161 target_sources(tfm_s
162 PRIVATE
163 $<$<NOT:$<BOOL:${TFM_PSA_API}>>:${CMAKE_BINARY_DIR}/generated/secure_fw/spm/cmsis_func/tfm_veneers.c>
164 $<$<BOOL:${TFM_PSA_API}>:${CMAKE_CURRENT_SOURCE_DIR}/cmsis_psa/tfm_psa_api_veneers.c>
165 )
166endif()