blob: d46705359a7f4f8d635006bbdb6d3df04ea386bb [file] [log] [blame]
Raef Colesabfe81a2020-07-10 09:52:34 +01001#-------------------------------------------------------------------------------
Sherry Zhangf58f2bd2022-01-10 17:21:11 +08002# Copyright (c) 2020-2022, Arm Limited. All rights reserved.
Chris Brand56b4d0c2021-12-17 16:15:58 -08003# Copyright (c) 2021, Cypress Semiconductor Corporation. All rights reserved.
Raef Colesabfe81a2020-07-10 09:52:34 +01004#
5# SPDX-License-Identifier: BSD-3-Clause
6#
7#-------------------------------------------------------------------------------
8
Raef Coles69817322020-10-19 14:14:14 +01009cmake_minimum_required(VERSION 3.15)
Raef Colesabfe81a2020-07-10 09:52:34 +010010
11add_library(tfm_spm STATIC)
12add_library(tfm_boot_status INTERFACE)
13add_library(tfm_arch INTERFACE)
14add_library(tfm_utilities INTERFACE)
15
16set(TFM_PARTITION_PLATFORM ON CACHE BOOL "Enable the TF-M Platform partition")
17
David Huf1841af2021-09-02 12:50:45 +080018# Generate TF-M version
19configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/tfm_version.h.in
20 ${CMAKE_BINARY_DIR}/generated/secure_fw/spm/include/tfm_version.h)
21
Raef Colesabfe81a2020-07-10 09:52:34 +010022target_include_directories(tfm_spm
23 PUBLIC
24 ${CMAKE_CURRENT_SOURCE_DIR}
25 ${CMAKE_CURRENT_SOURCE_DIR}/include
26 $<$<BOOL:${TFM_PSA_API}>:${CMAKE_CURRENT_SOURCE_DIR}/cmsis_psa>
27 $<$<BOOL:${TFM_PSA_API}>:${CMAKE_CURRENT_SOURCE_DIR}/cmsis_psa/include>
28 $<$<NOT:$<BOOL:${TFM_PSA_API}>>:${CMAKE_CURRENT_SOURCE_DIR}/cmsis_func>
29 $<$<NOT:$<BOOL:${TFM_PSA_API}>>:${CMAKE_CURRENT_SOURCE_DIR}/cmsis_func/include>
30 PRIVATE
31 ${CMAKE_SOURCE_DIR}
Ken Liue6f31e52021-08-16 13:42:25 +080032 ${CMAKE_SOURCE_DIR}/secure_fw/include
Raef Colesabfe81a2020-07-10 09:52:34 +010033 ${CMAKE_BINARY_DIR}/generated
David Huf1841af2021-09-02 12:50:45 +080034 ${CMAKE_BINARY_DIR}/generated/secure_fw/spm/include
Raef Colesabfe81a2020-07-10 09:52:34 +010035 $<$<BOOL:${TFM_PSA_API}>:${CMAKE_BINARY_DIR}/generated/secure_fw/spm/cmsis_psa>
36 $<$<NOT:$<BOOL:${TFM_PSA_API}>>:${CMAKE_BINARY_DIR}/generated/secure_fw/spm/cmsis_func>
37)
38
39target_sources(tfm_spm
40 PRIVATE
Ken Liu55ba01f2021-01-20 17:34:50 +080041 ffm/tfm_boot_data.c
42 ffm/tfm_core_utils.c
43 ffm/utilities.c
Øyvind Rønningstadf2c8dad2021-01-15 15:33:33 +010044 $<$<BOOL:${TFM_EXCEPTION_INFO_DUMP}>:cmsis_psa/exception_info.c>
Shawn Shan90f102f2021-02-19 10:45:07 +080045 $<$<NOT:$<STREQUAL:${TFM_SPM_LOG_LEVEL},TFM_SPM_LOG_LEVEL_SILENCE>>:ffm/spm_log.c>
Raef Colesabfe81a2020-07-10 09:52:34 +010046 $<$<BOOL:${TFM_MULTI_CORE_TOPOLOGY}>:cmsis_psa/tfm_multi_core_mem_check.c>
Ken Liu55ba01f2021-01-20 17:34:50 +080047 $<$<NOT:$<BOOL:${TFM_PSA_API}>>:ffm/tfm_core_mem_check.c>
Raef Colesabfe81a2020-07-10 09:52:34 +010048 $<$<BOOL:${TFM_PSA_API}>:cmsis_psa/arch/tfm_arch.c>
49 $<$<BOOL:${TFM_PSA_API}>:cmsis_psa/main.c>
50 $<$<BOOL:${TFM_PSA_API}>:cmsis_psa/spm_ipc.c>
Sherry Zhangf58f2bd2022-01-10 17:21:11 +080051 $<$<BOOL:${CONFIG_TFM_PSA_API_CROSS_CALL}>:cmsis_psa/spm_cross_call.c>
Ken Liuacd2a572021-05-12 16:19:04 +080052 $<$<BOOL:${TFM_PSA_API}>:cmsis_psa/static_load.c>
Mingyang Sun133a7922021-07-08 16:01:26 +080053 $<$<BOOL:${TFM_PSA_API}>:ffm/psa_api.c>
Ken Liuf39d8eb2021-10-07 12:55:33 +080054 $<$<BOOL:${TFM_PSA_API}>:ffm/backend.c>
Kevin Peng3f67b2e2021-10-18 17:47:27 +080055 $<$<BOOL:${TFM_PSA_API}>:ffm/interrupt.c>
Raef Colesabfe81a2020-07-10 09:52:34 +010056 $<$<BOOL:${TFM_PSA_API}>:cmsis_psa/tfm_core_svcalls_ipc.c>
Raef Colesabfe81a2020-07-10 09:52:34 +010057 $<$<BOOL:${TFM_PSA_API}>:cmsis_psa/tfm_pools.c>
Ken Liu5d73c872021-08-19 19:23:17 +080058 $<$<BOOL:${TFM_PSA_API}>:cmsis_psa/thread.c>
Raef Colesabfe81a2020-07-10 09:52:34 +010059 $<$<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>
Chris Brand56b4d0c2021-12-17 16:15:58 -080063 $<$<BOOL:${TFM_NS_MANAGE_NSID}>:ns_client_ext/tfm_ns_ctx.c>
64 ns_client_ext/tfm_spm_ns_ctx.c
Raef Colesabfe81a2020-07-10 09:52:34 +010065 $<$<NOT:$<BOOL:${TFM_PSA_API}>>:cmsis_func/tfm_secure_api.c>
66 #TODO add other arches
Gabor Abonyi866571c2021-10-07 13:56:19 +020067 $<$<AND:$<BOOL:${TFM_PSA_API}>,$<STREQUAL:${TFM_SYSTEM_ARCHITECTURE},armv8.1-m.main>>:cmsis_psa/arch/tfm_arch_v8m_main.c>
68 $<$<AND:$<BOOL:${TFM_PSA_API}>,$<STREQUAL:${TFM_SYSTEM_ARCHITECTURE},armv8-m.base>>:cmsis_psa/arch/tfm_arch_v8m_base.c>
69 $<$<AND:$<BOOL:${TFM_PSA_API}>,$<STREQUAL:${TFM_SYSTEM_ARCHITECTURE},armv8-m.main>>:cmsis_psa/arch/tfm_arch_v8m_main.c>
70 $<$<AND:$<BOOL:${TFM_PSA_API}>,$<STREQUAL:${TFM_SYSTEM_ARCHITECTURE},armv6-m>>:cmsis_psa/arch/tfm_arch_v6m_v7m.c>
71 $<$<AND:$<BOOL:${TFM_PSA_API}>,$<STREQUAL:${TFM_SYSTEM_ARCHITECTURE},armv7-m>>:cmsis_psa/arch/tfm_arch_v6m_v7m.c>
Raef Colesabfe81a2020-07-10 09:52:34 +010072)
73
Ken Liuea45b0d2021-05-22 17:41:25 +080074target_include_directories(tfm_partitions INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/cmsis_psa)
75
Raef Colesabfe81a2020-07-10 09:52:34 +010076target_link_libraries(tfm_spm
77 PUBLIC
78 tfm_arch
79 PRIVATE
80 psa_interface
81 platform_s
82 tfm_boot_status
83 tfm_secure_api
84 tfm_partitions
David Huf07e97d2021-02-15 22:05:40 +080085 tfm_fih
Kevin Peng498c45b2021-08-31 17:57:15 +080086 tfm_sprt
Raef Colesabfe81a2020-07-10 09:52:34 +010087)
88
89target_compile_definitions(tfm_spm
90 PRIVATE
91 $<$<CONFIG:Debug>:TFM_CORE_DEBUG>
92 $<$<AND:$<BOOL:${BL2}>,$<BOOL:${MCUBOOT_MEASURED_BOOT}>>:BOOT_DATA_AVAILABLE>
Øyvind Rønningstadf2c8dad2021-01-15 15:33:33 +010093 $<$<BOOL:${TFM_EXCEPTION_INFO_DUMP}>:TFM_EXCEPTION_INFO_DUMP>
Sherry Zhnag482b88b2021-08-19 17:51:47 +080094 $<$<BOOL:${TFM_NS_MANAGE_NSID}>:TFM_NS_MANAGE_NSID>
Sherry Zhangf58f2bd2022-01-10 17:21:11 +080095 $<$<BOOL:${CONFIG_TFM_SPM_BACKEND_IPC}>:CONFIG_TFM_SPM_BACKEND_IPC>
96 $<$<BOOL:${CONFIG_TFM_SPM_BACKEND_SFN}>:CONFIG_TFM_SPM_BACKEND_SFN>
Feder Liang55194382021-11-22 16:45:33 +080097 # CONFIG_TFM_FP
98 $<$<STREQUAL:${CONFIG_TFM_FP},hard>:CONFIG_TFM_FP=2>
99 $<$<STREQUAL:${CONFIG_TFM_FP},soft>:CONFIG_TFM_FP=0>
Feder Liangd4dbaa92021-09-07 15:34:46 +0800100)
101
102target_compile_options(tfm_spm
103 PUBLIC
104 ${COMPILER_CP_FLAG}
Raef Colesabfe81a2020-07-10 09:52:34 +0100105)
106
107# The veneers give warnings about not being properly declared so they get hidden
108# to not overshadow _real_ warnings.
109set_source_files_properties(tfm_secure_api.c
110 PROPERTIES
TTornblom611dba12021-09-30 12:09:38 +0200111 COMPILE_FLAGS
112 $<$<C_COMPILER_ID:ARMClang>:-Wno-implicit-function-declaration>
113 $<$<C_COMPILER_ID:GNU>:-Wno-implicit-function-declaration>
114 $<$<C_COMPILER_ID:IAR>:>
Raef Colesabfe81a2020-07-10 09:52:34 +0100115)
116
Raef Colesd8f67502020-10-13 10:45:33 +0100117############################ Partition Defs ####################################
118
119target_compile_definitions(tfm_partition_defs
120 INTERFACE
121 $<$<STREQUAL:${TEST_PSA_API},IPC>:PSA_API_TEST_IPC>
122)
123
Raef Colesabfe81a2020-07-10 09:52:34 +0100124############################ TFM arch ##########################################
125
126target_include_directories(tfm_arch
127 INTERFACE
128 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/cmsis_psa/arch>
129)
130
131############################ Boot Status #######################################
132
133target_include_directories(tfm_boot_status
134 INTERFACE
135 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
136)
137
138############################ TFM utilities #####################################
139
140target_include_directories(tfm_utilities
141 INTERFACE
142 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
143)
144
145############################ Secure API ########################################
146
147target_link_libraries(tfm_secure_api
Summer Qin5a212ec2020-11-19 15:48:57 +0800148 INTERFACE
Raef Colesabfe81a2020-07-10 09:52:34 +0100149 tfm_partitions
150)
151
152target_include_directories(tfm_secure_api
Summer Qin5a212ec2020-11-19 15:48:57 +0800153 INTERFACE
Raef Colesabfe81a2020-07-10 09:52:34 +0100154 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
Kevin Pengfc7b7712021-05-08 13:42:56 +0800155 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/interface>
156 $<$<NOT:$<BOOL:${TFM_PSA_API}>>:${CMAKE_CURRENT_SOURCE_DIR}/cmsis_func/include>
Raef Colesabfe81a2020-07-10 09:52:34 +0100157 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/arch/include>
158)
159
160############################# Secure veneers ###################################
161
162if(NOT TFM_MULTI_CORE_TOPOLOGY)
163 # If this is added to the spm, it is discarded as it is not used. Since the
164 # spm is a static library it can't generate veneers under all compilers so
165 # instead this single file is added to the tfm_s target.
166 target_sources(tfm_s
167 PRIVATE
168 $<$<NOT:$<BOOL:${TFM_PSA_API}>>:${CMAKE_BINARY_DIR}/generated/secure_fw/spm/cmsis_func/tfm_veneers.c>
Sherry Zhnag482b88b2021-08-19 17:51:47 +0800169 $<$<BOOL:${TFM_NS_MANAGE_NSID}>:${CMAKE_CURRENT_SOURCE_DIR}/ns_client_ext/tfm_ns_client_ext.c>
Raef Colesabfe81a2020-07-10 09:52:34 +0100170 )
171endif()